This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
from sqlite3 import Error | |
def add_items_to_database(db_file,stock_name,stock_quantity,stock_bought_price_weighted_avg,stock_fees,stock_currency): | |
try: | |
conn = sqlite3.connect(db_file) | |
print("INSERT INTO stocks (Stock,Bought_Price_Avg,Currency,Fees,Quantity) VALUES ('"+str(stock_name)+"',"+str(stock_bought_price_weighted_avg)+",'"+str(stock_currency)+"',"+str(stock_fees)+","+str(stock_quantity)+")") | |
conn.execute("INSERT INTO stocks (Stock,Bought_Price_Avg,Currency,Fees,Quantity) VALUES ('"+stock_name+"',"+stock_bought_price_weighted_avg+",'"+stock_currency+"',"+stock_fees+","+stock_quantity+")") | |
conn.commit() | |
except Error as e: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Summary which deals with different markets | |
st.write('Summary') | |
summary_df = df.reindex(columns=['Profit/Loss','Profit/Loss (%)','Market Value','Total Spent','Currency']).groupby(['Currency']).agg('sum') | |
summary_df['Profit/Loss (%)'] = ((summary_df['Market Value'] - summary_df['Total Spent']) / summary_df['Market Value']) *100 | |
st.table(summary_df) | |
# Final Tally (SGD) | |
st.write('Final Table (SGD)') | |
final_df = df.reindex(columns=['Market Value (SGD)','Total Spent (SGD)','Currency']).groupby(['Currency']).agg('sum') | |
final_df_sgd = final_df.sum() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
call activate.bat activate money | |
call streamlit run C:\Users\USER\Documents\Stocktracker\main_stock_app.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
from sqlite3 import Error | |
DATABASE_FILE_LOCATION = os.getcwd()+"\pythonsqlite.db" ## in C:\User\User\Desktop | |
TABLE_DIC = {'stocks':'stocks','crypto':'crypto','stock_trans':'stock_transaction','crypto_trans':'crypto_transaction'} ## Stocks always first, cryto always second | |
def create_connection(db_file): | |
""" create a database connection to a SQLite database """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from streamlit.hashing import _CodeHasher | |
try: | |
# Before Streamlit 0.65 | |
from streamlit.ReportThread import get_report_ctx | |
from streamlit.server.Server import Server | |
except ModuleNotFoundError: | |
# After Streamlit 0.65 | |
from streamlit.report_thread import get_report_ctx | |
from streamlit.server.server import Server |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
def main(test): | |
st.set_page_config(layout="wide") | |
state = _get_state() | |
st.sidebar.title(":floppy_disk: Dashboard") | |
page = st.sidebar.radio("Select your page", tuple(pages.keys())) | |
#Removing and add pages |