aboutsummaryrefslogtreecommitdiff
path: root/app.py
diff options
context:
space:
mode:
authorloit <michael.foiani@gmail.com>2025-07-29 00:59:43 -0400
committerloit <michael.foiani@gmail.com>2025-07-29 00:59:43 -0400
commit0372b76ee22ea4421b70d6f7f8c2b29b2c7ac9dc (patch)
tree42dbf007e93e366550ea339fc9737d7718d67e46 /app.py
parent00d89073d7802983b11f9e5931f932444806defd (diff)
add basic features to indicte if parameters are bad
Diffstat (limited to 'app.py')
-rw-r--r--app.py48
1 files changed, 29 insertions, 19 deletions
diff --git a/app.py b/app.py
index c251f73..68aacb8 100644
--- a/app.py
+++ b/app.py
@@ -27,26 +27,31 @@ app = Dash(__name__)
# intersected_y.append(y)
app.layout = html.Div([
- html.H4('Interactive color selection with simple Dash example'),
- html.Label("Ticker ", htmlFor="ticker"),
- dcc.Input(id="ticker", value="SPY", type="text"),
- html.Br(),
- html.Label("Period ", htmlFor="period"),
- dcc.Dropdown(
- id="period_dropdown",
- options=["1d","5d","1mo","3mo","6mo","1y","2y","5y","10y","ytd","max"],
- value = "1y",
- ),
- html.Br(),
- html.Label("Interval ", htmlFor="Interval"),
- dcc.Dropdown(
- id="interval_dropdown",
- options=["1m", "2m", "5m", "15m", "30m", "60m", "90m", "1h", "4h", "1d", "5d", "1wk", "1mo", "3mo"],
- value = "1d",
+ html.H4('Backtesting using the EMA method (5 vs 13) [ALPHA VERSION 0.0.2]'),
+ html.Div(
+ [
+ html.Label("Ticker ", htmlFor="ticker"),
+ dcc.Input(id="ticker", value="SPY", type="text"),
+ html.Br(),
+ html.Label("Period ", htmlFor="period_dropdown"),
+ dcc.Dropdown(
+ id="period_dropdown",
+ options=["1d","5d","1mo","3mo","6mo","1y","2y","5y","10y","ytd","max"],
+ value = "1y"),
+ html.Br(),
+ html.Label("Interval ", htmlFor="interval_dropdown"),
+ dcc.Dropdown(
+ id="interval_dropdown",
+ options=["1m", "2m", "5m", "15m", "30m", "60m", "90m", "1h", "4h", "1d", "5d", "1wk", "1mo", "3mo"],
+ value = "1d",
+ ),
+ html.P(id='error_message'),
+ ],
+ id='input_params'
),
html.Hr(),
dcc.Graph(id="graph"),
- html.P("If bought and sold on these signals, the percent gain/loss would be: TODO"),
+ html.P("If bought and sold on these signals, the percent gain/loss would be:"),
html.P(id="percent_gain")
])
@@ -54,15 +59,20 @@ app.layout = html.Div([
@app.callback(
Output("graph", "figure"),
Output("percent_gain", "children"),
+ Output("input_params", "style"),
+ Output("error_message", "children"),
Input("ticker", "value"),
Input("period_dropdown", "value"),
Input("interval_dropdown", "value")
)
def display_color(ticker, period, interval):
chart_data = fetch_chart_data(ticker, period, interval)
+ error_style = {"color" : "inherit"}
+ error_message = ''
if chart_data['error'] == True:
# implement a feeback mechanism for ERROR codes
- print("TODO: FIX THIS")
+ error_style = {"color" : "red"}
+ error_message = 'Issue with parameter selection. Please try again.'
timestamps_raw = chart_data['timestamps']
timestamps = [datetime.datetime.fromtimestamp(t) for t in timestamps_raw]
@@ -105,7 +115,7 @@ def display_color(ticker, period, interval):
yaxis=go.layout.YAxis(title='Price ($)')
)
)
- return (fig, percent_gain)
+ return fig, percent_gain, error_style, error_message