Trading API

To use the trading API, you will need to create an API key.

Please note that there is a default limit of 6 calls per second.

Balances

poloniex_aio.trading.returnBalances(session, api_key, secret_key)

Returns all of your available balances

Parameters:
  • session – Aiohttp client session object
  • api_key (String) – The API key
  • secret_key (String) – The API secret key

Complete balances

poloniex_aio.trading.returnCompleteBalances(session, api_key, secret_key, *, account=None)

Returns all of your balances, including available balance, balance on orders,and the estimated BTC value of your balance.

Parameters:
  • session – Aiohttp client session object
  • api_key (String) – The API key
  • secret_key (String) – The API secret key
  • account (String) – By default, this call is limited to your exchange account; set this parameter to “all” to include your margin and lending accounts.

Deposit Addresses

poloniex_aio.trading.returnDepositAddresses(session, api_key, secret_key)

Returns all of your deposit addresses.

Parameters:
  • session – Aiohttp client session object
  • api_key (String) – The API key
  • secret_key (String) – The API secret key

Generate new address

poloniex_aio.trading.generateNewAddress(session, api_key, secret_key, *, currency)

Generates a new deposit address

Parameters:
  • session – Aiohttp client session object
  • api_key (String) – The API key
  • secret_key (String) – The API secret key
  • currency (String) – The address will be generated for the currency specified here

Depoists and withdrawals history

poloniex_aio.trading.returnDepositsWithdrawals(session, api_key, secret_key, *, start=None, end=None)

Returns your deposit and withdrawal history within a range

Parameters:
  • session – Aiohttp client session object
  • api_key (String) – The API key
  • secret_key (String) – The API secret key
  • start (String) – UNIX timestamp. Every returned value will have a timestamps greater or equal.
  • end (String) – UNIX timestamp. Every returned value will have a timestamps lower or equal.

Open orders

poloniex_aio.trading.returnOpenOrders(session, api_key, secret_key, *, currencyPair)

Returns your open orders for a given market.

Parameters:
  • session – Aiohttp client session object
  • api_key (String) – The API key
  • secret_key (String) – The API secret key
  • currencyPair (String) – The currency pair. Set this to “all” to return open orders for all markets.

Trade History

poloniex_aio.trading.returnTradeHistory(session, api_key, secret_key, *, currencyPair, start=None, end=None, limit=None)

Returns your trade history for a given market.

If you do not specify a range, it will be limited to one day.

Parameters:
  • session – Aiohttp client session object
  • api_key (String) – The API key
  • secret_key (String) – The API secret key
  • currencyPair (String) – The currency pair. Set this to “all” to return open orders for all markets.
  • start (String) – UNIX timestamp. Every returned value will have a timestamps greater or equal.
  • end (String) – UNIX timestamp. Every returned value will have a timestamps lower or equal.
  • limit (String) – Maximum number of returned values. Default to 500, max 10 000

Trades involving an order

poloniex_aio.trading.returnOrderTrades(session, api_key, secret_key, *, orderNumber)

Returns all trades involving a given order

Parameters:
  • session – Aiohttp client session object
  • api_key (String) – The API key
  • secret_key (String) – The API secret key
  • orderNumber (String) – The order id

Buy order

poloniex_aio.trading.buy(session, api_key, secret_key, *, currencyPair, rate, amount, fillOrKill=None, immediateOrCancel=None, postOnly=None)

Places a limit buy order in a given market.

Parameters:
  • session – Aiohttp client session object
  • api_key (String) – the API key
  • secret_key (String) – the API secret key
  • currencyPair (String) – the currency pair
  • rate (String) – the rate to buy
  • amount (String) – the amount to buy
  • fillOrKill (String) – a fill-or-kill order will either fill in its entirety or be completely aborted
  • immediateOrCancel (String) – an immediate-or-cancel order can be partially or completely filled, but any portion of the order that cannot be filled immediately will be canceled rather than left on the order book.
  • postOnly (String) – a post-only order will only be placed if no portion of it fills immediately; this guarantees you will never pay the taker fee on any part of the order that fills.

Sell order

poloniex_aio.trading.sell(session, api_key, secret_key, *, currencyPair, rate, amount, fillOrKill=None, immediateOrCancel=None, postOnly=None)

Places a sell order in a given market. Parameters and output are the same as for the buy method.

Cancer an order

poloniex_aio.trading.cancelOrder(session, api_key, secret_key, *, orderNumber)

Cancels an order you have placed in a given market.

Parameters:
  • session – Aiohttp client session object
  • api_key (String) – The API key
  • secret_key (String) – The API secret key
  • orderNumber (String) – Order ID

Move an order

poloniex_aio.trading.moveOrder(session, api_key, secret_key, *, orderNumber, rate, amount=None, immediateOrCancel=None, postOnly=None)

Cancels an order and places a new one of the same type in a single atomic transaction, meaning either both operations will succeed or both will fail.

Parameters:
  • session – Aiohttp client session object
  • api_key (String) – The API key
  • secret_key (String) – The API secret key
  • orderNumber (String) – The order id
  • rate (String) – the new rate
  • amount (String) – the new amount
  • immediateOrCancel (String) – an immediate-or-cancel order can be partially or completely filled, but any portion of the order that cannot be filled immediately will be canceled rather than left on the order book.
  • postOnly (String) – a post-only order will only be placed if no portion of it fills immediately; this guarantees you will never pay the taker fee on any part of the order that fills.

Withdraw

poloniex_aio.trading.withdraw(session, api_key, secret_key, *, currency, amount, address, paymentId=None)

Immediately places a withdrawal for a given currency

Parameters:
  • session – Aiohttp client session object
  • api_key (String) – The API key
  • secret_key (String) – The API secret key
  • currency (String) – The currency to withdraw
  • amount (String) – The amount to withdraw
  • address (String) – The destination address
  • paymentId (String) – XMR only

Fee info

poloniex_aio.trading.returnFeeInfo(session, api_key, secret_key)

If you are enrolled in the maker-taker fee schedule, returns your current trading fees and trailing 30-day volume in BTC.

This information is updated once every 24 hours.

Parameters:
  • session – Aiohttp client session object
  • api_key (String) – The API key
  • secret_key (String) – The API secret key

Balances sorted by account

poloniex_aio.trading.returnAvailableAccountBalances(session, api_key, secret_key, *, account=None)

Returns your balances sorted by account.

Parameters:
  • session – Aiohttp client session object
  • api_key (String) – The API key
  • secret_key (String) – The API secret key
  • account (String) – if you wish to fetch only the balances of one account, set the account here.

Tradable balances

poloniex_aio.trading.returnTradableBalances(session, api_key, secret_key)

Returns your current tradable balances for each currency in each market for which margin trading is enabled.

Parameters:
  • session – Aiohttp client session object
  • api_key (String) – The API key
  • secret_key (String) – The API secret key

Transfers

poloniex_aio.trading.transferBalance(session, api_key, secret_key, *, currency, amount, fromAccount, toAccount)

Transfers funds from one account to another.

Parameters:
  • session – Aiohttp client session object
  • api_key (String) – The API key
  • secret_key (String) – The API secret key
  • fromAccount (String) – Source account
  • toAccount (String) – Destination account

Margin account summary

poloniex_aio.trading.returnMarginAccountSummary(session, api_key, secret_key)

Returns a summary of your entire margin account.

Parameters:
  • session – Aiohttp client session object
  • api_key (String) – The API key
  • secret_key (String) – The API secret key

Margin buy order

poloniex_aio.trading.marginBuy(session, api_key, secret_key, *, currencyPair, rate, amount, lendingRate=None)

Places a margin buy order in a given market.

Parameters:
  • session – Aiohttp client session object
  • api_key (String) – The API key
  • secret_key (String) – The API secret key
  • currencyPair (String) – The currency pair
  • rate (String) – The order rate.
  • amount (String) – The order amount.
  • lendingRate (String) – Maximum lending rate.

Margin sell order

poloniex_aio.trading.marginSell(session, api_key, secret_key, *, currencyPair, rate, amount, lendingRate=None)

Places a margin sell order in a given market. Parameters and output are the same as for the marginBuy method.

Margin position

poloniex_aio.trading.getMarginPosition(session, api_key, secret_key, *, currencyPair)

Returns information about your margin position in a given market.

Parameters:
  • session – Aiohttp client session object
  • api_key (String) – The API key
  • secret_key (String) – The API secret key
  • currencyPair (String) – The currency pair. Set this to “all” if you wish to fetch all of your margin positions at once.

Close margin position

poloniex_aio.trading.closeMarginPosition(session, api_key, secret_key, *, currencyPair)

Closes your margin position in a given market.

Parameters:
  • session – Aiohttp client session object
  • api_key (String) – The API key
  • secret_key (String) – The API secret key
  • currencyPair (String) – The currency pair.

Create a loan offer

poloniex_aio.trading.createLoanOffer(session, api_key, secret_key, *, currency, amount, duration, autoRenew, lendingRate)

Creates a loan offer for a given currency.

Parameters:
  • session – Aiohttp client session object
  • api_key (String) – The API key
  • secret_key (String) – The API secret key
  • currency (String) – The currency to lend
  • amount (String) – Amount of currency to lend
  • duration (String) – Lending duration
  • autoRenew (String) – Should the loan offer auto renew.
  • lendingRate (String) – The lending rate

Cancel a loan offer

poloniex_aio.trading.cancelLoanOffer(session, api_key, secret_key, *, orderNumber)

Cancels a loan offer

Parameters:
  • session – Aiohttp client session object
  • api_key (String) – The API key
  • secret_key (String) – The API secret key
  • orderNumber (String) – The loan offer ID

Open loan offers

poloniex_aio.trading.returnOpenLoanOffers(session, api_key, secret_key)

Returns your open loan offers for each currency.

Parameters:
  • session – Aiohttp client session object
  • api_key (String) – The API key
  • secret_key (String) – The API secret key

Active loans

poloniex_aio.trading.returnActiveLoans(session, api_key, secret_key)

Returns your active loans for each currency.

Parameters:
  • session – Aiohttp client session object
  • api_key (String) – The API key
  • secret_key (String) – The API secret key

Lending history

poloniex_aio.trading.returnLendingHistory(session, api_key, secret_key, *, start, end, limit=None)

Returns your lending history within a time range.

Parameters:
  • session – Aiohttp client session object
  • api_key (String) – The API key
  • secret_key (String) – The API secret key
  • start (String) – UNIX timestamp. Every returned value will have a timestamps greater or equal.
  • end (String) – UNIX timestamp. Every returned value will have a timestamps lower or equal.
  • limit (String) – Maximum number of returned values.

Toggles the autoRenew setting

poloniex_aio.trading.toggleAutoRenew(session, api_key, secret_key, *, orderNumber)

Toggles the autoRenew setting on an active.

Parameters:
  • session – Aiohttp client session object
  • api_key (String) – The API key
  • secret_key (String) – The API secret key
  • orderNumber (String) – The loan ID