Fixed ccxt (#2666)

* Fixed ccxt

* Tells you when a bad source is sent

Co-authored-by: hjoaquim <h.joaquim@campus.fct.unl.pt>
This commit is contained in:
Colin Delahunty
2022-09-30 12:34:56 +02:00
committed by GitHub
parent 7f9f753b39
commit eb82d95054
2 changed files with 8 additions and 3 deletions

View File

@@ -310,8 +310,8 @@ def load(
exchange: str = "binance",
vs_currency: str = "usdt",
end_date: datetime = datetime.now(),
source: str = "ccxt",
):
source: str = "CCXT",
) -> pd.DataFrame:
"""Load crypto currency to perform analysis on CoinGecko is used as source for price and
YahooFinance for volume.
@@ -330,7 +330,7 @@ def load(
Dataframe consisting of price and volume data
"""
df = pd.DataFrame()
if source == "ccxt":
if source == "CCXT":
pair = f"{symbol.upper()}/{vs_currency.upper()}"
try:
df = fetch_ccxt_ohlc(
@@ -410,6 +410,8 @@ def load(
console.print(f"\nPair {pair} not found in Yahoo Finance\n")
return pd.DataFrame()
df.index.name = "date"
else:
console.print("[red]Invalid source sent[/red]\n")
return df

View File

@@ -262,6 +262,9 @@ def load(
df_stock_candidate = load_stock_polygon(
symbol, start_date, end_date, weekly, monthly
)
else:
console.print("[red]Invalid source for stock[/red]\n")
return
if df_stock_candidate.empty:
return df_stock_candidate