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

Method fetch_trades

python/ccxt/async_support/gate.py:3404–3508  ·  view source on GitHub ↗

get the list of most recent trades for a particular symbol https://www.gate.com/docs/developers/apiv4/en/#query-market-transaction-records https://www.gate.com/docs/developers/apiv4/en/#futures-market-transaction-records https://www.gate.com/docs/developers/apiv4/en

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

Source from the content-addressed store, hash-verified

3402 ]
3403
3404 async def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
3405 """
3406 get the list of most recent trades for a particular symbol
3407
3408 https://www.gate.com/docs/developers/apiv4/en/#query-market-transaction-records
3409 https://www.gate.com/docs/developers/apiv4/en/#futures-market-transaction-records
3410 https://www.gate.com/docs/developers/apiv4/en/#futures-market-transaction-records-2
3411 https://www.gate.com/docs/developers/apiv4/en/#market-trade-records
3412
3413 :param str symbol: unified symbol of the market to fetch trades for
3414 :param int [since]: timestamp in ms of the earliest trade to fetch
3415 :param int [limit]: the maximum amount of trades to fetch
3416 :param dict [params]: extra parameters specific to the exchange API endpoint
3417 :param int [params.until]: timestamp in ms of the latest trade to fetch
3418 :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
3419 :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/?id=public-trades>`
3420 """
3421 await self.load_markets()
3422 paginate = False
3423 paginate, params = self.handle_option_and_params(params, 'fetchTrades', 'paginate')
3424 if paginate:
3425 return await self.fetch_paginated_call_dynamic('fetchTrades', symbol, since, limit, params)
3426 market = self.market(symbol)
3427 #
3428 # spot
3429 #
3430 # request = {
3431 # 'currency_pair': market['id'],
3432 # 'limit': limit, # maximum number of records to be returned in a single list
3433 # 'last_id': 'id', # specify list staring point using the id of last record in previous list-query results
3434 # 'reverse': False, # True to retrieve records where id is smaller than the specified last_id, False to retrieve records where id is larger than the specified last_id
3435 # }
3436 #
3437 # swap, future
3438 #
3439 # request = {
3440 # 'settle': market['settleId'],
3441 # 'contract': market['id'],
3442 # 'limit': limit, # maximum number of records to be returned in a single list
3443 # 'last_id': 'id', # specify list staring point using the id of last record in previous list-query results
3444 # 'from': since / 1000), # starting time in seconds, if not specified, to and limit will be used to limit response items
3445 # 'to': self.seconds(), # end time in seconds, default to current time
3446 # }
3447 #
3448 request, query = self.prepare_request(market, None, params)
3449 until = self.safe_integer_2(params, 'to', 'until')
3450 if until is not None:
3451 params = self.omit(params, ['until'])
3452 request['to'] = self.parse_to_int(until / 1000)
3453 if limit is not None:
3454 request['limit'] = min(limit, 1000) # default 100, max 1000
3455 if since is not None and (market['contract']):
3456 request['from'] = self.parse_to_int(since / 1000)
3457 response: List
3458 if market['type'] == 'spot' or market['type'] == 'margin':
3459 response = await self.publicSpotGetTrades(self.extend(request, query))
3460 elif market['swap']:
3461 response = await self.publicFuturesGetSettleTrades(self.extend(request, query))

Callers

nothing calls this directly

Calls 15

prepare_requestMethod · 0.95
publicSpotGetTradesMethod · 0.95
NotSupportedClass · 0.90
safe_integer_2Method · 0.80
parse_to_intMethod · 0.80
parse_tradesMethod · 0.80
load_marketsMethod · 0.45

Tested by

no test coverage detected