async def foo13(): async with aiohttp.ClientSession() as deps.session: deps.thor_man = ThorNodeAddressManager(deps.cfg.thornode.seed, deps.session) ppf = PoolPriceFetcher(deps) data = await ppf.get_current_pool_data_full() print(data)
async def send_to_channel_test_message(d: DepContainer): d.broadcaster = Broadcaster(d) async with aiohttp.ClientSession() as d.session: d.thor_man = ThorNodeAddressManager(d.cfg.thornode.seed, d.session) lph = LastPriceHolder() ppf = PoolPriceFetcher(d) notifier_pool_churn = PoolChurnNotifier(d) await ppf.get_current_pool_data_full() # feed original pools await notifier_pool_churn.on_data(ppf, None) lph.pool_info_map = deepcopy(lph.pool_info_map) # make a copy del lph.pool_info_map['BNB.AERGO-46B'] # deleted pool del lph.pool_info_map['BNB.BEAR-14C'] # deleted pool lph.pool_info_map['BNB.FSN-E14'].status = PoolInfo.ENABLED lph.pool_info_map['BNB.RAVEN-F66'].status = PoolInfo.BOOTSTRAP lph.pool_info_map['BTC.BTC'] = PoolInfo('BTC.BTC', 18555, 18555, 100, 18555 * 100, PoolInfo.BOOTSTRAP) await notifier_pool_churn.on_data( ppf, None) # must notify about changes above ^^^ await notifier_pool_churn.on_data(ppf, None) # no update at this moment!
async def create_thor_node_connector(self): d = self.deps cfg = d.cfg.thornode d.thor_man = ThorNodeAddressManager(cfg.seed) d.thor_man.session = d.session d.thor_nodes = ThorNode(d.thor_man, d.session, cohort_size=cfg.consensus.cohort, consensus=cfg.consensus.agree) await d.thor_man.reload_nodes_ip()
async def load_one_pool_liquidity(d: DepContainer, addr, pool=BTCB_SYMBOL): async with aiohttp.ClientSession() as d.session: await d.db.get_redis() lpf = LiqPoolFetcher(d) ppf = PoolPriceFetcher(d) d.thor_man = ThorNodeAddressManager(d.cfg.thornode.seed, d.session) await ppf.get_current_pool_data_full() cur_liqs = await lpf.fetch_all_pool_liquidity_info(addr) cur_liq: CurrentLiquidity = cur_liqs[pool] stake_report = await lpf.fetch_stake_report_for_pool(cur_liq, ppf) # -------- print out ---------- print(f'cur_liq = {cur_liq}') print() redeem_rune, redeem_asset = stake_report.redeemable_rune_asset print(f'redeem_rune = {redeem_rune} and redeem_asset = {redeem_asset}') print() USD, ASSET, RUNE = stake_report.USD, stake_report.ASSET, stake_report.RUNE print(f'current_value(USD) = {stake_report.current_value(USD)}') print(f'current_value(ASSET) = {stake_report.current_value(ASSET)}') print(f'current_value(RUNE) = {stake_report.current_value(RUNE)}') print() gl_usd, gl_usd_p = stake_report.gain_loss(USD) gl_ass, gl_ass_p = stake_report.gain_loss(ASSET) gl_rune, gl_rune_p = stake_report.gain_loss(RUNE) print(f'gain/loss(USD) = {gl_usd}, {gl_usd_p:.1f} %') print(f'gain/loss(ASSET) = {gl_ass}, {gl_ass_p:.1f} %') print(f'gain/loss(RUNE) = {gl_rune}, {gl_rune_p:.1f} %') print() lp_abs, lp_per = stake_report.lp_vs_hold apy = stake_report.lp_vs_hold_apy print(f'stake_report.lp_vs_hold = {lp_abs}, {lp_per:.1f} %') print(f'stake_report.lp_vs_hold_apy = {apy}') return stake_report
async def main(): async with aiohttp.ClientSession() as session: thor_man = ThorNodeAddressManager( 'https://chaosnet-seed.thorchain.info/', session) node = await thor_man.select_node() print(node)
# stakes = await load_summary_for_address(d, addr) # direct load img = await lp_address_summary_picture(stakes, charts, RussianLocalization(), value_hidden=hide) img.save(PICTURE_PATH, "PNG") os.system(f'open "{PICTURE_PATH}"') if __name__ == '__main__': logging.basicConfig(level=logging.INFO) d = DepContainer() d.loop = asyncio.get_event_loop() d.cfg = Config() d.loc_man = LocalizationManager() d.thor_man = ThorNodeAddressManager(d.cfg.thornode.seed) d.db = DB(d.loop) # d.loop.run_until_complete( # test_one_pool_picture_generator(d, # 'bnb1rv89nkw2x5ksvhf6jtqwqpke4qhh7jmudpvqmj', # pool=BTCB_SYMBOL, # hide=True)) d.loop.run_until_complete( test_summary_picture_generator( d, 'bnb157zacwqaplw5kdwpkrve6n2jdxu3ps9cj3xdcp', hide=False)) # bnb1rv89nkw2x5ksvhf6jtqwqpke4qhh7jmudpvqmj