avantis_trader_sdk.feed package

Submodules

avantis_trader_sdk.feed.feed_client module

class avantis_trader_sdk.feed.feed_client.FeedClient(ws_url='wss://hermes.pyth.network/ws', on_error=None, on_close=None, hermes_url='https://hermes.pyth.network/v2/updates/price/latest')[source]

Bases: object

Client for interacting with the Pyth price feed websocket.

async get_latest_price_updates(identifiers)[source]

Retrieves the latest price updates for the specified feed ids.

Parameters:
  • feedIds – The list of feed ids to retrieve the latest price updates for.

  • identifiers (List[str])

Returns:

A PriceFeedUpdatesResponse object containing the latest price updates.

get_pair_from_feed_id(feed_id)[source]

Retrieves the pair string from the feed id.

Parameters:

feed_id – The feed id to retrieve the pair string for.

Returns:

The pair string.

async listen_for_price_updates()[source]

Listens for price updates from the Pyth price feed websocket. When a price update is received, the registered callbacks will be called with the updated price feed data.

Raises:

Exception – If an error occurs while listening for price updates.

register_price_feed_callback(identifier, callback)[source]

Registers a callback for price feed updates.

Parameters:
  • identifier – The identifier of the price feed to register the callback for.

  • callback – The callback to register.

Raises:

ValueError – If the identifier is unknown.

unregister_price_feed_callback(identifier, callback)[source]

Unregisters a callback for price feed updates.

Parameters:
  • identifier – The identifier of the price feed to unregister the callback for.

  • callback – The callback to unregister.

Module contents