question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

fetch_open_orders error for gateio

See original GitHub issue
  • OS: linux
  • Programming Language version: python 3.10
  • CCXT version: 1.0.65

Hi, I have some issue with fetch open orders for gateio cross margin. fetch_open_orders for gateio margin returns all orders on spot fetch_open_orders for gateio cross margin does not return any orders

import asyncio
import ccxtpro
from pprint import pprint
import sys
sys.stdout = open('error', 'w')
print(ccxtpro.__version__)

exchange = get_exchange('gateio_hedge_margin')
# exchange: ccxtpro.Exchange = getattr(ccxtpro, 'gateio')({
#     'enableRateLimit': True,
#     'apiKey': '',
#     'secret': '',
#     'uid': '',
#     'options': {
#         'defaultType': 'margin',
#     }
# })
symbol = 'XCAD/USDT'
exchange.verbose=True
async def main():
    while True:  
        response = await exchange.fetch_open_orders(symbol)
        # response = await exchange.fetch_open_orders(symbol, params={'defaultType': 'cross_margin'})
        pprint(response)
        break
    await exchange.close()

asyncio.run(main())
REPLACE_THIS_WITH_YOUR_OUTPUT_ERROR_EXCEPTION_IN_TEXT_NO_SCREENSHOTS

fetchopenorders.txt

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
samgermaincommented, Apr 19, 2022

fetch_open_orders for gateio margin returns all orders on spot

That correct, the api endpoint is the same so they’re mixed together

fetch_open_orders for gateio cross margin does not return any orders

I’ll look into this, currently you need to specify the parameter account as cross_margin but I’ll add a unified params.marginType parameter

0reactions
samgermaincommented, May 12, 2022

@leastchaos It’s updated now, you can now pass marginMode in params as cross or isolated. When margin mode is unset or set to isolated both cross and isolated orders are returned. You can filter them checking whether info['account'] is set to margin or spot


Python v3.10.2 CCXT v1.82.16

# Isolated                                                                # Spot                                                   # Cross                     

gateio.fetchOpenOrders(ADA/USDT, None, None, {'marginMode': 'isolated'})  gateio.fetchOpenOrders(ADA/USDT)                         gateio.fetchOpenOrders(ADA/USDT, None, None, {'marginMode': 'cross'})
[{'amount': 3.0,                                                          [{'amount': 3.0,                                         [{'amount': 3.0,
  'average': None,                                                          'average': None,                                         'average': None,
  'clientOrderId': 'apiv4',                                                 'clientOrderId': 'apiv4',                                'clientOrderId': 'apiv4',
  'cost': 0.0,                                                              'cost': 0.0,                                             'cost': 0.0,
  'datetime': '2022-05-12T00:33:10.872Z',                                   'datetime': '2022-05-12T00:33:10.868Z',                  'datetime': '2022-05-12T01:01:40.287Z',
  'fee': None,                                                              'fee': None,                                             'fee': None,
  'fees': [{'cost': '0', 'currency': 'GT'},                                 'fees': [{'cost': '0', 'currency': 'GT'},                'fees': [{'cost': '0', 'currency': 'GT'},
           {'cost': '0', 'currency': 'ADA'},                                         {'cost': '0', 'currency': 'ADA'},                        {'cost': '0', 'currency': 'ADA'},
           {'cost': '0', 'currency': 'USDT'}],                                       {'cost': '0', 'currency': 'USDT'}],                      {'cost': '0', 'currency': 'USDT'}],
  'filled': 0.0,                                                            'filled': 0.0,                                           'filled': 0.0,
  'id': '154740237893',                                                     'id': '154740237893',                                    'id': '154756422810',
  'info': {'account': 'spot',                                               'info': {'account': 'spot',                              'info': {'account': 'cross_margin',
           'amount': '3',                                                            'amount': '3',                                           'amount': '3',
           'create_time': '1652315590',                                              'create_time': '1652315590',                             'create_time': '1652317300',
           'create_time_ms': '1652315590872',                                        'create_time_ms': '1652315590868',                       'create_time_ms': '1652317300287',
           'currency_pair': 'ADA_USDT',                                              'currency_pair': 'ADA_USDT',                             'currency_pair': 'ADA_USDT',
           'fee': '0',                                                               'fee': '0',                                              'fee': '0',
           'fee_currency': 'ADA',                                                    'fee_currency': 'ADA',                                   'fee_currency': 'ADA',
           'fill_price': '0',                                                        'fill_price': '0',                                       'fill_price': '0',
           'filled_total': '0',                                                      'filled_total': '0',                                     'filled_total': '0',
           'gt_discount': False,                                                     'gt_discount': False,                                    'gt_discount': False,
           'gt_fee': '0',                                                            'gt_fee': '0',                                           'gt_fee': '0',
           'iceberg': '0',                                                           'iceberg': '0',                                          'iceberg': '0',
           'id': '154740237893',                                                     'id': '154740237893',                                    'id': '154756422810',
           'left': '3',                                                              'left': '3',                                             'left': '3',
           'point_fee': '0',                                                         'point_fee': '0',                                        'point_fee': '0',
           'price': '0.44',                                                          'price': '0.44',                                         'price': '0.44',
           'rebated_fee': '0',                                                       'rebated_fee': '0',                                      'rebated_fee': '0',
           'rebated_fee_currency': 'USDT',                                           'rebated_fee_currency': 'USDT',                          'rebated_fee_currency': 'USDT',
           'side': 'buy',                                                            'side': 'buy',                                           'side': 'buy',
           'status': 'open',                                                         'status': 'open',                                        'status': 'open',
           'text': 'apiv4',                                                          'text': 'apiv4',                                         'text': 'apiv4',
           'time_in_force': 'gtc',                                                   'time_in_force': 'gtc',                                  'time_in_force': 'gtc',
           'type': 'limit',                                                          'type': 'limit',                                         'type': 'limit',
           'update_time': '1652315590',                                              'update_time': '1652315590',                             'update_time': '1652317300',
           'update_time_ms': '1652315590872'},                                       'update_time_ms': '1652315590868'},                      'update_time_ms': '1652317300287'},
  'lastTradeTimestamp': 1652315590872,                                      'lastTradeTimestamp': 1652315590868,                     'lastTradeTimestamp': 1652317300287,
  'postOnly': False,                                                        'postOnly': False,                                       'postOnly': False,
  'price': 0.44,                                                            'price': 0.44,                                           'price': 0.44,
  'remaining': 3.0,                                                         'remaining': 3.0,                                        'remaining': 3.0,
  'side': 'buy',                                                            'side': 'buy',                                           'side': 'buy',
  'status': 'open',                                                         'status': 'open',                                        'status': 'open',
  'stopPrice': None,                                                        'stopPrice': None,                                       'stopPrice': None,
  'symbol': 'ADA/USDT',                                                     'symbol': 'ADA/USDT',                                    'symbol': 'ADA/USDT',
  'timeInForce': 'GTC',                                                     'timeInForce': 'GTC',                                    'timeInForce': 'GTC',
  'timestamp': 1652315590872,                                               'timestamp': 1652315590868,                              'timestamp': 1652317300287,
  'trades': [],                                                             'trades': [],                                            'trades': [],
  'type': 'limit'},                                                         'type': 'limit'},                                        'type': 'limit'}]
 {'amount': 3.0,                                                           {'amount': 3.0,
  'average': None,                                                          'average': None,
  'clientOrderId': 'apiv4',                                                 'clientOrderId': 'apiv4',
  'cost': 0.0,                                                              'cost': 0.0,
  'datetime': '2022-05-12T01:01:32.631Z',                                   'datetime': '2022-05-12T01:01:32.637Z',
  'fee': None,                                                              'fee': None,
  'fees': [{'cost': '0', 'currency': 'GT'},                                 'fees': [{'cost': '0', 'currency': 'GT'},
           {'cost': '0', 'currency': 'ADA'},                                         {'cost': '0', 'currency': 'ADA'},
           {'cost': '0', 'currency': 'USDT'}],                                       {'cost': '0', 'currency': 'USDT'}],
  'filled': 0.0,                                                            'filled': 0.0,
  'id': '154756354270',                                                     'id': '154756354270',
  'info': {'account': 'margin',                                             'info': {'account': 'margin',
           'amount': '3',                                                            'amount': '3',
           'create_time': '1652317292',                                              'create_time': '1652317292',
           'create_time_ms': '1652317292631',                                        'create_time_ms': '1652317292637',
           'currency_pair': 'ADA_USDT',                                              'currency_pair': 'ADA_USDT',
           'fee': '0',                                                               'fee': '0',
           'fee_currency': 'ADA',                                                    'fee_currency': 'ADA',
           'fill_price': '0',                                                        'fill_price': '0',
           'filled_total': '0',                                                      'filled_total': '0',
           'gt_discount': False,                                                     'gt_discount': False,
           'gt_fee': '0',                                                            'gt_fee': '0',
           'iceberg': '0',                                                           'iceberg': '0',
           'id': '154756354270',                                                     'id': '154756354270',
           'left': '3',                                                              'left': '3',
           'point_fee': '0',                                                         'point_fee': '0',
           'price': '0.44',                                                          'price': '0.44',
           'rebated_fee': '0',                                                       'rebated_fee': '0',
           'rebated_fee_currency': 'USDT',                                           'rebated_fee_currency': 'USDT',
           'side': 'buy',                                                            'side': 'buy',
           'status': 'open',                                                         'status': 'open',
           'text': 'apiv4',                                                          'text': 'apiv4',
           'time_in_force': 'gtc',                                                   'time_in_force': 'gtc',
           'type': 'limit',                                                          'type': 'limit',
           'update_time': '1652317292',                                              'update_time': '1652317292',
           'update_time_ms': '1652317292631'},                                       'update_time_ms': '1652317292637'},
  'lastTradeTimestamp': 1652317292631,                                      'lastTradeTimestamp': 1652317292637,
  'postOnly': False,                                                        'postOnly': False,
  'price': 0.44,                                                            'price': 0.44,
  'remaining': 3.0,                                                         'remaining': 3.0,
  'side': 'buy',                                                            'side': 'buy',
  'status': 'open',                                                         'status': 'open',
  'stopPrice': None,                                                        'stopPrice': None,
  'symbol': 'ADA/USDT',                                                     'symbol': 'ADA/USDT',
  'timeInForce': 'GTC',                                                     'timeInForce': 'GTC',
  'timestamp': 1652317292631,                                               'timestamp': 1652317292637,
  'trades': [],                                                             'trades': [],
  'type': 'limit'}]                                                         'type': 'limit'}]
Read more comments on GitHub >

github_iconTop Results From Across the Web

Possible Causes of Contract Order Failure - Gate.io
Opening a position: 1.Check if there is sufficient balance in your contract account, if there isn't, you will be notified "Transfer fund first"....
Read more >
About not processing buy order for newly listed coins on gate.io
When a coin countdown ends and it is opened to trade, I create an order within the first 164 milliseconds at the latest....
Read more >
Gate exchange can't get orders using app script - Stack Overflow
I run script in app script to get data from gate API by GET /spot/orders ... This code is work good and give...
Read more >
gate-api - PyPI
Class Method HTTP request SubAccountApi list_sub_accounts GET /sub_accounts SubAccountApi create_sub_accounts POST /sub_accounts SubAccountApi get_sub_account GET /sub_accounts/
Read more >
gate-api - npm
Class Method HTTP request DeliveryApi listDeliveryContracts GET /delivery//contracts DeliveryApi getDeliveryContract GET /delivery//contracts/ DeliveryApi listDeliveryOrderBook GET /delivery//order_book
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found