mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-28 21:12:16 +00:00
* Started new tests * Added special function * Improved dict * Finished new test * Got bad functions to 75 * Got bad func to 73 * Bad func down to 60 * Bad func down to 50 * Bad func down to 35 * Got bad func to 30 * No more bad functions * Added tests * Added fix * Fixed some tests * Fixed some tests * Fixed some tests * Fixed some tests * Added tests to CI * Fixed CI tests * Fixed CI tests * Imrproved CI tests * Fixed reports * Fixed reports * Added stuff * Removed CI * Fixed * Fixed some typing' Co-authored-by: minhhoang1023 <40023817+minhhoang1023@users.noreply.github.com>
79 lines
2.1 KiB
Python
79 lines
2.1 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 log_start_end
|
|
from openbb_terminal.helper_funcs import export_data, print_rich_table
|
|
from openbb_terminal.decorators import check_api_key
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@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 = "",
|
|
) -> 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.head(limit),
|
|
headers=list(df.columns),
|
|
show_index=False,
|
|
title="Recent CryptoPanic Posts",
|
|
)
|
|
|
|
export_data(
|
|
export,
|
|
os.path.dirname(os.path.abspath(__file__)),
|
|
"news",
|
|
df,
|
|
)
|