async def main(): async with Api() as api: settings = Settings.load() stock_store = StockStore(api, settings) tty = Tty(settings, stock_store) if settings.refresh: await tty.draw_live() else: await tty.draw()
def setUp(self) -> None: self.api = Api() self.api._query = Mock() self.settings = Settings( positions={ "AAPL": 1, "AMD": 10, "SHOP.TO": 100, "VGRO.TO": 1000, }, watchlist=["AAPL", "AMD", "SHOP.TO", "VGRO.TO"], )
def main(): try: api = Api() settings = Settings() stock_store = StockStore(api, settings) tty = Tty(settings, stock_store) if settings.refresh: tty.draw_live() else: tty.draw() except SystemExit: pass except: if IS_DEBUG: raise else: crash_report()
async def main(): try: async with Api() as api: settings = Settings() stock_store = StockStore(api, settings) await stock_store.update_stocks() tty = Tty(settings, stock_store) if settings.refresh: await tty.draw_live() else: await tty.draw() except SystemExit: pass except: if IS_DEBUG: raise else: crash_report()
def test_get_forex_rates(): forex = Api().get_forex_rates("USD") assert forex.USD == 1
def test_get_quote(): Api().get_quote("AAPL")
from stonky.api import Api import sys api = Api() result = api.get_quote(sys.argv[1]) print(result)