golosscripts.feed
¶
Module Contents¶
-
class
FeedUpdater
(node: Union[str, List[str]], keys: Union[str, List[str]], witness: str, dry_run: bool = False, source: str = 'graphene', node_gph: Optional[Union[str, List[str]]] = None, markets: Optional[List[str]] = None, metric: str = 'weighted_average', depth_pct: float = 20.0, threshold_pct: float = 10.0, interval: int = 3600, k: float = 1.0, max_age: int = 86400)[source]¶ Bases:
golosscripts.golos_helper.GolosHelper
This class is used to calculate and update ‘sbd_exchange_rate’ for witness.
- Parameters
witness (str) – witness name to update feed for
dry_run (bool) – only do price calculation without sending transaction
markets (list) – list of bitshares markets to use to obtain price, in format [‘QUOTE/BASE’]
metric (str) – what metric to use to calculate price
depth_pct (float) – how deeply measure market for volume
threshold_pct (float) – price change threshold to trigger price feed publish
interval (int) – how often calculate new price
k (float) – correction coefficient, adjusts price up or down
max_age (int) – max age of price feed to trigger force-publish
-
static
calc_weighted_average_price
(prices: List[market_data])[source]¶ Calculate weighted average price using “volume” key.
- Parameters
prices (list) – list of market_data tuples
-
static
is_last_price_too_old
(witness_data: Witness, max_age: int)[source]¶ Check last price update time and return True if older than max_age.
- Parameters
witness_data – witness object dict, usually
golos.witness.Witness
Witness instancemax_age (int) – max seconds since last update
-
async
calc_price_gph_golos
(self)[source]¶ Calculate price GPH/GOLOS using GOLOS markets on bitshares.
Calculate price GBG/GOLOS using GOLOS markets on bitshares.