mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-12-01 13:44:16 +00:00
Refactor to match black format
This commit is contained in:
@@ -23,43 +23,45 @@ from gamestonk_terminal.helper_funcs import (
|
||||
from gamestonk_terminal import feature_flags as gtff
|
||||
|
||||
d_signals = {
|
||||
'top_gainers': 'Top Gainers',
|
||||
'top_losers': 'Top Losers',
|
||||
'new_high': 'New High',
|
||||
'new_low': 'New Low',
|
||||
'most_volatile': 'Most Volatile',
|
||||
'most_active': 'Most Active',
|
||||
'unusual_volume': 'Unusual Volume',
|
||||
'overbought': 'Overbought',
|
||||
'oversold': 'Oversold',
|
||||
'downgrades': 'Downgrades',
|
||||
'upgrades': 'Upgrades',
|
||||
'earnings_before': 'Earnings Before',
|
||||
'earnings_after': 'Earnings After',
|
||||
'recent_insider_buying': 'Recent Insider Buying',
|
||||
'recent_insider_selling': 'Recent Insider Selling',
|
||||
'major_news': 'Major News',
|
||||
'horizontal_sr': 'Horizontal S/R',
|
||||
'tl_resistance': 'TL Resistance',
|
||||
'tl_support': 'TL Support',
|
||||
'wedge_up': 'Wedge Up',
|
||||
'wedge_down': 'Wedge Down',
|
||||
'wedge': 'Wedge',
|
||||
'triangle_ascending': 'Triangle Ascending',
|
||||
'triangle_descending': 'Triangle Descending',
|
||||
'channel_up': 'Channel Up',
|
||||
'channel_down': 'Channel Down',
|
||||
'channel': 'Channel',
|
||||
'double_top': 'Double Top',
|
||||
'double_bottom': 'Double Bottom',
|
||||
'multiple_top': 'Multiple Top',
|
||||
'multiple_bottom': 'Multiple Bottom',
|
||||
'head_shoulders': 'Head & Shoulders',
|
||||
'head_shoulders_inverse': 'Head & Shoulders Inverse'
|
||||
"top_gainers": "Top Gainers",
|
||||
"top_losers": "Top Losers",
|
||||
"new_high": "New High",
|
||||
"new_low": "New Low",
|
||||
"most_volatile": "Most Volatile",
|
||||
"most_active": "Most Active",
|
||||
"unusual_volume": "Unusual Volume",
|
||||
"overbought": "Overbought",
|
||||
"oversold": "Oversold",
|
||||
"downgrades": "Downgrades",
|
||||
"upgrades": "Upgrades",
|
||||
"earnings_before": "Earnings Before",
|
||||
"earnings_after": "Earnings After",
|
||||
"recent_insider_buying": "Recent Insider Buying",
|
||||
"recent_insider_selling": "Recent Insider Selling",
|
||||
"major_news": "Major News",
|
||||
"horizontal_sr": "Horizontal S/R",
|
||||
"tl_resistance": "TL Resistance",
|
||||
"tl_support": "TL Support",
|
||||
"wedge_up": "Wedge Up",
|
||||
"wedge_down": "Wedge Down",
|
||||
"wedge": "Wedge",
|
||||
"triangle_ascending": "Triangle Ascending",
|
||||
"triangle_descending": "Triangle Descending",
|
||||
"channel_up": "Channel Up",
|
||||
"channel_down": "Channel Down",
|
||||
"channel": "Channel",
|
||||
"double_top": "Double Top",
|
||||
"double_bottom": "Double Bottom",
|
||||
"multiple_top": "Multiple Top",
|
||||
"multiple_bottom": "Multiple Bottom",
|
||||
"head_shoulders": "Head & Shoulders",
|
||||
"head_shoulders_inverse": "Head & Shoulders Inverse",
|
||||
}
|
||||
|
||||
|
||||
def get_screener_data(preset_loaded: str, data_type: str, signal: str, limit: int, ascend: bool):
|
||||
def get_screener_data(
|
||||
preset_loaded: str, data_type: str, signal: str, limit: int, ascend: bool
|
||||
):
|
||||
"""Screener Overview
|
||||
|
||||
Parameters
|
||||
@@ -82,9 +84,7 @@ def get_screener_data(preset_loaded: str, data_type: str, signal: str, limit: in
|
||||
"""
|
||||
preset_filter = configparser.RawConfigParser()
|
||||
preset_filter.optionxform = str
|
||||
preset_filter.read(
|
||||
"gamestonk_terminal/screener/presets/" + preset_loaded + ".ini"
|
||||
)
|
||||
preset_filter.read("gamestonk_terminal/screener/presets/" + preset_loaded + ".ini")
|
||||
|
||||
d_general = preset_filter["General"]
|
||||
d_filters = {
|
||||
@@ -127,21 +127,18 @@ def get_screener_data(preset_loaded: str, data_type: str, signal: str, limit: in
|
||||
ascend=ascend,
|
||||
)
|
||||
else:
|
||||
df_screen = screen.ScreenerView(
|
||||
order=d_general["Order"], ascend=ascend
|
||||
)
|
||||
df_screen = screen.ScreenerView(order=d_general["Order"], ascend=ascend)
|
||||
|
||||
else:
|
||||
if limit > 0:
|
||||
df_screen = screen.ScreenerView(
|
||||
limit=limit, ascend=ascend
|
||||
)
|
||||
df_screen = screen.ScreenerView(limit=limit, ascend=ascend)
|
||||
else:
|
||||
df_screen = screen.ScreenerView(ascend=ascend)
|
||||
|
||||
return df_screen
|
||||
|
||||
def screener(other_args: List[str], loaded_preset: str, data_type : str):
|
||||
|
||||
def screener(other_args: List[str], loaded_preset: str, data_type: str):
|
||||
"""Screener
|
||||
|
||||
Parameters
|
||||
@@ -209,7 +206,13 @@ def screener(other_args: List[str], loaded_preset: str, data_type : str):
|
||||
if not ns_parser:
|
||||
return
|
||||
|
||||
df_screen = get_screener_data(ns_parser.preset, data_type, ns_parser.signal, ns_parser.limit, ns_parser.ascend)
|
||||
df_screen = get_screener_data(
|
||||
ns_parser.preset,
|
||||
data_type,
|
||||
ns_parser.signal,
|
||||
ns_parser.limit,
|
||||
ns_parser.ascend,
|
||||
)
|
||||
|
||||
if isinstance(df_screen, pd.DataFrame):
|
||||
print(df_screen.to_string())
|
||||
@@ -222,7 +225,7 @@ def screener(other_args: List[str], loaded_preset: str, data_type : str):
|
||||
|
||||
|
||||
def view_signals(other_args: List[str]):
|
||||
""" View list of available signals
|
||||
"""View list of available signals
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@@ -246,35 +249,73 @@ def view_signals(other_args: List[str]):
|
||||
print("top_losers stocks with the highest %% price loss today.")
|
||||
print("new_high stocks making 52-week high today")
|
||||
print("new_low stocks making 52-week low today")
|
||||
print("most_volatile stocks with the highest widest high/low trading range today")
|
||||
print(
|
||||
"most_volatile stocks with the highest widest high/low trading range today"
|
||||
)
|
||||
print("most_active stocks with the highest trading volume today")
|
||||
print("unusual_volume stocks with unusually high volume today - the highest relative volume ratio")
|
||||
print("overbought stock is becoming overvalued and may experience a pullback.")
|
||||
print("oversold oversold stocks may represent a buying opportunity for investors.")
|
||||
print(
|
||||
"unusual_volume stocks with unusually high volume today - the highest relative volume ratio"
|
||||
)
|
||||
print(
|
||||
"overbought stock is becoming overvalued and may experience a pullback."
|
||||
)
|
||||
print(
|
||||
"oversold oversold stocks may represent a buying opportunity for investors."
|
||||
)
|
||||
print("downgrades stocks downgraded by analysts today")
|
||||
print("upgrades stocks upgraded by analysts today.")
|
||||
print("earnings_before companies reporting earnings today, before market open")
|
||||
print("earnings_after companies reporting earnings today, after market close")
|
||||
print(
|
||||
"earnings_before companies reporting earnings today, before market open"
|
||||
)
|
||||
print(
|
||||
"earnings_after companies reporting earnings today, after market close"
|
||||
)
|
||||
print("recent_insider_buying stocks with recent insider buying activity")
|
||||
print("recent_insider_selling stocks with recent insider selling activity")
|
||||
print("major_news stocks with the highest news coverage today")
|
||||
print("horizontal_sr horizontal channel of price range between support and resistance trendlines")
|
||||
print(
|
||||
"horizontal_sr horizontal channel of price range between support and resistance trendlines"
|
||||
)
|
||||
print("tl_resistance once a rising trendline is broken")
|
||||
print("tl_support once a falling trendline is broken")
|
||||
print("wedge_up upward trendline support and upward trendline resistance (reversal)")
|
||||
print("wedge_down downward trendline support and downward trendline resistance (reversal)")
|
||||
print("wedge upward trendline support, downward trendline resistance (contiunation)")
|
||||
print("triangle_ascending upward trendline support and horizontal trendline resistance")
|
||||
print("triangle_descending horizontal trendline support and downward trendline resistance")
|
||||
print("channel_up both support and resistance trendlines slope upward")
|
||||
print("channel_down both support and resistance trendlines slope downward")
|
||||
print("channel both support and resistance trendlines are horizontal")
|
||||
print("double_top stock with 'M' shape that indicates a bearish reversal in trend")
|
||||
print("double_bottom stock with 'W' shape that indicates a bullish reversal in trend")
|
||||
print(
|
||||
"wedge_up upward trendline support and upward trendline resistance (reversal)"
|
||||
)
|
||||
print(
|
||||
"wedge_down downward trendline support and downward trendline resistance (reversal)"
|
||||
)
|
||||
print(
|
||||
"wedge upward trendline support, downward trendline resistance (contiunation)"
|
||||
)
|
||||
print(
|
||||
"triangle_ascending upward trendline support and horizontal trendline resistance"
|
||||
)
|
||||
print(
|
||||
"triangle_descending horizontal trendline support and downward trendline resistance"
|
||||
)
|
||||
print(
|
||||
"channel_up both support and resistance trendlines slope upward"
|
||||
)
|
||||
print(
|
||||
"channel_down both support and resistance trendlines slope downward"
|
||||
)
|
||||
print(
|
||||
"channel both support and resistance trendlines are horizontal"
|
||||
)
|
||||
print(
|
||||
"double_top stock with 'M' shape that indicates a bearish reversal in trend"
|
||||
)
|
||||
print(
|
||||
"double_bottom stock with 'W' shape that indicates a bullish reversal in trend"
|
||||
)
|
||||
print("multiple_top same as double_top hitting more highs")
|
||||
print("multiple_bottom same as double_bottom hitting more lows")
|
||||
print("head_shoulders chart formation that predicts a bullish-to-bearish trend reversal")
|
||||
print("head_shoulders_inverse chart formation that predicts a bearish-to-bullish trend reversal")
|
||||
print(
|
||||
"head_shoulders chart formation that predicts a bullish-to-bearish trend reversal"
|
||||
)
|
||||
print(
|
||||
"head_shoulders_inverse chart formation that predicts a bearish-to-bullish trend reversal"
|
||||
)
|
||||
print("")
|
||||
|
||||
except Exception as e:
|
||||
|
||||
@@ -33,7 +33,7 @@ class ScreenerController:
|
||||
"ownership",
|
||||
"performance",
|
||||
"technical",
|
||||
"signals"
|
||||
"signals",
|
||||
]
|
||||
|
||||
def __init__(self):
|
||||
@@ -83,17 +83,23 @@ class ScreenerController:
|
||||
if not ns_parser:
|
||||
return
|
||||
|
||||
presets = [preset.split('.')[0] for preset in os.listdir('gamestonk_terminal/screener/presets')]
|
||||
presets = [
|
||||
preset.split(".")[0]
|
||||
for preset in os.listdir("gamestonk_terminal/screener/presets")
|
||||
]
|
||||
|
||||
for preset in presets:
|
||||
with open('gamestonk_terminal/screener/presets/' + preset + '.ini', encoding='utf8') as f:
|
||||
with open(
|
||||
"gamestonk_terminal/screener/presets/" + preset + ".ini",
|
||||
encoding="utf8",
|
||||
) as f:
|
||||
description = ""
|
||||
for line in f:
|
||||
if "[General]" == line.strip():
|
||||
break
|
||||
description += line.strip()
|
||||
print(f"\nPRESET: {preset}")
|
||||
print(description.split('Description: ')[1].replace('#',''))
|
||||
print(description.split("Description: ")[1].replace("#", ""))
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
@@ -101,7 +107,6 @@ class ScreenerController:
|
||||
print("")
|
||||
return
|
||||
|
||||
|
||||
@staticmethod
|
||||
def set_preset(self, other_args: List[str]):
|
||||
""" Set preset """
|
||||
@@ -118,7 +123,10 @@ class ScreenerController:
|
||||
type=str,
|
||||
default="template",
|
||||
help="Filter presets",
|
||||
choices=[preset.split('.')[0] for preset in os.listdir('gamestonk_terminal/screener/presets')],
|
||||
choices=[
|
||||
preset.split(".")[0]
|
||||
for preset in os.listdir("gamestonk_terminal/screener/presets")
|
||||
],
|
||||
)
|
||||
|
||||
try:
|
||||
@@ -138,7 +146,6 @@ class ScreenerController:
|
||||
print("")
|
||||
return
|
||||
|
||||
|
||||
def switch(self, an_input: str):
|
||||
"""Process and dispatch input
|
||||
|
||||
|
||||
Reference in New Issue
Block a user