mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-29 05:21:48 +00:00
* fix conversion error str to float by replacing commas in numeric columns * fix conversion error str to float by replacing commas in numeric columns * adds -d as default arg if a date is provided * fixe order of parameters * fixed the check on the emptiness of the trading view recommendation * added more screeners * changed if in order to avoid result used before assignment exception Co-authored-by: James Maslek <jmaslek11@gmail.com>
62 lines
1.7 KiB
Python
62 lines
1.7 KiB
Python
"""Tradingview view"""
|
|
__docformat__ = "numpy"
|
|
|
|
import logging
|
|
import os
|
|
import pandas as pd
|
|
|
|
from openbb_terminal.decorators import log_start_end
|
|
from openbb_terminal.helper_funcs import export_data, print_rich_table
|
|
from openbb_terminal.stocks.technical_analysis import tradingview_model
|
|
from openbb_terminal.rich_config import console
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@log_start_end(log=logger)
|
|
def print_recommendation(
|
|
symbol: str,
|
|
screener: str = "america",
|
|
exchange: str = "",
|
|
interval: str = "",
|
|
export: str = "",
|
|
):
|
|
"""Print tradingview recommendation based on technical indicators
|
|
|
|
Parameters
|
|
----------
|
|
symbol : str
|
|
Ticker symbol to get tradingview recommendation based on technical indicators
|
|
screener : str
|
|
Screener based on tradingview docs https://python-tradingview-ta.readthedocs.io/en/latest/usage.html
|
|
exchange: str
|
|
Exchange based on tradingview docs https://python-tradingview-ta.readthedocs.io/en/latest/usage.html
|
|
interval: str
|
|
Interval time to check technical indicators and correspondent recommendation
|
|
export: str
|
|
Format of export file
|
|
"""
|
|
|
|
recom = tradingview_model.get_tradingview_recommendation(
|
|
symbol, screener, exchange, interval
|
|
)
|
|
|
|
if (isinstance(recom, pd.DataFrame) and recom.empty) or (
|
|
not isinstance(recom, pd.DataFrame) and not recom
|
|
):
|
|
console.print("[red]The API did not return any recommendations.[/red]\n")
|
|
return
|
|
|
|
export_data(
|
|
export,
|
|
os.path.dirname(os.path.abspath(__file__)),
|
|
"recom",
|
|
recom,
|
|
)
|
|
print_rich_table(
|
|
recom,
|
|
headers=list(recom.columns),
|
|
title="Ticker Recommendation",
|
|
show_index=True,
|
|
)
|