From b973d25f0ad2c57325e4d71924fd7ae7b1cf4d46 Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Fri, 4 Mar 2022 01:12:08 +0800 Subject: [PATCH 1/2] change twap/twac to emap/emac (#23) --- pythclient/pythaccounts.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/pythclient/pythaccounts.py b/pythclient/pythaccounts.py index 2adaba4..34b4944 100644 --- a/pythclient/pythaccounts.py +++ b/pythclient/pythaccounts.py @@ -37,20 +37,17 @@ class PythPriceStatus(Enum): class PythPriceType(Enum): UNKNOWN = 0 PRICE = 1 - # TWAP/VOL removed after V2 - TWAP = 2 - VOLATILITY = 3 -# Join time-weighted exponential moving average for TWAP and TWAC -class TwEmaType(Enum): +# Join exponential moving average for EMA price and EMA confidence +class EmaType(Enum): UNKNOWN = 0 - TWAPVALUE = 1 - TWAPNUMERATOR = 2 - TWAPDENOMINATOR = 3 - TWACVALUE = 4 - TWACNUMERATOR = 5 - TWACDENOMINATOR = 6 + EMA_PRICE_VALUE = 1 + EMA_PRICE_NUMERATOR = 2 + EMA_PRICE_DENOMINATOR = 3 + EMA_CONFIDENCE_VALUE = 4 + EMA_CONFIDENCE_NUMERATOR = 5 + EMA_CONFIDENCE_DENOMINATOR = 6 def _check_base64(format: str): @@ -489,7 +486,7 @@ def __init__(self, key: SolanaPublicKey, solana: SolanaClient, *, product: Optio self.next_price_account_key: Optional[SolanaPublicKey] = None self.aggregate_price_info: Optional[PythPriceInfo] = None self.price_components: List[PythPriceComponent] = [] - self.derivations: Dict[TwEmaType, int] = {} + self.derivations: Dict[EmaType, int] = {} self.min_publishers: Optional[int] = None @property @@ -557,7 +554,7 @@ def update_from(self, buffer: bytes, *, version: int, offset: int = 0) -> None: last_slot, valid_slot = struct.unpack_from(" Date: Thu, 17 Mar 2022 11:12:15 +0200 Subject: [PATCH 2/2] Update to sync with fork. --- pythclient/pythaccounts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pythclient/pythaccounts.py b/pythclient/pythaccounts.py index 08a4f51..1c9145e 100644 --- a/pythclient/pythaccounts.py +++ b/pythclient/pythaccounts.py @@ -651,7 +651,7 @@ def to_json(self): "next_price_account_key": str(self.next_price_account_key), "aggregate_price_info": self.aggregate_price_info.to_json(), "price_components": [x.to_json() for x in self.price_components], - "derivations": {TwEmaType(x).name: self.derivations.get(x) for x in list(self.derivations.keys())}, + "derivations": {EmaType(x).name: self.derivations.get(x) for x in list(self.derivations.keys())}, "min_publishers": self.min_publishers, "aggregate_price": self.aggregate_price, "aggregate_price_confidence_interval": self.aggregate_price_confidence_interval