Files
OpenBB/openbb_terminal/cryptocurrency/overview/cryptopanic_view.py
jose-donato 40cfe8148d Interactive tables using react (#4386)
* feat: experimenting tables with react

* feat: adding new interactive tables

* feat: adding more table features

* small changes

* update

* Update backend.py

* Update backend.py

* fix: dark mode?

* feat: lot of table improvements

* fix: my b

* fix: load only when prod

* feat: naive detect links and dates

* handle index and column names

* increased min width

* codespell

* mypy, pylint

* fix: added new chart, export, etc

* testing

* updates

* fix : add PLOT_OPEN_EXPORT,  USE_INTERACTIVE_DF to user dataclass

* bump pywry version, readd removed `plots_backend().start()`

* req files

* Update unit-test.yml

* Update unit-test.yml

* Update unit-test.yml

* updates

* fixing some date things

* update table

* fix formatting with timezones

* fixing some long prints and tables

* Mickey Mouse

Co-authored-by: teh_coderer <tehcoderer@users.noreply.github.com>
Co-authored-by: jose-donato <jose-donato@users.noreply.github.com>

* fix: ?!?!?

* adding limit arg to all print_rich_table

* tests

* lint

* simple by Default on interactive charts

* playing with some css (thks jose)

* Fix #4426

* Edit some structure

* fix sdk generation

* Update backend.py

* fa menu tested and working

* fix #4460

* fix #4460 drop indices

* update tests

* update tests

* Update helper_funcs.py

* tests

* Update unit-test.yml

* Update etf.ipynb

---------

Co-authored-by: teh_coderer <me@tehcoderer.com>
Co-authored-by: andrewkenreich <andrew.kenreich@gmail.com>
Co-authored-by: teh_coderer <tehcoderer@users.noreply.github.com>
Co-authored-by: jose-donato <jose-donato@users.noreply.github.com>
Co-authored-by: James Maslek <jmaslek11@gmail.com>
2023-03-13 17:50:48 +00:00

84 lines
2.2 KiB
Python

"""Cryptopanic view"""
__docformat__ = "numpy"
import logging
import os
from typing import Optional
from openbb_terminal.cryptocurrency.overview import cryptopanic_model
from openbb_terminal.decorators import check_api_key, log_start_end
from openbb_terminal.helper_funcs import export_data, print_rich_table
logger = logging.getLogger(__name__)
# pylint: disable=too-many-arguments
@log_start_end(log=logger)
@check_api_key(["API_CRYPTO_PANIC_KEY"])
def display_news(
post_kind: str = "news",
region: str = "en",
filter_: Optional[str] = None,
limit: int = 25,
sortby: str = "published_at",
ascend: bool = False,
links: bool = False,
export: str = "",
sheet_name: Optional[str] = None,
) -> None:
"""Display recent posts from CryptoPanic news aggregator platform.
[Source: https://cryptopanic.com/]
Parameters
----------
limit: int
number of news to display
post_kind: str
Filter by category of news. Available values: news or media.
filter_: Optional[str]
Filter by kind of news. One from list: rising|hot|bullish|bearish|important|saved|lol
region: str
Filter news by regions. Available regions are: en (English), de (Deutsch), nl (Dutch),
es (Español), fr (Français), it (Italiano), pt (Português), ru (Русский)
sortby: str
Key to sort by.
ascend: bool
Sort in ascending order.
links: bool
Show urls for news
export : str
Export dataframe data to csv,json,xlsx file
"""
df = cryptopanic_model.get_news(
limit=limit,
post_kind=post_kind,
filter_=filter_,
region=region,
sortby=sortby,
ascend=ascend,
)
if not df.empty:
if not links:
df.drop("link", axis=1, inplace=True)
else:
df = df[["title", "link"]]
print_rich_table(
df,
headers=list(df.columns),
show_index=False,
title="Recent CryptoPanic Posts",
export=bool(export),
limit=limit,
)
export_data(
export,
os.path.dirname(os.path.abspath(__file__)),
"news",
df,
sheet_name,
)