Skip to content

Commit

Permalink
build model ready
Browse files Browse the repository at this point in the history
  • Loading branch information
eethansmith committed Dec 13, 2023
1 parent ee231f6 commit 7268d3d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Binary file modified backend/myapp/__pycache__/graph_stock_holdings_day.cpython-38.pyc
Binary file not shown.
16 changes: 14 additions & 2 deletions backend/myapp/graph_stock_holdings_day.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def get_stock_history_day(request, ticker):
historical_prices = today_data

shares_held = get_current_shares_held(ticker)
current_open_time = today_data.index[0]

# Fetch the previous day's closing price
previous_day_data = stock.history(period="2d", interval="1d")
Expand All @@ -64,10 +65,21 @@ def get_stock_history_day(request, ticker):
previous_close = previous_day_data['Close'].iloc[-2]
previous_close_paid = shares_held * previous_close

# Add previous day's close as the first data point
adjusted_close_time = current_open_time - timedelta(minutes=1)
adjusted_close_time_str = adjusted_close_time.tz_convert(timezone).strftime('%Y-%m-%d %H:%M:%S')

historical_values = [{
"date": adjusted_close_time_str,
"value": previous_close * shares_held,
"value_paid": previous_close_paid
}]

# Add rest of the historical values
historical_values.extend([{
"date": date.tz_convert(timezone).strftime('%Y-%m-%d %H:%M:%S'),
"value": row['Close'] * shares_held, # Current value of shares held
"value_paid": previous_close_paid # Value based on previous day's close
} for date, row in historical_prices.iterrows()]
} for date, row in historical_prices.iterrows()])

return JsonResponse(historical_values, safe=False)
return JsonResponse(historical_values, safe=False)
1 change: 0 additions & 1 deletion frontend/src/StockGraphingAll.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ function StockGraphAll({ ticker, timeFrame }) { // Use destructuring to get the
label: 'Stock Value',
data: stockData.map(data => data.value),
fill: false,
backgroundColor: 'rgba(75, 192, 192 0.1)',
borderColor: 'rgb(75, 245, 192)',
borderWidth: 0.8,
tension: 0.1,
Expand Down

0 comments on commit 7268d3d

Please sign in to comment.