:mod:`golosscripts.feed` ======================== .. py:module:: golosscripts.feed Module Contents --------------- .. data:: log .. data:: bitshares_markets :annotation: = ['RUDEX.GOLOS/GPH', 'RUDEX.GOLOS/RUDEX.BTC', 'RUDEX.GOLOS/RUDEX.USDT'] .. data:: market_data .. py:class:: PriceSource Bases: :class:`enum.Enum` .. attribute:: graphene :annotation: = 1 .. attribute:: kuna :annotation: = 2 .. py:class:: Metric Bases: :class:`enum.Enum` .. attribute:: median :annotation: = 1 .. attribute:: mean :annotation: = 2 .. attribute:: weighted_average :annotation: = 3 .. py: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) Bases: :class:`golosscripts.golos_helper.GolosHelper` This class is used to calculate and update 'sbd_exchange_rate' for witness. :param str,list node: golos node to connect to :param str,list keys: witness active keys :param str witness: witness name to update feed for :param bool dry_run: only do price calculation without sending transaction :param str,list node_gph: graphene node :param list markets: list of bitshares markets to use to obtain price, in format ['QUOTE/BASE'] :param str metric: what metric to use to calculate price :param float depth_pct: how deeply measure market for volume :param float threshold_pct: price change threshold to trigger price feed publish :param int interval: how often calculate new price :param float k: correction coefficient, adjusts price up or down :param int max_age: max age of price feed to trigger force-publish .. method:: calc_weighted_average_price(prices: List[market_data]) :staticmethod: Calculate weighted average price using "volume" key. :param list prices: list of market_data tuples .. method:: is_last_price_too_old(witness_data: Witness, max_age: int) :staticmethod: Check last price update time and return True if older than max_age. :param witness_data: witness object dict, usually :py:class:`golos.witness.Witness` Witness instance :param int max_age: max seconds since last update .. method:: calc_price_gph_golos(self) :async: Calculate price GPH/GOLOS using GOLOS markets on bitshares. .. method:: calc_price_gbg_golos_bitshares(self) :async: Calculate price GBG/GOLOS using GOLOS markets on bitshares. .. method:: calc_price_kuna(self) :async: Calculate price GBG/GOLOS using kuna.io GOL ticker. .. method:: publish_price(self, force: bool = False) :async: Publish price feed once. :param bool force: force-publish price even if update is not needed .. method:: run_forever(self) :async: Run in continuous mode to make price feed updates periodically. Example for python 3.7+: .. code-block:: python feed_updater = FeedUpdater() asyncio.run(feed_updater.run_forever())