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

Method fetch_my_trades

python/ccxt/gate.py:3550–3680  ·  view source on GitHub ↗

Fetch personal trading history https://www.gate.com/docs/developers/apiv4/en/#query-personal-trading-records https://www.gate.com/docs/developers/apiv4/en/#query-personal-trading-records-by-time-range https://www.gate.com/docs/developers/apiv4/en/#query-personal-tra

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

Source from the content-addressed store, hash-verified

3548 return response
3549
3550 def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3551 """
3552 Fetch personal trading history
3553
3554 https://www.gate.com/docs/developers/apiv4/en/#query-personal-trading-records
3555 https://www.gate.com/docs/developers/apiv4/en/#query-personal-trading-records-by-time-range
3556 https://www.gate.com/docs/developers/apiv4/en/#query-personal-trading-records-3
3557 https://www.gate.com/docs/developers/apiv4/en/#query-personal-trading-records-4
3558
3559 :param str symbol: unified market symbol
3560 :param int [since]: the earliest time in ms to fetch trades for
3561 :param int [limit]: the maximum number of trades structures to retrieve
3562 :param dict [params]: extra parameters specific to the exchange API endpoint
3563 :param str [params.marginMode]: 'cross' or 'isolated' - marginMode for margin trading if not provided self.options['defaultMarginMode'] is used
3564 :param str [params.type]: 'spot', 'swap', or 'future', if not provided self.options['defaultMarginMode'] is used
3565 :param int [params.until]: The latest timestamp, in ms, that fetched trades were made
3566 :param int [params.page]: *spot only* Page number
3567 :param str [params.order_id]: *spot only* Filter trades with specified order ID. symbol is also required if self field is present
3568 :param str [params.order]: *contract only* Futures order ID, return related data only if specified
3569 :param int [params.offset]: *contract only* list offset, starting from 0
3570 :param str [params.last_id]: *contract only* specify list staring point using the id of last record in previous list-query results
3571 :param int [params.count_total]: *contract only* whether to return total number matched, default to 0(no return)
3572 :param bool [params.unifiedAccount]: set to True for fetching trades in a unified account
3573 :param bool [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
3574 :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/?id=trade-structure>`
3575 """
3576 self.load_markets()
3577 self.load_unified_status()
3578 paginate = False
3579 paginate, params = self.handle_option_and_params(params, 'fetchMyTrades', 'paginate')
3580 if paginate:
3581 return self.fetch_paginated_call_dynamic('fetchMyTrades', symbol, since, limit, params)
3582 type = None
3583 marginMode = None
3584 request = {}
3585 market = self.market(symbol) if (symbol is not None) else None
3586 until = self.safe_integer(params, 'until')
3587 params = self.omit(params, ['until'])
3588 type, params = self.handle_market_type_and_params('fetchMyTrades', market, params)
3589 contract = (type == 'swap') or (type == 'future') or (type == 'option')
3590 if contract:
3591 request, params = self.prepare_request(market, type, params)
3592 if type == 'option':
3593 params = self.omit(params, 'order_id')
3594 else:
3595 if market is not None:
3596 request['currency_pair'] = market['id'] # Should always be set for non-trigger
3597 marginMode, params = self.get_margin_mode(False, params)
3598 request['account'] = marginMode
3599 if limit is not None:
3600 request['limit'] = limit # default 100, max 1000
3601 if since is not None:
3602 request['from'] = self.parse_to_int(since / 1000)
3603 if until is not None:
3604 request['to'] = self.parse_to_int(until / 1000)
3605 response: List
3606 if type == 'spot' or type == 'margin':
3607 response = self.privateSpotGetMyTrades(self.extend(request, params))

Callers 1

fetch_order_tradesMethod · 0.95

Calls 15

load_unified_statusMethod · 0.95
prepare_requestMethod · 0.95
get_margin_modeMethod · 0.95
NotSupportedClass · 0.90
safe_integerMethod · 0.80
parse_to_intMethod · 0.80
parse_tradesMethod · 0.80

Tested by

no test coverage detected