jarvisx17 commited on
Commit
dc72b91
1 Parent(s): 352f1aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -6,7 +6,7 @@ st.title("Stock Portfolio and Tax Analysis")
6
 
7
  # Initialize empty dataframes for stock sales and portfolio stocks
8
  if 'stock_sales' not in st.session_state:
9
- st.session_state.stock_sales = pd.DataFrame(columns=['Name', 'Sale Price', 'Purchase Price', 'Holding Period (Months)'])
10
  if 'portfolio_stocks' not in st.session_state:
11
  st.session_state.portfolio_stocks = pd.DataFrame(columns=['Name', 'Purchase Price', 'Current Price', 'Quantity'])
12
 
@@ -25,11 +25,11 @@ def add_stock_sale():
25
  with col5:
26
  holding_period_months = st.number_input("Holding Period (Months)", min_value=1, key="stock_sale_holding_period")
27
 
28
- submit_button = st.form_submit_button("Add Stock Sale")
29
  if submit_button:
30
  new_stock = pd.DataFrame([{'Name': name, 'Sale Price': sale_price, 'Purchase Price': purchase_price, 'Quantity': sell_quantity, 'Holding Period (Months)': holding_period_months}])
31
  st.session_state.stock_sales = pd.concat([st.session_state.stock_sales, new_stock], ignore_index=True)
32
- st.success("Stock Sale Added!")
33
 
34
  # Define function to add portfolio stock
35
  def add_portfolio_stock():
@@ -53,7 +53,7 @@ def add_portfolio_stock():
53
  # Define functions to edit and delete stocks
54
  def delete_stock_sale(index):
55
  st.session_state.stock_sales = st.session_state.stock_sales.drop(index).reset_index(drop=True)
56
- st.success("Stock Sale Deleted!")
57
 
58
  def delete_portfolio_stock(index):
59
  st.session_state.portfolio_stocks = st.session_state.portfolio_stocks.drop(index).reset_index(drop=True)
@@ -65,7 +65,7 @@ def edit_stock_sale(index, name, sale_price, purchase_price, holding_period_mont
65
  st.session_state.stock_sales.at[index, 'Purchase Price'] = purchase_price
66
  st.session_state.stock_sales.at[index, 'Quantity'] = sell_quantity
67
  st.session_state.stock_sales.at[index, 'Holding Period (Months)'] = holding_period_months
68
- st.success("Stock Sale Updated!")
69
 
70
  def edit_portfolio_stock(index, name, purchase_price, current_price, quantity):
71
  st.session_state.portfolio_stocks.at[index, 'Name'] = name
 
6
 
7
  # Initialize empty dataframes for stock sales and portfolio stocks
8
  if 'stock_sales' not in st.session_state:
9
+ st.session_state.stock_sales = pd.DataFrame(columns=['Name', 'Sale Price', 'Purchase Price', 'Quantity', 'Holding Period (Months)'])
10
  if 'portfolio_stocks' not in st.session_state:
11
  st.session_state.portfolio_stocks = pd.DataFrame(columns=['Name', 'Purchase Price', 'Current Price', 'Quantity'])
12
 
 
25
  with col5:
26
  holding_period_months = st.number_input("Holding Period (Months)", min_value=1, key="stock_sale_holding_period")
27
 
28
+ submit_button = st.form_submit_button("Add Sold Stock")
29
  if submit_button:
30
  new_stock = pd.DataFrame([{'Name': name, 'Sale Price': sale_price, 'Purchase Price': purchase_price, 'Quantity': sell_quantity, 'Holding Period (Months)': holding_period_months}])
31
  st.session_state.stock_sales = pd.concat([st.session_state.stock_sales, new_stock], ignore_index=True)
32
+ st.success("Sold Stock Added!")
33
 
34
  # Define function to add portfolio stock
35
  def add_portfolio_stock():
 
53
  # Define functions to edit and delete stocks
54
  def delete_stock_sale(index):
55
  st.session_state.stock_sales = st.session_state.stock_sales.drop(index).reset_index(drop=True)
56
+ st.success("Sold Stock Deleted!")
57
 
58
  def delete_portfolio_stock(index):
59
  st.session_state.portfolio_stocks = st.session_state.portfolio_stocks.drop(index).reset_index(drop=True)
 
65
  st.session_state.stock_sales.at[index, 'Purchase Price'] = purchase_price
66
  st.session_state.stock_sales.at[index, 'Quantity'] = sell_quantity
67
  st.session_state.stock_sales.at[index, 'Holding Period (Months)'] = holding_period_months
68
+ st.success("Sold Stock Updated!")
69
 
70
  def edit_portfolio_stock(index, name, purchase_price, current_price, quantity):
71
  st.session_state.portfolio_stocks.at[index, 'Name'] = name