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

Method fetch_trades

python/ccxt/cex.py:631–675  ·  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

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

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