Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sdk dates #3354

Merged
merged 120 commits into from
Nov 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
a81448e
example changes in slopes
montezdesousa Oct 27, 2022
ccb2129
change lettering size and side bar capitalization
montezdesousa Oct 27, 2022
1f25632
revert back to Fira
montezdesousa Oct 27, 2022
fe76e38
start automatic website generation
montezdesousa Oct 28, 2022
f8d70f3
this was autogen
montezdesousa Oct 28, 2022
4cfe250
add examples to slopes model
montezdesousa Oct 28, 2022
f5f681a
generate slopes doc
montezdesousa Oct 28, 2022
9764dcb
change to _index.md
montezdesousa Oct 28, 2022
1d34948
allow italic formatting
montezdesousa Oct 28, 2022
87a14d6
fix regex
montezdesousa Oct 28, 2022
07c9fe8
option to regenerate paths
montezdesousa Oct 28, 2022
5d1e96a
update alt docs
montezdesousa Oct 28, 2022
976baed
fix generate
montezdesousa Oct 28, 2022
fe3e3ce
update alt
montezdesousa Oct 28, 2022
04e110a
fix generate
montezdesousa Oct 28, 2022
43f874a
update common
montezdesousa Oct 28, 2022
e0cf405
target italic only for types
montezdesousa Oct 30, 2022
a19c096
format alt
montezdesousa Oct 30, 2022
7d71fad
format italic common
montezdesousa Oct 30, 2022
d1c529f
add sig indentation
montezdesousa Oct 30, 2022
3f99fe3
update sig indent alt
montezdesousa Oct 30, 2022
c970d95
update common ident
montezdesousa Oct 30, 2022
1083a8a
add todo
montezdesousa Oct 30, 2022
970294d
generate docstrings for all menus
montezdesousa Oct 30, 2022
98fe782
fix maxdd
montezdesousa Oct 30, 2022
643c6c4
fix returns font size
montezdesousa Oct 30, 2022
3a33505
fix keys docs
montezdesousa Oct 30, 2022
d43942f
fix more docstrings
montezdesousa Oct 30, 2022
3bbaa45
escape literal symbols
montezdesousa Oct 30, 2022
72f8697
escape literal symbols
montezdesousa Oct 30, 2022
1a73345
reformat keys
montezdesousa Oct 30, 2022
30e716a
format opt
montezdesousa Oct 31, 2022
0ab31bc
remove literal escape
montezdesousa Oct 31, 2022
7938f6e
remove another literal escape
montezdesousa Oct 31, 2022
adcaa76
remove another literal escape
montezdesousa Oct 31, 2022
58375f6
Merge branch 'main' into sdk_doc
JerBouma Oct 31, 2022
c4419b4
unindent returns
montezdesousa Nov 1, 2022
03de87b
update docs return unindent
montezdesousa Nov 1, 2022
5962459
Merge branch 'sdk_doc' of github.com:OpenBB-finance/OpenBBTerminal in…
montezdesousa Nov 1, 2022
29862e5
add comma in last arg
montezdesousa Nov 1, 2022
fac1d4a
fix funcs without params
montezdesousa Nov 1, 2022
7658509
fix signature
montezdesousa Nov 2, 2022
fb3e49c
compact some code
montezdesousa Nov 2, 2022
634bbb5
refactor some more code
montezdesousa Nov 2, 2022
e1e59ff
refactor some code
montezdesousa Nov 2, 2022
d23723a
some final cleanup
montezdesousa Nov 2, 2022
b38d52f
write docstrings
montezdesousa Nov 2, 2022
55f293a
change main
montezdesousa Nov 2, 2022
4fb9e17
move futures paths
montezdesousa Nov 2, 2022
a5a2a03
generate futures docs
montezdesousa Nov 2, 2022
e682d45
add external axes references
montezdesousa Nov 2, 2022
154e148
fix typo
montezdesousa Nov 2, 2022
357a86b
revert to double docstring
montezdesousa Nov 2, 2022
73f3315
fix small bug
montezdesousa Nov 3, 2022
2d5a96d
remove docs folder
montezdesousa Nov 6, 2022
8827007
generate.py in website folder
montezdesousa Nov 6, 2022
ef42d96
add forecast to docs
montezdesousa Nov 6, 2022
52676b4
clear some warnings
montezdesousa Nov 6, 2022
5d4c61a
fix underscore
montezdesousa Nov 7, 2022
e0fced9
remove cite
montezdesousa Nov 7, 2022
22574a2
Merge branch 'main' into sdk_doc
montezdesousa Nov 7, 2022
9c7b720
refresh website docs
montezdesousa Nov 7, 2022
4072526
fix forecast docstrings
montezdesousa Nov 7, 2022
76cf3c7
fix po
montezdesousa Nov 7, 2022
372448c
fix po docs and remove italic
montezdesousa Nov 7, 2022
751101f
fix more docstrings
montezdesousa Nov 7, 2022
1f528cf
remove last warning
montezdesousa Nov 7, 2022
a74d1c3
Merge branch 'main' into sdk_doc
montezdesousa Nov 7, 2022
3d7f48b
codespell
montezdesousa Nov 7, 2022
1264b9d
Merge branch 'sdk_doc' of github.com:OpenBB-finance/OpenBBTerminal in…
montezdesousa Nov 7, 2022
91a6be7
flake8
montezdesousa Nov 7, 2022
1307418
exclude website contente from flake
montezdesousa Nov 7, 2022
469f0d1
noqa on optimizer
montezdesousa Nov 7, 2022
92311ff
update website
montezdesousa Nov 8, 2022
dc6f104
fix mypy
montezdesousa Nov 8, 2022
b6c0113
remove setup from mypy
montezdesousa Nov 8, 2022
39c13c0
Merge branch 'main' into sdk_doc
montezdesousa Nov 8, 2022
1f16f3e
mypy to openbbterminal
montezdesousa Nov 8, 2022
7c8fbc8
update precommit
montezdesousa Nov 8, 2022
1d213ba
Merge branch 'sdk_doc' of github.com:OpenBB-finance/OpenBBTerminal in…
montezdesousa Nov 8, 2022
1a61540
pylint
montezdesousa Nov 8, 2022
ca05e8f
Merge branch 'main' into sdk_doc
montezdesousa Nov 8, 2022
04071ab
Merge branch 'main' into sdk_doc
montezdesousa Nov 8, 2022
4528aa8
Merge branch 'main' into sdk_doc
montezdesousa Nov 9, 2022
333682c
try to remove sdk loading issue
montezdesousa Nov 9, 2022
b8fa491
Merge branch 'main' into sdk_dates
montezdesousa Nov 9, 2022
8088c9c
fix dates active command
montezdesousa Nov 9, 2022
504bfc6
fix crypto.change formats
montezdesousa Nov 9, 2022
72c9f74
fix eb formats
montezdesousa Nov 9, 2022
7367aa4
Merge branch 'main' into sdk_dates
montezdesousa Nov 9, 2022
e68bef0
nonzero fix
montezdesousa Nov 9, 2022
af75976
Merge branch 'sdk_dates' of github.com:OpenBB-finance/OpenBBTerminal …
montezdesousa Nov 9, 2022
30050d6
Merge branch 'main' into sdk_dates
montezdesousa Nov 10, 2022
dacefcd
format dates crypto.load
montezdesousa Nov 10, 2022
3322654
Merge branch 'sdk_dates' of github.com:OpenBB-finance/OpenBBTerminal …
montezdesousa Nov 10, 2022
f5fefc3
Merge branch 'main' into sdk_dates
montezdesousa Nov 10, 2022
f28739d
format supply transac
montezdesousa Nov 10, 2022
5c855af
Merge branch 'sdk_dates' of github.com:OpenBB-finance/OpenBBTerminal …
montezdesousa Nov 10, 2022
05fcd41
format hr altindex
montezdesousa Nov 10, 2022
c134b92
format load crypto
montezdesousa Nov 10, 2022
7263855
regenerate docs
montezdesousa Nov 10, 2022
f1bf526
format ba trend dates
montezdesousa Nov 10, 2022
5fdcaef
regenerate docs
montezdesousa Nov 10, 2022
0c6525e
format ba trend
montezdesousa Nov 10, 2022
18ff6cf
candle defaults
montezdesousa Nov 10, 2022
c5265e2
fix sentiment test
montezdesousa Nov 10, 2022
062c61a
Merge branch 'main' into sdk_dates
montezdesousa Nov 10, 2022
753dcf9
remove unused import
montezdesousa Nov 10, 2022
afd8f1f
Merge branch 'sdk_dates' of github.com:OpenBB-finance/OpenBBTerminal …
montezdesousa Nov 10, 2022
9e0ffad
shopt
montezdesousa Nov 10, 2022
6370cbf
shopt again
montezdesousa Nov 10, 2022
3487992
revert crypto helpers
montezdesousa Nov 10, 2022
4339d16
test shopt
montezdesousa Nov 10, 2022
7dfe438
fix some tests
montezdesousa Nov 10, 2022
aeec18d
skip trending test
montezdesousa Nov 10, 2022
34a6e95
fix alcoin test
montezdesousa Nov 10, 2022
8b6b8c2
helpers
montezdesousa Nov 10, 2022
5ce4b2a
write docs
montezdesousa Nov 10, 2022
ad0bc46
rewrite helper
montezdesousa Nov 10, 2022
dc7b29d
Merge branch 'main' into sdk_dates
montezdesousa Nov 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ def check_supported_ticker(symbol: str) -> bool:

@check_api_key(["API_SENTIMENTINVESTOR_TOKEN"])
def get_trending(
start_date: datetime = datetime.today(), hour: int = 0, number: int = 10
start_date: str = datetime.today().strftime("%Y-%m-%d"),
hour: int = 0,
number: int = 10,
) -> pd.DataFrame:
"""Get sentiment data on the most talked about tickers
within the last hour
Expand All @@ -137,8 +139,8 @@ def get_trending(

Parameters
----------
start_date: datetime
Datetime object (e.g. datetime(2021, 12, 21)
start_date : str
Initial date, format YYYY-MM-DD
hour: int
Hour of the day in 24-hour notation (e.g. 14)
number : int
Expand All @@ -152,7 +154,7 @@ def get_trending(
"""

# type is datetime
start_timestamp = start_date + timedelta(hours=hour)
start_timestamp = datetime.strptime(start_date, "%Y-%m-%d") + timedelta(hours=hour)

payload: Dict[str, Union[int, str]] = {
"token": cfg.API_SENTIMENTINVESTOR_TOKEN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def display_historical(
@log_start_end(log=logger)
@check_api_key(["API_SENTIMENTINVESTOR_TOKEN"])
def display_trending(
start_date: datetime = datetime.today(),
start_date: str = datetime.today().strftime("%Y-%m-%d"),
hour: int = 0,
number: int = 10,
limit: int = 10,
Expand All @@ -157,8 +157,8 @@ def display_trending(

Parameters
----------
start_date: datetime
Datetime object (e.g. datetime(2021, 12, 21)
start_date : str
Initial date, format YYYY-MM-DD
hour: int
Hour of the day in 24-hour notation (e.g. 14)
number : int
Expand All @@ -171,10 +171,6 @@ def display_trending(
Format to export data
"""

# Force datetime format to be datetime(year, month, day, 0, 0)
# 0 hours and minutes to look since day starts
start_date = datetime(start_date.year, start_date.month, start_date.day)

df = sentimentinvestor_model.get_trending(start_date, hour, number)

if df.empty:
Expand Down
56 changes: 50 additions & 6 deletions openbb_terminal/cryptocurrency/cryptocurrency_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,40 @@
]


def check_datetime(
ck_date: datetime | 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
Date to check, by default None
start : bool, optional
If True and string is invalid, will return 1100 days ago
If False and string is invalid, will return today, by default True

Returns
-------
datetime
Datetime object
"""
error_catch = (datetime.now() - timedelta(days=1100)) if start else datetime.now()
try:
if ck_date is None:
return error_catch
if isinstance(ck_date, datetime):
return ck_date
if isinstance(ck_date, str):
return datetime.strptime(ck_date, "%Y-%m-%d")
except Exception:
console.print(
f"Invalid date format (YYYY-MM-DD), "
f"Using {error_catch.strftime('%Y-%m-%d')} for {ck_date}"
)
return error_catch


def _load_coin_map(file_name: str) -> pd.DataFrame:
if file_name.split(".")[1] != "json":
raise TypeError("Please load json file")
Expand Down Expand Up @@ -472,11 +506,11 @@ def load_from_yahoofinance(

def load(
symbol: str,
start_date: datetime = (datetime.now() - timedelta(days=1100)),
start_date: datetime | str | None = None,
interval: str = "1440",
exchange: str = "binance",
vs_currency: str = "usdt",
end_date: datetime = datetime.now(),
end_date: datetime | str | None = None,
source: str = "CCXT",
) -> pd.DataFrame:
"""Load crypto currency to get data for
Expand All @@ -485,17 +519,17 @@ def load(
----------
symbol: str
Coin to get
start_date: datetime
The datetime to start at
start_date: str or datetime, optional
Start date to get data from with. - datetime or string format (YYYY-MM-DD)
interval: str
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: datetime
The datetime to end at
end_date: str or datetime, optional
End date to get data from with. - datetime or string format (YYYY-MM-DD)
source: str
The source of the data
Choose from: CCXT, CoinGecko, YahooFinance
Expand All @@ -505,6 +539,16 @@ def load(
pd.DataFrame
Dataframe consisting of price and volume data
"""

if start_date is None:
start_date = (datetime.now() - timedelta(days=1100)).strftime("%Y-%m-%d")

if end_date is None:
end_date = datetime.now().strftime("%Y-%m-%d")

start_date = check_datetime(start_date)
end_date = check_datetime(end_date, start=False)

if source == "CCXT":
return load_from_ccxt(symbol, start_date, interval, exchange, vs_currency)
if source == "CoinGecko":
Expand Down
20 changes: 12 additions & 8 deletions openbb_terminal/cryptocurrency/due_diligence/dd_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,11 @@ def call_nonzero(self, other_args: List[str]):
)

if ns_parser:

glassnode_view.display_non_zero_addresses(
symbol=self.symbol.upper(),
start_date=int(datetime.timestamp(ns_parser.since)),
end_date=int(datetime.timestamp(ns_parser.until)),
start_date=ns_parser.since.strftime("%Y-%m-%d"),
end_date=ns_parser.until.strftime("%Y-%m-%d"),
export=ns_parser.export,
)

Expand Down Expand Up @@ -429,11 +430,12 @@ def call_active(self, other_args: List[str]):
)

if ns_parser:

glassnode_view.display_active_addresses(
symbol=self.symbol.upper(),
interval=ns_parser.interval,
start_date=int(datetime.timestamp(ns_parser.since)),
end_date=int(datetime.timestamp(ns_parser.until)),
start_date=ns_parser.since.strftime("%Y-%m-%d"),
end_date=ns_parser.until.strftime("%Y-%m-%d"),
export=ns_parser.export,
)

Expand Down Expand Up @@ -493,11 +495,12 @@ def call_change(self, other_args: List[str]):
)

if ns_parser:

glassnode_view.display_exchange_net_position_change(
symbol=self.symbol.upper(),
exchange=ns_parser.exchange,
start_date=int(datetime.timestamp(ns_parser.since)),
end_date=int(datetime.timestamp(ns_parser.until)),
start_date=ns_parser.since.strftime("%Y-%m-%d"),
end_date=ns_parser.until.strftime("%Y-%m-%d"),
export=ns_parser.export,
)
else:
Expand Down Expand Up @@ -564,11 +567,12 @@ def call_eb(self, other_args: List[str]):
)

if ns_parser:

glassnode_view.display_exchange_balances(
symbol=self.symbol.upper(),
exchange=ns_parser.exchange,
start_date=int(datetime.timestamp(ns_parser.since)),
end_date=int(datetime.timestamp(ns_parser.until)),
start_date=ns_parser.since.strftime("%Y-%m-%d"),
end_date=ns_parser.until.strftime("%Y-%m-%d"),
percentage=ns_parser.percentage,
export=ns_parser.export,
)
Expand Down
Loading