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

Method fetch_trades

python/ccxt/async_support/hyperliquid.py:1470–1526  ·  view source on GitHub ↗

get the list of most recent trades for a particular symbol https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-fills https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-fills-by-time

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

Source from the content-addressed store, hash-verified

1468 ]
1469
1470 async def fetch_trades(self, symbol: Str, since: Int = None, limit: Int = None, params={}):
1471 """
1472 get the list of most recent trades for a particular symbol
1473
1474 https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-fills
1475 https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-fills-by-time
1476
1477 :param str symbol: unified market symbol
1478 :param int [since]: the earliest time in ms to fetch trades for
1479 :param int [limit]: the maximum number of trades structures to retrieve
1480 :param dict [params]: extra parameters specific to the exchange API endpoint
1481 :param int [params.until]: timestamp in ms of the latest trade
1482 :param str [params.address]: wallet address that made trades
1483 :param str [params.user]: wallet address that made trades
1484 :param str [params.subAccountAddress]: sub account user address
1485 :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/?id=trade-structure>`
1486 """
1487 userAddress = None
1488 userAddress, params = self.handle_public_address('fetchTrades', params)
1489 await self.load_markets()
1490 market = None
1491 if symbol is not None:
1492 market = self.market(symbol)
1493 request = {
1494 'user': userAddress,
1495 }
1496 if since is not None:
1497 request['type'] = 'userFillsByTime'
1498 request['startTime'] = since
1499 else:
1500 request['type'] = 'userFills'
1501 until = self.safe_integer(params, 'until')
1502 params = self.omit(params, 'until')
1503 if until is not None:
1504 request['endTime'] = until
1505 response = await self.publicPostInfo(self.extend(request, params))
1506 #
1507 # [
1508 # {
1509 # "closedPnl": "0.19343",
1510 # "coin": "ETH",
1511 # "crossed": True,
1512 # "dir": "Close Long",
1513 # "fee": "0.050062",
1514 # "hash": "0x09d77c96791e98b5775a04092584ab010d009445119c71e4005c0d634ea322bc",
1515 # "liquidationMarkPx": null,
1516 # "oid": 3929354691,
1517 # "px": "2381.1",
1518 # "side": "A",
1519 # "startPosition": "0.0841",
1520 # "sz": "0.0841",
1521 # "tid": 128423918764978,
1522 # "time": 1704262888911
1523 # }
1524 # ]
1525 #
1526 return self.parse_trades(response, market, since, limit)
1527

Callers

nothing calls this directly

Calls 8

handle_public_addressMethod · 0.95
marketMethod · 0.95
safe_integerMethod · 0.80
parse_tradesMethod · 0.80
publicPostInfoMethod · 0.65
load_marketsMethod · 0.45
omitMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected