Private Methods
Private Endpoints
- class dgtx.private.PrivateApiClient
Trading privat client of Digitex
- cancel_order(orders: dgtx.digitex_rest_core.model.cancel_order.CancelOrder) dgtx.digitex_rest_core.model.cancel_order.CancelOrder
- Parameters
orders – CancelOrder class instance
to cancel an order(s) - send market_id and list of client_id(s)
to cancel order(s) by market - send only market_id
to cancel all orders for the account - send empty body
- Returns
CancelOrder class instance
{'market_id': 1, 'orders_client_ids': ['0344b6d7-9fc1-419e-b4aa-cff0b9bd82d5', 'ec825f37-1af8-46ae-89d5-d2b0ffbdaf3f', 'e164d630-de6e-4549-bde1-123f06d663ab'], 'trader_id': 119887}
- get_balance() List[dgtx.digitex_rest_core.model.balance.Balance]
Returns user balances. for unrealized p&l see get position
- Returns
List of balances per currency
[{'available_balance': Decimal('0'), 'currency': {'code': 'BXR', 'currency_scale': 4, 'id': 32, 'name': 'Blockster', 'withdraw_fee': Decimal('0E-18')}, 'main_balance': Decimal('0'), 'total_balance': Decimal('0'), 'trading_balance': Decimal('0')}, {'available_balance': Decimal('0.000499750000000000'), 'currency': {'code': 'BTC', 'currency_scale': 8, 'id': 2, 'name': 'Bitcoin', 'withdraw_fee': Decimal('0.000050000000000000')}, 'main_balance': Decimal('0'), 'total_balance': Decimal('0.000499750000000000'), 'trading_balance': Decimal('0.000499750000000000')}, {'available_balance': Decimal('65772.610500000000000000'), 'currency': {'code': 'DGTX', 'currency_scale': 4, 'id': 1, 'name': 'Digitex', 'withdraw_fee': Decimal('100.000000000000000000')}, 'main_balance': Decimal('0'), 'total_balance': Decimal('65772.610500000000000000'), 'trading_balance': Decimal('65772.610500000000000000')}, {'available_balance': Decimal('0.014990700000000000'), 'currency': {'code': 'ETH', 'currency_scale': 8, 'id': 4, 'name': 'Ethereum', 'withdraw_fee': Decimal('100.000000000000000000')}, 'main_balance': Decimal('0'), 'total_balance': Decimal('0.014990700000000000'), 'trading_balance': Decimal('0.014990700000000000')}, {'available_balance': Decimal('1.553271480000000000'), 'currency': {'code': 'USDC', 'currency_scale': 4, 'id': 7, 'name': 'USD Coin', 'withdraw_fee': Decimal('100.000000000000000000')}, 'main_balance': Decimal('0'), 'total_balance': Decimal('1.553271480000000000'), 'trading_balance': Decimal('1.553271480000000000')}, {'available_balance': Decimal('0'), 'currency': {'code': 'USDT', 'currency_scale': 4, 'id': 6, 'name': 'USDT', 'withdraw_fee': Decimal('100.000000000000000000')}, 'main_balance': Decimal('0'), 'total_balance': Decimal('0'), 'trading_balance': Decimal('0')} ]
- get_order_history(**kwargs) dgtx.digitex_rest_core.model.paged_orders_response.PagedOrdersResponse
Get trader’s order history. Returns orders that are no longer in execution. These are orders with statuses; FILLED, CANCELED or REJECTED
- Parameters
created_at_from (str, optional) – timestamp in microseconds. Returns order created after this ts
created_at_to (str, optional) – timestamp in microseconds. Returns order created before this ts
market_id (int, optional) – Return orders only for this market id
page_size (int, optional) – Number of items on a page.
cursor (str, optional) – return trades from this page (response.next, response.previous)
status (int, optional) – return only orders with this status id
- Returns
PagedOrdersResponse
{'next': 'cD0yMDIxLTA5LTI2KzA4JTNBMzYlM0E1OC41ODM4MzclMkIwMCUzQTAw', 'previous': None, 'results': [{'average_price': Decimal('0'), 'client_id': '6ab2f191-c341-42c2-b31f-e0b9a06c234d', 'created_at': 1632645707702350, 'duration': 4, 'executed_quantity': None, 'market_id': 1, 'orig_quantity': Decimal('3.000000000000000000'), 'price': Decimal('0E-18'), 'quantity': Decimal('0E-18'), 'reduce_only': False, 'side': 2, 'status': 5, 'stop_loss_price': None, 'type': 1}, {'average_price': Decimal('0'), 'client_id': '2e5abae0-15d2-4128-9451-430cbe6c2afa', 'created_at': 1632645418590972, 'duration': 4, 'executed_quantity': None, 'market_id': 1, 'orig_quantity': Decimal('1.000000000000000000'), 'price': Decimal('0E-18'), 'quantity': Decimal('0E-18'), 'reduce_only': False, 'side': 2, 'status': 5, 'stop_loss_price': None, 'type': 1}] }
- get_order_status(client_id) List[dgtx.digitex_rest_core.model.order_status_info.OrderStatusInfo]
Get single order status. The exchange only guarantees unique order id per market.
- Parameters
client_id (str, required) – Id of a an order UUID. Examples: “d3c32cc8-89b7-4a4a-8847-7a255e7739ad”
- Returns
List[OrderStatusInfo]
[ {'average_price': Decimal('0'), 'client_id': 'ec825f37-1af8-46ae-89d5-d2b0ffbdaf3f', 'created_at': 1632500527901353, 'duration': 1, 'executed_quantity': None, 'market_id': 1, 'orig_quantity': Decimal('12.000000000000000000'), 'price': Decimal('48000.000000000000000000'), 'quantity': Decimal('12.000000000000000000'), 'reduce_only': None, 'side': 2, 'status': 2, 'stop_loss_price': None, 'type': 2} ]
- get_orders(**kwargs) dgtx.digitex_rest_core.model.paged_orders_response.PagedOrdersResponse
Get all orders info, with extra params. Show only orders in status: ACCEPTED, FILLED, PARTIAL
- Parameters
type (int, optional) – Filtering by order type.
status (int, optional) – Filtering by order status.
side (int, optional) – Filtering by order side.
market_id (int, optional) – Filtering by market id.
page_size (int, optional) – Number of items on a page.
cursor (str, optional) – Query for listing pages.
- Returns
{'next': None, 'previous': None, 'results': [{'average_price': Decimal('0'), 'client_id': 'ec825f37-1af8-46ae-89d5-d2b0ffbdaf3f', 'created_at': 1632500527901353, 'duration': 1, 'executed_quantity': None, 'market_id': 1, 'orig_quantity': Decimal('12.000000000000000000'), 'price': Decimal('48000.000000000000000000'), 'quantity': Decimal('12.000000000000000000'), 'reduce_only': None, 'side': 2, 'status': 2, 'stop_loss_price': None, 'type': 2}, {'average_price': Decimal('0'), 'client_id': 'e164d630-de6e-4549-bde1-123f06d663ab', 'created_at': 1632397829564555, 'duration': 1, 'executed_quantity': None, 'market_id': 1, 'orig_quantity': Decimal('7.000000000000000000'), 'price': Decimal('35000.000000000000000000'), 'quantity': Decimal('7.000000000000000000'), 'reduce_only': None, 'side': 1, 'status': 2, 'stop_loss_price': None, 'type': 2}] }
- get_position() List[dgtx.digitex_rest_core.model.position_item.PositionItem]
Shows current position of the trader in the futures market.
- Returns
List[PositionItem]
[ {'contract_currency_id': 1, 'entry_price': Decimal('41347.500000000000000000'), 'leverage': Decimal('9.0'), 'liquidation_price': Decimal('43642.500000000000000000'), 'mark_price': Decimal('41375.308400000000000000'), 'market_id': 1, 'position_margin': Decimal('367.533600000000000000'), 'position_side': 2, 'quantity': Decimal('4.000000000000000000'), 'timestamp': 1632645712797059, 'unrealized_pnl': Decimal('-4.200000000000000000000000000')}, {'contract_currency_id': 1, 'entry_price': None, 'leverage': None, 'liquidation_price': None, 'mark_price': Decimal('2765.148000000000000000'), 'market_id': 2, 'position_margin': Decimal('0E-18'), 'position_side': None, 'quantity': Decimal('0E-18'), 'timestamp': 1632645314273798, 'unrealized_pnl': None},
- get_trade_history(**kwargs) dgtx.digitex_rest_core.model.paged_history_trades.PagedHistoryTrades
Get trade history.
- Parameters
traded_at_from (int, optional) – timestamp in microseconds. Return only trades from this ts
traded_at_to (int, optional) – timestamp in microseconds. Return only trades prior to this ts
market_id (int, optional) – market id. Return only trades for this market
page_size (int, optional) – Number of items on a page.
cursor (str, optional) – return trades from this page (response.next, response.previous)
- Returns
PagedHistoryTrades
{'next': 'bz0xJnA9MjAyMS0wOS0yNiswOCUzQTM2JTNBNTguNTgzODM3JTJCMDAlM0EwMA==', 'previous': None, 'results': [{'contract_id': 170147649, 'market_id': 1, 'price': Decimal('41360.000000000000000000'), 'quantity': Decimal('3.000000000000000000'), 'side': 2, 'traded_at': 1632645707694451}, {'contract_id': 170144115, 'market_id': 1, 'price': Decimal('41310.000000000000000000'), 'quantity': Decimal('1.000000000000000000'), 'side': 2, 'traded_at': 1632645418583837}, {'contract_id': 169264015, 'market_id': 1, 'price': Decimal('42420.000000000000000000'), 'quantity': Decimal('9.000000000000000000'), 'side': 2, 'traded_at': 1632575224882760}] }
- place_order(order: dgtx.extra_data_classes.PlaceOrderMeta) dgtx.digitex_rest_core.model.place_order.PlaceOrder
- Parameters
order – PlaceOrderMeta instance
- Returns
PlaceOrder instance
{'client_id': '0344b6d7-9fc1-419e-b4aa-cff0b9bd82d5', 'duration': 2, 'leverage': 10, 'market_id': 1, 'price': Decimal('38000.000000000000000000'), 'quantity': Decimal('9.000000000000000000'), 'side': 1, 'trader_id': 119887, 'type': 2}
- update_order(order: dgtx.extra_data_classes.UpdateOrderMeta) dgtx.digitex_rest_core.model.update_order.UpdateOrder
If at the time of the order change it is executed or becomes inactive for any of the reasons, then you will open a new order with the parameters that you passed
- Parameters
order –
client_id (str(UUID-4), required) – client id, can be found in orders instance
market_id (int, required) – market id, can be found in markets instance
side (int, required) – BUY = 1 SELL = 2
type (int, required) – MARKET = 1 LIMIT = 2
duration (int, required) – Duration of the order GFD = 1 GTC = 2 GTF = 3 IOC = 4 FOK = 5
leverage (int, required) – Leverage of the trades, only valid for futures market and will be ignored for spot
quantity (decimal, required) – Quantity of the order. If you are trading futures, this is - amount of contracts. for spot - it depends on your side.
price (decimal, required) – Price of the orders
:return .. code-block:: json
- {
“client_id”: “6a7bc84b-746a-405a-8688-85502b275b7d”, “duration”: 2, “leverage”: 1, “market_id”: 1, “price”: “46000.000000000000000000”, “quantity”: “1.000000000000000000”, “side”: 1, “trader_id”: 119511, “type”: 2
}