summaryrefslogtreecommitdiffstats
path: root/openbb_terminal/cryptocurrency/cryptocurrency_helpers.py
diff options
context:
space:
mode:
Diffstat (limited to 'openbb_terminal/cryptocurrency/cryptocurrency_helpers.py')
-rw-r--r--openbb_terminal/cryptocurrency/cryptocurrency_helpers.py61
1 files changed, 30 insertions, 31 deletions
diff --git a/openbb_terminal/cryptocurrency/cryptocurrency_helpers.py b/openbb_terminal/cryptocurrency/cryptocurrency_helpers.py
index 3b00fc6e796..8c86ab45ed9 100644
--- a/openbb_terminal/cryptocurrency/cryptocurrency_helpers.py
+++ b/openbb_terminal/cryptocurrency/cryptocurrency_helpers.py
@@ -1,40 +1,39 @@
"""Cryptocurrency helpers"""
# pylint: disable=too-many-lines,too-many-return-statements
-from __future__ import annotations
-
-import os
-import json
-from datetime import datetime, timedelta
import difflib
+import json
import logging
+import os
+from datetime import datetime, timedelta
+from typing import Union
-import pandas as pd
-import numpy as np
import ccxt
import matplotlib.pyplot as plt
-from matplotlib.ticker import LogLocator, ScalarFormatter
-import yfinance as yf
import mplfinance as mpf
+import numpy as np
+import pandas as pd
+import yfinance as yf
+from matplotlib.ticker import LogLocator, ScalarFormatter
from pycoingecko import CoinGeckoAPI
-from openbb_terminal.helper_funcs import (
- lambda_long_number_format,
- plot_autoscale,
- export_data,
- print_rich_table,
- lambda_long_number_format_y_axis,
- is_valid_axes_count,
-)
from openbb_terminal.config_plot import PLOT_DPI
from openbb_terminal.config_terminal import theme
-from openbb_terminal.rich_config import console
-from openbb_terminal.cryptocurrency.due_diligence import coinpaprika_model
from openbb_terminal.cryptocurrency.discovery import pycoingecko_model
+from openbb_terminal.cryptocurrency.due_diligence import coinpaprika_model
from openbb_terminal.cryptocurrency.due_diligence.pycoingecko_model import (
- get_ohlc,
get_coin_tokenomics,
+ get_ohlc,
)
+from openbb_terminal.helper_funcs import (
+ export_data,
+ is_valid_axes_count,
+ lambda_long_number_format,
+ lambda_long_number_format_y_axis,
+ plot_autoscale,
+ print_rich_table,
+)
+from openbb_terminal.rich_config import console
logger = logging.getLogger(__name__)
@@ -115,13 +114,13 @@ YF_CURRENCY = [
def check_datetime(
- ck_date: datetime | str | None = None, start: bool = True
+ ck_date: Union[datetime, Union[str, None]] = None, start: bool = True
) -> datetime:
"""Checks if given argument is string and attempts to convert to datetime.
Parameters
----------
- ck_date : Optional[Union[datetime, str]], optional
+ ck_date : Union[datetime, Union[str, None]], optional
Date to check, by default None
start : bool, optional
If True and string is invalid, will return 1100 days ago
@@ -488,11 +487,11 @@ def load_from_yahoofinance(
def load(
symbol: str,
- start_date: datetime | str | None = None,
- interval: str | int = "1440",
+ start_date: Union[datetime, Union[str, None]] = None,
+ interval: Union[str, int] = "1440",
exchange: str = "binance",
vs_currency: str = "usdt",
- end_date: datetime | str | None = None,
+ end_date: Union[datetime, Union[str, None]] = None,
source: str = "CCXT",
) -> pd.DataFrame:
"""Load crypto currency to get data for
@@ -501,16 +500,16 @@ def load(
----------
symbol: str
Coin to get
- start_date: str or datetime, optional
+ start_date: Union[datetime, Union[str, None]], optional
Start date to get data from with. - datetime or string format (YYYY-MM-DD)
- interval: str|int
+ interval: Union[str, int]
The interval between data points in minutes.
Choose from: 1, 15, 30, 60, 240, 1440, 10080, 43200
exchange: str:
The exchange to get data from.
vs_currency: str
Quote Currency (Defaults to usdt)
- end_date: str or datetime, optional
+ end_date: Union[datetime, Union[str, None]], optional
End date to get data from with. - datetime or string format (YYYY-MM-DD)
source: str
The source of the data
@@ -752,7 +751,7 @@ def plot_chart(
source: str = "",
exchange: str = "",
interval: str = "",
- external_axes: list[plt.Axes] | None = None,
+ external_axes: Union[list[plt.Axes], None] = None,
yscale: str = "linear",
) -> None:
"""Load data for Technical Analysis
@@ -802,7 +801,7 @@ def plot_candles(
volume: bool = True,
ylabel: str = "",
title: str = "",
- external_axes: list[plt.Axes] | None = None,
+ external_axes: Union[list[plt.Axes], None] = None,
yscale: str = "linear",
) -> None:
"""Plot candle chart from dataframe. [Source: Binance]
@@ -882,7 +881,7 @@ def plot_order_book(
bids: np.ndarray,
asks: np.ndarray,
coin: str,
- external_axes: list[plt.Axes] | None = None,
+ external_axes: Union[list[plt.Axes], None] = None,
) -> None:
"""
Plots Bid/Ask. Can be used for Coinbase and Binance