sscdev#

Submodules#

Attributes#

Classes#

KeyVaultClient

Allows management and retrieval of secrets from Azure Key Vault.

SqlClient

OpenMeteo

DataLakeClient

DataLake Client to connect to Azure DataLake in SSCDEV

Utilities

A utility class to manage environment setup, including package installations,

LunoClient

Python SDK for the Luno API.

DatabricksClient

Unified client for interacting with Databricks SQL and Workspace Files API.

Functions#

collect_logs(func)

Decorator for logging function calls and tracing with Azure Monitor.

Package Contents#

class sscdev.KeyVaultClient#

Allows management and retrieval of secrets from Azure Key Vault.

client#
get_secret(secret_name: str) str#
set_secret(secret_name: str, secret_value: str) None#
delete_secret(secret_name: str) None#
list_secrets() list#
class sscdev.SqlClient(DB)#
connect_to_db(conn_string: str, max_retries: int = 10) None#

Attempts to connect to the database using the provided connection string.

Parameters: - conn_string (str): The database connection string. - max_retries (int): The maximum number of connection attempts.

Raises: - Exception: If unable to connect to the database after the specified attempts.

read(query: str) pandas.DataFrame#

Executes a read (SELECT) SQL query and returns the results as a pandas DataFrame.

Parameters: - query (str): The SQL query to execute.

Returns: - pd.DataFrame: The result of the SQL query.

Example: >>> SqlClient.read(‘SELECT * FROM SalesLT.SalesOrderDetail’)

write(data: pandas.DataFrame, table: str, schema: str = None, if_exists='append') None#

Writes data to the specified SQL table.

Parameters: - data (pd.DataFrame): The pandas DataFrame to write to the table. - table (str): The name of the SQL table to write to. - schema (str): The schema name in the database. Default is None. - if_exists (str): Behavior when the table already exists. Default is “append”. Other options include “replace” and “fail”.

Example: >>> SqlClient.write(data, “Historical”, “Weather”)

query(query: str) None#

Executes a general SQL query (e.g., INSERT, UPDATE, DELETE).

Parameters: - query (str): The SQL query to execute.

Example: >>> SqlClient.query(‘INSERT INTO TableName (column1, column2) VALUES (value1, value2)’)

list_schemas() list#

Lists all schemas in the connected database.

Returns: - list: A list of schema names in the database.

Example: >>> SqlClient.list_schemas()

list_tables(schema: str = None) list#

Lists all tables in the connected database, optionally under a specified schema.

Parameters: - schema (str): The schema name (optional).

Returns: - list: A list of table names in the specified schema or all tables if schema is not specified.

Example: >>> SqlClient.list_tables() >>> SqlClient.list_tables(schema=’public’)

table_exists(table_name: str, schema: str = None) bool#

Checks if a specific table exists in the database.

Parameters: - table_name (str): The name of the table to check. - schema (str, optional): The schema name in the database.

Returns: - bool: True if the table exists, False otherwise.

Example: >>> SqlClient.table_exists(‘SalesOrderDetail’, schema=’SalesLT’)

get_columns(table_name: str, schema: str = None) pandas.DataFrame#

Retrieves the columns and their data types from a specific table.

Parameters: - table_name (str): The name of the table. - schema (str, optional): The schema name in the database.

Returns: - pd.DataFrame: DataFrame containing column names and data types.

Example: >>> SqlClient.get_columns(‘SalesOrderDetail’, schema=’SalesLT’)

close_connection() None#

Closes the database connection.

Example: >>> SqlClient.close_connection()

execute_stored_procedure(procedure_name: str, params: dict = None) pandas.DataFrame#

Executes a stored procedure and returns the result.

Parameters: - procedure_name (str): The name of the stored procedure to execute. - params (dict, optional): A dictionary of parameters to pass to the procedure.

Returns: - pd.DataFrame: The result of the stored procedure.

Example: >>> SqlClient.execute_stored_procedure(‘sp_GetSalesData’, {‘param1’: ‘value1’})

class sscdev.OpenMeteo#
get_history(latitude: float, longitude: float, start_date: str, end_date: str) pandas.DataFrame#

Fetches historical weather data for the given coordinates and date range.

Parameters: - latitude (float): Latitude of the location. - longitude (float): Longitude of the location. - start_date (str): The start date for the historical data in YYYY-MM-DD format. - end_date (str): The end date for the historical data in YYYY-MM-DD format.

Returns: - pd.DataFrame: A DataFrame containing the historical weather data.

Example: >>> OpenMeteo.get_weather_history(35.6895, 139.6917, ‘2023-01-01’, ‘2023-01-07’)

get_forecast(latitude: float, longitude: float) pandas.DataFrame#

Fetches weather forecast data for the given coordinates.

Parameters: - latitude (float): Latitude of the location. - longitude (float): Longitude of the location.

Returns: - pd.DataFrame: A DataFrame containing the weather forecast data.

Example: >>> OpenMeteo.get_weather_forecast(35.6895, 139.6917)

get_weather(latitude: float, longitude: float) pandas.DataFrame#

Fetches current weather data for the given coordinates.

Parameters: - latitude (float): Latitude of the location. - longitude (float): Longitude of the location.

Returns: - pd.DataFrame: A DataFrame containing the current weather data.

Example: >>> OpenMeteo.get_current_weather(35.6895, 139.6917)

get_alerts(latitude: float, longitude: float) pandas.DataFrame#

Fetches weather alerts for the given coordinates.

Parameters: - latitude (float): Latitude of the location. - longitude (float): Longitude of the location.

Returns: - pd.DataFrame: A DataFrame containing the weather alerts.

Example: >>> OpenMeteo.get_weather_alerts(35.6895, 139.6917)

class sscdev.DataLakeClient#

DataLake Client to connect to Azure DataLake in SSCDEV

service_client#
file_system_name = 'dst'#
file_system_client#
directory_client#
create_container() None#
delete_container() None#
create_directory(directory_name: str) None#
delete_directory(directory_name: str) None#
ls(directory_name: str) list#
upload(file_name: str, content: bytes) None#
delete(file_name: str) None#
read(file_name: str) bytes#
move(source_file_name: str, destination_file_name: str) None#
class sscdev.Utilities#

A utility class to manage environment setup, including package installations, ODBC driver installations, firewall rule updates, and Aiven service IP filter updates.

firewall(service=None)#

Updates the firewall rule for the specified service. If no service is specified, updates both SQL Server and PostgreSQL Server firewall rules.

static ip()#

Retrieves the current public IP address.

sscdev.collect_logs(func)#

Decorator for logging function calls and tracing with Azure Monitor.

Args: - func (function): The function to be wrapped by the decorator.

Returns: - wrapper (function): The wrapped function with logging and tracing.

Example: >>> @collect_logs >>> def example_function(x, y): >>> return x + y

class sscdev.LunoClient(base_url='', timeout=0)#

Bases: LunoBaseClient

Python SDK for the Luno API.

Example usage:

from luno_python.client import Client

c = Client(api_key_id=’key_id’, api_key_secret=’key_secret’)

try:

res = c.get_ticker(pair=’XBTZAR’) print res

except Exception as e:

print e

cancel_withdrawal(id)#

Makes a call to DELETE /api/1/withdrawals/{id}.

Cancels a withdrawal request. This can only be done if the request is still in state <code>PENDING</code>.

Permissions required: <code>Perm_W_Withdrawals</code>

Parameters:

id (int) – ID of the withdrawal to cancel.

create_account(currency, name)#

Makes a call to POST /api/1/accounts.

This request creates an Account for the specified currency. Please note that the balances for the Account will be displayed based on the <code>asset</code> value, which is the currency the Account is based on.

Permissions required: <code>Perm_W_Addresses</code>

Parameters:
  • currency (str) –

    The currency code for the Account you want to create. Please see the Currency section for a detailed list of currencies supported by the Luno platform.

    Users must be verified to trade currency in order to be able to create an Account. For more information on the verification process, please see <a href=”/help/en/articles/1000168396”>How do I verify my identity?</a>.

    Users have a limit of 10 accounts per currency.

  • name (str) – The label to use for this account

create_beneficiary(account_type, bank_account_number, bank_name, bank_recipient)#

Makes a call to POST /api/1/beneficiaries.

Create a new beneficiary.

Permissions required: <code>Perm_W_Beneficiaries</code>

Parameters:
  • account_type (str) – Bank account type

  • bank_account_number (str) – Beneficiary bank account number

  • bank_name (str) – Bank SWIFT code

  • bank_recipient (str) – The owner of the recipient account

create_funding_address(asset, account_id=None, name=None)#

Makes a call to POST /api/1/funding_address.

Allocates a new receive address to your account. There is a rate limit of 1 address per hour, but bursts of up to 10 addresses are allowed. Only 1 Ethereum receive address can be created.

Permissions required: <code>Perm_W_Addresses</code>

Parameters:
  • asset (str) – Currency code of the asset.

  • account_id (int) – An optional account_id to assign the new Receive Address too

  • name (str) – An optional name for the new Receive Address

create_withdrawal(amount, type, beneficiary_id=None, external_id=None, fast=None, reference=None)#

Makes a call to POST /api/1/withdrawals.

Creates a new withdrawal request to the specified beneficiary.

Permissions required: <code>Perm_W_Withdrawals</code>

Parameters:
  • amount (float) – Amount to withdraw. The currency withdrawn depends on the type setting.

  • type (str) – Withdrawal method.

  • beneficiary_id (int) – The beneficiary ID of the bank account the withdrawal will be paid out to. This parameter is required if the user has set up multiple beneficiaries. The beneficiary ID can be found by selecting on the beneficiary name on the user’s <a href=”/wallet/beneficiaries”>Beneficiaries</a> page.

  • external_id (str) – Optional unique ID to associate with this withdrawal. Useful to prevent duplicate sends. This field supports all alphanumeric characters including “-” and “_”.

  • fast (bool) – If true, it will be a fast withdrawal if possible. Fast withdrawals come with a fee. Currently fast withdrawals are only available for type=ZAR_EFT; for other types, an error is returned. Fast withdrawals are not possible for Bank of Baroda, Deutsche Bank, Merrill Lynch South Africa, UBS, Postbank and Tyme Bank. The fee to be charged is the same as when withdrawing from the UI.

  • reference (str) – For internal use. Deprecated: We don’t allow custom references and will remove this soon.

delete_beneficiary(id)#

Makes a call to DELETE /api/1/beneficiaries/{id}.

Delete a beneficiary

Permissions required: <code>Perm_W_Beneficiaries</code>

Parameters:

id (int) – ID of the Beneficiary to delete.

get_balances(assets=None)#

Makes a call to GET /api/1/balance.

The list of all Accounts and their respective balances for the requesting user.

Permissions required: <code>Perm_R_Balance</code>

Parameters:

assets (list) – Only return balances for wallets with these currencies (if not provided, all balances will be returned). To request balances for multiple currencies, pass the parameter multiple times, e.g. assets=XBT&assets=ETH.

get_candles(duration, pair, since)#

Makes a call to GET /api/exchange/1/candles.

Get candlestick market data from the specified time until now, from the oldest to the most recent.

Permissions required: <code>MP_None</code>

Parameters:
  • duration (int) – Candle duration in seconds. For example, 300 corresponds to 5m candles. Currently supported durations are: 60 (1m), 300 (5m), 900 (15m), 1800 (30m), 3600 (1h), 10800 (3h), 14400 (4h), 28800 (8h), 86400 (24h), 259200 (3d), 604800 (7d).

  • pair (str) – Currency pair

  • since (int) – Filter to candles starting on or after this timestamp (Unix milliseconds). Only up to 1000 of the earliest candles are returned.

get_fee_info(pair)#

Makes a call to GET /api/1/fee_info.

Returns the fees and 30 day trading volume (as of midnight) for a given currency pair. For complete details, please see <a href=”en/countries”>Fees & Features</a>.

Permissions required: <code>Perm_R_Orders</code>

Parameters:

pair (str) – Get fee information about this pair.

get_funding_address(asset, address=None)#

Makes a call to GET /api/1/funding_address.

Returns the default receive address associated with your account and the amount received via the address. Users can specify an optional address parameter to return information for a non-default receive address. In the response, <code>total_received</code> is the total confirmed amount received excluding unconfirmed transactions. <code>total_unconfirmed</code> is the total sum of unconfirmed receive transactions.

Permissions required: <code>Perm_R_Addresses</code>

Parameters:
  • asset (str) – Currency code of the asset.

  • address (str) – Specific cryptocurrency address to retrieve. If not provided, the default address will be used.

get_move(client_move_id=None, id=None)#

Makes a call to GET /api/exchange/1/move.

Get a specific move funds instruction by either <code>id</code> or <code>client_move_id</code>. If both are provided an API error will be returned.

Permissions required: <code>MP_None</code>

Parameters:
  • client_move_id (str) – Get by the user defined ID. This is mutually exclusive with <code>id</code> and is required if <code>id</code> is not provided.

  • id (str) – Get by the system ID. This is mutually exclusive with <code>client_move_id</code> and is required if <code>client_move_id</code> is not provided.

get_order(id)#

Makes a call to GET /api/1/orders/{id}.

Get an Order’s details by its ID.

Permissions required: <code>Perm_R_Orders</code>

Parameters:

id (str) – Order reference

get_order_book(pair)#

Makes a call to GET /api/1/orderbook_top.

This request returns the best 100 bids and asks, for the currency pair specified, in the Order Book.

asks are sorted by price ascending and bids are sorted by price descending.

Multiple orders at the same price are aggregated.

Parameters:

pair (str) – Currency pair of the Orders to retrieve

get_order_book_full(pair)#

Makes a call to GET /api/1/orderbook.

This request returns all bids and asks, for the currency pair specified, in the Order Book.

asks are sorted by price ascending and bids are sorted by price descending.

Multiple orders at the same price are not aggregated.

<b>WARNING:</b> This may return a large amount of data. Users are recommended to use the <a href=”#operation/getOrderBookTop”>top 100 bids and asks</a> or the <a href=”#tag/Streaming-API”>Streaming API</a>.

Parameters:

pair (str) – Currency pair of the Orders to retrieve

get_order_v2(id)#

Makes a call to GET /api/exchange/2/orders/{id}.

Get the details for an order.

Permissions required: <code>Perm_R_Orders</code>

Parameters:

id (str) – Order reference

get_order_v3(client_order_id=None, id=None)#

Makes a call to GET /api/exchange/3/order.

Get the details for an order by order reference or client order ID. Exactly one of the two parameters must be provided, otherwise an error is returned. Permissions required: <code>Perm_R_Orders</code>

Parameters:
  • client_order_id (str) – Client Order ID has the value that was passed in when the Order was posted.

  • id (str) – Order reference

get_ticker(pair)#

Makes a call to GET /api/1/ticker.

Returns the latest ticker indicators for the specified currency pair.

Please see the <a href=”#tag/currency “>Currency list</a> for the complete list of supported currency pairs.

Parameters:

pair (str) – Currency pair

get_tickers(pair=None)#

Makes a call to GET /api/1/tickers.

Returns the latest ticker indicators from all active Luno exchanges.

Please see the <a href=”#tag/currency “>Currency list</a> for the complete list of supported currency pairs.

Parameters:

pair (list) – Return tickers for multiple markets (if not provided, all tickers will be returned). To request tickers for multiple markets, pass the parameter multiple times, e.g. pair=XBTZAR&pair=ETHZAR.

get_withdrawal(id)#

Makes a call to GET /api/1/withdrawals/{id}.

Returns the status of a particular withdrawal request.

Permissions required: <code>Perm_R_Withdrawals</code>

Parameters:

id (int) – Withdrawal ID to retrieve.

list_beneficiaries(bank_recipient=None)#

Makes a call to GET /api/1/beneficiaries.

Returns a list of bank beneficiaries.

Permissions required: <code>Perm_R_Beneficiaries</code>

Parameters:

bank_recipient (str)

list_moves(before=None, limit=None)#

Makes a call to GET /api/exchange/1/move/list_moves.

Returns a list of the most recent moves ordered from newest to oldest. This endpoint will list up to 100 most recent moves by default.

Permissions required: <code>MP_None</code>

Parameters:
  • before (int) – Filter to moves requested before this timestamp (Unix milliseconds)

  • limit (int) – Limit to this many moves

list_orders(created_before=None, limit=None, pair=None, state=None)#

Makes a call to GET /api/1/listorders.

Returns a list of the most recently placed Orders. Users can specify an optional <code>state=PENDING</code> parameter to restrict the results to only open Orders. Users can also specify the market by using the optional currency pair parameter.

Permissions required: <code>Perm_R_Orders</code>

Parameters:
  • created_before (int) – Filter to orders created before this timestamp (Unix milliseconds)

  • limit (int) – Limit to this many orders

  • pair (str) – Filter to only orders of this currency pair

  • state (str) – Filter to only orders of this state

list_orders_v2(closed=None, created_before=None, limit=None, pair=None)#

Makes a call to GET /api/exchange/2/listorders.

Returns a list of the most recently placed orders ordered from newest to oldest. This endpoint will list up to 100 most recent open orders by default.

<b>Please note:</b> This data is archived 100 days after an exchange order is completed.

Permissions required: <Code>Perm_R_Orders</Code>

Parameters:
  • closed (bool) – If true, will return closed orders instead of open orders.

  • created_before (int) – Filter to orders created before this timestamp (Unix milliseconds)

  • limit (int) – Limit to this many orders

  • pair (str) – Filter to only orders of this currency pair.

list_pending_transactions(id)#

Makes a call to GET /api/1/accounts/{id}/pending.

Return a list of all transactions that have not completed for the Account.

Pending transactions are not numbered, and may be reordered, deleted or updated at any time.

Permissions required: <code>Perm_R_Transactions</code>

Parameters:

id (int) – Account ID

list_trades(pair, since=None)#

Makes a call to GET /api/1/trades.

Returns a list of recent trades for the specified currency pair. At most 100 trades are returned per call and never trades older than 24h. The trades are sorted from newest to oldest.

Please see the <a href=”#tag/currency “>Currency list</a> for the complete list of supported currency pairs.

Parameters:
  • pair (str) – Currency pair of the market to list the trades from

  • since (int) – Fetch trades executed after this time, specified as a Unix timestamp in milliseconds. An error will be returned if this is before 24h ago. Use this parameter to either restrict to a shorter window or to iterate over the trades in case you need more than the 100 most recent trades.

list_transactions(id, max_row, min_row)#

Makes a call to GET /api/1/accounts/{id}/transactions.

Return a list of transaction entries from an account.

Transaction entry rows are numbered sequentially starting from 1, where 1 is the oldest entry. The range of rows to return are specified with the <code>min_row</code> (inclusive) and <code>max_row</code> (exclusive) parameters. At most 1000 rows can be requested per call.

If <code>min_row</code> or <code>max_row</code> is non-positive, the range wraps around the most recent row. For example, to fetch the 100 most recent rows, use <code>min_row=-100</code> and <code>max_row=0</code>.

Permissions required: <code>Perm_R_Transactions</code>

Parameters:
  • id (int) – Account ID - the unique identifier for the specific Account.

  • max_row (int) – Maximum of the row range to return (exclusive)

  • min_row (int) – Minimum of the row range to return (inclusive)

list_transfers(account_id, before=None, limit=None)#

Makes a call to GET /api/exchange/1/transfers.

Returns a list of the most recent confirmed transfers ordered from newest to oldest. This includes bank transfers, card payments, or on-chain transactions that have been reflected on your account available balance.

Note that the Transfer amount is always a positive value and you should use the inbound flag to determine the direction of the transfer.

If you need to paginate the results you can set the before parameter to the last returned transfer created_at field value and repeat the request until you have all the transfers you need. This endpoint will list up to 100 transfers at a time by default.

Permissions required: <Code>Perm_R_Transfers</Code>

Parameters:
  • account_id (int) – Unique identifier of the account to list the transfers from.

  • before (int) – Filter to transfers created before this timestamp (Unix milliseconds). The default value (0) will return the latest transfers on the account.

  • limit (int) – Limit to this many transfers.

list_user_trades(pair, after_seq=None, before=None, before_seq=None, limit=None, since=None, sort_desc=None)#

Makes a call to GET /api/1/listtrades.

Returns a list of the recent Trades for a given currency pair for this user, sorted by oldest first. If <code>before</code> is specified, then Trades are returned sorted by most-recent first.

<code>type</code> in the response indicates the type of Order that was placed to participate in the trade. Possible types: <code>BID</code>, <code>ASK</code>.

If <code>is_buy</code> in the response is true, then the Order which completed the trade (market taker) was a Bid Order.

Results of this query may lag behind the latest data.

Permissions required: <code>Perm_R_Orders</code>

Parameters:
  • pair (str) – Filter to trades of this currency pair.

  • after_seq (int) – Filter to trades from (including) this sequence number. Default behaviour is not to include this filter.

  • before (int) – Filter to trades before this timestamp (Unix milliseconds).

  • before_seq (int) – Filter to trades before (excluding) this sequence number. Default behaviour is not to include this filter.

  • limit (int) – Limit to this number of trades (default 100).

  • since (int) – Filter to trades on or after this timestamp (Unix milliseconds).

  • sort_desc (bool) – If set to true, sorts trades in descending order, otherwise ascending order will be assumed.

list_withdrawals(before_id=None, limit=None)#

Makes a call to GET /api/1/withdrawals.

Returns a list of withdrawal requests.

Permissions required: <code>Perm_R_Withdrawals</code>

Parameters:
  • before_id (int) – Filter to withdrawals requested on or before the withdrawal with this ID. Can be used for pagination.

  • limit (int) – Limit to this many withdrawals

markets(pair=None)#

Makes a call to GET /api/exchange/1/markets.

List all supported markets parameter information like price scale, min and max order volumes and market ID.

Parameters:

pair (list) – List of market pairs to return. Requesting only the required pairs will improve response times.

move(amount, credit_account_id, debit_account_id, client_move_id=None)#

Makes a call to POST /api/exchange/1/move.

Move funds between two of your transactional accounts with the same currency The funds may not be moved by the time the request returns. The GET method can be used to poll for the move’s status.

Note: moves will show as transactions, but not as transfers.

Permissions required: <code>MP_None_Write</code>

Parameters:
  • amount (float) – Amount to transfer. Must be positive.

  • credit_account_id (int) – The account to credit the funds to.

  • debit_account_id (int) – The account to debit the funds from.

  • client_move_id (str) – Client move ID. May only contain alphanumeric (0-9, a-z, or A-Z) and special characters (_ ; , . -). Maximum length: 255. It will be available in read endpoints, so you can use it to avoid duplicate moves between the same accounts. Values must be unique across all your successful calls of this endpoint; trying to create a move request with the same client_move_id as one of your past move requests will result in a HTTP 409 Conflict response.

post_limit_order(pair, price, type, volume, base_account_id=None, client_order_id=None, counter_account_id=None, post_only=None, stop_direction=None, stop_price=None, time_in_force=None, timestamp=None, ttl=None)#

Makes a call to POST /api/1/postorder.

<b>Warning!</b> Orders cannot be reversed once they have executed. Please ensure your program has been thoroughly tested before submitting Orders.

If no <code>base_account_id</code> or <code>counter_account_id</code> are specified, your default base currency or counter currency account will be used. You can find your Account IDs by calling the <a href=”#operation/getBalances”>Balances</a> API.

Permissions required: <code>Perm_W_Orders</code>

Parameters:
  • pair (str) – The currency pair to trade.

  • price (float) – Limit price as a decimal string in units of ZAR/BTC.

  • type (str) – <code>BID</code> for a bid (buy) limit order<br> <code>ASK</code> for an ask (sell) limit order

  • volume (float) – Amount of cryptocurrency to buy or sell as a decimal string in units of the currency.

  • base_account_id (int) – The base currency Account to use in the trade.

  • client_order_id (str) – Client order ID. May only contain alphanumeric (0-9, a-z, or A-Z) and special characters (_ ; , . -). Maximum length: 255. It will be available in read endpoints, so you can use it to reconcile Luno with your internal system. Values must be unique across all your successful order creation endpoint calls; trying to create an order with the same client_order_id as one of your past orders will result in a HTTP 409 Conflict response.

  • counter_account_id (int) – The counter currency Account to use in the trade.

  • post_only (bool) – Post-only Orders will be cancelled if they would otherwise have traded immediately. For example, if there’s a bid at ZAR 100,000 and you place a post-only ask at ZAR 100,000, your order will be cancelled instead of trading. If the best bid is ZAR 100,000 and you place a post-only ask at ZAR 101,000, your order won’t trade but will go into the order book.

  • stop_direction (str) –

    Side of the trigger price to activate the order. This should be set if stop_price is also set.

    RELATIVE_LAST_TRADE will automatically infer the direction based on the last trade price and the stop price. If last trade price is less than stop price then stop direction is ABOVE otherwise is BELOW.

  • stop_price (float) – Trigger trade price to activate this order as a decimal string. If this is set then this is treated as a Stop Limit Order and stop_direction is expected to be set too.

  • time_in_force (str) – <code>GTC</code> Good ‘Til Cancelled. The order remains open until it is filled or cancelled by the user.</br> <code>IOC</code> Immediate Or Cancel. The part of the order that cannot be filled immediately will be cancelled. Cannot be post-only.</br> <code>FOK</code> Fill Or Kill. If the order cannot be filled immediately and completely it will be cancelled before any trade. Cannot be post-only.

  • timestamp (int) – Unix timestamp in milliseconds of when the request was created and sent.

  • ttl (int) – Specifies the number of milliseconds after timestamp the request is valid for. If timestamp is not specified, ttl will not be used.

post_market_order(pair, type, base_account_id=None, base_volume=None, client_order_id=None, counter_account_id=None, counter_volume=None, timestamp=None, ttl=None)#

Makes a call to POST /api/1/marketorder.

A Market Order executes immediately, and either buys as much of the asset that can be bought for a set amount of fiat currency, or sells a set amount of the asset for as much as possible.

<b>Warning!</b> Orders cannot be reversed once they have executed. Please ensure your program has been thoroughly tested before submitting Orders.

If no <code>base_account_id</code> or <code>counter_account_id</code> are specified, the default base currency or counter currency account will be used. Users can find their account IDs by calling the <a href=”#operation/getBalances”>Balances</a> request.

Permissions required: <code>Perm_W_Orders</code>

Parameters:
  • pair (str) – The currency pair to trade.

  • type (str) – <code>BUY</code> to buy an asset<br> <code>SELL</code> to sell an asset

  • base_account_id (int) – The base currency account to use in the trade.

  • base_volume (float) – For a <code>SELL</code> order: amount of the base currency to use (e.g. how much BTC to sell for EUR in the BTC/EUR market)

  • client_order_id (str) – Client order ID. May only contain alphanumeric (0-9, a-z, or A-Z) and special characters (_ ; , . -). Maximum length: 255. It will be available in read endpoints, so you can use it to reconcile Luno with your internal system. Values must be unique across all your successful order creation endpoint calls; trying to create an order with the same client_order_id as one of your past orders will result in a HTTP 409 Conflict response.

  • counter_account_id (int) – The counter currency account to use in the trade.

  • counter_volume (float) – For a <code>BUY</code> order: amount of the counter currency to use (e.g. how much EUR to use to buy BTC in the BTC/EUR market)

  • timestamp (int) – Unix timestamp in milliseconds of when the request was created and sent.

  • ttl (int) – Specifies the number of milliseconds after timestamp the request is valid for. If timestamp is not specified, ttl will not be used.

send(address, amount, currency, account_id=None, description=None, destination_tag=None, external_id=None, forex_notice_self_declaration=None, has_destination_tag=None, is_drb=None, is_forex_send=None, memo=None, message=None)#

Makes a call to POST /api/1/send.

Send assets from an Account. Please note that the asset type sent must match the receive address of the same cryptocurrency of the same type - Bitcoin to Bitcoin, Ethereum to Ethereum, etc.

Sends can be made to cryptocurrency receive addresses.

<b>Note:</b> This is currently unavailable to users who are verified in countries with money travel rules.

Permissions required: <code>Perm_W_Send</code>

Parameters:
  • address (str) –

    Destination address or email address.

    <b>Note</b>: <ul> <li>Ethereum addresses must be <a href=”ethereum/EIPs” target=”_blank” rel=”nofollow”>checksummed</a>.</li> <li>Ethereum sends to email addresses are not supported.</li> </ul>

  • amount (float) – Amount to send as a decimal string.

  • currency (str) – Currency to send.

  • account_id (int) – Optional source account. In case of multiple accounts for a single currency, the source account that will provide the funds for the transaction may be specified. If omitted, the default account will be used.

  • description (str) – User description for the transaction to record on the account statement.

  • destination_tag (int) – Optional XRP destination tag. Note that HasDestinationTag must be true if this value is provided.

  • external_id (str) – Optional unique ID to associate with this withdrawal. Useful to prevent duplicate sends in case of failure. This supports all alphanumeric characters, as well as “-” and “_”.

  • forex_notice_self_declaration (bool) – Only required for Foreign Exchange Notification under the Malaysia FEN rules. ForexNoticeSelfDeclaration must be true if the user has exceeded his/her annual investment limit in foreign currency assets.

  • has_destination_tag (bool) – Optional boolean flag indicating that a XRP destination tag is provided (even if zero).

  • is_drb (bool) – Only required for Foreign Exchange Notification under the Malaysia FEN rules. IsDRB must be true if the user has Domestic Ringgit Borrowing (DRB).

  • is_forex_send (bool) – Only required for Foreign Exchange Notification under the Malaysia FEN rules. IsForexSend must be true if sending to an address hosted outside of Malaysia.

  • memo (str) – Optional memo string used to provide account information for ATOM, etc. where it holds “account” information for a generic address.

  • message (str) – Message to send to the recipient. This is only relevant when sending to an email address.

send_fee(address, amount, currency)#

Makes a call to GET /api/1/send_fee.

Calculate fees involved with a crypto send request.

Send address can be to a cryptocurrency receive address, or the email address of another Luno platform user.

Permissions required: <code>MP_None</code>

Parameters:
  • address (str) –

    Destination address or email address.

    <b>Note</b>: <ul> <li>Ethereum addresses must be <a href=”ethereum/EIPs” target=”_blank” rel=”nofollow”>checksummed</a>.</li> <li>Ethereum sends to email addresses are not supported.</li> </ul>

  • amount (float) – Amount to send as a decimal string.

  • currency (str) – Currency to send.

stop_order(order_id)#

Makes a call to POST /api/1/stoporder.

Request to cancel an Order.

<b>Note!</b>: Once an Order has been completed, it can not be reversed. The return value from this request will indicate if the Stop request was successful or not.

Permissions required: <code>Perm_W_Orders</code>

Parameters:

order_id (str) – The Order identifier as a string.

update_account_name(id, name)#

Makes a call to PUT /api/1/accounts/{id}/name.

Update the name of an account with a given ID.

Permissions required: <code>Perm_W_Addresses</code>

Parameters:
  • id (int) – Account ID - the unique identifier for the specific Account.

  • name (str) – The label to use for this account

validate(address, currency, address_name=None, beneficiary_name=None, country=None, date_of_birth=None, destination_tag=None, has_destination_tag=None, institution_name=None, is_legal_entity=None, is_private_wallet=None, is_self_send=None, memo=None, nationality=None, physical_address=None, wallet_name=None)#

Makes a call to POST /api/1/address/validate.

Validate receive addresses, to which a customer wishes to make cryptocurrency sends, are verified under covering regulatory requirements for the customer such as travel rules.

Permissions required: <code>Perm_W_Send</code>

Parameters:
  • address (str) –

    Destination address or email address.

    <b>Note</b>: <ul> <li>Ethereum addresses must be <a href=”ethereum/EIPs” target=”_blank” rel=”nofollow”>checksummed</a>.</li> <li>Ethereum validations of email addresses are not supported.</li> </ul>

  • currency (str) – Currency is the currency associated with the address.

  • address_name (str) – AddressName is the optional name under which to store the address as in the address book.

  • beneficiary_name (str) – BeneficiaryName is the name of the beneficial owner if is it is a private address

  • country (str) – Country is the ISO 3166-1 country code of the beneficial owner of the address

  • date_of_birth (str) – DateOfBirth is the date of birth of the (non-institutional) beneficial owner of the address in the form “YYYY-MM-DD”

  • destination_tag (int) – Optional XRP destination tag. Note that HasDestinationTag must be true if this value is provided.

  • has_destination_tag (bool) – Optional boolean flag indicating that a XRP destination tag is provided (even if zero).

  • institution_name (str) – InstitutionName is the name of the beneficial owner if is it is a legal entities address

  • is_legal_entity (bool) – IsLegalEntity indicates if the address is for a legal entity and not a private beneficiary. If this field is true then the fields BeneficiaryName, Nationality & DateOfBirth should be empty but the fields InstitutionName and Country should be populated. If this field is false and IsSelfSend is false (or empty) then the field InstitutionName should be empty but the fields BeneficiaryName, Nationality & DateOfBirth and Country should be populated.

  • is_private_wallet (bool) – IsPrivateWallet indicates if the address is for private wallet and not held at an exchange.

  • is_self_send (bool) – IsSelfSend to indicate that the address belongs to the customer. If this field is true then the remaining omitempty fields should not be populated.

  • memo (str) – Optional memo string used to provide account information for ATOM, etc. where it holds “account” information for a generic address.

  • nationality (str) – Nationality ISO 3166-1 country code of the nationality of the (non-institutional) beneficial owner of the address

  • physical_address (str) – PhysicalAddress is the legal physical address of the beneficial owner of the crypto address

  • wallet_name (str) – PrivateWalletName is the name of the private wallet

class sscdev.DatabricksClient(config: str | None = None, base_path: str | None = None)#

Unified client for interacting with Databricks SQL and Workspace Files API. Uses secure credentials from Azure KeyVault under the ‘Databricks’ secret name by default. Automatically prepends a configurable base path to all file operations.

_full_path(relative_path: str) str#

Constructs the full path by prepending the base path.

query(query: str) pandas.DataFrame#

Executes a SQL query and returns results as a DataFrame.

mkdir(path: str)#

Creates a new directory at the specified relative path.

rm(path: str, recurse: bool = False)#

Deletes a file or directory at the specified relative path. If recurse=True and the path is a directory, deletes all contents recursively before removing the directory.

Parameters:

path (str): Relative path to the file or directory. recurse (bool): Whether to recursively delete directory contents. Defaults to False.

read(path: str) bytes | None#

Reads a file from the specified relative path and returns its raw bytes.

upload(path: str, contents: bytes, overwrite: bool = True)#

Uploads a file to the specified relative path.

ls(path: str | None = '/', recurse: bool = False) pandas.DataFrame#

Lists contents of a directory at the specified relative path and returns as a Pandas DataFrame. If recurse=True, traverses subdirectories recursively.

Parameters:

path (str): Relative path within the base directory. recurse (bool): Whether to list contents recursively. Defaults to False.

Returns:

pd.DataFrame: Directory contents with metadata and relative paths.

sscdev.__version__ = '3.0.0'#