Ccxt: [okex] fetchMyTrades missing

Created on 29 Mar 2020  ·  60Comments  ·  Source: ccxt/ccxt

GET/api/spot/v3/fill

https://www.okex.com/docs/en/#spot-detail

enhancement question

Most helpful comment

@npomfret in your output I see this:

[
    {..., "trade_id":"3578669"}, --+-- pair of "trades" # 1
    {..., "trade_id":"3578669"}, -/
    {..., "trade_id":"3578668"}, --+-- pair of "trades" # 2
    {..., "trade_id":"3578668"}, -/
    {..., "trade_id":"3578667"}, --+-- pair of "trades" # 3
    {..., "trade_id":"3578667"}, -/
] 

So, despite that there are more than two pairs, each pair is just two trades, which makes it possible to group those by a trade_id. There was no trade_id previously, so it was impossible to pair them previously. But they have added it a month ago (must be the negative feedback from the users) and that makes the grouping+parsing possible now:

Screen-Shot-2020-03-29-at-21 07 56

All 60 comments

I think it's api/spot/v3/fills.

They actually return two rows for each trade from that endpoint. Which is a big problem, don't know why OKEX would do that to their clients...

I made two trades, and it returns 4 rows, and it's impossible to know which ones are "mine", without comparing the order ids to a list of orders that must be retrieved separately.

okex.spotGetFills ([object Object])
fetch:
 okex GET https://www.okex.com/api/spot/v3/fills?instrument_id=ETH-USDT
Request:
 {
  'OK-ACCESS-KEY': 'XXXXXXXXXXXXXXXXXXXX',
  'OK-ACCESS-PASSPHRASE': 'XXXXXXXXXXXXXXXXXXXX',
  'OK-ACCESS-TIMESTAMP': '2020-03-29T11:56:04.837Z',
  'OK-ACCESS-SIGN': 'XXXXXXXXXXXXXXXXXXXX'
}
 undefined

handleRestResponse:
 okex GET https://www.okex.com/api/spot/v3/fills?instrument_id=ETH-USDT 200 OK
Response:
 {
  'Cache-Control': 'no-cache, no-store, max-age=0, must-revalidate',
  'Cf-Cache-Status': 'DYNAMIC',
  'Cf-Ray': '57b967d25f2c5aaa-DME',
  Connection: 'keep-alive',
  'Content-Encoding': 'gzip',
  'Content-Type': 'application/json',
  Date: 'Sun, 29 Mar 2020 11:56:05 GMT',
  'Expect-Ct': 'max-age=604800, ' +
    'report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"',
  Expires: '0',
  'Ok-After': '10562922668',
  'Ok-Before': '10562924353',
  'Ok-From': '10562924353',
  'Ok-Limit': '100',
  'Ok-To': '10562922668',
  Pragma: 'no-cache',
  Server: 'cloudflare',
  'Set-Cookie': '__cfduid=d11d37f09a80ff6d29e491533b6108b2e1585482964; expires=Tue, ' +
    '28-Apr-20 11:56:04 GMT; path=/; domain=.okex.com; HttpOnly; ' +
    'SameSite=Lax, locale=en_US; Max-Age=604800; Expires=Sun, 05-Apr-2020 ' +
    '11:56:04 GMT; Path=/',
  'Strict-Transport-Security': 'max-age=63072000; includeSubdomains; preload',
  'Transfer-Encoding': 'chunked',
  Vary: 'Accept-Encoding',
  Via: 'King Kong',
  'X-Brokerid': '0',
  'X-Content-Type-Options': 'nosniff',
  'X-Frame-Options': 'DENY',
  'X-Kong-Proxy-Latency': '0',
  'X-Kong-Upstream-Latency': '79',
  'X-Xss-Protection': '1; mode=block'
}
 [{"created_at":"2020-03-29T11:55:25.000Z","currency":"USDT","exec_type":"T","fee":"-0.04647925","instrument_id":"ETH-USDT","ledger_id":"10562924353","liquidity":"T","order_id":"4636470489136128","price":"129.13","product_id":"ETH-USDT","side":"buy","size":"30.98616393","timestamp":"2020-03-29T11:55:25.000Z","trade_id":"18551601"},{"created_at":"2020-03-29T11:55:25.000Z","currency":"ETH","exec_type":"T","fee":"0","instrument_id":"ETH-USDT","ledger_id":"10562924352","liquidity":"T","order_id":"4636470489136128","price":"129.13","product_id":"ETH-USDT","side":"sell","size":"0.23996099","timestamp":"2020-03-29T11:55:25.000Z","trade_id":"18551601"},{"created_at":"2020-03-29T11:55:16.000Z","currency":"ETH","exec_type":"T","fee":"-0.00036049","instrument_id":"ETH-USDT","ledger_id":"10562922669","liquidity":"T","order_id":"4636469894136832","price":"129.16","product_id":"ETH-USDT","side":"buy","size":"0.240322","timestamp":"2020-03-29T11:55:16.000Z","trade_id":"18551600"},{"created_at":"2020-03-29T11:55:16.000Z","currency":"USDT","exec_type":"T","fee":"0","instrument_id":"ETH-USDT","ledger_id":"10562922668","liquidity":"T","order_id":"4636469894136832","price":"129.16","product_id":"ETH-USDT","side":"sell","size":"31.03998952","timestamp":"2020-03-29T11:55:16.000Z","trade_id":"18551600"}]

              created_at | currency | exec_type |         fee | instrument_id |   ledger_id | liquidity |         order_id |  price | product_id | side |        size |                timestamp | trade_id
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2020-03-29T11:55:25.000Z |     USDT |         T | -0.04647925 |      ETH-USDT | 10562924353 |         T | 4636470489136128 | 129.13 |   ETH-USDT |  buy | 30.98616393 | 2020-03-29T11:55:25.000Z | 18551601
2020-03-29T11:55:25.000Z |      ETH |         T |           0 |      ETH-USDT | 10562924352 |         T | 4636470489136128 | 129.13 |   ETH-USDT | sell |  0.23996099 | 2020-03-29T11:55:25.000Z | 18551601
2020-03-29T11:55:16.000Z |      ETH |         T | -0.00036049 |      ETH-USDT | 10562922669 |         T | 4636469894136832 | 129.16 |   ETH-USDT |  buy |    0.240322 | 2020-03-29T11:55:16.000Z | 18551600
2020-03-29T11:55:16.000Z |     USDT |         T |           0 |      ETH-USDT | 10562922668 |         T | 4636469894136832 | 129.16 |   ETH-USDT | sell | 31.03998952 | 2020-03-29T11:55:16.000Z | 18551600
4 objects

@npomfret so, considering the above, we have two options:

  1. don't add fetchMyTrades to OKEX to avoid confusion
  2. add it and return two times more trades from it than expected, for both sides of each fill.

What would you suggest?

@npomfret the format they return from ../fills is really much closer to the ledger output than to a list of fills...

@npomfret also, there's a third option:

  1. don't add fetchMyTrades to OKEX to avoid confusion
  2. add it and return two times more trades from it than expected, for both sides of each fill
  3. pair them by trade_id and return joined pairs with side = undefined

Let me know your thoughts.

Oh yes, I remember this nonsense now... it will break pagination too right?

it will break pagination too right?

Well, they don't offer any time-based pagination anymore (only by id), so the pagination will still be possible, though, if you pass limit=100, you will receive 50 trades, obviously. We could add a warning to the users, something they could acknowledge, suppress and adjust for... Let me know if you think (3) is a viable option.

If adding a warning is an option, could we just return each fill as if it belonged to the user and leave it up to them to filter out the ones they don't want?

could we just return each fill as if it belonged to the user and leave it up to them to filter out the ones they don't want?

In that case, half of the info will be missing in all trades. If you look carefully into the table above – the data is distributed over rows in a way that makes a single entry meaningless without its pair. I'd rather merge those pairs in CCXT, to properly parse the fees and the sides where possible. Otherwise there's really no point in having a unified method that returns non-unified results – we'd rather recommend to fallback to the implicit endpoint for user-specific parsing. Does that make sense?

Give me some time, I'll places some orders and see what the trades look like

Hmmm, the logic I have in my app (which I wrote a while ago and don't remember how I came to the conclusion that I did) using loadTradesForOrder...

  • discard the sell item(s) from the fills (regardless of the side of the originating order)
  • reverse engineer the price for the remaining item(s):

                const {price, amount} = trade;
                const trueAmount = amount / price;
                trade.cost = amount;
                trade.amount = trueAmount;
    
    • update the side of the fills (but I use the original order to do this) - can't see a way around this

Here is a sell order with it's fills:

order: {
  "id": "4590592864626688",
  "cost": 0.009865732254,
  "info": {
    "side": "sell",
    "size": "1.599762",
    "type": "limit",
    "funds": "",
    "price": "0.006167",
    "state": "2",
    "status": "filled",
    "notional": "",
    "order_id": "4590592864626688",
    "price_avg": "0.006167",
    "timestamp": "2020-03-21T09:28:08.000Z",
    "client_oid": "",
    "created_at": "2020-03-21T09:28:08.000Z",
    "order_type": "0",
    "product_id": "LTC-BTC",
    "filled_size": "1.599762",
    "instrument_id": "LTC-BTC",
    "filled_notional": "0.009865732254"
  },
  "side": "sell",
  "type": "limit",
  "price": 0.006167,
  "amount": 1.599762,
  "filled": 1.599762,
  "status": "closed",
  "symbol": "LTC/BTC",
  "average": 0.006167,
  "datetime": "2020-03-21T09:28:08.000Z",
  "remaining": 0,
  "timestamp": 1584782888000,
  "clientOrderId": ""
}
fills: [
  {
    "info": {
      "created_at": "2020-03-21T09:28:17.000Z",
      "currency": "BTC",
      "exec_type": "M",
      "fee": "-0.00000987",
      "instrument_id": "LTC-BTC",
      "ledger_id": "10397867660",
      "liquidity": "M",
      "order_id": "4590592864626688",
      "price": "0.006167",
      "product_id": "LTC-BTC",
      "side": "buy",
      "size": "0.00986573",
      "timestamp": "2020-03-21T09:28:17.000Z",
      "trade_id": "3720712"
    },
    "timestamp": 1584782897000,
    "datetime": "2020-03-21T09:28:17.000Z",
    "symbol": "LTC/BTC",
    "id": "3720712",
    "order": "4590592864626688",
    "takerOrMaker": "maker",
    "side": "buy",
    "price": 0.006167,
    "amount": 0.00986573,
    "cost": 0.00006084195691,
    "fee": {
      "cost": 0.00000987,
      "currency": "LTC"
    }
  },
  {
    "info": {
      "created_at": "2020-03-21T09:28:17.000Z",
      "currency": "LTC",
      "exec_type": "M",
      "fee": "0",
      "instrument_id": "LTC-BTC",
      "ledger_id": "10397867659",
      "liquidity": "M",
      "order_id": "4590592864626688",
      "price": "0.006167",
      "product_id": "LTC-BTC",
      "side": "sell",
      "size": "1.599762",
      "timestamp": "2020-03-21T09:28:17.000Z",
      "trade_id": "3720712"
    },
    "timestamp": 1584782897000,
    "datetime": "2020-03-21T09:28:17.000Z",
    "symbol": "LTC/BTC",
    "id": "3720712",
    "order": "4590592864626688",
    "takerOrMaker": "maker",
    "side": "sell",
    "price": 0.006167,
    "amount": 1.599762,
    "cost": 0.009865732253999998,
    "fee": {
      "cost": 0,
      "currency": "BTC"
    }
  }
]

And here is a buy order with it's fills:

order: {
  "id": "4624897385308160",
  "cost": 0.00305113878,
  "info": {
    "side": "buy",
    "size": "0.149346",
    "type": "limit",
    "funds": "",
    "price": "0.02043",
    "state": "2",
    "status": "filled",
    "notional": "",
    "order_id": "4624897385308160",
    "price_avg": "0.02043",
    "timestamp": "2020-03-27T10:52:13.000Z",
    "client_oid": "",
    "created_at": "2020-03-27T10:52:13.000Z",
    "order_type": "0",
    "product_id": "ETH-BTC",
    "filled_size": "0.149346",
    "instrument_id": "ETH-BTC",
    "filled_notional": "0.00305113878"
  },
  "side": "buy",
  "type": "limit",
  "price": 0.02043,
  "amount": 0.149346,
  "filled": 0.149346,
  "status": "closed",
  "symbol": "ETH/BTC",
  "average": 0.02043,
  "datetime": "2020-03-27T10:52:13.000Z",
  "remaining": 0,
  "timestamp": 1585306333000,
  "clientOrderId": ""
}
fills: [
  {
    "info": {
      "created_at": "2020-03-27T10:52:30.000Z",
      "currency": "ETH",
      "exec_type": "M",
      "fee": "-0.00000589",
      "instrument_id": "ETH-BTC",
      "ledger_id": "10524879996",
      "liquidity": "M",
      "order_id": "4624897385308160",
      "price": "0.02043",
      "product_id": "ETH-BTC",
      "side": "buy",
      "size": "0.00589",
      "timestamp": "2020-03-27T10:52:30.000Z",
      "trade_id": "3352276"
    },
    "timestamp": 1585306350000,
    "datetime": "2020-03-27T10:52:30.000Z",
    "symbol": "ETH/BTC",
    "id": "3352276",
    "order": "4624897385308160",
    "takerOrMaker": "maker",
    "side": "buy",
    "price": 0.02043,
    "amount": 0.00589,
    "cost": 0.00012033270000000001,
    "fee": {
      "cost": 0.00000589,
      "currency": "ETH"
    }
  },
  {
    "info": {
      "created_at": "2020-03-27T10:52:30.000Z",
      "currency": "BTC",
      "exec_type": "M",
      "fee": "0",
      "instrument_id": "ETH-BTC",
      "ledger_id": "10524879995",
      "liquidity": "M",
      "order_id": "4624897385308160",
      "price": "0.02043",
      "product_id": "ETH-BTC",
      "side": "sell",
      "size": "0.00012033",
      "timestamp": "2020-03-27T10:52:30.000Z",
      "trade_id": "3352276"
    },
    "timestamp": 1585306350000,
    "datetime": "2020-03-27T10:52:30.000Z",
    "symbol": "ETH/BTC",
    "id": "3352276",
    "order": "4624897385308160",
    "takerOrMaker": "maker",
    "side": "sell",
    "price": 0.02043,
    "amount": 0.00012033,
    "cost": 0.0000024583418999999998,
    "fee": {
      "cost": 0,
      "currency": "BTC"
    }
  },
  {
    "info": {
      "created_at": "2020-03-27T10:53:47.000Z",
      "currency": "ETH",
      "exec_type": "M",
      "fee": "-0.00014346",
      "instrument_id": "ETH-BTC",
      "ledger_id": "10524894801",
      "liquidity": "M",
      "order_id": "4624897385308160",
      "price": "0.02043",
      "product_id": "ETH-BTC",
      "side": "buy",
      "size": "0.143456",
      "timestamp": "2020-03-27T10:53:47.000Z",
      "trade_id": "3352278"
    },
    "timestamp": 1585306427000,
    "datetime": "2020-03-27T10:53:47.000Z",
    "symbol": "ETH/BTC",
    "id": "3352278",
    "order": "4624897385308160",
    "takerOrMaker": "maker",
    "side": "buy",
    "price": 0.02043,
    "amount": 0.143456,
    "cost": 0.00293080608,
    "fee": {
      "cost": 0.00014346,
      "currency": "ETH"
    }
  },
  {
    "info": {
      "created_at": "2020-03-27T10:53:47.000Z",
      "currency": "BTC",
      "exec_type": "M",
      "fee": "0",
      "instrument_id": "ETH-BTC",
      "ledger_id": "10524894799",
      "liquidity": "M",
      "order_id": "4624897385308160",
      "price": "0.02043",
      "product_id": "ETH-BTC",
      "side": "sell",
      "size": "0.0029308",
      "timestamp": "2020-03-27T10:53:47.000Z",
      "trade_id": "3352278"
    },
    "timestamp": 1585306427000,
    "datetime": "2020-03-27T10:53:47.000Z",
    "symbol": "ETH/BTC",
    "id": "3352278",
    "order": "4624897385308160",
    "takerOrMaker": "maker",
    "side": "sell",
    "price": 0.02043,
    "amount": 0.0029308,
    "cost": 0.000059876244,
    "fee": {
      "cost": 0,
      "currency": "BTC"
    }
  }
]

@npomfret

  • discard the sell item(s) from the fills (regardless of the side of the originating order)

We don't really have to discard the sell side, since it contains the amount information which we can use. I'll do my best to upload the implementation soon.

@npomfret i think i've sold it already on my side, just need a little bit more time to debug it... They don't make it too easy, to be honest...

Cool

They actually return two rows for each trade from that endpoint

Its more than 2 sometimes (see my example)

@npomfret can you plz post your raw response ? In your last snippet, the trade_id for the last two trades is the same, which makes me think there's always just two unique trade_ids...

Also, to my mind, there should be just one trade with a nonzero fee in each subset of trades.

handleRestResponse:
 okex GET https://www.okex.com/api/spot/v3/fills?instrument_id=LTC-BTC&order_id=4574017996875776&limit=100 200 OK 
Response:
 { ...
  Expires: '0',
  'Ok-After': '10326339101',
  'Ok-Before': '10326343267',
  'Ok-From': '10326343267',
  'Ok-Limit': '100',
  'Ok-To': '10326339101',
  Pragma: 'no-cache',
  ... } 
 [{"created_at":"2020-03-18T11:13:45.000Z","currency":"LTC","exec_type":"M","fee":"0","instrument_id":"LTC-BTC","ledger_id":"10326343267","liquidity":"M","order_id":"4574017996875776","price":"0.006495","product_id":"LTC-BTC","side":"sell","size":"0.085735","timestamp":"2020-03-18T11:13:45.000Z","trade_id":"3578669"},{"created_at":"2020-03-18T11:13:45.000Z","currency":"BTC","exec_type":"M","fee":"-0.00000056","instrument_id":"LTC-BTC","ledger_id":"10326343262","liquidity":"M","order_id":"4574017996875776","price":"0.006495","product_id":"LTC-BTC","side":"buy","size":"0.00055684","timestamp":"2020-03-18T11:13:45.000Z","trade_id":"3578669"},{"created_at":"2020-03-18T11:13:29.000Z","currency":"LTC","exec_type":"M","fee":"0","instrument_id":"LTC-BTC","ledger_id":"10326339570","liquidity":"M","order_id":"4574017996875776","price":"0.006495","product_id":"LTC-BTC","side":"sell","size":"0.33062499","timestamp":"2020-03-18T11:13:29.000Z","trade_id":"3578668"},{"created_at":"2020-03-18T11:13:29.000Z","currency":"BTC","exec_type":"M","fee":"-0.00000215","instrument_id":"LTC-BTC","ledger_id":"10326339562","liquidity":"M","order_id":"4574017996875776","price":"0.006495","product_id":"LTC-BTC","side":"buy","size":"0.0021474","timestamp":"2020-03-18T11:13:29.000Z","trade_id":"3578668"},{"created_at":"2020-03-18T11:13:27.000Z","currency":"BTC","exec_type":"M","fee":"-0.00000015","instrument_id":"LTC-BTC","ledger_id":"10326339111","liquidity":"M","order_id":"4574017996875776","price":"0.006495","product_id":"LTC-BTC","side":"buy","size":"0.00014112","timestamp":"2020-03-18T11:13:27.000Z","trade_id":"3578667"},{"created_at":"2020-03-18T11:13:27.000Z","currency":"LTC","exec_type":"M","fee":"0","instrument_id":"LTC-BTC","ledger_id":"10326339101","liquidity":"M","order_id":"4574017996875776","price":"0.006495","product_id":"LTC-BTC","side":"sell","size":"0.021729","timestamp":"2020-03-18T11:13:27.000Z","trade_id":"3578667"}] 

@npomfret in your output I see this:

[
    {..., "trade_id":"3578669"}, --+-- pair of "trades" # 1
    {..., "trade_id":"3578669"}, -/
    {..., "trade_id":"3578668"}, --+-- pair of "trades" # 2
    {..., "trade_id":"3578668"}, -/
    {..., "trade_id":"3578667"}, --+-- pair of "trades" # 3
    {..., "trade_id":"3578667"}, -/
] 

So, despite that there are more than two pairs, each pair is just two trades, which makes it possible to group those by a trade_id. There was no trade_id previously, so it was impossible to pair them previously. But they have added it a month ago (must be the negative feedback from the users) and that makes the grouping+parsing possible now:

Screen-Shot-2020-03-29-at-21 07 56

@npomfret hey, I've uploaded the implementation, should be ok (as far as I could test at this time). If you can run it extensively on your side and report your results – that will be really appreciated! Thx for your help!

I've tested but it's only giving me orders going back a short while. It says on their website that "The history records will be kept for 1 month" which is annoying.

However, for the few trades that I do have it looks good so far.

It says on their website that "The history records will be kept for 1 month" which is annoying.

Yes, unfortunately, we can't workaround that limitation if it's on their side...

However, for the few trades that I do have it looks good so far.

Thanks for your help, plz, don't hesitate if anything!

it is possible a situation when the oldest trades in result have the same order ID but not paired:

 {
    created_at: '2020-03-28T09:22:28.000Z',
    currency: 'CVT',
    exec_type: 'T',
    fee: '-0.0079155',
    instrument_id: 'CVT-USDT',
    ledger_id: '10543151858',
    liquidity: 'T',
    order_id: '4630206726285312',
    price: '0.01238',
    product_id: 'CVT-USDT',
    side: 'buy',
    size: '8.795',
    timestamp: '2020-03-28T09:22:28.000Z',
    trade_id: '937664'
  },
  {
    created_at: '2020-03-28T09:22:28.000Z',
    currency: 'CVT',
    exec_type: 'T',
    fee: '-0.0158292',
    instrument_id: 'CVT-USDT',
    ledger_id: '10543151857',
    liquidity: 'T',
    order_id: '4630206726285312',
    price: '0.01238',
    product_id: 'CVT-USDT',
    side: 'buy',
    size: '17.588',
    timestamp: '2020-03-28T09:22:28.000Z',
    trade_id: '937663'
  }

image

Possibly because they happens at the same time, so there are no their "brothers" in result because of limit 100 and they are at the start of responce. But It leads to an error:

NotSupported: okex parseMyTrade() received unrecognized response format, more than two trades in one fill, the exchange API might have changed, paste your verbose output: https://github.com/ccxt/ccxt/wiki/FAQ#what-is-required-to-get-help

May be it will be better to cut this orders instead of error?

@ndubel can you plz paste the complete verbose output for the particular request? (having a complete output i could probably add a workaround for this case – need to see which other trades may be around there – all of them).

@ndubel

Possibly because they happens at the same time, so there are no their "brothers" in result because of limit 100 and they are at the start of responce. But It leads to an error:
NotSupported: okex parseMyTrade() received unrecognized response format, more than two trades in one fill, the exchange API might have changed, paste your verbose output: https://github.com/ccxt/ccxt/wiki/FAQ#what-is-required-to-get-help
May be it will be better to cut this orders instead of error?

Most likely you're right on the cause of the issue, so I will consider dropping those trades. However, if we drop them, the user will not receive his complete trade history on each page "turnover"... What would you suggest in this case? Just return them as plain entries without attempting to parse them and let the user handle that according to the augmented data on their actual orders and other stuff?

fetch:
 okex GET https://www.okex.com/api/spot/v3/fills?instrument_id=CVT-USDT
Request:
 {
  'OK-ACCESS-KEY': '
  'OK-ACCESS-PASSPHRASE': '',
  'OK-ACCESS-TIMESTAMP': '2020-03-30T19:22:36.667Z',
  'OK-ACCESS-SIGN': '='
}
 undefined

handleRestResponse:
 okex GET https://www.okex.com/api/spot/v3/fills?instrument_id=CVT-USDT 200 OK
Response:
 {
  'Cache-Control': 'no-cache, no-store, max-age=0, must-revalidate',
  'Cf-Cache-Status': 'DYNAMIC',
  'Cf-Ray': '-WAW',
  Connection: 'keep-alive',
  'Content-Encoding': 'gzip',
  'Content-Type': 'application/json',
  Date: 'Mon, 30 Mar 2020 19:22:37 GMT',
  'Expect-Ct': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"',
  Expires: '0',
  'Ok-After': '10543151857',
  'Ok-Before': '10584226163',
  'Ok-From': '10584226163',
  'Ok-Limit': '100',
  'Ok-To': '10543151857',
  Pragma: 'no-cache',
  Server: 'cloudflare',
  'Set-Cookie': '__cfduid=; expires=Wed, 29-Apr-20 19:22:36 GMT; path=/; domain=.okex.com; HttpOnly; SameSite=Lax, locale=en_US; Max-Age=604800; Expires=Mon, 06-Apr-2020 19:22:36 GMT; Path=/',
  'Strict-Transport-Security': 'max-age=63072000; includeSubdomains; preload',
  'Transfer-Encoding': 'chunked',
  Vary: 'Accept-Encoding',
  Via: 'kong/1.4.0',
  'X-Brokerid': '0',
  'X-Content-Type-Options': 'nosniff',
  'X-Frame-Options': 'DENY',
  'X-Kong-Proxy-Latency': '1',
  'X-Kong-Upstream-Latency': '420',
  'X-Xss-Protection': '1; mode=block'
}
 [{"created_at":"2020-03-30T15:38:17.000Z","currency":"CVT","exec_type":"M","fee":"-0.7903692","instrument_id":"CVT-USDT","ledger_id":"10584226163","liquidity":"M","order_id":"4643009137941504","price":"0.01051","product_id":"CVT-USDT","side":"buy","size":"1317.282","timestamp":"2020-03-30T15:38:17.000Z","trade_id":"983811"},{"created_at":"2020-03-30T15:38:17.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10584226162","liquidity":"M","order_id":"4643009137941504","price":"0.01051","product_id":"CVT-USDT","side":"sell","size":"13.84463382","timestamp":"2020-03-30T15:38:17.000Z","trade_id":"983811"},{"created_at":"2020-03-30T13:15:07.000Z","currency":"USDT","exec_type":"M","fee":"-0.00330852","instrument_id":"CVT-USDT","ledger_id":"10582380913","liquidity":"M","order_id":"4642445178264576","price":"0.01053","product_id":"CVT-USDT","side":"buy","size":"5.51419245","timestamp":"2020-03-30T13:15:07.000Z","trade_id":"981381"},{"created_at":"2020-03-30T13:15:07.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10582380912","liquidity":"M","order_id":"4642445178264576","price":"0.01053","product_id":"CVT-USDT","side":"sell","size":"523.665","timestamp":"2020-03-30T13:15:07.000Z","trade_id":"981381"},{"created_at":"2020-03-30T13:14:43.000Z","currency":"USDT","exec_type":"M","fee":"-0.10852555","instrument_id":"CVT-USDT","ledger_id":"10582376265","liquidity":"M","order_id":"4642444152953856","price":"0.01045","product_id":"CVT-USDT","side":"buy","size":"180.87590455","timestamp":"2020-03-30T13:14:43.000Z","trade_id":"981373"},{"created_at":"2020-03-30T13:14:43.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10582376264","liquidity":"M","order_id":"4642444152953856","price":"0.01045","product_id":"CVT-USDT","side":"sell","size":"17308.699","timestamp":"2020-03-30T13:14:43.000Z","trade_id":"981373"},{"created_at":"2020-03-30T13:06:14.000Z","currency":"USDT","exec_type":"M","fee":"-0.16468926","instrument_id":"CVT-USDT","ledger_id":"10582271991","liquidity":"M","order_id":"4642404858864640","price":"0.01075","product_id":"CVT-USDT","side":"buy","size":"274.4820935","timestamp":"2020-03-30T13:06:14.000Z","trade_id":"981223"},{"created_at":"2020-03-30T13:06:14.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10582271990","liquidity":"M","order_id":"4642404858864640","price":"0.01075","product_id":"CVT-USDT","side":"sell","size":"25533.218","timestamp":"2020-03-30T13:06:14.000Z","trade_id":"981223"},{"created_at":"2020-03-30T13:06:05.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10582269805","liquidity":"M","order_id":"4642404858864640","price":"0.01075","product_id":"CVT-USDT","side":"sell","size":"3.112","timestamp":"2020-03-30T13:06:05.000Z","trade_id":"981220"},{"created_at":"2020-03-30T13:06:05.000Z","currency":"USDT","exec_type":"M","fee":"-0.00002008","instrument_id":"CVT-USDT","ledger_id":"10582269804","liquidity":"M","order_id":"4642404858864640","price":"0.01075","product_id":"CVT-USDT","side":"buy","size":"0.033454","timestamp":"2020-03-30T13:06:05.000Z","trade_id":"981220"},{"created_at":"2020-03-30T13:06:04.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10582269384","liquidity":"M","order_id":"4642404858864640","price":"0.01075","product_id":"CVT-USDT","side":"sell","size":"1282.686","timestamp":"2020-03-30T13:06:04.000Z","trade_id":"981219"},{"created_at":"2020-03-30T13:06:04.000Z","currency":"USDT","exec_type":"M","fee":"-0.00827333","instrument_id":"CVT-USDT","ledger_id":"10582269383","liquidity":"M","order_id":"4642404858864640","price":"0.01075","product_id":"CVT-USDT","side":"buy","size":"13.7888745","timestamp":"2020-03-30T13:06:04.000Z","trade_id":"981219"},{"created_at":"2020-03-30T12:32:21.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10581831725","liquidity":"M","order_id":"4642276130295808","price":"0.01076","product_id":"CVT-USDT","side":"sell","size":"98.53008396","timestamp":"2020-03-30T12:32:21.000Z","trade_id":"980614"},{"created_at":"2020-03-30T12:32:21.000Z","currency":"CVT","exec_type":"M","fee":"-5.4942426","instrument_id":"CVT-USDT","ledger_id":"10581831724","liquidity":"M","order_id":"4642276130295808","price":"0.01076","product_id":"CVT-USDT","side":"buy","size":"9157.071","timestamp":"2020-03-30T12:32:21.000Z","trade_id":"980614"},{"created_at":"2020-03-30T10:27:05.000Z","currency":"CVT","exec_type":"M","fee":"-3.114141","instrument_id":"CVT-USDT","ledger_id":"10580109889","liquidity":"M","order_id":"4641785076997121","price":"0.01041","product_id":"CVT-USDT","side":"buy","size":"5190.235","timestamp":"2020-03-30T10:27:05.000Z","trade_id":"978527"},{"created_at":"2020-03-30T10:27:05.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10580109888","liquidity":"M","order_id":"4641785076997121","price":"0.01041","product_id":"CVT-USDT","side":"sell","size":"54.03034635","timestamp":"2020-03-30T10:27:05.000Z","trade_id":"978527"},{"created_at":"2020-03-30T09:58:53.000Z","currency":"CVT","exec_type":"M","fee":"-57.4829406","instrument_id":"CVT-USDT","ledger_id":"10579755201","liquidity":"M","order_id":"4641674268183552","price":"0.01013","product_id":"CVT-USDT","side":"buy","size":"95804.901","timestamp":"2020-03-30T09:58:53.000Z","trade_id":"978038"},{"created_at":"2020-03-30T09:58:53.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10579755200","liquidity":"M","order_id":"4641674268183552","price":"0.01013","product_id":"CVT-USDT","side":"sell","size":"970.50364713","timestamp":"2020-03-30T09:58:53.000Z","trade_id":"978038"},{"created_at":"2020-03-30T09:58:42.000Z","currency":"USDT","exec_type":"M","fee":"-0.00952574","instrument_id":"CVT-USDT","ledger_id":"10579752850","liquidity":"M","order_id":"4641673859635200","price":"0.01103","product_id":"CVT-USDT","side":"buy","size":"15.87621801","timestamp":"2020-03-30T09:58:42.000Z","trade_id":"978033"},{"created_at":"2020-03-30T09:58:42.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10579752849","liquidity":"M","order_id":"4641673859635200","price":"0.01103","product_id":"CVT-USDT","side":"sell","size":"1439.367","timestamp":"2020-03-30T09:58:42.000Z","trade_id":"978033"},{"created_at":"2020-03-30T09:58:33.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10579751235","liquidity":"M","order_id":"4641668313320448","price":"0.01021","product_id":"CVT-USDT","side":"sell","size":"783.53620798","timestamp":"2020-03-30T09:58:33.000Z","trade_id":"978030"},{"created_at":"2020-03-30T09:58:33.000Z","currency":"CVT","exec_type":"M","fee":"-46.0452228","instrument_id":"CVT-USDT","ledger_id":"10579751234","liquidity":"M","order_id":"4641668313320448","price":"0.01021","product_id":"CVT-USDT","side":"buy","size":"76742.038","timestamp":"2020-03-30T09:58:33.000Z","trade_id":"978030"},{"created_at":"2020-03-30T09:49:19.000Z","currency":"CVT","exec_type":"T","fee":"-4.1587605","instrument_id":"CVT-USDT","ledger_id":"10579638481","liquidity":"T","order_id":"4641636942941184","price":"0.01065","product_id":"CVT-USDT","side":"buy","size":"4620.845","timestamp":"2020-03-30T09:49:19.000Z","trade_id":"977869"},{"created_at":"2020-03-30T09:49:19.000Z","currency":"USDT","exec_type":"T","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10579638480","liquidity":"T","order_id":"4641636942941184","price":"0.01065","product_id":"CVT-USDT","side":"sell","size":"49.21199925","timestamp":"2020-03-30T09:49:19.000Z","trade_id":"977869"},{"created_at":"2020-03-30T09:41:36.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10579540094","liquidity":"M","order_id":"4641593025193984","price":"0.01068","product_id":"CVT-USDT","side":"sell","size":"239.76072408","timestamp":"2020-03-30T09:41:36.000Z","trade_id":"977737"},{"created_at":"2020-03-30T09:41:36.000Z","currency":"CVT","exec_type":"M","fee":"-13.4697036","instrument_id":"CVT-USDT","ledger_id":"10579540093","liquidity":"M","order_id":"4641593025193984","price":"0.01068","product_id":"CVT-USDT","side":"buy","size":"22449.506","timestamp":"2020-03-30T09:41:36.000Z","trade_id":"977737"},{"created_at":"2020-03-30T09:38:22.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10579501012","liquidity":"M","order_id":"4641593025193984","price":"0.01068","product_id":"CVT-USDT","side":"sell","size":"127.87066812","timestamp":"2020-03-30T09:38:22.000Z","trade_id":"977682"},{"created_at":"2020-03-30T09:38:22.000Z","currency":"CVT","exec_type":"M","fee":"-7.1837454","instrument_id":"CVT-USDT","ledger_id":"10579501011","liquidity":"M","order_id":"4641593025193984","price":"0.01068","product_id":"CVT-USDT","side":"buy","size":"11972.909","timestamp":"2020-03-30T09:38:22.000Z","trade_id":"977682"},{"created_at":"2020-03-29T08:47:50.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10560637476","liquidity":"M","order_id":"4635732375398400","price":"0.00947","product_id":"CVT-USDT","side":"sell","size":"243818.623","timestamp":"2020-03-29T08:47:50.000Z","trade_id":"961039"},{"created_at":"2020-03-29T08:47:50.000Z","currency":"USDT","exec_type":"M","fee":"-1.38537742","instrument_id":"CVT-USDT","ledger_id":"10560637475","liquidity":"M","order_id":"4635732375398400","price":"0.00947","product_id":"CVT-USDT","side":"buy","size":"2308.96235981","timestamp":"2020-03-29T08:47:50.000Z","trade_id":"961039"},{"created_at":"2020-03-29T06:02:17.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10558649475","liquidity":"M","order_id":"4635081393840128","price":"0.00907","product_id":"CVT-USDT","side":"sell","size":"908.90865452","timestamp":"2020-03-29T06:02:17.000Z","trade_id":"958218"},{"created_at":"2020-03-29T06:02:17.000Z","currency":"CVT","exec_type":"M","fee":"-60.1262616","instrument_id":"CVT-USDT","ledger_id":"10558649474","liquidity":"M","order_id":"4635081393840128","price":"0.00907","product_id":"CVT-USDT","side":"buy","size":"100210.436","timestamp":"2020-03-29T06:02:17.000Z","trade_id":"958218"},{"created_at":"2020-03-29T06:00:41.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10558630393","liquidity":"M","order_id":"4635075500444672","price":"0.00939","product_id":"CVT-USDT","side":"sell","size":"7.437","timestamp":"2020-03-29T06:00:41.000Z","trade_id":"958182"},{"created_at":"2020-03-29T06:00:41.000Z","currency":"USDT","exec_type":"M","fee":"-0.00004191","instrument_id":"CVT-USDT","ledger_id":"10558630392","liquidity":"M","order_id":"4635075500444672","price":"0.00939","product_id":"CVT-USDT","side":"buy","size":"0.06983343","timestamp":"2020-03-29T06:00:41.000Z","trade_id":"958182"},{"created_at":"2020-03-29T06:00:41.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10558630350","liquidity":"M","order_id":"4635075500444672","price":"0.00939","product_id":"CVT-USDT","side":"sell","size":"2053.726","timestamp":"2020-03-29T06:00:41.000Z","trade_id":"958181"},{"created_at":"2020-03-29T06:00:41.000Z","currency":"USDT","exec_type":"M","fee":"-0.0115707","instrument_id":"CVT-USDT","ledger_id":"10558630349","liquidity":"M","order_id":"4635075500444672","price":"0.00939","product_id":"CVT-USDT","side":"buy","size":"19.28448714","timestamp":"2020-03-29T06:00:41.000Z","trade_id":"958181"},{"created_at":"2020-03-29T03:25:10.000Z","currency":"USDT","exec_type":"M","fee":"-0.53406","instrument_id":"CVT-USDT","ledger_id":"10556829874","liquidity":"M","order_id":"4634462765977600","price":"0.00989","product_id":"CVT-USDT","side":"buy","size":"890.1","timestamp":"2020-03-29T03:25:10.000Z","trade_id":"955717"},{"created_at":"2020-03-29T03:25:10.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10556829873","liquidity":"M","order_id":"4634462765977600","price":"0.00989","product_id":"CVT-USDT","side":"sell","size":"90000","timestamp":"2020-03-29T03:25:10.000Z","trade_id":"955717"},{"created_at":"2020-03-29T03:11:40.000Z","currency":"CVT","exec_type":"M","fee":"-141.5225994","instrument_id":"CVT-USDT","ledger_id":"10556674309","liquidity":"M","order_id":"4634410650109952","price":"0.00962","product_id":"CVT-USDT","side":"buy","size":"235870.999","timestamp":"2020-03-29T03:11:40.000Z","trade_id":"955488"},{"created_at":"2020-03-29T03:11:40.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10556674308","liquidity":"M","order_id":"4634410650109952","price":"0.00962","product_id":"CVT-USDT","side":"sell","size":"2269.07901038","timestamp":"2020-03-29T03:11:40.000Z","trade_id":"955488"},{"created_at":"2020-03-29T03:01:56.000Z","currency":"USDT","exec_type":"M","fee":"-1.36226477","instrument_id":"CVT-USDT","ledger_id":"10556559280","liquidity":"M","order_id":"4634372448739328","price":"0.00979","product_id":"CVT-USDT","side":"buy","size":"2270.44128091","timestamp":"2020-03-29T03:01:56.000Z","trade_id":"955315"},{"created_at":"2020-03-29T03:01:56.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10556559277","liquidity":"M","order_id":"4634372448739328","price":"0.00979","product_id":"CVT-USDT","side":"sell","size":"231914.329","timestamp":"2020-03-29T03:01:56.000Z","trade_id":"955315"},{"created_at":"2020-03-29T02:58:50.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10556523940","liquidity":"M","order_id":"4634360243969024","price":"0.00937","product_id":"CVT-USDT","side":"sell","size":"494.36801199","timestamp":"2020-03-29T02:58:50.000Z","trade_id":"955236"},{"created_at":"2020-03-29T02:58:50.000Z","currency":"CVT","exec_type":"M","fee":"-31.6564362","instrument_id":"CVT-USDT","ledger_id":"10556523939","liquidity":"M","order_id":"4634360243969024","price":"0.00937","product_id":"CVT-USDT","side":"buy","size":"52760.727","timestamp":"2020-03-29T02:58:50.000Z","trade_id":"955236"},{"created_at":"2020-03-29T02:58:11.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10556516837","liquidity":"M","order_id":"4634357798034432","price":"0.00947","product_id":"CVT-USDT","side":"sell","size":"1293.13461762","timestamp":"2020-03-29T02:58:11.000Z","trade_id":"955219"},{"created_at":"2020-03-29T02:58:11.000Z","currency":"CVT","exec_type":"M","fee":"-81.9303876","instrument_id":"CVT-USDT","ledger_id":"10556516836","liquidity":"M","order_id":"4634357798034432","price":"0.00947","product_id":"CVT-USDT","side":"buy","size":"136550.646","timestamp":"2020-03-29T02:58:11.000Z","trade_id":"955219"},{"created_at":"2020-03-29T02:54:35.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10556475535","liquidity":"M","order_id":"4634341777940480","price":"0.01034","product_id":"CVT-USDT","side":"sell","size":"1178.918","timestamp":"2020-03-29T02:54:35.000Z","trade_id":"955155"},{"created_at":"2020-03-29T02:54:35.000Z","currency":"USDT","exec_type":"M","fee":"-0.00731401","instrument_id":"CVT-USDT","ledger_id":"10556475534","liquidity":"M","order_id":"4634341777940480","price":"0.01034","product_id":"CVT-USDT","side":"buy","size":"12.19001212","timestamp":"2020-03-29T02:54:35.000Z","trade_id":"955155"},{"created_at":"2020-03-29T02:54:25.000Z","currency":"USDT","exec_type":"M","fee":"-0.29115379","instrument_id":"CVT-USDT","ledger_id":"10556473608","liquidity":"M","order_id":"4634341777940480","price":"0.01034","product_id":"CVT-USDT","side":"buy","size":"485.2563034","timestamp":"2020-03-29T02:54:25.000Z","trade_id":"955152"},{"created_at":"2020-03-29T02:54:25.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10556473607","liquidity":"M","order_id":"4634341777940480","price":"0.01034","product_id":"CVT-USDT","side":"sell","size":"46930.01","timestamp":"2020-03-29T02:54:25.000Z","trade_id":"955152"},{"created_at":"2020-03-29T02:53:59.000Z","currency":"USDT","exec_type":"M","fee":"-0.00586128","instrument_id":"CVT-USDT","ledger_id":"10556468880","liquidity":"M","order_id":"4634341277248512","price":"0.01032","product_id":"CVT-USDT","side":"buy","size":"9.76878816","timestamp":"2020-03-29T02:53:59.000Z","trade_id":"955143"},{"created_at":"2020-03-29T02:53:59.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10556468879","liquidity":"M","order_id":"4634341277248512","price":"0.01032","product_id":"CVT-USDT","side":"sell","size":"946.588","timestamp":"2020-03-29T02:53:59.000Z","trade_id":"955143"},{"created_at":"2020-03-29T02:53:58.000Z","currency":"USDT","exec_type":"M","fee":"-0.00137119","instrument_id":"CVT-USDT","ledger_id":"10556468696","liquidity":"M","order_id":"4634341277248512","price":"0.01032","product_id":"CVT-USDT","side":"buy","size":"2.2853124","timestamp":"2020-03-29T02:53:58.000Z","trade_id":"955142"},{"created_at":"2020-03-29T02:53:58.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10556468695","liquidity":"M","order_id":"4634341277248512","price":"0.01032","product_id":"CVT-USDT","side":"sell","size":"221.445","timestamp":"2020-03-29T02:53:58.000Z","trade_id":"955142"},{"created_at":"2020-03-29T02:53:57.000Z","currency":"USDT","exec_type":"M","fee":"-0.0086586","instrument_id":"CVT-USDT","ledger_id":"10556468638","liquidity":"M","order_id":"4634341277248512","price":"0.01032","product_id":"CVT-USDT","side":"buy","size":"14.43099264","timestamp":"2020-03-29T02:53:57.000Z","trade_id":"955141"},{"created_at":"2020-03-29T02:53:57.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10556468637","liquidity":"M","order_id":"4634341277248512","price":"0.01032","product_id":"CVT-USDT","side":"sell","size":"1398.352","timestamp":"2020-03-29T02:53:57.000Z","trade_id":"955141"},{"created_at":"2020-03-29T02:53:57.000Z","currency":"USDT","exec_type":"M","fee":"-0.0086586","instrument_id":"CVT-USDT","ledger_id":"10556468519","liquidity":"M","order_id":"4634341277248512","price":"0.01032","product_id":"CVT-USDT","side":"buy","size":"14.43099264","timestamp":"2020-03-29T02:53:57.000Z","trade_id":"955140"},{"created_at":"2020-03-29T02:53:57.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10556468518","liquidity":"M","order_id":"4634341277248512","price":"0.01032","product_id":"CVT-USDT","side":"sell","size":"1398.352","timestamp":"2020-03-29T02:53:57.000Z","trade_id":"955140"},{"created_at":"2020-03-29T02:53:57.000Z","currency":"USDT","exec_type":"M","fee":"-0.03479012","instrument_id":"CVT-USDT","ledger_id":"10556468459","liquidity":"M","order_id":"4634341277248512","price":"0.01032","product_id":"CVT-USDT","side":"buy","size":"57.98352888","timestamp":"2020-03-29T02:53:57.000Z","trade_id":"955139"},{"created_at":"2020-03-29T02:53:57.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10556468458","liquidity":"M","order_id":"4634341277248512","price":"0.01032","product_id":"CVT-USDT","side":"sell","size":"5618.559","timestamp":"2020-03-29T02:53:57.000Z","trade_id":"955139"},{"created_at":"2020-03-29T02:53:57.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10556468447","liquidity":"M","order_id":"4634341277248512","price":"0.01032","product_id":"CVT-USDT","side":"sell","size":"2609.411","timestamp":"2020-03-29T02:53:57.000Z","trade_id":"955138"},{"created_at":"2020-03-29T02:53:57.000Z","currency":"USDT","exec_type":"M","fee":"-0.01615748","instrument_id":"CVT-USDT","ledger_id":"10556468446","liquidity":"M","order_id":"4634341277248512","price":"0.01032","product_id":"CVT-USDT","side":"buy","size":"26.92912152","timestamp":"2020-03-29T02:53:57.000Z","trade_id":"955138"},{"created_at":"2020-03-29T02:53:50.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10556467268","liquidity":"M","order_id":"4634339557581824","price":"0.0103","product_id":"CVT-USDT","side":"sell","size":"1398.352","timestamp":"2020-03-29T02:53:50.000Z","trade_id":"955128"},{"created_at":"2020-03-29T02:53:50.000Z","currency":"USDT","exec_type":"M","fee":"-0.00864182","instrument_id":"CVT-USDT","ledger_id":"10556467267","liquidity":"M","order_id":"4634339557581824","price":"0.0103","product_id":"CVT-USDT","side":"buy","size":"14.4030256","timestamp":"2020-03-29T02:53:50.000Z","trade_id":"955128"},{"created_at":"2020-03-29T02:53:47.000Z","currency":"USDT","exec_type":"M","fee":"-0.00864182","instrument_id":"CVT-USDT","ledger_id":"10556466724","liquidity":"M","order_id":"4634339557581824","price":"0.0103","product_id":"CVT-USDT","side":"buy","size":"14.4030256","timestamp":"2020-03-29T02:53:47.000Z","trade_id":"955127"},{"created_at":"2020-03-29T02:53:47.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10556466723","liquidity":"M","order_id":"4634339557581824","price":"0.0103","product_id":"CVT-USDT","side":"sell","size":"1398.352","timestamp":"2020-03-29T02:53:47.000Z","trade_id":"955127"},{"created_at":"2020-03-29T02:53:47.000Z","currency":"USDT","exec_type":"M","fee":"-0.01115827","instrument_id":"CVT-USDT","ledger_id":"10556466720","liquidity":"M","order_id":"4634339557581824","price":"0.0103","product_id":"CVT-USDT","side":"buy","size":"18.5971032","timestamp":"2020-03-29T02:53:47.000Z","trade_id":"955126"},{"created_at":"2020-03-29T02:53:47.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10556466719","liquidity":"M","order_id":"4634339557581824","price":"0.0103","product_id":"CVT-USDT","side":"sell","size":"1805.544","timestamp":"2020-03-29T02:53:47.000Z","trade_id":"955126"},{"created_at":"2020-03-29T02:53:47.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10556466702","liquidity":"M","order_id":"4634339557581824","price":"0.0103","product_id":"CVT-USDT","side":"sell","size":"30073.02","timestamp":"2020-03-29T02:53:47.000Z","trade_id":"955125"},{"created_at":"2020-03-29T02:53:47.000Z","currency":"USDT","exec_type":"M","fee":"-0.18585127","instrument_id":"CVT-USDT","ledger_id":"10556466701","liquidity":"M","order_id":"4634339557581824","price":"0.0103","product_id":"CVT-USDT","side":"buy","size":"309.752106","timestamp":"2020-03-29T02:53:47.000Z","trade_id":"955125"},{"created_at":"2020-03-29T02:53:47.000Z","currency":"USDT","exec_type":"M","fee":"-0.12264466","instrument_id":"CVT-USDT","ledger_id":"10556466655","liquidity":"M","order_id":"4634339557581824","price":"0.0103","product_id":"CVT-USDT","side":"buy","size":"204.4077539","timestamp":"2020-03-29T02:53:47.000Z","trade_id":"955124"},{"created_at":"2020-03-29T02:53:47.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10556466654","liquidity":"M","order_id":"4634339557581824","price":"0.0103","product_id":"CVT-USDT","side":"sell","size":"19845.413","timestamp":"2020-03-29T02:53:47.000Z","trade_id":"955124"},{"created_at":"2020-03-29T02:49:14.000Z","currency":"CVT","exec_type":"T","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10556413816","liquidity":"T","order_id":"4634322782787584","price":"0.01034","product_id":"CVT-USDT","side":"sell","size":"1","timestamp":"2020-03-29T02:49:14.000Z","trade_id":"955050"},{"created_at":"2020-03-29T02:49:14.000Z","currency":"USDT","exec_type":"T","fee":"-0.00000931","instrument_id":"CVT-USDT","ledger_id":"10556413815","liquidity":"T","order_id":"4634322782787584","price":"0.01034","product_id":"CVT-USDT","side":"buy","size":"0.01034","timestamp":"2020-03-29T02:49:14.000Z","trade_id":"955050"},{"created_at":"2020-03-29T02:48:20.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10556402989","liquidity":"M","order_id":"4634319092736000","price":"0.01031","product_id":"CVT-USDT","side":"sell","size":"58484.75","timestamp":"2020-03-29T02:48:20.000Z","trade_id":"955037"},{"created_at":"2020-03-29T02:48:20.000Z","currency":"USDT","exec_type":"M","fee":"-0.36178667","instrument_id":"CVT-USDT","ledger_id":"10556402988","liquidity":"M","order_id":"4634319092736000","price":"0.01031","product_id":"CVT-USDT","side":"buy","size":"602.9777725","timestamp":"2020-03-29T02:48:20.000Z","trade_id":"955037"},{"created_at":"2020-03-29T02:41:52.000Z","currency":"CVT","exec_type":"T","fee":"-16.8558327","instrument_id":"CVT-USDT","ledger_id":"10556324732","liquidity":"T","order_id":"4634293794924544","price":"0.00947","product_id":"CVT-USDT","side":"buy","size":"18728.703","timestamp":"2020-03-29T02:41:52.000Z","trade_id":"954923"},{"created_at":"2020-03-29T02:41:52.000Z","currency":"USDT","exec_type":"T","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10556324731","liquidity":"T","order_id":"4634293794924544","price":"0.00947","product_id":"CVT-USDT","side":"sell","size":"177.36081741","timestamp":"2020-03-29T02:41:52.000Z","trade_id":"954923"},{"created_at":"2020-03-29T02:41:05.000Z","currency":"CVT","exec_type":"M","fee":"-2.291652","instrument_id":"CVT-USDT","ledger_id":"10556315593","liquidity":"M","order_id":"4634290735767552","price":"0.00951","product_id":"CVT-USDT","side":"buy","size":"3819.42","timestamp":"2020-03-29T02:41:05.000Z","trade_id":"954904"},{"created_at":"2020-03-29T02:41:05.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10556315592","liquidity":"M","order_id":"4634290735767552","price":"0.00951","product_id":"CVT-USDT","side":"sell","size":"36.3226842","timestamp":"2020-03-29T02:41:05.000Z","trade_id":"954904"},{"created_at":"2020-03-29T02:41:03.000Z","currency":"USDT","exec_type":"M","fee":"-0.10693014","instrument_id":"CVT-USDT","ledger_id":"10556315078","liquidity":"M","order_id":"4634290270200833","price":"0.00983","product_id":"CVT-USDT","side":"buy","size":"178.21689734","timestamp":"2020-03-29T02:41:03.000Z","trade_id":"954902"},{"created_at":"2020-03-29T02:41:03.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10556315077","liquidity":"M","order_id":"4634290270200833","price":"0.00983","product_id":"CVT-USDT","side":"sell","size":"18129.898","timestamp":"2020-03-29T02:41:03.000Z","trade_id":"954902"},{"created_at":"2020-03-29T02:40:44.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10556311738","liquidity":"M","order_id":"4634289240172544","price":"0.00989","product_id":"CVT-USDT","side":"sell","size":"3672.697","timestamp":"2020-03-29T02:40:44.000Z","trade_id":"954896"},{"created_at":"2020-03-29T02:40:44.000Z","currency":"USDT","exec_type":"M","fee":"-0.02179379","instrument_id":"CVT-USDT","ledger_id":"10556311737","liquidity":"M","order_id":"4634289240172544","price":"0.00989","product_id":"CVT-USDT","side":"buy","size":"36.32297333","timestamp":"2020-03-29T02:40:44.000Z","trade_id":"954896"},{"created_at":"2020-03-29T02:38:07.000Z","currency":"USDT","exec_type":"M","fee":"-0.00000631","instrument_id":"CVT-USDT","ledger_id":"10556282801","liquidity":"M","order_id":"4634279038822400","price":"0.0105","product_id":"CVT-USDT","side":"buy","size":"0.0105","timestamp":"2020-03-29T02:38:07.000Z","trade_id":"954840"},{"created_at":"2020-03-29T02:38:07.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10556282800","liquidity":"M","order_id":"4634279038822400","price":"0.0105","product_id":"CVT-USDT","side":"sell","size":"1","timestamp":"2020-03-29T02:38:07.000Z","trade_id":"954840"},{"created_at":"2020-03-29T02:36:03.000Z","currency":"USDT","exec_type":"M","fee":"-0.00000661","instrument_id":"CVT-USDT","ledger_id":"10556259812","liquidity":"M","order_id":"4634270856536064","price":"0.01101","product_id":"CVT-USDT","side":"buy","size":"0.01101","timestamp":"2020-03-29T02:36:03.000Z","trade_id":"954782"},{"created_at":"2020-03-29T02:36:03.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10556259811","liquidity":"M","order_id":"4634270856536064","price":"0.01101","product_id":"CVT-USDT","side":"sell","size":"1","timestamp":"2020-03-29T02:36:03.000Z","trade_id":"954782"},{"created_at":"2020-03-28T12:23:34.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10545457985","liquidity":"M","order_id":"4630917175055360","price":"0.01232","product_id":"CVT-USDT","side":"sell","size":"851.32133856","timestamp":"2020-03-28T12:23:34.000Z","trade_id":"940771"},{"created_at":"2020-03-28T12:23:34.000Z","currency":"CVT","exec_type":"M","fee":"-41.4604548","instrument_id":"CVT-USDT","ledger_id":"10545457984","liquidity":"M","order_id":"4630917175055360","price":"0.01232","product_id":"CVT-USDT","side":"buy","size":"69100.758","timestamp":"2020-03-28T12:23:34.000Z","trade_id":"940771"},{"created_at":"2020-03-28T12:22:52.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10545450328","liquidity":"M","order_id":"4630915317504000","price":"0.01232","product_id":"CVT-USDT","side":"sell","size":"5.99204144","timestamp":"2020-03-28T12:22:52.000Z","trade_id":"940745"},{"created_at":"2020-03-28T12:22:52.000Z","currency":"CVT","exec_type":"M","fee":"-0.2918202","instrument_id":"CVT-USDT","ledger_id":"10545450327","liquidity":"M","order_id":"4630915317504000","price":"0.01232","product_id":"CVT-USDT","side":"buy","size":"486.367","timestamp":"2020-03-28T12:22:52.000Z","trade_id":"940745"},{"created_at":"2020-03-28T12:22:52.000Z","currency":"CVT","exec_type":"M","fee":"-2.3378718","instrument_id":"CVT-USDT","ledger_id":"10545450280","liquidity":"M","order_id":"4630915317504000","price":"0.01232","product_id":"CVT-USDT","side":"buy","size":"3896.453","timestamp":"2020-03-28T12:22:52.000Z","trade_id":"940741"},{"created_at":"2020-03-28T12:22:52.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10545450279","liquidity":"M","order_id":"4630915317504000","price":"0.01232","product_id":"CVT-USDT","side":"sell","size":"48.00430096","timestamp":"2020-03-28T12:22:52.000Z","trade_id":"940741"},{"created_at":"2020-03-28T12:15:07.000Z","currency":"CVT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10545362279","liquidity":"M","order_id":"4630868516211712","price":"0.01299","product_id":"CVT-USDT","side":"sell","size":"19086.125","timestamp":"2020-03-28T12:15:07.000Z","trade_id":"940590"},{"created_at":"2020-03-28T12:15:07.000Z","currency":"USDT","exec_type":"M","fee":"-0.14875726","instrument_id":"CVT-USDT","ledger_id":"10545362278","liquidity":"M","order_id":"4630868516211712","price":"0.01299","product_id":"CVT-USDT","side":"buy","size":"247.92876375","timestamp":"2020-03-28T12:15:07.000Z","trade_id":"940590"},{"created_at":"2020-03-28T10:13:01.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10543800928","liquidity":"M","order_id":"4630405165945856","price":"0.01166","product_id":"CVT-USDT","side":"sell","size":"724.21288412","timestamp":"2020-03-28T10:13:01.000Z","trade_id":"938501"},{"created_at":"2020-03-28T10:13:01.000Z","currency":"CVT","exec_type":"M","fee":"-37.2665292","instrument_id":"CVT-USDT","ledger_id":"10543800927","liquidity":"M","order_id":"4630405165945856","price":"0.01166","product_id":"CVT-USDT","side":"buy","size":"62110.882","timestamp":"2020-03-28T10:13:01.000Z","trade_id":"938501"},{"created_at":"2020-03-28T09:22:28.000Z","currency":"CVT","exec_type":"T","fee":"-0.0079155","instrument_id":"CVT-USDT","ledger_id":"10543151858","liquidity":"T","order_id":"4630206726285312","price":"0.01238","product_id":"CVT-USDT","side":"buy","size":"8.795","timestamp":"2020-03-28T09:22:28.000Z","trade_id":"937664"},{"created_at":"2020-03-28T09:22:28.000Z","currency":"CVT","exec_type":"T","fee":"-0.0158292","instrument_id":"CVT-USDT","ledger_id":"10543151857","liquidity":"T","order_id":"4630206726285312","price":"0.01238","product_id":"CVT-USDT","side":"buy","size":"17.588","timestamp":"2020-03-28T09:22:28.000Z","trade_id":"937663"}]

NotSupported: okex parseMyTrade() received unrecognized response format, more than two trades in one fill, the exchange API might have changed, paste your verbose output: https://github.com/ccxt/ccxt/wiki/FAQ#what-is-required-to-get-help
    at okex.parseMyTrade (/var/www/node/bot/test/node_modules/ccxt/js/okex.js:2574:19)
    at okex.parseMyTrades (/var/www/node/bot/test/node_modules/ccxt/js/okex.js:2698:32)
    at okex.fetchMyTrades (/var/www/node/bot/test/node_modules/ccxt/js/okex.js:2803:21)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async test (/var/www/node/bot/test/test.js:139:23) {
  constructor: [Function: NotSupported],
  name: 'NotSupported'
}

@ndubel @npomfret to be honest, in the light of those limitations on the OKEX side, i don't see a reasonable solution except to revert fetchMyTrades back to false as it was before (it was actually true when I think about it). What do you say?
I think it is not usable as an endpoint for fetching the history of trades, but rather as an implicit endpoint.... We can't deduce trades from there consistently without introducing unwanted caching layers. Lmk your thoughts.

As for me just return them as plain will be good.

@ndubel it breaks the semantics of fetchMyTrades though, so, if a plain result is ok, would it make sense to remove fetchMyTrades and let the users use the implicit endpoint?

Sorry, I don't fully understand the problem. Can you explain again?

Is it that in the example provided there are two 'trades' that aren't paired 937663 and 937664?

@npomfret when this endpoint is used to fetch trades for a single order with fetchOrderTrades – there is no problem, because most of the orders are closed in less than limit = 100 (50 okex-pairs of) trades.

However, when you're paginating with the fetchMyTrades you get a uniform set of trades, and some "okex-pairs" can land on different pages, because of how chaotically OKEX does the ordering – that makes impossible to recognize those edge-trades as complete (full-pair) trades, without having the previous or the next page or without having a cache of orders... Which means that the trades that fall on the "boundaries" between those pages are unusable without the rest of the info. So we can only drop them. Which is bad, because that is equivalent to losing info. Returning plain results from fetchMyTrades to the user (without pairing) also makes little sense, because an implicit endpoint would be easier to work with, than adding a special case for fetchMyTrades for OKEX specifically.

Let me know if that clarifies the problem.

Go it. Another reason to start considering a pagination api.

So are we suggesting to keep fetchOrderTrades, but drop fetchMyTrades?

If there are 51 or more fills, do we need to add a warning to fetchOrderTrades?

Another reason to start considering a pagination api.

We already considering it as intensively as we can )))

So are we suggesting to keep fetchOrderTrades, but drop fetchMyTrades?

Yes, for now...

If there are 51 or more fills, do we need to add a warning to fetchOrderTrades?

... or drop both for now and let the user use fetchLedger ... I'd rather drop a lying method than keep it.

Did we test the above problem by requesting the 2nd page and asserting that the missing fills are present?

@ndubel can you confirm that the next page has those matching pairs?

Orders after 10543151858 in my case:

{"created_at":"2020-03-28T09:22:28.000Z","currency":"CVT","exec_type":"T","fee":"-0.0158292","instrument_id":"CVT-USDT","ledger_id":"10543151857","liquidity":"T","order_id":"4630206726285312","price":"0.01238","product_id":"CVT-USDT","side":"buy","size":"17.588","timestamp":"2020-03-28T09:22:28.000Z",
"trade_id":"937663"},
{"created_at":"2020-03-28T09:22:28.000Z","currency":"CVT","exec_type":"T","fee":"-0.0079146","instrument_id":"CVT-USDT","ledger_id":"10543151856","liquidity":"T","order_id":"4630206726285312","price":"0.01238","product_id":"CVT-USDT","side":"buy","size":"8.794","timestamp":"2020-03-28T09:22:28.000Z",
"trade_id":"937662"},
{"created_at":"2020-03-28T09:22:28.000Z","currency":"CVT","exec_type":"T","fee":"-0.0158292","instrument_id":"CVT-USDT","ledger_id":"10543151855","liquidity":"T","order_id":"4630206726285312","price":"0.01238","product_id":"CVT-USDT","side":"buy","size":"17.588","timestamp":"2020-03-28T09:22:28.000Z",
"trade_id":"937661"},
{"created_at":"2020-03-28T09:22:28.000Z","currency":"CVT","exec_type":"T","fee":"-0.0079146","instrument_id":"CVT-USDT","ledger_id":"10543151854","liquidity":"T","order_id":"4630206726285312","price":"0.01238","product_id":"CVT-USDT","side":"buy","size":"8.794","timestamp":"2020-03-28T09:22:28.000Z",
"trade_id":"937660"}
,{"created_at":"2020-03-28T09:22:28.000Z","currency":"CVT","exec_type":"T","fee":"-0.0079146","instrument_id":"CVT-USDT","ledger_id":"10543151853","liquidity":"T","order_id":"4630206726285312","price":"0.01238","product_id":"CVT-USDT","side":"buy","size":"8.794","timestamp":"2020-03-28T09:22:28.000Z",
"trade_id":"937659"},
{"created_at":"2020-03-28T09:22:28.000Z","currency":"USDT","exec_type":"T","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10543151852","liquidity":"T","order_id":"4630206726285312","price":"0.01238","product_id":"CVT-USDT","side":"sell","size":"0.10888209","timestamp":"2020-03-28T09:22:28.000Z",
"trade_id":"937664"}, //pair of this one was on previous page
{"created_at":"2020-03-28T09:22:28.000Z","currency":"USDT","exec_type":"T","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10543151851","liquidity":"T","order_id":"4630206726285312","price":"0.01238","product_id":"CVT-USDT","side":"sell","size":"0.21773944","timestamp":"2020-03-28T09:22:28.000Z",
"trade_id":"937663"},
{"created_at":"2020-03-28T09:22:28.000Z","currency":"USDT","exec_type":"T","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10543151850","liquidity":"T","order_id":"4630206726285312","price":"0.01238","product_id":"CVT-USDT","side":"sell","size":"0.10886971","timestamp":"2020-03-28T09:22:28.000Z",
"trade_id":"937662"},
{"created_at":"2020-03-28T09:22:28.000Z","currency":"USDT","exec_type":"T","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10543151849","liquidity":"T","order_id":"4630206726285312","price":"0.01238","product_id":"CVT-USDT","side":"sell","size":"0.21773944","timestamp":"2020-03-28T09:22:28.000Z",
"trade_id":"937661"},
{"created_at":"2020-03-28T09:22:28.000Z","currency":"USDT","exec_type":"T","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10543151848","liquidity":"T","order_id":"4630206726285312","price":"0.01238","product_id":"CVT-USDT","side":"sell","size":"0.10886971","timestamp":"2020-03-28T09:22:28.000Z",
"trade_id":"937660"},
{"created_at":"2020-03-28T09:22:28.000Z","currency":"USDT","exec_type":"T","fee":"0","instrument_id":"CVT-USDT","ledger_id":"10543151847","liquidity":"T","order_id":"4630206726285312","price":"0.01238","product_id":"CVT-USDT","side":"sell","size":"0.10886971","timestamp":"2020-03-28T09:22:28.000Z",
"trade_id":"937659"}

So yes, it's all ok with paginition

Instead of deleting it completely, can we consider adding an undocumented method that does paging that will serve as an experiment into building a new api?

I'm sure there's a million ways to do it.

async paginateMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
  if(params.nextPageParams) {
    // get next page
  } else {
   // get first page
  }
 ...
 const page = {
   'trades': items,
   'nextPageParams': {...}
 }
 return page;
}

@npomfret the problem is how do you implement that pagination method without receiving all okex trades first, which are only stored for 3 months. So whatever way you wrap it with whatever pagination – the OKEX will eventually break it, if a pair happens on the boundary of 3 months. We just don't have a unified method that returns "halfs of trades". Regardless of pagination, it will break that pagination if you try to merge the pairs. And, in contrary, if you don't merge the pairs and return all rows separately, then there's no point in having fetchMyTrades that returns a non-unified result for one specific exchange... in other words – we'd just recommend to use the implicit endpoint in that case, because... do we really want to unify this specific API nonsense? If we do, how would you call a method to return halfs of trades? And if you find a good name for the method – wouldn't this method be too unique for this exchange?

Let me know your thoughts, plz, your feedback is very important. Thx!

Yeah, in the situation you've described you will get some unpaired events. But that's fine I think, we just discard them. After all, the dataset is 100% guaranteed to be incomplete anyway because it only goes back a short period of time. So we do our best, pair up everything that can be paired and throw away the tail ends.

@npomfret

But that's fine I think, we just discard them

Ok, let's assume that we discard some trades without pairs on the 3-mo boundary.

So we do our best, pair up everything that can be paired and throw away the tail ends.

Ok, but then, what exactly should we provide? Do you mean a unified method that will loop over all pages to return as many of them as possible? It's impossible to do it atomically "by a specific page number" for OKEX without fetching all "pairable" trades first. I mean, it's either "all" or "nothing". Do you suggest to add a unified method for "all" ?

Thinking more about it, it could paginate backwards into the past down to since, and then drop all unpaired trades on the since boundary, returning just the paired trades from since, and by default it would stop after the first (most recent) page, doing just one call and returning just the most recent "pairable" trades...

Yeah, always go backwards... most recent page first. Then any unpaired rows get retuned in the page object along with other parameters are required to get the next page. The next call to the page method uses those parameters to create it's http call, and uses the unpaired rows together with the new rows to produce trades... and so on.

I think that makes sense. Not sure we even need the since parameter do we? The client can just choose to stop when they reach whatever point they're happy with.

@npomfret yeah, that makes sense... Can you plz show a sample of usage, some pseudocode of how the user would call that method and how the stop-condition would work on the user side?

This particular step is not entirely clear:

Then any unpaired rows get retuned in the page object along with other parameters are required to get the next page.

How would the user add a stop-condition for the traversal, and how would that stop-condition look like?

I would imagine something like:

let result = {}
while (true) {
    result = await fetchAllMyTrades (symbol, result)
    if (what?) {  // ←------------------------------------------ what is expected here?
        break;
    }
}

Feels like there's lots of ways to do it. The most basic thing I can think if is a loop just like you've described:

    let theThingIWantToStopAt = "";// a date for example
    let keepGoing = true;
    let pageParms = undefined;
    while(keepGoing) {
        const page = await exchange.fetchAllMyStuff(pageParms);
        const {arrayOfSuff, nextPageParams} = page;

        if(arrayOfSuff.has(theThingIWantToStopAt)) {
            keepGoing = false;
        } else {
            pageParms = nextPageParams;
        }

        this.processMyStuff(arrayOfSuff);// write to the db or something
    }

... however, this isn't what I do in my app. It's more like this:

    await this.exchange.startPaginatingThroughMyStuff(someInitialParams, async (arrayOfStuff /* call back with the page of data */) => {
        await this.processMyStuff(arrayOfStuff);// save the to db or something

        if (arrayOfStuff.has(myStopCondition)) {
            return "stop"
        } else {
            return "keepgoing"
        }
    });

I hide the pagination from the user. The user simply returns a signal to either end the pagination or continue it. If the _paginator_ reaches the point where no _stuff_ is returned then it stops on its own. If the user returns nothing at all with each page it continues.

hi team - I must admit i read htis htread a couple of times but am still a bitt confused. I ideally want to use fetch_my_trades and be able to use pagination to fetch my past trades for up to 3 months (which I understand to be the exchange's limitation here). I realise that a simple use of the 'since' param of the method does not work ie. it always returns the last 50 trades.

can I achieve that only via fetch_closed_orders? or fetch_ledger? the format returned by fetch_my_trades is preferable since it includes fee paid.
thanks

@robzer hi! According to the OKEX docs, it should be possible to get your list of trades (more than just the most recent trades, back into the past) using fetch_my_trades with since pagination. However, the timerange you can query is limited to the past 3 months.

hi @kroitor - I agree but I am afraid the method fetch_my_trades does not return the expected result when passing the since param. for example I tried to use it:

sin=o.parse8601('2020-05-01T00:00:00')
orders = o.fetch_my_trades(pair, sin, limit=3)
but it onoly returns my last 3 trades as opposed to the 3 trades from sin

I think this might be an okex limitation related to https://github.com/ccxt/ccxt/issues/2877

@robzer can you please paste the verbose request+response for that request?

ccxt version: 1.29.15
sin=o.parse8601('2020-05-01T00:00:00') orders = o.fetch_my_trades('BTC/USDT', sin, limit=1) print(orders['datetime'])
it returns '2020-05-30T15:51:46.000Z',

verbose

Request: GET https://www.okex.com/api/spot/v3/fills?instrument_id=BTC-USDT {'OK-ACCESS-KEY': '', 'OK-ACCESS-PASSPHRASE': '', 'OK-ACCESS-TIMESTAMP': '2020-06-04T18:04:49.100Z', 'OK-ACCESS-SIGN'', 'User-Agent': 'python-requests/2.23.0', 'Accept-Encoding': 'gzip, deflate'} None

Response: GET https://www.okex.com/api/spot/v3/fills?instrument_id=BTC-USDT 200 {'Date': 'Thu, 04 Jun 2020 18:04:49 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Set-Cookie': '__cfduid=de1dc46037a947f3b6b561304823574e21591293889; expires=Sat, 04-Jul-20 18:04:49 GMT; path=/; domain=.okex.com; HttpOnly; SameSite=Lax, locale=en_US; Max-Age=604800; Expires=Thu, 11-Jun-2020 18:04:49 GMT; Path=/', 'Vary': 'Accept-Encoding', 'OK-BEFORE': '186990067624529921', 'OK-AFTER': '184831268805496832', 'OK-FROM': '186990067624529921', 'OK-TO': '184831268805496832', 'OK-LIMIT': '100', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Cache-Control': 'no-cache, no-store, max-age=0, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'X-Frame-Options': 'DENY', 'X-BrokerID': '0', 'X-Kong-Upstream-Latency': '85', 'X-Kong-Proxy-Latency': '1', 'Via': 'kong/1.4.3', 'Strict-Transport-Security': 'max-age=63072000; includeSubdomains; preload', 'Content-Encoding': 'gzip', 'CF-Cache-Status': 'DYNAMIC', 'cf-request-id': '03221ae2670000bc7e69ac2200000001', 'Expect-CT': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"', 'Server': 'cloudflare', 'CF-RAY': '59e394170adcbc7e-SEA'} [{"created_at":"2020-05-30T15:51:46.000Z","currency":"BTC","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"186990067624529921","liquidity":"M","order_id":"4988462525461504","price":"9512.5","product_id":"BTC-USDT","side":"sell","size":"0.001","timestamp":"2020-05-30T15:51:46.000Z","trade_id":"85242324"},{"created_at":"2020-05-30T15:51:46.000Z","currency":"USDT","exec_type":"M","fee":"-0.0095125","instrument_id":"BTC-USDT","ledger_id":"186990067624529920","liquidity":"M","order_id":"4988462525461504","price":"9512.5","product_id":"BTC-USDT","side":"buy","size":"9.5125","timestamp":"2020-05-30T15:51:46.000Z","trade_id":"85242324"},{"created_at":"2020-05-29T07:51:34.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"186506834101227527","liquidity":"M","order_id":"4980910639767553","price":"9518.4","product_id":"BTC-USDT","side":"sell","size":"9.5184","timestamp":"2020-05-29T07:51:34.000Z","trade_id":"84625346"},{"created_at":"2020-05-29T07:51:34.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"186506834101227526","liquidity":"M","order_id":"4980910639767553","price":"9518.4","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-29T07:51:34.000Z","trade_id":"84625346"},{"created_at":"2020-05-29T07:51:34.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"186506834101227525","liquidity":"M","order_id":"4980910679998464","price":"9519.3","product_id":"BTC-USDT","side":"sell","size":"9.5193","timestamp":"2020-05-29T07:51:34.000Z","trade_id":"84625331"},{"created_at":"2020-05-29T07:51:34.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"186506834101227524","liquidity":"M","order_id":"4980910679998464","price":"9519.3","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-29T07:51:34.000Z","trade_id":"84625331"},{"created_at":"2020-05-29T07:51:34.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"186506834101227523","liquidity":"M","order_id":"4980910725618688","price":"9519.9","product_id":"BTC-USDT","side":"sell","size":"9.5199","timestamp":"2020-05-29T07:51:34.000Z","trade_id":"84625327"},{"created_at":"2020-05-29T07:51:34.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"186506834101227522","liquidity":"M","order_id":"4980910725618688","price":"9519.9","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-29T07:51:34.000Z","trade_id":"84625327"},{"created_at":"2020-05-29T07:51:34.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"186506834101227521","liquidity":"M","order_id":"4980910771625985","price":"9520.6","product_id":"BTC-USDT","side":"sell","size":"9.5206","timestamp":"2020-05-29T07:51:34.000Z","trade_id":"84625320"},{"created_at":"2020-05-29T07:51:34.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"186506834101227520","liquidity":"M","order_id":"4980910771625985","price":"9520.6","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-29T07:51:34.000Z","trade_id":"84625320"},{"created_at":"2020-05-29T07:51:34.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"186506831421067269","liquidity":"M","order_id":"4980910815209472","price":"9521.1","product_id":"BTC-USDT","side":"sell","size":"9.5211","timestamp":"2020-05-29T07:51:34.000Z","trade_id":"84625314"},{"created_at":"2020-05-29T07:51:34.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"186506831421067268","liquidity":"M","order_id":"4980910815209472","price":"9521.1","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-29T07:51:34.000Z","trade_id":"84625314"},{"created_at":"2020-05-29T07:48:39.000Z","currency":"BTC","exec_type":"T","fee":"0","instrument_id":"BTC-USDT","ledger_id":"186506097086517249","liquidity":"T","order_id":"4980901051656192","price":"9518.2","product_id":"BTC-USDT","side":"sell","size":"0.005","timestamp":"2020-05-29T07:48:39.000Z","trade_id":"84624186"},{"created_at":"2020-05-29T07:48:39.000Z","currency":"USDT","exec_type":"T","fee":"-0.0713865","instrument_id":"BTC-USDT","ledger_id":"186506097086517248","liquidity":"T","order_id":"4980901051656192","price":"9518.2","product_id":"BTC-USDT","side":"buy","size":"47.591","timestamp":"2020-05-29T07:48:39.000Z","trade_id":"84624186"},{"created_at":"2020-05-28T16:20:18.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"186272471136686085","liquidity":"M","order_id":"4977224811437056","price":"9464.6","product_id":"BTC-USDT","side":"sell","size":"9.4646","timestamp":"2020-05-28T16:20:18.000Z","trade_id":"84368543"},{"created_at":"2020-05-28T16:20:18.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"186272471136686084","liquidity":"M","order_id":"4977224811437056","price":"9464.6","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-28T16:20:18.000Z","trade_id":"84368543"},{"created_at":"2020-05-28T16:20:11.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"186272441780752389","liquidity":"M","order_id":"4977224858746880","price":"9465.6","product_id":"BTC-USDT","side":"sell","size":"9.4656","timestamp":"2020-05-28T16:20:11.000Z","trade_id":"84368323"},{"created_at":"2020-05-28T16:20:11.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"186272441780752388","liquidity":"M","order_id":"4977224858746880","price":"9465.6","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-28T16:20:11.000Z","trade_id":"84368323"},{"created_at":"2020-05-28T16:20:11.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"186272441780752387","liquidity":"M","order_id":"4977224911313920","price":"9466.1","product_id":"BTC-USDT","side":"sell","size":"9.4661","timestamp":"2020-05-28T16:20:11.000Z","trade_id":"84368316"},{"created_at":"2020-05-28T16:20:11.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"186272441780752386","liquidity":"M","order_id":"4977224911313920","price":"9466.1","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-28T16:20:11.000Z","trade_id":"84368316"},{"created_at":"2020-05-28T16:20:11.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"186272441780752385","liquidity":"M","order_id":"4977224958828544","price":"9466.5","product_id":"BTC-USDT","side":"sell","size":"9.4665","timestamp":"2020-05-28T16:20:11.000Z","trade_id":"84368307"},{"created_at":"2020-05-28T16:20:11.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"186272441780752384","liquidity":"M","order_id":"4977224958828544","price":"9466.5","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-28T16:20:11.000Z","trade_id":"84368307"},{"created_at":"2020-05-28T16:19:46.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"186272339280351233","liquidity":"M","order_id":"4977225083670528","price":"9467.3","product_id":"BTC-USDT","side":"sell","size":"9.4673","timestamp":"2020-05-28T16:19:46.000Z","trade_id":"84368105"},{"created_at":"2020-05-28T16:19:46.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"186272339280351232","liquidity":"M","order_id":"4977225083670528","price":"9467.3","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-28T16:19:46.000Z","trade_id":"84368105"},{"created_at":"2020-05-28T16:11:15.000Z","currency":"BTC","exec_type":"T","fee":"0","instrument_id":"BTC-USDT","ledger_id":"186270192732033029","liquidity":"T","order_id":"4977215027636224","price":"9471","product_id":"BTC-USDT","side":"sell","size":"0.005","timestamp":"2020-05-28T16:11:15.000Z","trade_id":"84365100"},{"created_at":"2020-05-28T16:11:15.000Z","currency":"USDT","exec_type":"T","fee":"-0.0710325","instrument_id":"BTC-USDT","ledger_id":"186270192732033028","liquidity":"T","order_id":"4977215027636224","price":"9471","product_id":"BTC-USDT","side":"buy","size":"47.355","timestamp":"2020-05-28T16:11:15.000Z","trade_id":"84365100"},{"created_at":"2020-05-28T15:54:59.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"186266099154243587","liquidity":"M","order_id":"4977150627500032","price":"9476.2","product_id":"BTC-USDT","side":"sell","size":"9.4762","timestamp":"2020-05-28T15:54:59.000Z","trade_id":"84350332"},{"created_at":"2020-05-28T15:54:59.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"186266099154243586","liquidity":"M","order_id":"4977150627500032","price":"9476.2","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-28T15:54:59.000Z","trade_id":"84350332"},{"created_at":"2020-05-28T15:54:59.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"186266099154243585","liquidity":"M","order_id":"4977151011284992","price":"9476.4","product_id":"BTC-USDT","side":"sell","size":"9.4764","timestamp":"2020-05-28T15:54:59.000Z","trade_id":"84350330"},{"created_at":"2020-05-28T15:54:59.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"186266099154243584","liquidity":"M","order_id":"4977151011284992","price":"9476.4","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-28T15:54:59.000Z","trade_id":"84350330"},{"created_at":"2020-05-28T15:54:56.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"186266086508417025","liquidity":"M","order_id":"4977150711782400","price":"9476.3","product_id":"BTC-USDT","side":"sell","size":"9.4763","timestamp":"2020-05-28T15:54:56.000Z","trade_id":"84350309"},{"created_at":"2020-05-28T15:54:56.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"186266086508417024","liquidity":"M","order_id":"4977150711782400","price":"9476.3","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-28T15:54:56.000Z","trade_id":"84350309"},{"created_at":"2020-05-28T15:48:21.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"186264431062765577","liquidity":"M","order_id":"4977092326670336","price":"9462.7","product_id":"BTC-USDT","side":"sell","size":"9.4627","timestamp":"2020-05-28T15:48:21.000Z","trade_id":"84346865"},{"created_at":"2020-05-28T15:48:21.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"186264431062765576","liquidity":"M","order_id":"4977092326670336","price":"9462.7","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-28T15:48:21.000Z","trade_id":"84346865"},{"created_at":"2020-05-28T15:48:04.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"186264360745259017","liquidity":"M","order_id":"4977092401516544","price":"9463.5","product_id":"BTC-USDT","side":"sell","size":"9.4635","timestamp":"2020-05-28T15:48:04.000Z","trade_id":"84346634"},{"created_at":"2020-05-28T15:48:04.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"186264360745259016","liquidity":"M","order_id":"4977092401516544","price":"9463.5","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-28T15:48:04.000Z","trade_id":"84346634"},{"created_at":"2020-05-28T15:48:04.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"186264360745259015","liquidity":"M","order_id":"4977092671989760","price":"9463.8","product_id":"BTC-USDT","side":"sell","size":"9.4638","timestamp":"2020-05-28T15:48:04.000Z","trade_id":"84346632"},{"created_at":"2020-05-28T15:48:04.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"186264360745259014","liquidity":"M","order_id":"4977092671989760","price":"9463.8","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-28T15:48:04.000Z","trade_id":"84346632"},{"created_at":"2020-05-28T15:46:40.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"186264008100761601","liquidity":"M","order_id":"4977092826850304","price":"9465.8","product_id":"BTC-USDT","side":"sell","size":"9.4658","timestamp":"2020-05-28T15:46:40.000Z","trade_id":"84345696"},{"created_at":"2020-05-28T15:46:40.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"186264008100761600","liquidity":"M","order_id":"4977092826850304","price":"9465.8","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-28T15:46:40.000Z","trade_id":"84345696"},{"created_at":"2020-05-28T15:40:17.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"186262402898677771","liquidity":"M","order_id":"4977093029482497","price":"9467.2","product_id":"BTC-USDT","side":"sell","size":"9.4672","timestamp":"2020-05-28T15:40:17.000Z","trade_id":"84338697"},{"created_at":"2020-05-28T15:40:17.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"186262402898677770","liquidity":"M","order_id":"4977093029482497","price":"9467.2","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-28T15:40:17.000Z","trade_id":"84338697"},{"created_at":"2020-05-28T15:40:17.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"186262402898677769","liquidity":"M","order_id":"4977093249424384","price":"9467.5","product_id":"BTC-USDT","side":"sell","size":"9.4675","timestamp":"2020-05-28T15:40:17.000Z","trade_id":"84338694"},{"created_at":"2020-05-28T15:40:17.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"186262402898677768","liquidity":"M","order_id":"4977093249424384","price":"9467.5","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-28T15:40:17.000Z","trade_id":"84338694"},{"created_at":"2020-05-27T12:34:15.000Z","currency":"BTC","exec_type":"T","fee":"0","instrument_id":"BTC-USDT","ledger_id":"185853197976948741","liquidity":"T","order_id":"4970699503133696","price":"9175.2","product_id":"BTC-USDT","side":"sell","size":"0.005","timestamp":"2020-05-27T12:34:15.000Z","trade_id":"83806111"},{"created_at":"2020-05-27T12:34:15.000Z","currency":"USDT","exec_type":"T","fee":"-0.068814","instrument_id":"BTC-USDT","ledger_id":"185853197976948740","liquidity":"T","order_id":"4970699503133696","price":"9175.2","product_id":"BTC-USDT","side":"buy","size":"45.876","timestamp":"2020-05-27T12:34:15.000Z","trade_id":"83806111"},{"created_at":"2020-05-27T11:15:06.000Z","currency":"BTC","exec_type":"T","fee":"0","instrument_id":"BTC-USDT","ledger_id":"185833275863420929","liquidity":"T","order_id":"4970388208107520","price":"9120.6","product_id":"BTC-USDT","side":"sell","size":"0.005","timestamp":"2020-05-27T11:15:06.000Z","trade_id":"83762378"},{"created_at":"2020-05-27T11:15:06.000Z","currency":"USDT","exec_type":"T","fee":"-0.0684045","instrument_id":"BTC-USDT","ledger_id":"185833275863420928","liquidity":"T","order_id":"4970388208107520","price":"9120.6","product_id":"BTC-USDT","side":"buy","size":"45.603","timestamp":"2020-05-27T11:15:06.000Z","trade_id":"83762378"},{"created_at":"2020-05-25T09:23:25.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"185080395577511937","liquidity":"M","order_id":"4958624411443200","price":"8871.8","product_id":"BTC-USDT","side":"sell","size":"8.8718","timestamp":"2020-05-25T09:23:25.000Z","trade_id":"82892170"},{"created_at":"2020-05-25T09:23:25.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"185080395577511936","liquidity":"M","order_id":"4958624411443200","price":"8871.8","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-25T09:23:25.000Z","trade_id":"82892170"},{"created_at":"2020-05-25T09:22:21.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"185080127058169859","liquidity":"M","order_id":"4958620169102336","price":"8858.7","product_id":"BTC-USDT","side":"sell","size":"8.8587","timestamp":"2020-05-25T09:22:21.000Z","trade_id":"82891604"},{"created_at":"2020-05-25T09:22:21.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"185080127058169858","liquidity":"M","order_id":"4958620169102336","price":"8858.7","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-25T09:22:21.000Z","trade_id":"82891604"},{"created_at":"2020-05-25T09:22:21.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"185080127058169857","liquidity":"M","order_id":"4958620247801859","price":"8858.8","product_id":"BTC-USDT","side":"sell","size":"8.8588","timestamp":"2020-05-25T09:22:21.000Z","trade_id":"82891603"},{"created_at":"2020-05-25T09:22:21.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"185080127058169856","liquidity":"M","order_id":"4958620247801859","price":"8858.8","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-25T09:22:21.000Z","trade_id":"82891603"},{"created_at":"2020-05-25T09:21:27.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"185079899785613323","liquidity":"M","order_id":"4958616548425729","price":"8850.6","product_id":"BTC-USDT","side":"sell","size":"8.8506","timestamp":"2020-05-25T09:21:27.000Z","trade_id":"82891176"},{"created_at":"2020-05-25T09:21:27.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"185079899785613322","liquidity":"M","order_id":"4958616548425729","price":"8850.6","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-25T09:21:27.000Z","trade_id":"82891176"},{"created_at":"2020-05-25T09:21:27.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"185079899785613321","liquidity":"M","order_id":"4958616635530240","price":"8850.9","product_id":"BTC-USDT","side":"sell","size":"8.8509","timestamp":"2020-05-25T09:21:27.000Z","trade_id":"82891174"},{"created_at":"2020-05-25T09:21:27.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"185079899785613320","liquidity":"M","order_id":"4958616635530240","price":"8850.9","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-25T09:21:27.000Z","trade_id":"82891174"},{"created_at":"2020-05-25T09:20:49.000Z","currency":"BTC","exec_type":"T","fee":"0","instrument_id":"BTC-USDT","ledger_id":"185079740326563841","liquidity":"T","order_id":"4958614213115904","price":"8845.9","product_id":"BTC-USDT","side":"sell","size":"0.005","timestamp":"2020-05-25T09:20:49.000Z","trade_id":"82891070"},{"created_at":"2020-05-25T09:20:49.000Z","currency":"USDT","exec_type":"T","fee":"-0.06634425","instrument_id":"BTC-USDT","ledger_id":"185079740326563840","liquidity":"T","order_id":"4958614213115904","price":"8845.9","product_id":"BTC-USDT","side":"buy","size":"44.2295","timestamp":"2020-05-25T09:20:49.000Z","trade_id":"82891070"},{"created_at":"2020-05-24T18:47:32.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"184859973061791745","liquidity":"M","order_id":"4955104651536384","price":"8955.3","product_id":"BTC-USDT","side":"sell","size":"8.9553","timestamp":"2020-05-24T18:47:32.000Z","trade_id":"82613290"},{"created_at":"2020-05-24T18:47:32.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"184859973061791744","liquidity":"M","order_id":"4955104651536384","price":"8955.3","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-24T18:47:32.000Z","trade_id":"82613290"},{"created_at":"2020-05-24T18:29:40.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"184855476168118277","liquidity":"M","order_id":"4955104689934336","price":"8955.5","product_id":"BTC-USDT","side":"sell","size":"8.9555","timestamp":"2020-05-24T18:29:40.000Z","trade_id":"82610277"},{"created_at":"2020-05-24T18:29:40.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"184855476168118276","liquidity":"M","order_id":"4955104689934336","price":"8955.5","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-24T18:29:40.000Z","trade_id":"82610277"},{"created_at":"2020-05-24T18:29:03.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"184855320857235457","liquidity":"M","order_id":"4955104752263168","price":"8956.2","product_id":"BTC-USDT","side":"sell","size":"8.9562","timestamp":"2020-05-24T18:29:03.000Z","trade_id":"82610230"},{"created_at":"2020-05-24T18:29:03.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"184855320857235456","liquidity":"M","order_id":"4955104752263168","price":"8956.2","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-24T18:29:03.000Z","trade_id":"82610230"},{"created_at":"2020-05-24T18:28:47.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"184855253723205647","liquidity":"M","order_id":"4955104800231424","price":"8956.3","product_id":"BTC-USDT","side":"sell","size":"8.9563","timestamp":"2020-05-24T18:28:47.000Z","trade_id":"82610210"},{"created_at":"2020-05-24T18:28:47.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"184855253723205646","liquidity":"M","order_id":"4955104800231424","price":"8956.3","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-24T18:28:47.000Z","trade_id":"82610210"},{"created_at":"2020-05-24T18:28:47.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"184855252079038471","liquidity":"M","order_id":"4955105049143296","price":"8956.4","product_id":"BTC-USDT","side":"sell","size":"8.9564","timestamp":"2020-05-24T18:28:47.000Z","trade_id":"82610209"},{"created_at":"2020-05-24T18:28:47.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"184855252079038470","liquidity":"M","order_id":"4955105049143296","price":"8956.4","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-24T18:28:47.000Z","trade_id":"82610209"},{"created_at":"2020-05-24T18:28:47.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"184855252079038469","liquidity":"M","order_id":"4955105093771264","price":"8956.8","product_id":"BTC-USDT","side":"sell","size":"8.9568","timestamp":"2020-05-24T18:28:47.000Z","trade_id":"82610205"},{"created_at":"2020-05-24T18:28:47.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"184855252079038468","liquidity":"M","order_id":"4955105093771264","price":"8956.8","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-24T18:28:47.000Z","trade_id":"82610205"},{"created_at":"2020-05-24T18:28:47.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"184855252079038467","liquidity":"M","order_id":"4955105138659328","price":"8957.1","product_id":"BTC-USDT","side":"sell","size":"8.9571","timestamp":"2020-05-24T18:28:47.000Z","trade_id":"82610202"},{"created_at":"2020-05-24T18:28:47.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"184855252079038466","liquidity":"M","order_id":"4955105138659328","price":"8957.1","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-24T18:28:47.000Z","trade_id":"82610202"},{"created_at":"2020-05-24T18:28:47.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"184855252079038465","liquidity":"M","order_id":"4955105216188416","price":"8957.2","product_id":"BTC-USDT","side":"sell","size":"8.9572","timestamp":"2020-05-24T18:28:47.000Z","trade_id":"82610201"},{"created_at":"2020-05-24T18:28:47.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"184855252079038464","liquidity":"M","order_id":"4955105216188416","price":"8957.2","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-24T18:28:47.000Z","trade_id":"82610201"},{"created_at":"2020-05-24T17:10:53.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"184835651588935691","liquidity":"M","order_id":"4954800123110400","price":"8954.3","product_id":"BTC-USDT","side":"sell","size":"8.9543","timestamp":"2020-05-24T17:10:53.000Z","trade_id":"82589879"},{"created_at":"2020-05-24T17:10:53.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"184835651588935690","liquidity":"M","order_id":"4954800123110400","price":"8954.3","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-24T17:10:53.000Z","trade_id":"82589879"},{"created_at":"2020-05-24T17:10:53.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"184835651588935689","liquidity":"M","order_id":"4954800265913344","price":"8954.6","product_id":"BTC-USDT","side":"sell","size":"8.9546","timestamp":"2020-05-24T17:10:53.000Z","trade_id":"82589875"},{"created_at":"2020-05-24T17:10:53.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"184835651588935688","liquidity":"M","order_id":"4954800265913344","price":"8954.6","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-24T17:10:53.000Z","trade_id":"82589875"},{"created_at":"2020-05-24T17:06:29.000Z","currency":"BTC","exec_type":"T","fee":"0","instrument_id":"BTC-USDT","ledger_id":"184834541788680199","liquidity":"T","order_id":"4954783003468800","price":"8968.7","product_id":"BTC-USDT","side":"sell","size":"0.00277059","timestamp":"2020-05-24T17:06:29.000Z","trade_id":"82587819"},{"created_at":"2020-05-24T17:06:29.000Z","currency":"USDT","exec_type":"T","fee":"-0.03727289","instrument_id":"BTC-USDT","ledger_id":"184834541788680198","liquidity":"T","order_id":"4954783003468800","price":"8968.7","product_id":"BTC-USDT","side":"buy","size":"24.84859053","timestamp":"2020-05-24T17:06:29.000Z","trade_id":"82587819"},{"created_at":"2020-05-24T17:06:29.000Z","currency":"BTC","exec_type":"T","fee":"0","instrument_id":"BTC-USDT","ledger_id":"184834541788680197","liquidity":"T","order_id":"4954783003468800","price":"8968.7","product_id":"BTC-USDT","side":"sell","size":"0.00222941","timestamp":"2020-05-24T17:06:29.000Z","trade_id":"82587818"},{"created_at":"2020-05-24T17:06:29.000Z","currency":"USDT","exec_type":"T","fee":"-0.02999237","instrument_id":"BTC-USDT","ledger_id":"184834541788680196","liquidity":"T","order_id":"4954783003468800","price":"8968.7","product_id":"BTC-USDT","side":"buy","size":"19.99490946","timestamp":"2020-05-24T17:06:29.000Z","trade_id":"82587818"},{"created_at":"2020-05-24T16:54:22.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"184831493678911489","liquidity":"M","order_id":"4954734614961152","price":"8873.7","product_id":"BTC-USDT","side":"sell","size":"8.8737","timestamp":"2020-05-24T16:54:22.000Z","trade_id":"82577913"},{"created_at":"2020-05-24T16:54:22.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"184831493678911488","liquidity":"M","order_id":"4954734614961152","price":"8873.7","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-24T16:54:22.000Z","trade_id":"82577913"},{"created_at":"2020-05-24T16:54:06.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"184831426213531649","liquidity":"M","order_id":"4954734245141504","price":"8869.1","product_id":"BTC-USDT","side":"sell","size":"8.8691","timestamp":"2020-05-24T16:54:06.000Z","trade_id":"82577636"},{"created_at":"2020-05-24T16:54:06.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"184831426213531648","liquidity":"M","order_id":"4954734245141504","price":"8869.1","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-24T16:54:06.000Z","trade_id":"82577636"},{"created_at":"2020-05-24T16:54:03.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"184831411671879687","liquidity":"M","order_id":"4954733990665216","price":"8865","product_id":"BTC-USDT","side":"sell","size":"8.865","timestamp":"2020-05-24T16:54:03.000Z","trade_id":"82577555"},{"created_at":"2020-05-24T16:54:03.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"184831411671879686","liquidity":"M","order_id":"4954733990665216","price":"8865","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-24T16:54:03.000Z","trade_id":"82577555"},{"created_at":"2020-05-24T16:54:03.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"184831411671879685","liquidity":"M","order_id":"4954734033332224","price":"8865.9","product_id":"BTC-USDT","side":"sell","size":"8.8659","timestamp":"2020-05-24T16:54:03.000Z","trade_id":"82577550"},{"created_at":"2020-05-24T16:54:03.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"184831411671879684","liquidity":"M","order_id":"4954734033332224","price":"8865.9","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-24T16:54:03.000Z","trade_id":"82577550"},{"created_at":"2020-05-24T16:54:03.000Z","currency":"USDT","exec_type":"M","fee":"0","instrument_id":"BTC-USDT","ledger_id":"184831411671879683","liquidity":"M","order_id":"4954734067345408","price":"8866.3","product_id":"BTC-USDT","side":"sell","size":"8.8663","timestamp":"2020-05-24T16:54:03.000Z","trade_id":"82577548"},{"created_at":"2020-05-24T16:54:03.000Z","currency":"BTC","exec_type":"M","fee":"-0.000001","instrument_id":"BTC-USDT","ledger_id":"184831411671879682","liquidity":"M","order_id":"4954734067345408","price":"8866.3","product_id":"BTC-USDT","side":"buy","size":"0.001","timestamp":"2020-05-24T16:54:03.000Z","trade_id":"82577548"},{"created_at":"2020-05-24T16:53:28.000Z","currency":"BTC","exec_type":"T","fee":"0","instrument_id":"BTC-USDT","ledger_id":"184831268805496837","liquidity":"T","order_id":"4954731856485376","price":"8874.4","product_id":"BTC-USDT","side":"sell","size":"0.00203632","timestamp":"2020-05-24T16:53:28.000Z","trade_id":"82576378"},{"created_at":"2020-05-24T16:53:28.000Z","currency":"USDT","exec_type":"T","fee":"-0.02710668","instrument_id":"BTC-USDT","ledger_id":"184831268805496836","liquidity":"T","order_id":"4954731856485376","price":"8874.4","product_id":"BTC-USDT","side":"buy","size":"18.0711182","timestamp":"2020-05-24T16:53:28.000Z","trade_id":"82576378"},{"created_at":"2020-05-24T16:53:28.000Z","currency":"BTC","exec_type":"T","fee":"0","instrument_id":"BTC-USDT","ledger_id":"184831268805496835","liquidity":"T","order_id":"4954731856485376","price":"8874.4","product_id":"BTC-USDT","side":"sell","size":"0.00293745","timestamp":"2020-05-24T16:53:28.000Z","trade_id":"82576377"},{"created_at":"2020-05-24T16:53:28.000Z","currency":"USDT","exec_type":"T","fee":"-0.03910216","instrument_id":"BTC-USDT","ledger_id":"184831268805496834","liquidity":"T","order_id":"4954731856485376","price":"8874.4","product_id":"BTC-USDT","side":"buy","size":"26.06810628","timestamp":"2020-05-24T16:53:28.000Z","trade_id":"82576377"},{"created_at":"2020-05-24T16:53:28.000Z","currency":"BTC","exec_type":"T","fee":"0","instrument_id":"BTC-USDT","ledger_id":"184831268805496833","liquidity":"T","order_id":"4954731856485376","price":"8874.4","product_id":"BTC-USDT","side":"sell","size":"0.00002623","timestamp":"2020-05-24T16:53:28.000Z","trade_id":"82576376"},{"created_at":"2020-05-24T16:53:28.000Z","currency":"USDT","exec_type":"T","fee":"-0.00034917","instrument_id":"BTC-USDT","ledger_id":"184831268805496832","liquidity":"T","order_id":"4954731856485376","price":"8874.4","product_id":"BTC-USDT","side":"buy","size":"0.23277551","timestamp":"2020-05-24T16:53:28.000Z","trade_id":"82576376"}]
2020-05-30T15:51:46.000Z

@robzer ah, right, OKEX does not accept a since value for datetime pagination. However you can still paginate using the before and after with id-based pagination (it must be a ledger_id) in this case.

print(orders['datetime'])

↑ There's a typo here, orders is an array.


Try this:

import ccxt
exchange = ccxt.okex({
    'enableRateLimit': True,
    'apiKey': 'YOUR_API_KEY',
    'secret': 'YOUR_SECRET',
})
all_trades = []
symbol = 'BTC/USDT'
params = {}
while True:
    trades = exchange.fetch_my_trades(symbol, None, None, params)
        all_trades = all_trades + trades
    if not len(trades):
        break
    last_trade = trades[-1]
    last_ledger_id = last_trade['info'][1]['ledger_id']
    params['after'] = last_ledger_id  # try with 'after' or 'before'
print(len(all_trades))

If that does not work for you, i'm afraid you'll have to fall back to ledger entries.
Let me know if that does not help.

Edited for typos

question: in fetch_my_trades 'order' is not unique, in fetch_closed_orders its is. I was looking to paginate over 'order' ...

why shall I use ledger_id? how do I know which one is 'mine'? on the below trade I did, I was the buyer... how do I make sure to 'paginate' over the right id? is the order always the same ie. the second?

[{'created_at': '2020-06-04T18:35:54.000Z',
  'currency': 'USDT',
  'exec_type': 'M',
  'fee': '0',
  'instrument_id': 'BTC-USDT',
  'ledger_id': '188843312965832727',
  'liquidity': 'M',
  'order_id': '5017419848829952',
  'price': '9821.7',
  'product_id': 'BTC-USDT',
  'side': 'sell',
  'size': '9.8217',
  'timestamp': '2020-06-04T18:35:54.000Z',
  'trade_id': '88329094'},
 {'created_at': '2020-06-04T18:35:54.000Z',
  'currency': 'BTC',
  'exec_type': 'M',
  'fee': '-0.000001',
  'instrument_id': 'BTC-USDT',
  'ledger_id': '188843312965832726',
  'liquidity': 'M',
  'order_id': '5017419848829952',
  'price': '9821.7',
  'product_id': 'BTC-USDT',
  'side': 'buy',
  'size': '0.001',
  'timestamp': '2020-06-04T18:35:54.000Z',
  'trade_id': '88329094'}]

to answer your question @kroitor , pagination works
there was a typo here: last_ledger_id = last_trade['info'][1]['ledger_id']
but this assumes that 'my' trade is always in second position from the above response it seems to be the case but would be good to get it confirmed

but this assumes that 'my' trade is always in second position from the above response it seems to be the case but would be good to get it confirmed

Yeah, OKEX doesn't make our lifes easy in that regard. Unfortunately, this is not guaranteed, nor documented. So, I believe you would want to solve this using the fetch_closed_orders (to see which trades are yours) + fetch_ledger. This difficulty with the OKEX API is the actual design issue discussed above. It is very hard to workaround it to get the actual trades list, without referring to the other pieces of historical info, served from other methods for personal history. We'd love to have a true fetch_my_trades for it, but with this design, it's almost impossible to do without additional lookups.

Yes. Question, do you expect fetch_closed_orders and fetch_my_trades paginated as per above to return the same len?

@robzer sorry, can you elaborate on the question a bit? What do you mean _"return the same len"_ ?

all_trades = []
symbol = 'BTC/USDT'
params = {}
while True:
    trades = o.fetch_my_trades(symbol, None, None, params)
    all_trades = all_trades + trades
    if not len(trades):
        break
    last_trade = trades[-1]
    last_ledger_id = last_trade['info'][1]['ledger_id']
    params['after'] = last_ledger_id  # try with 'after' or 'before'
df_page=pd.DataFrame(data=all_trades)
pp(len(df_page))
````
returns 96

but 

closed = o.fetch_closed_orders(symbol)
df_closed=pd.DataFrame(data=closed)
pp(len(df_closed))
```
returns 92

I am wondering where the difference comes from.

@robzer each order may be filled with more than one trade:

of course. Thank you very much @kroitor.

ccxt version: 1.29.58
i am back with a question on fetch_ledger. I am paginating over ledger id using either params{'after': 'ledger_id'} or params{'before': 'ledger_id'} and I wanted to confirm that when I get IndexError: list index out of range this means that I tried to go back to far in the past (>3months, OKEX limitation)?

#o.verbose=True
params = {'after': 181933287198511105}
led=o.fetch_ledger('BTC',None,None,params)
# led=o.fetch_ledger('BTC',None,None)
pp(len(led))
pp(led[0])
pp(led[-1])

returns

8
{'account': None,
 'after': 0.0021427460995039,
 'amount': 0.001647351231045,
 'before': None,
 'currency': 'BTC',
 'datetime': '2020-05-16T11:46:03.000Z',
 'fee': {'cost': None, 'currency': 'BTC'},
 'id': '181854798390841349',
 'info': {'amount': '0.001647351231045',
          'balance': '0.0021427460995039',
          'created_at': '2020-05-16T11:46:03.000Z',
          'currency': 'BTC',
          'details': {'instrument_id': 'ETH-BTC',
                      'order_id': '4908224500807680',
                      'product_id': 'ETH-BTC'},
          'ledger_id': '181854798390841349',
          'timestamp': '2020-05-16T11:46:03.000Z',
          'type': 'trade'},
 'referenceAccount': None,
 'referenceId': '4908224500807680',
 'status': 'ok',
 'timestamp': 1589629563000,
 'type': 'trade'}
{'account': None,
 'after': 0.0036272959901939,
 'amount': 0.000313824861,
 'before': None,
 'currency': 'BTC',
 'datetime': '2020-05-16T16:54:15.000Z',
 'fee': {'cost': None, 'currency': 'BTC'},
 'id': '181932361322680320',
 'info': {'amount': '0.000313824861',
          'balance': '0.0036272959901939',
          'created_at': '2020-05-16T16:54:15.000Z',
          'currency': 'BTC',
          'details': {'instrument_id': 'ETH-BTC',
                      'order_id': '4909426538136576',
                      'product_id': 'ETH-BTC'},
          'ledger_id': '181932361322680320',
          'timestamp': '2020-05-16T16:54:15.000Z',
          'type': 'trade'},
 'referenceAccount': None,
 'referenceId': '4909426538136576',
 'status': 'ok',
 'timestamp': 1589648055000,
 'type': 'trade'}
True

then if I take the last ledger_id from the above to get stuff from futher in the past:

o.verbose=True
params = {'after': 181854798390841349}
led=o.fetch_ledger('BTC',None,None,params)
# led=o.fetch_ledger('BTC',None,None)
pp(len(led))
pp(led[0])
pp(led[-1])

I get the below errors


Response: GET https://www.okex.com/api/spot/v3/accounts/BTC/ledger?after=181854798390841349 200 {'Date': 'Tue, 09 Jun 2020 20:52:53 GMT', 'Content-Type': 'application/json', 'Content-Length': '2', 'Connection': 'keep-alive', 'Set-Cookie': '__cfduid=d4dc4bda1208cb7c655429d5a6ca521531591735973; expires=Thu, 09-Jul-20 20:52:53 GMT; path=/; domain=.okex.com; HttpOnly; SameSite=Lax, locale=en_US; Max-Age=604800; Expires=Tue, 16-Jun-2020 20:52:53 GMT; Path=/', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Cache-Control': 'no-cache, no-store, max-age=0, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'X-Frame-Options': 'DENY', 'X-BrokerID': '0', 'X-Kong-Upstream-Latency': '33', 'X-Kong-Proxy-Latency': '0', 'Via': 'kong/1.4.3', 'Strict-Transport-Security': 'max-age=63072000; includeSubdomains; preload', 'Accept-Ranges': 'bytes', 'CF-Cache-Status': 'DYNAMIC', 'cf-request-id': '033c748e860000d8f1ae3c3200000001', 'Expect-CT': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"', 'Server': 'cloudflare', 'CF-RAY': '5a0dbd2a78bfd8f1-AMS'} []
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-93-746952727d04> in <module>()
      1 o.verbose=True
      2 params = {'after': 181854798390841349}
----> 3 led=o.fetch_ledger('BTC',None,None,params)
      4 # led=o.fetch_ledger('BTC',None,None)
      5 pp(len(led))

/usr/local/lib/python3.6/dist-packages/ccxt/okex.py in fetch_ledger(self, code, since, limit, params)
   2899         #     ]
   2900         #
-> 2901         isArray = isinstance(response[0], list)
   2902         isMargin = (type == 'margin')
   2903         entries = response[0] if (isMargin and isArray) else response

IndexError: list index out of range

is that expected?

@robzer

is that expected?

Nope, it should return an empty array in this case, however, it is missing a check for array length which causes that exception, i will add a workaround to it shortly. Thx for reporting it!

@robzer it should be ok as of version 1.29.60+, let me know if you have any other issues or difficulties with it.

Works like a dream now, thank you @kroitor. I used the below script:

all_ledger_quote= []
limit = None
params = {}
while True:
    ledger = okex.fetch_ledger('BTC', None, None, params)
    all_ledger_quote = all_ledger_quote + ledger
    if not ledger:
                  break
    last_ledger = ledger[0]
    last_ledger_id = last_ledger['info']['ledger_id']
    params['after'] = last_ledger_id  
df_all_ledger_quote=pd.DataFrame(data=all_ledger_quote)
df_all_ledger_quote=df_all_ledger_quote.sort_values(by=['datetime'])
df_all_ledger_quote.head()

returns expected results.

@robzer thx to you for your feedback, appreciate it!

Hihi @kroitor the above script started returning duplicated 'id' values :(

version: (1.30.47)

is that expected?

@robzer

is that expected?

No, but OKEX could've changed something, can you paste your verbose output?

Was this page helpful?
0 / 5 - 0 ratings