aboutsummaryrefslogtreecommitdiff
path: root/app.py
diff options
context:
space:
mode:
authorloit <michael.foiani@gmail.com>2025-07-31 13:20:08 -0400
committerloit <michael.foiani@gmail.com>2025-07-31 13:20:08 -0400
commit2f195e7f14e57e07ec291e8bfeee6da54ef35575 (patch)
tree572fccc4563c3bfb62f70d86ef271b70aedcf0ec /app.py
parentde9b1d2297e02a71e06f386066c106406a9477f3 (diff)
attemp using the alpaca api for history data
Diffstat (limited to 'app.py')
-rw-r--r--app.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/app.py b/app.py
index 952edf5..fc8276b 100644
--- a/app.py
+++ b/app.py
@@ -1,8 +1,10 @@
from dash import Dash, dcc, html, Input, Output
import plotly.graph_objects as go
import json
-from datetime import datetime
+from datetime import datetime, timedelta
from ema_algo import Ema_Algo
+from api import fetch_chart_data_yahoo
+import pytz
app = Dash(__name__)
@@ -79,7 +81,7 @@ def display_color(ticker, period, interval):
# Code to execute no matter what (optional)
raw_timestamps = chart_data['timestamps']
- timestamps = [datetime.fromtimestamp(t) for t in raw_timestamps]
+ timestamps = [datetime.fromtimestamp(t).astimezone(pytz.timezone('US/Eastern')) for t in raw_timestamps]
prices = chart_data['prices']
# test to see if graphc works, TODO make it abstracted
@@ -102,10 +104,16 @@ def display_color(ticker, period, interval):
go.Scatter(name='Buys', x=buy_times, y=buy_prices, line=dict(color='rgb(0, 0, 255)'), mode='markers', marker_size=10),
go.Scatter(name='Sells', x=sell_times, y=sell_prices, line=dict(color='rgb(255, 255, 0)'), mode='markers', marker_size=10)
]
+ data = fetch_chart_data_yahoo('XRP-USD', '1m')
+ times = [datetime.fromtimestamp(t).astimezone(pytz.timezone('US/Eastern')) for t in data['timestamps']]
+ comp_scatter = go.Scatter(name='Price (yahoo)', x=times, y=data['prices'], line=dict(color='rgb(255, 0, 0)'), mode='lines')
fig = go.Figure(
data = [
go.Scatter(name='Price', x=timestamps, y=prices, line=dict(color='rgb(0, 0, 0)'), mode='lines'),
- ] + algo_graphs + buy_sell_scatters,
+ comp_scatter
+ ]
+ # + algo_graphs + buy_sell_scatters
+ ,
layout = go.Layout(
title=go.layout.Title(text='Chart for ' + chart_data['name']),
xaxis=go.layout.XAxis(title='Date (dt=' + url_params['interval'] + ', range=' + url_params['period'] + ')'),