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

Method fetch_trades

python/ccxt/gate.py:3403–3507  ·  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

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