mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-29 05:21:48 +00:00
* added dependency * added pyth models * dependencies * docs * some improvements to this pyth command (#2433) * some improvements to this pyth command * minor improv * dependencies * tests Co-authored-by: DidierRLopes <dro.lopes@campus.fct.unl.pt>; COlin
32 lines
973 B
Python
32 lines
973 B
Python
# pylint: disable= C0301
|
|
|
|
import asyncio
|
|
import logging
|
|
|
|
from openbb_terminal.cryptocurrency.pyth_model import get_price
|
|
from openbb_terminal.decorators import log_start_end
|
|
from openbb_terminal.rich_config import console
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@log_start_end(log=logger)
|
|
def display_price(symbol: str) -> None:
|
|
"""Displays live price from pyth live feed [Source: https://pyth.network/]
|
|
|
|
Parameters
|
|
----------
|
|
symbol : str
|
|
Symbol of the asset to get price for
|
|
"""
|
|
try:
|
|
while True:
|
|
price, confidence, previous_price = asyncio.run(get_price(symbol))
|
|
console.print(
|
|
f"{symbol} = {'[red]' if previous_price >= price else '[green]'}"
|
|
f"{price}{'[/red]' if previous_price >= price else '[/green]'} ± {confidence}",
|
|
end="\r",
|
|
)
|
|
except KeyboardInterrupt:
|
|
print(f"\n\nStopped watching {symbol} price and confidence interval\n")
|