MCPcopy Create free account
hub / github.com/ccxt/ccxt / fetch_trades

Method fetch_trades

python/ccxt/async_support/cex.py:632–676  ·  view source on GitHub ↗

get the list of most recent trades for a particular symbol https://trade.cex.io/docs/#rest-public-api-calls-trade-history :param str symbol: unified symbol of the market to fetch trades for :param int [since]: timestamp in ms of the earliest trade to fetch

(self, symbol: str, since: Int = None, limit: Int = None, params={})

Source from the content-addressed store, hash-verified

630 }, market)
631
632 async def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
633 """
634 get the list of most recent trades for a particular symbol
635
636 https://trade.cex.io/docs/#rest-public-api-calls-trade-history
637
638 :param str symbol: unified symbol of the market to fetch trades for
639 :param int [since]: timestamp in ms of the earliest trade to fetch
640 :param int [limit]: the maximum amount of trades to fetch
641 :param dict [params]: extra parameters specific to the exchange API endpoint
642 :param int [params.until]: timestamp in ms of the latest entry
643 :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/?id=public-trades>`
644 """
645 await self.load_markets()
646 market = self.market(symbol)
647 request = {
648 'pair': market['id'],
649 }
650 if since is not None:
651 request['fromDateISO'] = self.iso8601(since)
652 until = None
653 until, params = self.handle_param_integer_2(params, 'until', 'till')
654 if until is not None:
655 request['toDateISO'] = self.iso8601(until)
656 if limit is not None:
657 request['pageSize'] = min(limit, 10000) # has a bug, still returns more trades
658 response = await self.publicPostGetTradeHistory(self.extend(request, params))
659 #
660 # {
661 # "ok": "ok",
662 # "data": {
663 # "pageSize": "10",
664 # "trades": [
665 # {
666 # "tradeId": "1728630559823-0",
667 # "dateISO": "2024-10-11T07:09:19.823Z",
668 # "side": "SELL",
669 # "price": "60879.5",
670 # "amount": "0.00165962"
671 # },
672 # ... followed by older trades
673 #
674 data = self.safe_dict(response, 'data', {})
675 trades = self.safe_list(data, 'trades', [])
676 return self.parse_trades(trades, market, since, limit)
677
678 def parse_trade(self, trade: dict, market: Market = None) -> Trade:
679 #

Callers

nothing calls this directly

Calls 9

safe_dictMethod · 0.80
safe_listMethod · 0.80
parse_tradesMethod · 0.80
load_marketsMethod · 0.45
marketMethod · 0.45
iso8601Method · 0.45
extendMethod · 0.45

Tested by

no test coverage detected