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

Method fetch_trades

python/ccxt/hyperliquid.py:1469–1525  ·  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

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

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