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

Method fetch_ticker

python/ccxt/phemex.py:1516–1585  ·  view source on GitHub ↗

fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#query24hrsticker :param str symbol: unified symbol of the mar

(self, symbol: str, params={})

Source from the content-addressed store, hash-verified

1514 }, market)
1515
1516 def fetch_ticker(self, symbol: str, params={}) -> Ticker:
1517 """
1518 fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
1519
1520 https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#query24hrsticker
1521
1522 :param str symbol: unified symbol of the market to fetch the ticker for
1523 :param dict [params]: extra parameters specific to the exchange API endpoint
1524 :returns dict: a `ticker structure <https://docs.ccxt.com/?id=ticker-structure>`
1525 """
1526 self.load_markets()
1527 market = self.market(symbol)
1528 request = {
1529 'symbol': market['id'],
1530 # 'id': 123456789, # optional request id
1531 }
1532 response: dict
1533 if market['swap']:
1534 if market['inverse'] or market['settle'] == 'USD':
1535 response = self.v1GetMdTicker24hr(self.extend(request, params))
1536 else:
1537 response = self.v2GetMdV2Ticker24hr(self.extend(request, params))
1538 else:
1539 response = self.v1GetMdSpotTicker24hr(self.extend(request, params))
1540 #
1541 # spot
1542 #
1543 # {
1544 # "error": null,
1545 # "id": 0,
1546 # "result": {
1547 # "askEp": 943836000000,
1548 # "bidEp": 943601000000,
1549 # "highEp": 955946000000,
1550 # "lastEp": 943803000000,
1551 # "lowEp": 924973000000,
1552 # "openEp": 948693000000,
1553 # "symbol": "sBTCUSDT",
1554 # "timestamp": 1592471203505728630,
1555 # "turnoverEv": 111822826123103,
1556 # "volumeEv": 11880532281
1557 # }
1558 # }
1559 #
1560 # swap
1561 #
1562 # {
1563 # "error": null,
1564 # "id": 0,
1565 # "result": {
1566 # "askEp": 2332500,
1567 # "bidEp": 2331000,
1568 # "fundingRateEr": 10000,
1569 # "highEp": 2380000,
1570 # "indexEp": 2329057,
1571 # "lastEp": 2331500,
1572 # "lowEp": 2274000,
1573 # "markEp": 2329232,

Callers

nothing calls this directly

Calls 8

parse_tickerMethod · 0.95
safe_dictMethod · 0.80
v1GetMdTicker24hrMethod · 0.65
v2GetMdV2Ticker24hrMethod · 0.65
v1GetMdSpotTicker24hrMethod · 0.65
load_marketsMethod · 0.45
marketMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected