Skip to content

Orders History

poloniex-sdk edited this page Jan 10, 2023 · 3 revisions

Order History

get_history

get_history(account_type=None, hide_cancel=None, start_time=None, end_time=None, begins_from=None, **kwargs)

Get a list of historical orders in an account.

Args:

  • account_type (str, optional): SPOT is the default and only supported one.
  • hide_cancel (bool, optional): true or false. Whether canceled orders should not be retrieved. (Default: false)
  • start_time (int, optional): (milliseconds since UNIX epoch) Orders updated before start_time will not be retrieved.
  • end_time (int, optional): (milliseconds since UNIX epoch) Orders updated after end_time will not be retrieved.
  • begins_from (int, optional): An 'orderId'. The query begins at ‘from'.

Keyword Args:

  • type (str, optional): MARKET, LIMIT, LIMIT_MAKER (Default: all types).
  • side (str, optional): BUY, SELL (Default: both sides).
  • symbol (str, optional): Any supported symbol (Default: all symbols).
  • direction (str, optional): PRE, NEXT The direction before or after ‘from'.
  • states (str, optional): FAILED, FILLED, CANCELED. PARTIALLY_CANCELED Multiple states can be specified and separated with comma. (Default: all states)
  • limit (int, optional): The max number of orders could be returned. (Default: 100)

Returns:

A list of json objects with order history information:

[
    {
        'id': (str) Order id,
        'clientOrderId': (str) User specified id,
        'symbol': (str) The symbol the trade is for, like BTC_USDT,
        'accountType': (str) Account type,
        'side': (str) Possible sides(BUY, SELL),
        'type': (str) Possible types(MARKET, LIMIT, LIMIT_MAKER),
        'timeInForce': (str) Possible values(GTC, IOC, FOK),
        'price': (str) Price for the order,
        'avgPrice': (str) avgPrice = filledAmount/filledQuantity,
        'quantity': (str) Quote units to be traded for order,
        'amount': (str) Base units to be traded for order,
        'filledQuantity': (str) Quote units already traded on order,
        'filledAmount': (str) Base units already traded on order,
        'state': (str) Possible states(PENDING_NEW, NEW, PARTIALLY_FILLED, FILLED, PENDING_CANCEL,
                       PARTIALLY_CANCELED, CANCELED, REJECTED, EXPIRED, FAILED),
        'orderSource': (str) Possible values(API, APP, WEB),
        'createTime': (int) Create time,
        'updateTime': (int) Update time
    },
    {...},
    ...
]

Raises:

  • RequestError: An error occurred communicating with trade engine.

Example:

response = client.orders().get_history(symbol='BTC_USDT')
print(response)

Smart Orders History

get_history

get_history(account_type=None, hide_cancel=None, start_time=None, end_time=None, begins_from=None, **kwargs)

Get a list of historical smart orders in an account.

Args:

  • account_type (str, optional): SPOT is the default and only supported one.
  • hide_cancel (bool, optional): true or false. Whether canceled orders should not be retrieved. (Default: false)
  • start_time (int, optional): (milliseconds since UNIX epoch) Orders updated before start_time will not be retrieved.
  • end_time (int, optional): (milliseconds since UNIX epoch) Orders updated after end_time will not be retrieved.
  • begins_from (int, optional): An 'orderId'. The query begins at ‘from'.

Keyword Args:

  • type (str, optional): MARKET, LIMIT, LIMIT_MAKER (Default: all types).
  • side (str, optional): BUY, SELL (Default: both sides).
  • symbol (str, optional): Any supported symbol (Default: all symbols).
  • direction (str, optional): PRE, NEXT The direction before or after ‘from'.
  • states (str, optional): FAILED, FILLED, CANCELED. PARTIALLY_CANCELED Multiple states can be specified and separated with comma. (Default: all states)
  • limit (int, optional): The max number of orders could be returned. (Default: 100)

Returns:

A list of json objects with smart order history information:

[
    {
        'id': (str) Order id,
        'clientOrderId': (str) User specified id,
        'symbol': (str) The symbol the trade is for, like BTC_USDT,
        'accountType': (str) Account type,
        'side': (str) Possible sides(BUY, SELL),
        'type': (str) Possible types(MARKET, LIMIT, LIMIT_MAKER),
        'timeInForce': (str) Possible values(GTC, IOC, FOK),
        'price': (str) Price for the order,
        'avgPrice': (str) avgPrice = filledAmount/filledQuantity,
        'quantity': (str) Quote units to be traded for order,
        'amount': (str) Base units to be traded for order,
        'filledQuantity': (str) Quote units already traded on order,
        'filledAmount': (str) Base units already traded on order,
        'state': (str) Possible states(PENDING_NEW, NEW, PARTIALLY_FILLED, FILLED, PENDING_CANCEL,
                       PARTIALLY_CANCELED, CANCELED, REJECTED, EXPIRED, FAILED),
        'orderSource': (str) Possible values(API, APP, WEB),
        'createTime': (int) Create time,
        'updateTime': (int) Update time
    },
    {...},
    ...
]

Raises:

  • RequestError: An error occurred communicating with trade engine.

Example:

response = client.smartorders().get_history(symbol='BTC_USDT')
print(response)

Clone this wiki locally