ayinggg commited on
Commit
9478fe6
·
verified ·
1 Parent(s): 13401e2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -51,7 +51,7 @@ class Investment_Simulator:
51
 
52
  def update_portfolio_history(self):
53
  now = datetime.now()
54
- total_value = compute_portfolio_value()
55
  self.portfolio_history.append((now, total_value))
56
 
57
  def plot_portfolio_value(self):
@@ -79,7 +79,7 @@ class Investment_Simulator:
79
  self.portfolio["cash"] -= amount
80
  self.portfolio["stocks"][ticker] = self.portfolio["stocks"].get(ticker, 0) + qty
81
  self.history.append(f"🟢 Bought £{amount} of {ticker} ({qty} shares at £{price:.2f})")
82
- update_portfolio_history()
83
  return f"✅ Bought {qty} shares of {ticker} at £{price:.2f}"
84
 
85
  elif "sell" in user_input:
@@ -95,7 +95,7 @@ class Investment_Simulator:
95
  self.portfolio["stocks"][ticker] -= qty_to_sell
96
  self.portfolio["cash"] += amount
97
  self.history.append(f"🔴 Sold £{amount} of {ticker} ({qty_to_sell} shares at £{price:.2f})")
98
- update_portfolio_history()
99
  return f"✅ Sold {qty_to_sell} shares of {ticker} at £{price:.2f}"
100
 
101
  elif "portfolio" in user_input:
@@ -122,7 +122,7 @@ class Investment_Simulator:
122
  self.portfolio["stocks"].clear()
123
  self.history.clear()
124
  self.portfolio_history.clear()
125
- update_portfolio_history()
126
  return "🔁 Portfolio reset."
127
 
128
  else:
@@ -133,10 +133,10 @@ class Investment_Simulator:
133
 
134
  def run_all(self, text):
135
  response = process_input(text)
136
- fig = plot_portfolio_value()
137
  return response, fig
138
 
139
- update_portfolio_history()
140
 
141
  # ---------- UI Layout ----------
142
  custom_css = """
 
51
 
52
  def update_portfolio_history(self):
53
  now = datetime.now()
54
+ total_value = compute_portfolio_value(self)
55
  self.portfolio_history.append((now, total_value))
56
 
57
  def plot_portfolio_value(self):
 
79
  self.portfolio["cash"] -= amount
80
  self.portfolio["stocks"][ticker] = self.portfolio["stocks"].get(ticker, 0) + qty
81
  self.history.append(f"🟢 Bought £{amount} of {ticker} ({qty} shares at £{price:.2f})")
82
+ update_portfolio_history(self)
83
  return f"✅ Bought {qty} shares of {ticker} at £{price:.2f}"
84
 
85
  elif "sell" in user_input:
 
95
  self.portfolio["stocks"][ticker] -= qty_to_sell
96
  self.portfolio["cash"] += amount
97
  self.history.append(f"🔴 Sold £{amount} of {ticker} ({qty_to_sell} shares at £{price:.2f})")
98
+ update_portfolio_history(self)
99
  return f"✅ Sold {qty_to_sell} shares of {ticker} at £{price:.2f}"
100
 
101
  elif "portfolio" in user_input:
 
122
  self.portfolio["stocks"].clear()
123
  self.history.clear()
124
  self.portfolio_history.clear()
125
+ update_portfolio_history(self)
126
  return "🔁 Portfolio reset."
127
 
128
  else:
 
133
 
134
  def run_all(self, text):
135
  response = process_input(text)
136
+ fig = plot_portfolio_value(self)
137
  return response, fig
138
 
139
+ update_portfolio_history(self)
140
 
141
  # ---------- UI Layout ----------
142
  custom_css = """