Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bitget) - watch parse orders #22510

Merged
merged 1 commit into from
May 16, 2024
Merged

Conversation

ttodua
Copy link
Member

@ttodua ttodua commented May 16, 2024

async function test (){
    const e: Exchange = new pro.bitget();
    e.setSandboxMode(true);
    await e.loadMarkets();
    var symbol = "SEOS/SUSDT:SUSDT";
    e.setPositionMode(true);
     (async () =>
        {
            try
            {
                var _ordersParams = {};
                 _ordersParams["type"] = "future";
                 _ordersParams["productType"] = "SUSDT-FUTURES";

                while (true)
                {
                    var ordersResponse = await exchange.watchOrders(symbol, undefined, undefined, _ordersParams);
                    for (var order of ordersResponse)
                        c(order);
                }
            }
            catch (ex)  {  c(ex); }
        })(); 
        await e.sleep(2500); 
        var ticker = await e.fetchTicker(symbol);
        const prec = e.markets[symbol].precision.price;
        var resp = await e.createOrder(symbol, "limit", "buy", 100, ticker.ask- prec*2 );
        await e.sleep(50);
        await e.createOrder(symbol, "limit", "sell", 10, ticker.bid + prec*2);
        await e.createOrder(symbol, "market", "sell", 20);
        await e.createOrder(symbol, "market", "sell", 40);
        await e.createOrder(symbol, "market", "sell", 30);
}

runs now correctly.
I have also tested against spot partial fills

@ttodua ttodua added the bug label May 16, 2024
@carlosmiei carlosmiei changed the title fixes to w order fix(bitget) - watch parse orders May 16, 2024
@carlosmiei
Copy link
Collaborator

DEMO

 p bitget watchOrders "LTC/USDT:USDT" 
Python v3.11.7
CCXT v4.3.23
bitget.watchOrders(LTC/USDT:USDT)
[{'amount': 0.1,
  'average': None,
  'clientOrderId': '1174930092686221325',
  'cost': None,
  'datetime': '2024-05-16T09:18:03.918Z',
  'fee': {'cost': 0.0, 'currency': 'USDT'},
  'fees': [{'cost': 0.0, 'currency': 'USDT'}],
  'filled': None,
  'id': '1174930092673638403',
  'info': {'accBaseVolume': '0',
           'cTime': '1715851083918',
           'clientOid': '1174930092686221325',
           'enterPointSource': 'API',
           'feeDetail': [{'fee': '0', 'feeCoin': 'USDT'}],
           'force': 'gtc',
           'instId': 'LTCUSDT',
           'leverage': '10',
           'marginCoin': 'USDT',
           'marginMode': 'crossed',
           'notionalUsd': '8.217',
           'orderId': '1174930092673638403',
           'orderType': 'market',
           'posMode': 'hedge_mode',
           'posSide': 'short',
           'price': '0',
           'reduceOnly': 'no',
           'side': 'sell',
           'size': '0.1',
           'status': 'live',
           'tradeSide': 'open',
           'uTime': '1715851083918'},
  'lastTradeTimestamp': 1715851083918,
  'lastUpdateTimestamp': None,
  'postOnly': False,
  'price': None,
  'reduceOnly': None,
  'remaining': None,
  'side': 'sell',
  'status': 'open',
  'stopLossPrice': None,
  'stopPrice': None,
  'symbol': 'LTC/USDT:USDT',
  'takeProfitPrice': None,
  'timeInForce': 'GTC',
  'timestamp': 1715851083918,
  'trades': [],
  'triggerPrice': None,
  'type': 'market'}]
[{'amount': 0.1,
  'average': 82.18,
  'clientOrderId': '1174930092686221325',
  'cost': 8.218,
  'datetime': '2024-05-16T09:18:03.918Z',
  'fee': {'cost': 0.0049308, 'currency': 'USDT'},
  'fees': [{'cost': 0.0049308, 'currency': 'USDT'}],
  'filled': 0.1,
  'id': '1174930092673638403',
  'info': {'accBaseVolume': '0.1',
           'baseVolume': '0.1',
           'cTime': '1715851083918',
           'clientOid': '1174930092686221325',
           'enterPointSource': 'API',
           'feeDetail': [{'fee': '-0.0049308', 'feeCoin': 'USDT'}],
           'fillFee': '-0.0049308',
✗ p bitget watchOrders "LTC/USDT"      
Python v3.11.7
CCXT v4.3.23
bitget.watchOrders(LTC/USDT)
[{'amount': None,
  'average': None,
  'clientOrderId': '8c58f4d4-df0b-4457-83d8-24a35c253e87',
  'cost': 6.0,
  'datetime': '2024-05-16T09:19:21.148Z',
  'fee': None,
  'fees': [],
  'filled': None,
  'id': '1174930416609968140',
  'info': {'accBaseVolume': '0.0000',
           'cTime': '1715851161148',
           'clientOid': '8c58f4d4-df0b-4457-83d8-24a35c253e87',
           'enterPointSource': 'API',
           'feeDetail': [],
           'force': 'gtc',
           'instId': 'LTCUSDT',
           'newSize': '6.0000',
           'notional': '6.000000',
           'orderId': '1174930416609968140',
           'orderType': 'market',
           'priceAvg': '0.000',
           'side': 'buy',
           'size': '6.0000',
           'status': 'live',
           'uTime': '1715851161148'},
  'lastTradeTimestamp': 1715851161148,
  'lastUpdateTimestamp': None,
  'postOnly': False,
  'price': None,
  'reduceOnly': None,
  'remaining': None,
  'side': 'buy',
  'status': 'open',
  'stopLossPrice': None,
  'stopPrice': None,
  'symbol': 'LTC/USDT',
  'takeProfitPrice': None,
  'timeInForce': 'GTC',
  'timestamp': 1715851161148,
  'trades': [],
  'triggerPrice': None,
  'type': 'market'}]
[{'amount': 0.0729,
  'average': 82.217,
  'clientOrderId': '8c58f4d4-df0b-4457-83d8-24a35c253e87',
  'cost': 6.0,
  'datetime': '2024-05-16T09:19:21.148Z',
  'fee': {'cost': 7.29e-05, 'currency': 'LTC'},
  'fees': [{'cost': 7.29e-05, 'currency': 'LTC'}],
  'filled': 0.0729,
  'id': '1174930416609968140',
  'info': {'accBaseVolume': '0.0729',
           'baseVolume': '0.0729',
           'cTime': '1715851161148',
           'clientOid': '8c58f4d4-df0b-4457-83d8-24a35c253e87',
           'enterPointSource': 'API',
           'feeDetail': [{'fee': '-0.0000729', 'feeCoin': 'LTC'}],
           'fillFee': '-0.0000729',
           'fillFeeCoin': 'LTC',
           'fillPrice': '82.217',
           'fillTime': '1715851161220',
           'force': 'gtc',
           'instId': 'LTCUSDT',
           'newSize': '6.0000',
           'notional': '6.000000',
           'orderId': '1174930416609968140',
           'orderType': 'market',
           'priceAvg': '82.217',
           'side': 'buy',
           'size': '6.0000',
           'status': 'partially_filled',
           'tradeId': '1174930416910938208',
           'tradeScope': 'T',
           'uTime': '1715851161291'},
  'lastTradeTimestamp': 1715851161291,
  'lastUpdateTimestamp': None,
  'postOnly': False,
  'price': 82.217,
  'reduceOnly': None,
  'remaining': 0.0,
  'side': 'buy',
  'status': 'open',
  'stopLossPrice': None,
  'stopPrice': None,
  'symbol': 'LTC/USDT',
  'takeProfitPrice': None,
  'timeInForce': 'GTC',
  'timestamp': 1715851161148,
  'trades': [],
  'triggerPrice': None,
  'type': 'market'}]
[{'amount': 0.0729,
  'average': 82.217,
  'clientOrderId': '8c58f4d4-df0b-4457-83d8-24a35c253e87',
  'cost': 6.0,
  'datetime': '2024-05-16T09:19:21.148Z',
  'fee': {'cost': 7.29e-05, 'currency': 'LTC'},
  'fees': [{'cost': 7.29e-05, 'currency': 'LTC'}],
  'filled': 0.0729,
  'id': '1174930416609968140',
  'info': {'accBaseVolume': '0.0729',
           'cTime': '1715851161148',
           'clientOid': '8c58f4d4-df0b-4457-83d8-24a35c253e87',
           'enterPointSource': 'API',
           'feeDetail': [{'fee': '-0.0000729', 'feeCoin': 'LTC'}],
           'force': 'gtc',
           'instId': 'LTCUSDT',
           'newSize': '6.0000',
           'notional': '6.000000',
           'orderId': '1174930416609968140',
           'orderType': 'market',
           'priceAvg': '82.217',
           'side': 'buy',
           'size': '6.0000',
           'status': 'filled',
           'uTime': '1715851161292'},
  'lastTradeTimestamp': 1715851161292,
  'lastUpdateTimestamp': None,
  'postOnly': False,
  'price': 82.217,
  'reduceOnly': None,
  'remaining': 0.0,
  'side': 'buy',
  'status': 'closed',
  'stopLossPrice': None,
  'stopPrice': None,
  'symbol': 'LTC/USDT',
  'takeProfitPrice': None,
  'timeInForce': 'GTC',
  'timestamp': 1715851161148,
  'trades': [],
  'triggerPrice': None,
  'type': 'market'}]

@carlosmiei carlosmiei merged commit 77e95be into ccxt:master May 16, 2024
1 of 2 checks passed
@carlosmiei carlosmiei deleted the bitget-worders-2 branch May 16, 2024 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants