Common types#
Asset#
- class pragma_sdk.common.types.asset.Asset[source]#
Bases:
object- __init__(data_type: DataTypes, asset_id: str | int, expiration_timestamp: int | None = None)[source]#
- asset_id: int#
- expiration_timestamp: int | None#
PragmaClient#
- class pragma_sdk.common.types.client.PragmaClient[source]#
Bases:
ABC- abstract async publish_entries(entries: List[Entry]) Tuple[Dict | None, Dict | None] | List[InvokeResult][source]#
Publish entries to some destination.
- Parameters:
entries – List of Entry objects
execution_config – ExecutionConfig object. Only used for on-chain publishing.
- Returns:
Tuple of responses for spot and future entries
Currency#
- class pragma_sdk.common.types.currency.Currency[source]#
Bases:
object- __init__(currency_id: str, decimals: int, is_abstract_currency: bool, starknet_address: int | str | None = None, ethereum_address: int | str | None = None)[source]#
- decimals: int#
- ethereum_address: int#
- classmethod from_asset_config(config: AssetConfig) Self[source]#
- id: str#
- is_abstract_currency: bool#
- starknet_address: int#
Entries#
- class pragma_sdk.common.types.entry.BaseEntry[source]#
Bases:
objectBaseEntry is a dataclass that represents the common fields between SpotEntry and FutureEntry.
- __init__(*args: Any, **kwargs: Any) None#
- publisher: int#
- source: int#
- timestamp: int#
- class pragma_sdk.common.types.entry.Entry[source]#
Bases:
ABCAbstract class that represents an Entry. All entries must implement this class.
- static flatten_entries(entries: List[Entry]) List[int][source]#
This flattens entriees to tuples. Useful when you need the raw felt array
- static from_oracle_response(pair: Pair, oracle_response: OracleResponse, publisher_name: str, source_name: str) Entry | None[source]#
- class pragma_sdk.common.types.entry.FutureEntry[source]#
Bases:
EntryRepresents a Future Entry.
Also used to represent a Perp Entry - the only difference is that a perpetual future has no expiry timestamp.
- __init__(pair_id: str | int, price: int, timestamp: int, source: str | int, publisher: str | int, expiry_timestamp: int | None = None, volume: float | int | None = None)[source]#
- expiry_timestamp: int#
- static from_dict(entry_dict: Any) FutureEntry[source]#
- static from_oracle_response(pair: Pair, oracle_response: OracleResponse, publisher_name: str, source_name: str) FutureEntry | None[source]#
Builds the object from a PragmaAsset and an OracleResponse. Method primarly used by our price pusher package when we’re retrieving lastest oracle prices for comparisons with the latest prices of various APIs (binance etc).
- pair_id: int#
- price: int#
- volume: int#
- class pragma_sdk.common.types.entry.GenericEntry[source]#
Bases:
EntryRepresents a Generic Entry.
Currently used this way: instead of publishing all the future options for all availables instruments from Deribit, we place them in all a Merkle tree & we only publish the merkle root through this Generic entry. So the key will be DERIBIT_OPTIONS_DATA and the value the merkle root containing all the price feeds.
- __init__(key: str | int, value: int, timestamp: int, source: str | int, publisher: str | int)[source]#
- static from_dict(entry_dict: Any) GenericEntry[source]#
- static from_oracle_response(pair: Pair, oracle_response: OracleResponse, publisher_name: str, source_name: str) GenericEntry | None[source]#
Builds the object from a PragmaAsset and an OracleResponse. Method primarly used by our price pusher package when we’re retrieving lastest oracle prices for comparisons with the latest prices of various APIs (binance etc).
- key: int#
- value: int#
- class pragma_sdk.common.types.entry.SpotEntry[source]#
Bases:
EntryRepresents a Spot Entry.
- __init__(pair_id: str | int, price: int, timestamp: int, source: str | int, publisher: str | int, volume: float | int | None = None) None[source]#
- static from_oracle_response(pair: Pair, oracle_response: OracleResponse, publisher_name: str, source_name: str) SpotEntry | None[source]#
Builds a SpotEntry object from a Pair and an OracleResponse. Method primarly used by our price pusher package when we’re retrieving lastest oracle prices for comparisons with the latest prices of various APIs (binance etc).
- pair_id: int#
- price: int#
- volume: int#
Pair#
- class pragma_sdk.common.types.pair.Pair[source]#
Bases:
objectPair class to represent a trading pair.
- Parameters:
id – Corresponds to the felt representation of the pair e.g str_to_felt(“ETH/USD”)
base_currency – Base currency
quote_currency – Quote currency
- decimals() int[source]#
Returns the decimals of the pair. Corresponds to the minimum of both currencies’ decimals.
- classmethod from_asset_configs(base_asset: AssetConfig, quote_asset: AssetConfig) Pair[source]#
Return a Pair from two AssetConfigs. Return None if the base and quote assets are the same.
- Parameters:
base_asset – Base asset
quote_asset – Quote asset
- Returns:
Pair
- static from_tickers(base_ticker: str, quote_ticker: str) Pair[source]#
Return a Pair from two tickers. Return None if the base and quote tickers are the same.
- Parameters:
base_ticker – Base ticker
quote_ticker – Quote ticker
- Returns:
Pair
- id: int#
Misc#
- class pragma_sdk.common.types.types.AggregationMode[source]#
Bases:
StrEnum- AVERAGE = 'Mean'#
- ERROR = 'Error'#
- MEDIAN = 'Median'#