NashApi

class nash.api.NashApi[source]

Nash API Class

Methods

cancel_all_orders(market_name) Cancels all orders.
cancel_order(order_id, market_name) Cancels an order.
create_account(username, password[, …]) Create an account.
get_account_balance(currency) Get the account balance for a specific currency (e.g.
get_account_order(id) List the orders of this user.
get_account_portfolio(fiat_symbol, period) Gets account portfolio, optionally for a given fiat symbol or period
get_account_volumes() Get volumes for an account
get_all_asset_nonces() Updates internal list of asset/nonce sets for use in trading and adding movements.
get_assets_nonces(assets) Get a list of active nonces for an asset specified in the list provided
get_deposit_address(currency) Get a deposit address for a speciific currency
get_exchange_public_key() Get the public key of the exchange
get_exchange_status() Get current exchange status
get_market(market_name[, with_assets]) Gets a market by name.
get_movement(id) Get a movement for account by id
get_order_book(market_name) Gets an order book by market name.
get_orders_for_movement(unit) Get current asset nonce and and any orders that need to be resigned in order to add a new movement
get_sign_and_sync_states() Combines get_states, sign_states, and sync states into 1 easy to use method.
get_states() Gets a list of current balance states from the matching engine
get_ticker(market_name) Get ticker for a market
get_tokens_and_scripthashes() Return a list of tokens with info about chain and scripthash
list_account_balances(ignore_low_balance) List the balances of this user.
list_account_orders(market_name, status, …) List the orders of this user.
list_account_stakes() Get all stakes for an account
list_account_staking_dividends(month, year) Get staking dividends for account by month/year
list_account_staking_statements() List all staking statements for account
list_account_transactions(cursor, …) List the transactions of this user account.
list_assets() Lists all assets
list_candles(market_name, before, interval, …) Gets candles for a market
list_markets([with_assets]) Gets a list of all markets.
list_movements(currency, status, type) List movements for an account
list_orders(market_name, before, limit, …) Gets orders for a market
list_tickers() Gets current tickers
list_trades(market_name, before, limit) Lists all trades for a market
login(username, password[, twofa_code, …]) Login at the exchange.
logout() Logs the user out.
place_limit_order(market_name, amount, …) Place a limit order.
place_market_order(market_name, amount, …) Place a market order.
place_stop_limit_order(market_name, amount, …) Place a stop-limit order.
place_stop_market_order(market_name, amount, …) Place a stop market order.
sign_states(state_list, recycled_orders) Submits a list of signed balance states to the matching engine
sync_states(server_signed_states[, …]) Tells the system to sync a set of balances to the blockchain
verify_account(username, password[, do_login]) Auto-verifies an account.

Attributes

is_logged_in Returns whether the API is currently logged in or not.
cancel_all_orders(market_name: str = None) → nash.graphql_schema.CanceledOrders

Cancels all orders. If market_name is specified, only cancels all orders in that market.

Parameters:market_name (str, optional) – Market to cancel orders in. Defaults to None.
Returns:
Return type:nash.graphql_schema.CanceledOrders
cancel_order(order_id: str, market_name: str) → nash.graphql_schema.CanceledOrder

Cancels an order.

Parameters:
  • order_id (str) – Order ID to cancel
  • market_name (str) – Market of order to cancel
Returns:

the cancelled order

Return type:

nash.graphql_schema.CanceledOrder

Examples

>>> api.cancel_order("5142749", "eth_neo")
CanceledOrder(order_id='5142749')
create_account(username: str, password: str, country_code='US', state_code='MT', full_name='John Nasher', do_login=True)[source]

Create an account. Note that this is not usable in production environments.

Parameters:
  • username (str) – username to use
  • password (str) – password to use
  • country_code (str, optional) – country code of user. Defaults to ‘US’.
  • state_code (str, optional) – state or region of user. Defaults to ‘MT’.
  • full_name (str, optional) – full name of user. Defaults to ‘John Nasher’.
  • do_login (bool, optional) – whether to login after creating account. Defaults to True.
get_account_balance(currency: str) → nash.graphql_schema.AccountBalance

Get the account balance for a specific currency (e.g. ‘gas’)

Parameters:currency (str) – e.g. ‘gas’
Returns:balance
Return type:[nash.graphql_schema.AccountBalance]

Examples

>>> api.get_account_balance("eth")
AccountBalance(asset=Asset(blockchain='eth', blockchain_precision=18, deposit_precision=8, hash='30303030303030303030303030303030303030303030303030303030303030303030303030303030', name='Ethereum', symbol='eth', withdrawal_precision=8), available=CurrencyAmount(amount='21.5670000000000000000000000', currency='eth'), deposit_address=None, in_orders=CurrencyAmount(amount='0.0000000000000000000000000', currency='eth'), pending=CurrencyAmount(amount='0.0000000000000000000000000', currency='eth'), personal=CurrencyAmount())
get_account_order(id: int) → nash.graphql_schema.OrderHistory

List the orders of this user.

Parameters:id (int) – ID of order to retrieve
Returns:orders
Return type:nash.graphql_schema.OrderHistory

Examples

>>> orders = api.get_account_order(123)
get_account_portfolio(fiat_symbol: str = None, period: nash.graphql_schema.PortfolioGraphPeriod = 'MONTH') → nash.graphql_schema.AccountPortfolio

Gets account portfolio, optionally for a given fiat symbol or period

Parameters:
  • fiat_symbol (str, optional) – Currency to view fiat balance in. Defaults to None.
  • period (schema.PortfolioGraphPeriod, optional) – Period to view portfolio by. Defaults to “MONTH”.
Returns:

portfolio

Return type:

nash.graphql_schema.AccountPortfolio

get_account_volumes() → nash.graphql_schema.AccountVolume

Get volumes for an account

Returns:volume for this account
Return type:nash.graphql_schema.AccountVolume
get_all_asset_nonces()[source]

Updates internal list of asset/nonce sets for use in trading and adding movements.

get_assets_nonces(assets: list) → sgqlc.types.[AssetNonces]

Get a list of active nonces for an asset specified in the list provided

Parameters:assets (list(str)) – A list of assets, e.g. [“neo”, “eth”]
Returns:
Return type:[nash.graphql_schema.AssetNonces]

Examples

>>> api.get_assets_nonces(["neo", "eth"])
[AssetNonces(asset='eth', nonces=[1]), AssetNonces(asset='neo', nonces=[0])]
get_deposit_address(currency: str) → nash.graphql_schema.AccountDepositAddress

Get a deposit address for a speciific currency

Parameters:currency (str) – currency to get deposit address for. e.g. ‘eth’
Returns:a blockchain deposit address
Return type:nash.graphql_schema.AccountDepositAddress

Examples

>>> api.get_deposit_address("eth")
AccountDepositAddress(address='433CEAA0B6E98AB129DBDC4A3435F652ADA7BE7D', currency='eth')
get_exchange_public_key() → str

Get the public key of the exchange

Examples

>>> api.get_exchange_public_key()
'02e8973fb4ef7e09ed138c9d8f9c1ca2733ba9a2a3ef2af684cb09a53eaed4ba26'
Returns:The public key of the exchange
Return type:str
get_exchange_status() → nash.graphql_schema.ExchangeStatus

Get current exchange status

Examples

>>> api.get_exchange_status()
ExchangeStatus(status='running', server_timestamp=1551789721600, api_limits=[ApiLimit(request_name='candles', time_period='minutely', max_calls_per_time_period=20)])
Returns:The current status of the exchange
Return type:ExchangeStatus
get_market(market_name: str, with_assets=False) → nash.graphql_schema.Market

Gets a market by name.

Parameters:
  • market_name – name of market to get details for
  • with_assets (bool) – Whether to include the full objects for a_asset and b_asset (default=False)

Examples

>>> api.get_market('gas_neo')
Market(a_unit='gas', a_unit_precision=8, b_unit='neo', b_unit_precision=0, min_tick_size='1.0e-6', min_trade_size='1.0e-6', name='gas_neo', status='RUNNING')
Returns:a specific market
Return type:Market
get_movement(id: int) → nash.graphql_schema.Movement

Get a movement for account by id

Parameters:id (int) – Id of movement to retrieve
Returns:a specific movement
Return type:nash.graphql_schema.Movement
get_order_book(market_name: str) → nash.graphql_schema.OrderBook

Gets an order book by market name.

Examples

>>> api.get_order_book('eth_neo')
Parameters:market_name – name of market to get orders for
Returns:the order book
Return type:OrderBook
get_orders_for_movement(unit: str) → nash.graphql_schema.GetOrdersForMovementResponse

Get current asset nonce and and any orders that need to be resigned in order to add a new movement

Parameters:unit (str) – currency to query asset nonce and orders for
Returns:
Return type:nash.graphql_schema.GetOrdersForMovementResponse

Examples

>>> api.get_orders_for_movement('neo')
GetOrdersForMovementResponse(asset_nonce=1, recycled_orders=[])
get_sign_and_sync_states() → nash.graphql_schema.SyncStatesResponse

Combines get_states, sign_states, and sync states into 1 easy to use method. This should be called by a client for every 50 to 100 orders they place in order to reconcile their balances with the blockchain.

Returns:The signed messages from the matching engine
Return type:nash.graphql_schema.SignStatesResponse
get_states() → nash.graphql_schema.GetStatesResponse

Gets a list of current balance states from the matching engine

Returns:nash.graphql_schema.GetStatesResponse
get_ticker(market_name: str) → nash.graphql_schema.Ticker

Get ticker for a market

Parameters:market_name – Market to get ticker for (e.g. ‘eth_neo’)
Returns:
Return type:Ticker
get_tokens_and_scripthashes() → dict[source]

Return a list of tokens with info about chain and scripthash

is_logged_in

Returns whether the API is currently logged in or not.

Returns:is_logged_in (bool)
list_account_balances(ignore_low_balance: bool = False) → sgqlc.types.[AccountBalance]

List the balances of this user.

Parameters:ignore_low_balance (bool, optional) – currently unused

Examples

>>> api.list_account_balances()
[AccountBalance(asset=Asset(blockchain='eth', blockchain_precision=18, deposit_precision=8, hash='0000000000000000000000000000000000000000', name='Ethereum', symbol='eth', withdrawal_precision=8), available=CurrencyAmount(amount='21.5670000000000000000000000', currency='eth'), deposit_address='433CEAA0B6E98AB129DBDC4A3435F652ADA7BE7D', in_orders=CurrencyAmount(amount='0.0000000000000000000000000', currency='eth'), pending=CurrencyAmount(amount='0.0000000000000000000000000', currency='eth'), personal=CurrencyAmount(amount='0.029271040000000000', currency='eth')),
AccountBalance(asset=Asset(blockchain='eth', blockchain_precision=18, deposit_precision=8, hash='8462d1140c9dc51641c90a26a27849cca8d5e6e0', name='Basic Attention Token', symbol='bat', withdrawal_precision=8), available=CurrencyAmount(amount='0.00000000', currency='bat'), deposit_address='433CEAA0B6E98AB129DBDC4A3435F652ADA7BE7D', in_orders=CurrencyAmount(amount='0.00000000', currency='bat'), pending=CurrencyAmount(amount='0.00000000', currency='bat'), personal=CurrencyAmount(amount='11.000000000000000000', currency='bat')),
AccountBalance(asset=Asset(blockchain='eth', blockchain_precision=18, deposit_precision=8, hash='aed88173df2578fad078c48a33f0040364989fa8', name='USD Coin', symbol='usdc', withdrawal_precision=8), available=CurrencyAmount(amount='0.00000000', currency='usdc'), deposit_address='433CEAA0B6E98AB129DBDC4A3435F652ADA7BE7D', in_orders=CurrencyAmount(amount='0.00000000', currency='usdc'), pending=CurrencyAmount(amount='0.00000000', currency='usdc'), personal=CurrencyAmount(amount='51.000000000000000000', currency='usdc')),
AccountBalance(asset=Asset(blockchain='neo', blockchain_precision=8, deposit_precision=8, hash='602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7', name='GAS', symbol='gas', withdrawal_precision=8), available=CurrencyAmount(amount='0.00000000', currency='gas'), deposit_address='ALU8PyEw5csvUKdccez65jM6WGAo6m7sEX', in_orders=CurrencyAmount(amount='0.00000000', currency='gas'), pending=CurrencyAmount(amount='0.00000000', currency='gas'), personal=CurrencyAmount(amount='2.00000000', currency='gas')),
AccountBalance(asset=Asset(blockchain='neo', blockchain_precision=8, deposit_precision=0, hash='c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b', name='NEO', symbol='neo', withdrawal_precision=0), available=CurrencyAmount(amount='7.3620487500000000000000000', currency='neo'), deposit_address='ALU8PyEw5csvUKdccez65jM6WGAo6m7sEX', in_orders=CurrencyAmount(amount='0.0000000000000000000000000', currency='neo'), pending=CurrencyAmount(amount='0.0000000000000000000000000', currency='neo'), personal=CurrencyAmount(amount='5', currency='neo')),
AccountBalance(asset=Asset(blockchain='neo', blockchain_precision=8, deposit_precision=8, hash='36dfd2c33d4948a8429d00fc00a5bd70e02520ef', name='nOS', symbol='nos', withdrawal_precision=8), available=CurrencyAmount(amount='0.00000000', currency='nos'), deposit_address='ALU8PyEw5csvUKdccez65jM6WGAo6m7sEX', in_orders=CurrencyAmount(amount='0.00000000', currency='nos'), pending=CurrencyAmount(amount='0.00000000', currency='nos'), personal=CurrencyAmount(amount='50.00000000', currency='nos'))]
Returns:balances of this user
Return type:[nash.graphql_schema.AccountBalance]
list_account_orders(market_name: str = None, status: sgqlc.types.[OrderStatus] = None, before: str = None, buy_or_sell: nash.graphql_schema.OrderBuyOrSell = None, limit: int = None, range_start: sgqlc.types.datetime.DateTime = None, range_stop: sgqlc.types.datetime.DateTime = None, type: nash.graphql_schema.OrderType = None) → nash.graphql_schema.OrderHistory

List the orders of this user.

Parameters:
  • market_name (str, optional) – The market name to get account orders for
  • status ([OrderStatus], optional) – list of statuses to filter for
  • before (str, optional) – pagination cursor
  • buy_or_sell (OrderBuyOrSell, optional) – Whether to list only buy or sell orders
  • limit (int, optional) – Maximum amount of orders to return
  • range_start (str, optional) – iso8601 format
  • range_stop (str, optional) – iso8601 format
  • type (OrderType), optional) – list of order types to filter for
Returns:

order history of this account

Return type:

[nash.graphql_schema.OrderHistory]

Examples

>>> api.list_account_orders()
OrderHistory(next=None, orders=[Order(amount=CurrencyAmount(amount='1.44000000', currency='eth'), buy_or_sell='SELL', cancel_at=None, cancellation_policy=None, id='5142749', limit_price=CurrencyPrice(), market=Market(a_unit='eth', a_unit_precision=8, b_unit='neo', b_unit_precision=8, min_tick_size='0.001', min_trade_size='0.02000000', min_trade_size_b='0.50000000', name='eth_neo', status='RUNNING'), placed_at=datetime.datetime(2019, 9, 24, 20, 55, 13, 389520, tzinfo=datetime.timezone.utc), status='FILLED', stop_price=CurrencyPrice(), trades=[Trade(amount=CurrencyAmount(amount='0.10000000', currency='eth'), executed_at=datetime.datetime(2019, 9, 24, 20, 55, 13, 389520, tzinfo=datetime.timezone.utc), id='vRrkuYrQ18Sr23rVWk_ul_40Br9zl_zoKXReeL6776g', limit_price=CurrencyPrice(amount='18.450', currency_a='neo', currency_b='eth'), market=Market(a_unit='eth', a_unit_precision=8, b_unit='neo', b_unit_precision=8, min_tick_size='0.001', min_trade_size='0.02000000', min_trade_size_b='0.50000000', name='eth_neo', status='RUNNING')), Trade(amount=CurrencyAmount(amount='0.10000000', currency='eth'), executed_at=datetime.datetime(2019, 9, 24, 20, 55, 13, 389520, tzinfo=datetime.timezone.utc), id='Cb0S8iQwuBJA2m_3CqajA0EvmkaLtlZi_u0GNVyiLZI', limit_price=CurrencyPrice(amount='18.452', currency_a='neo', currency_b='eth'), market=Market(a_unit='eth', a_unit_precision=8, b_unit='neo', b_unit_precision=8, min_tick_size='0.001', min_trade_size='0.02000000', min_trade_size_b='0.50000000', name='eth_neo', status='RUNNING')), Trade(amount=CurrencyAmount(amount='0.10000000', currency='eth'), executed_at=datetime.datetime(2019, 9, 24, 20, 55, 13, 389520, tzinfo=datetime.timezone.utc), id='6QOfv9PSjxtsgD3NQYb2RN38Ud23FWBznLk2_BqMFKo', limit_price=CurrencyPrice(amount='18.451', currency_a='neo', currency_b='eth'), market=Market(a_unit='eth', a_unit_precision=8, b_unit='neo', b_unit_precision=8, min_tick_size='0.001', min_trade_size='0.02000000', min_trade_size_b='0.50000000', name='eth_neo', status='RUNNING')), Trade(amount=CurrencyAmount(amount='0.10000000', currency='eth'), executed_at=datetime.datetime(2019, 9, 24, 20, 55, 13, 389520, tzinfo=datetime.timezone.utc), id='HV6nZQgigjJnUCV1JJRUiF7C7FcS0RegjHuS5Jf6fNc', limit_price=CurrencyPrice(amount='18.452', currency_a='neo', currency_b='eth'), market=Market(a_unit='eth', a_unit_precision=8, b_unit='neo', b_unit_precision=8, min_tick_size='0.001', min_trade_size='0.02000000', min_trade_size_b='0.50000000', name='eth_neo', status='RUNNING'))], type='MARKET', amount_remaining=CurrencyAmount(amount='0.00000000', currency='eth'))])
>>> api.list_account_orders("gas_neo", "OPEN")
>>> api.list_account_orders("gas_neo", buy_or_sell="BUY")
>>> api.list_account_orders("gas_neo", buy_or_sell="BUY", range_start='2019-01-02T12:34:56Z', range_stop='2019-01-22T12:34:56Z')
list_account_stakes() → nash.graphql_schema.AccountStakes

Get all stakes for an account

Returns:all stakes
Return type:nash.graphql_schema.AccountStakes
list_account_staking_dividends(month: int, year: int) → nash.graphql_schema.AccountStakingDividends

Get staking dividends for account by month/year

Parameters:
  • month (int) – month to search for
  • year (int) – year to search for
Returns:

the dividends

Return type:

nash.graphql_schema.AccountStakingDividends

list_account_staking_statements() → sgqlc.types.[AccountStakingStatement]

List all staking statements for account

Returns:staking statements
Return type:[nash.graphql_schema.AccountStakingStatement]
list_account_transactions(cursor: str = None, fiat_symbol: str = None, limit: int = None) → nash.graphql_schema.ListAccountTransactionsResponse

List the transactions of this user account.

Parameters:
  • cursor (str, optional) – offset to search for
  • fiat_symbol (str, optional) – fiat symbol for value representation of transaction
  • limit (str, optional) – how many results to return
Returns:

transactions of this user

Return type:

nash.graphql_schema.ListAccountTransactionsResponse

Example

>>> api.list_account_transactions()
list_assets() → sgqlc.types.[Asset]

Lists all assets

Returns:
Return type:[Asset]

Example

>>> api.list_assets()
[Asset(blockchain='eth', hash='0d8775f648430679a709e98d2b0cb6250d2887ef', name='BAT', precision=18, symbol='bat', tradeable=True, withdrawal_precision=18),
Asset(blockchain='eth', hash='0000000000000000000000000000000000000000', name='Ethereum', precision=18, symbol='eth', tradeable=True, withdrawal_precision=18),
Asset(blockchain='neo', hash='602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7', name='Gas', precision=8, symbol='gas', tradeable=True, withdrawal_precision=8),
Asset(blockchain='neo', hash='bb3b54ab244b3658155f2db4429fc38ac4cef625', name='Moonlight Lux', precision=8, symbol='lx', tradeable=True, withdrawal_precision=8),
Asset(blockchain='neo', hash='1a16b760432e28aca03a76e9afe5522e9acad781', name='NEX Token', precision=8, symbol='nex', tradeable=True, withdrawal_precision=8),
...
list_candles(market_name: str, before: sgqlc.types.datetime.DateTime = None, interval: nash.graphql_schema.CandleInterval = 'ONE_MINUTE', limit: int = 25) → nash.graphql_schema.CandleRange

Gets candles for a market

Parameters:
  • market_name (str) – Market to list candles for (e.g. ‘eth_neo’)
  • before (iso8601 date, optional) – DateTime before which to list candles
  • interval (str/CandleInterval, optional) – CandleInterval
  • limit (int, optional) – max number of candles to retrieve
Returns:

Return type:

CandleRange

Examples

>>> api.list_candles('gas_neo')
CandleRange(candles=[Candle(a_volume=CurrencyAmount(amount='210.00000000', currency='gas'), b_volume=CurrencyAmount(amount='10', currency='neo'), close_price=CurrencyPrice(amount='0.047619', currency_a='neo', currency_b='gas'), high_price=CurrencyPrice(amount='0.047619', currency_a='neo', currency_b='gas'), interval='ONE_MINUTE', interval_starting_at=datetime.datetime(2019, 2, 28, 17, 49, tzinfo=datetime.timezone.utc), low_price=CurrencyPrice(amount='0.047619', currency_a='neo', currency_b='gas'), open_price=CurrencyPrice(amount='0.047619', currency_a='neo', currency_b='gas')), Candle(a_volume=CurrencyAmount(amount='22797.00000000', currency='gas'), b_volume=CurrencyAmount(amount='1714', currency='neo'), close_price=CurrencyPrice(amount='0.071428', currency_a='neo', currency_b='gas'), high_price=CurrencyPrice(amount='0.071428', currency_a='neo', currency_b='gas'), interval='ONE_MINUTE', interval_starting_at=datetime.datetime(2019, 2, 28, 17, 48, tzinfo=datetime.timezone.utc), low_price=CurrencyPrice(amount='0.083333', currency_a='neo', currency_b='gas'), open_price=CurrencyPrice(amount='0.071428', currency_a='neo', currency_b='gas'))])
list_markets(with_assets=False) → sgqlc.types.[Market]

Gets a list of all markets.

Parameters:with_assets (bool) – Whether to include the full objects for a_asset and b_asset (default=False)

Examples

>>> api.list_markets()
[Market(id='market:eth_neo', a_unit='eth', a_unit_precision=8, b_unit='neo', b_unit_precision=8, min_tick_size='0.001', min_trade_size='0.02000000', min_trade_size_b='0.50000000', min_trade_increment='0.00001', min_trade_increment_b='0.001', name='eth_neo', status='RUNNING'),
Market(id='market:eth_bat', a_unit='eth', a_unit_precision=7, b_unit='bat', b_unit_precision=7, min_tick_size='0.01', min_trade_size='0.0200000', min_trade_size_b='10.0000000', min_trade_increment='0.00001', min_trade_increment_b='0.01', name='eth_bat', status='RUNNING'),
...]
Returns:a list of markets
Return type:[Market]
list_movements(currency: str = None, status: nash.graphql_schema.MovementStatus = None, type: nash.graphql_schema.MovementType = None) → sgqlc.types.[Movement]

List movements for an account

Parameters:
  • ignore_low_balance (bool, optional) – currently unused
  • currency (str, optional) – currency to filter by
  • status (MovementStatus, optional) – MovementStatus to filter by
  • type (MovementType, optional) – MovementType to filter by
Returns:

movements of this account

Return type:

[nash.graphql_schema.Movement]

list_orders(market_name: str, before: sgqlc.types.datetime.DateTime = None, limit: int = 50, status: sgqlc.types.[OrderStatus] = None, buy_or_sell: nash.graphql_schema.OrderBuyOrSell = None, range_start: sgqlc.types.datetime.DateTime = None, range_stop: sgqlc.types.datetime.DateTime = None, order_types: sgqlc.types.[OrderType] = None) → nash.graphql_schema.OrderHistory

Gets orders for a market

Parameters:
  • market_name (str) – Market to list orders for (e.g. ‘eth_neo’)
  • before (iso8601 date, optional) – DateTime before which to list candles
  • limit (int, optional) – max number of candles to retrieve
  • status ([OrderStatus], optional) – status of orders to query
  • buy_or_sell (OrderBuyOrSell, optional) – ‘BUY’ or ‘SELL’
  • range_start (DateTime, optional) – start of orders to retrieve
  • range_stop (DateTime, optional) – end of orders to retrieve
  • order_types ([OrderType], optional) – ‘LIMIT’, ‘MARKET’, ‘STOP_LIMIT’, ‘STOP_MARKET’
Returns:

Return type:

OrderHistory

list_tickers() → sgqlc.types.[Ticker]

Gets current tickers

Returns:
Return type:[Ticker]
list_trades(market_name: str, before: sgqlc.types.datetime.DateTime = None, limit: int = 50) → nash.graphql_schema.TradeHistory

Lists all trades for a market

Parameters:
  • market_name – Market to list trades for (e.g. ‘eth_neo’)
  • before – DateTime before which to list candles
  • limit – max number of trades to retrieve
Returns:

Return type:

TradeHistory

login(username, password, twofa_code=None, auto_relogin=True)[source]

Login at the exchange. Receive the user key and chain indices, derive the private keys

If login fails for any reason, raises LoginFailedError.

Parameters:
  • username (str) – email address
  • password (str) – password
  • twofa_code (str, optional) – If 2FA is enabled, the current code
  • auto_relogin (bool) – Whether to automatically relogin after a session expiry. Defaults to True
Returns:

None

Raises:

nash.exceptions.LoginFailedError

logout()[source]

Logs the user out. Currently only clears local variables and tokens. Perhaps later we’d also issue a logout request to the CAS

Returns:None
place_limit_order(market_name: str, amount: nash.nash_core.CurrencyAmount, buy_or_sell: nash.graphql_schema.OrderBuyOrSell, cancellation_policy: nash.graphql_schema.OrderCancellationPolicy, limit_price: str, allow_taker: bool, cancel_at: int = None, retry_on_missing_nonces: bool = True) → nash.graphql_schema.OrderPlaced

Place a limit order.

Parameters:
  • market_name (str) – Market to place order for (e.g. ‘gas_neo’)
  • amount (CurrencyAmount) – Amount to buy or sell as a CurrencyAmount (i.e. CurrencyAmount.FromString(“0.12345 eth”))
  • buy_or_sell (str) – Either “BUY” or “SELL”
  • cancellation_policy (str/schema.OrderCancellationPolicy) – cancellation policy
  • limit_price (str) – Limit price, always specified in b_unit per a_unit of market (in eth_neo, stop price is X neo per eth, where we supply X)
  • allow_taker (bool) – Whether to allow a taker order
  • cancel_at (int, optional) – timestamp when to cancel for the GOOD_TIL_TIME cancellation policy
Returns:

Return type:

nash.graphql_schema.OrderPlaced

Raises:

AttributeError – if invalid market_name, buy_or_sell, amount or stop_price argument

Examples

Sell 1.44 GAS (for NEO) with limit price of 0.1:

>>> api.place_limit_order("gas_neo", "1.44", "SELL", "GOOD_TIL_CANCELLED", "0.1", allow_taker=True)
OrderPlaced(id='3150', status='PENDING')
place_market_order(market_name: str, amount: nash.nash_core.CurrencyAmount, buy_or_sell: nash.graphql_schema.OrderBuyOrSell, retry_on_missing_nonces: bool = True) → nash.graphql_schema.OrderPlaced

Place a market order.

Parameters:
  • market_name (str) – Market to place order for (e.g. ‘gas_neo’)
  • amount (CurrencyAmount) – Amount to buy or sell as a CurrencyAmount (i.e. CurrencyAmount.FromString(“0.12345 eth”))
  • buy_or_sell (str) – Either “BUY” or “SELL”
Returns:

placed order

Return type:

nash.graphql_schema.OrderPlaced

Raises:

AttributeError – if invalid market_name or buy_or_sell or amount argument

Examples

Sell 1.44 ETH (for NEO):

>>> api.place_market_order("eth_neo", CurrencyAmount("1.44","eth"), "SELL")
OrderPlaced(id='5142749', status='PENDING')
place_stop_limit_order(market_name: str, amount: nash.nash_core.CurrencyAmount, buy_or_sell: nash.graphql_schema.OrderBuyOrSell, cancellation_policy: nash.graphql_schema.OrderCancellationPolicy, limit_price: str, stop_price: str, allow_taker: bool, cancel_at: int = None, retry_on_missing_nonces: bool = True) → nash.graphql_schema.OrderPlaced

Place a stop-limit order.

Parameters:
  • market_name (str) – Market to place order for (e.g. ‘gas_neo’)
  • amount (CurrencyAmount) – Amount to buy or sell as a CurrencyAmount (i.e. CurrencyAmount.FromString(“0.12345 eth”))
  • buy_or_sell (str) – Either “BUY” or “SELL”
  • cancellation_policy (str/schema.OrderCancellationPolicy) – cancellation policy
  • limit_price (str) – Limit price, always specified in b_unit per a_unit of market (in eth_neo, stop price is X neo per eth, where we supply X)
  • stop_price (str) – Price to stop at, always specified in b_unit per a_unit of market (in eth_neo, stop price is X neo per eth, where we supply X)
  • allow_taker (bool) – Whether to allow a taker order
  • cancel_at (int, optional) – timestamp when to cancel, for the GOOD_TIL_TIME cancellation policy
Returns:

Return type:

nash.graphql_schema.OrderPlaced

Raises:

AttributeError – if invalid market_name, buy_or_sell, amount or stop_price argument

Examples

Sell 1.44 GAS (for NEO) with limit price of 0.1 and stop price of 0.2:

>>> api.place_stop_limit_order("gas_neo", "1.44", "SELL", "GOOD_TIL_CANCELLED", limit_price="0.1", stop_price="0.2", allow_taker=True)
OrderPlaced(id='3150', status='PENDING')
place_stop_market_order(market_name: str, amount: nash.nash_core.CurrencyAmount, buy_or_sell: nash.graphql_schema.OrderBuyOrSell, stop_price: str, retry_on_missing_nonces: bool = True) → nash.graphql_schema.OrderPlaced

Place a stop market order.

Parameters:
  • market_name (str) – Market to place order for (e.g. ‘gas_neo’)
  • amount (CurrencyAmount) – Amount to buy or sell as a CurrencyAmount (i.e. CurrencyAmount.FromString(“0.12345 eth”))
  • buy_or_sell (str) – Either “BUY” or “SELL”
  • stop_price (str) – Price to stop at, always specified in b_unit per a_unit of market (in eth_neo, stop price is X neo per eth, where we supply X)
Returns:

Return type:

nash.graphql_schema.OrderPlaced

Raises:

AttributeError – if invalid market_name, buy_or_sell, amount or stop_price argument

Examples

Sell 1.44 GAS (for NEO) with stop price of 0.1:

>>> api.place_stop_market_order("gas_neo", CurrencyAmount.FromString("1.44 gas)", "SELL", "0.1")
OrderPlaced(id='3150', status='PENDING')
sign_states(state_list: list, recycled_orders: list = []) → nash.graphql_schema.SignStatesResponse

Submits a list of signed balance states to the matching engine and gathers the same states with the matching engine signatures

Parameters:state_list (list) – A list of {‘message’:’abc’,’blockchain’:’neo’} items
Returns:The signed messages from the matching engine
Return type:nash.graphql_schema.SignStatesResponse
sync_states(server_signed_states: sgqlc.types.[ServerSignedState], override_movements=False) → nash.graphql_schema.SyncStatesResponse

Tells the system to sync a set of balances to the blockchain

Parameters:
  • server_signed_states ([ServerSignedState]) – ServerSignedState list retrieved from sign_states call.
  • override_movements (bool, optional) – Whether to clear pending deposits. Defaults to False.
Returns:

nash.graphql_schema.SyncStatesResponse

verify_account(username, password, do_login=True)[source]

Auto-verifies an account. Note that this will not work in production.

Parameters:
  • username (str) – username to verify
  • password (str) – password for user..
  • do_login (bool, optional) – whether to login after verifying. Defaults to True.