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!
def __init__(self): d = self.deps = DepContainer() d.cfg = Config() log_level = d.cfg.get('log_level', logging.INFO) logging.basicConfig( level=logging.getLevelName(log_level), format= '%(asctime)s.%(msecs)03d %(levelname)s %(module)s - %(funcName)s: %(message)s', datefmt='%Y-%m-%d %H:%M:%S', ) logging.info('-' * 100) logging.info(f"Log level: {log_level}") d.loop = asyncio.get_event_loop() d.db = DB(d.loop)
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
from services.lib.config import Config from services.lib.db import DB from services.lib.depcont import DepContainer async def q_points(d: DepContainer): image = await queue_graph(d, d.loc_man.get_from_lang('rus')) p = os.path.expanduser('~/sns_test.png') with open(p, 'wb') as f: f.write(image.getvalue()) os.system(f'open "{p}"') async def stake_graph(): ... async def test_plots(d): # await q_points(d) await stake_graph() if __name__ == '__main__': d = DepContainer() d.loc_man = LocalizationManager() d.loop = asyncio.get_event_loop() d.cfg = Config() d.db = DB(d.loop) d.loop.run_until_complete(test_plots(d))
import asyncio import json import logging import os import aiohttp from dataclasses_serialization.json import JSONSerializer from services.fetch.jobs import BridgeJobsFetcher from services.lib import datetime from services.lib.config import Config from services.lib.db import DB from services.lib.depcont import DepContainer from services.lib.utils import async_wrap d = DepContainer() d.cfg = Config() log_level = d.cfg.get('log_level', logging.INFO) logging.basicConfig( level=logging.getLevelName(log_level), format='%(asctime)s.%(msecs)03d %(levelname)s %(module)s - %(funcName)s: %(message)s', datefmt='%Y-%m-%d %H:%M:%S', ) logging.info(f"Log level: {log_level}") d.loop = asyncio.get_event_loop() d.db = DB(d.loop) job_fetch = BridgeJobsFetcher(d)
from services.lib.db import DB from services.fetch.node_ip_manager import ThorNodeAddressManager from services.fetch.pool_price import PoolPriceFetcher from services.lib.depcont import DepContainer from services.lib.money import pretty_money from services.models.time_series import TimeSeries from services.models.tx import StakePoolStats from services.notify.broadcast import Broadcaster from services.lib.texts import progressbar import matplotlib.pyplot as plt import seaborn as sns import pandas as pd import numpy as np deps = DepContainer() deps.cfg = Config() log_level = deps.cfg.get('log_level', logging.INFO) logging.basicConfig(level=logging.getLevelName(log_level)) logging.info(f"Log level: {log_level}") deps.loop = asyncio.get_event_loop() deps.db = DB(deps.loop) deps.bot = Bot(token=deps.cfg.telegram.bot.token, parse_mode=ParseMode.HTML) deps.dp = Dispatcher(deps.bot, loop=deps.loop) deps.loc_man = LocalizationManager() deps.broadcaster = Broadcaster(deps)
with open(PICKLE_PATH, 'wb') as f: pickle.dump((stakes, charts), f) # 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',