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

Method fetch_my_trades

python/ccxt/async_support/gate.py:3551–3681  ·  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

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