Skip to content

Commit 5d8bac6

Browse files
author
Jason
committed
init
0 parents  commit 5d8bac6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1751
-0
lines changed

.gitignore

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
2+
# Created by https://www.toptal.com/developers/gitignore/api/python
3+
# Edit at https://www.toptal.com/developers/gitignore?templates=python
4+
5+
### Python ###
6+
# Byte-compiled / optimized / DLL files
7+
__pycache__/
8+
*.py[cod]
9+
*$py.class
10+
11+
# Visual Studio Code
12+
.vscode/
13+
14+
# C extensions
15+
*.so
16+
17+
# Distribution / packaging
18+
.Python
19+
build/
20+
develop-eggs/
21+
dist/
22+
downloads/
23+
eggs/
24+
.eggs/
25+
lib/
26+
lib64/
27+
parts/
28+
sdist/
29+
var/
30+
wheels/
31+
share/python-wheels/
32+
*.egg-info/
33+
.installed.cfg
34+
*.egg
35+
MANIFEST
36+
37+
# PyInstaller
38+
# Usually these files are written by a python script from a template
39+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
40+
*.manifest
41+
*.spec
42+
43+
# Installer logs
44+
pip-log.txt
45+
pip-delete-this-directory.txt
46+
47+
# Unit test / coverage reports
48+
htmlcov/
49+
.tox/
50+
.nox/
51+
.coverage
52+
.coverage.*
53+
.cache
54+
nosetests.xml
55+
coverage.xml
56+
*.cover
57+
*.py,cover
58+
.hypothesis/
59+
.pytest_cache/
60+
cover/
61+
62+
# Translations
63+
*.mo
64+
*.pot
65+
66+
# Django stuff:
67+
*.log
68+
local_settings.py
69+
db.sqlite3
70+
db.sqlite3-journal
71+
72+
# Flask stuff:
73+
instance/
74+
.webassets-cache
75+
76+
# Scrapy stuff:
77+
.scrapy
78+
79+
# Sphinx documentation
80+
docs/_build/
81+
82+
# PyBuilder
83+
.pybuilder/
84+
target/
85+
86+
# Jupyter Notebook
87+
.ipynb_checkpoints
88+
89+
# IPython
90+
profile_default/
91+
ipython_config.py
92+
93+
# pyenv
94+
# For a library or package, you might want to ignore these files since the code is
95+
# intended to run in multiple environments; otherwise, check them in:
96+
# .python-version
97+
98+
# pipenv
99+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
100+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
101+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
102+
# install all needed dependencies.
103+
#Pipfile.lock
104+
105+
# poetry
106+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
107+
# This is especially recommended for binary packages to ensure reproducibility, and is more
108+
# commonly ignored for libraries.
109+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
110+
#poetry.lock
111+
112+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
113+
__pypackages__/
114+
115+
# Celery stuff
116+
celerybeat-schedule
117+
celerybeat.pid
118+
119+
# SageMath parsed files
120+
*.sage.py
121+
122+
# Environments
123+
.env
124+
.venv
125+
env/
126+
venv/
127+
ENV/
128+
env.bak/
129+
venv.bak/
130+
131+
# Spyder project settings
132+
.spyderproject
133+
.spyproject
134+
135+
# Rope project settings
136+
.ropeproject
137+
138+
# mkdocs documentation
139+
/site
140+
141+
# mypy
142+
.mypy_cache/
143+
.dmypy.json
144+
dmypy.json
145+
146+
# Pyre type checker
147+
.pyre/
148+
149+
# pytype static type analyzer
150+
.pytype/
151+
152+
# Cython debug symbols
153+
cython_debug/
154+
155+
# PyCharm
156+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158+
# and can be added to the global gitignore or merged into this file. For a more nuclear
159+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160+
.idea/
161+
162+
# End of https://www.toptal.com/developers/gitignore/api/python
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import sqlite3
2+
import datetime
3+
import Menu.MenuCommands as MenuCommands
4+
from Database.CommonSqliteActions import CommonSqliteActions
5+
6+
def fidelityBalanceUpdate(text_inputs,tkroot):
7+
_text_inputs = text_inputs.copy()
8+
for prop in _text_inputs:
9+
try:
10+
input_text = _text_inputs[prop].get("1.0", "end-1c").strip()
11+
_text_inputs[prop] = float(input_text)
12+
except ValueError:
13+
_text_inputs[prop] = "NULL"
14+
15+
sql = CommonSqliteActions()
16+
17+
try:
18+
sql.cursor.execute("INSERT INTO fidelity_account VALUES(\"{}\",{},{})".format(datetime.datetime.now(), _text_inputs["purchasingBalance"], _text_inputs["totalAccountBalance"]))
19+
20+
sql.closeDb()
21+
MenuCommands.MenuCommands.showFidelityAccountBalanceFrame(tkroot, "Table Updated")
22+
23+
except sqlite3.Error as error:
24+
MenuCommands.MenuCommands.showFidelityAccountBalanceFrame(tkroot, "Database Error: " + str(error.args))
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import sqlite3
2+
from Common.Helper import Helper
3+
import datetime
4+
import Menu.MenuCommands as MenuCommands
5+
from Database.CommonSqliteActions import CommonSqliteActions
6+
7+
async def fidelityBuyUpdate(input_rb, tkroot):
8+
tickers = input_rb.get("1.0",'end-1c')
9+
tickers = Helper.sanitizeList(tickers)
10+
sql = CommonSqliteActions()
11+
12+
try:
13+
sql.cursor.execute("DELETE FROM fidelity_buy")
14+
for ticker in tickers:
15+
if(ticker != ""):
16+
sql.cursor.execute("INSERT INTO fidelity_buy VALUES(\"{}\", \"{}\")"
17+
.format(datetime.datetime.now(),ticker))
18+
19+
sql.closeDb()
20+
21+
await MenuCommands.MenuCommands.showFidelityBuyFrame(tkroot, "Table Updated")
22+
23+
except sqlite3.Error as error:
24+
await MenuCommands.MenuCommands.showFidelityBuyFrame(tkroot, "Database Error: " + str(error.args))
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import pandas as pd
2+
import sqlite3
3+
from tkinter import messagebox
4+
import re
5+
from Database.CommonSqliteActions import CommonSqliteActions
6+
7+
def fidelityHoldingsImport(csv_file_location):
8+
sql = CommonSqliteActions()
9+
10+
try:
11+
sql.cursor.execute("DELETE FROM fidelity_portfolio")
12+
13+
panda_store = pd.read_csv(csv_file_location, encoding="utf-8-sig").fillna(0)
14+
15+
for index, row in panda_store.iterrows():
16+
if(row['Symbol'] != 0):
17+
if re.search("[*\d\s]", row['Symbol']) is None:
18+
total_return = row['Total Gain/Loss Dollar'].translate({ord(i): None for i in "$+,)"}).replace('(', '-')
19+
equity = row['Cost Basis'].translate({ord(i): None for i in "$,"})
20+
total_return_percent = row['Total Gain/Loss Percent'].translate({ord(i): None for i in "%+"})
21+
allocation = row['Percent Of Account'].replace('%', '')
22+
23+
insert_statement = "INSERT INTO fidelity_portfolio (ticker, name, shares, return, equity, percent_gain, percent_allocation) VALUES (\"{}\", \"{}\", {}, {}, {}, {}, {})".format(row['Symbol'], row['Description'], row['Quantity'], total_return, equity, total_return_percent, allocation)
24+
sql.cursor.execute(insert_statement)
25+
26+
sql.closeDb()
27+
28+
messagebox.showinfo(title="Success", message="Table successfully updated.")
29+
30+
except sqlite3.OperationalError as error:
31+
messagebox.showerror(title="Operational error", message=error.args)
32+
except sqlite3.Error as error:
33+
messagebox.showerror(title="Database error", message=error.args)
34+
except TypeError as error:
35+
messagebox.showerror(title="Type error", message=error.args)
36+
except KeyError as error:
37+
messagebox.showerror(title="Mismatching key", message = "The key can not be found in the file; check you are uploading the correct file or check format. Key:" + str(error.args))
38+
except ValueError:
39+
messagebox.showerror(title="No File Found", message="Invalid file path or no file selected")
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import sqlite3
2+
import datetime
3+
import Menu.MenuCommands as MenuCommands
4+
from Database.CommonSqliteActions import CommonSqliteActions
5+
6+
def fidelityPerformanceUpdate(text_inputs, tkroot):
7+
_text_inputs = text_inputs.copy()
8+
for prop in _text_inputs:
9+
try:
10+
input_text = _text_inputs[prop].get("1.0", "end-1c").strip()
11+
_text_inputs[prop] = float(input_text)
12+
except ValueError:
13+
_text_inputs[prop] = "NULL"
14+
15+
sql = CommonSqliteActions()
16+
17+
try:
18+
19+
sql.cursor.execute("INSERT INTO fidelity_performance VALUES(\"{}\", {}, {}, {}, {}, {}, {})".format(datetime.datetime.now(), _text_inputs["one_day_percent_return"],_text_inputs["year_to_date_percent_return"], _text_inputs["one_year_percent_return"], _text_inputs["three_year_percent_return"],_text_inputs["five_year_percent_return"], _text_inputs["ten_year_percent_return"] ))
20+
21+
sql.closeDb()
22+
23+
MenuCommands.MenuCommands.showFidelityPerformanceFrame(tkroot, "Table Updated")
24+
25+
except sqlite3.Error as error:
26+
MenuCommands.MenuCommands.showFidelityPerformanceFrame(tkroot, error)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import sqlite3
2+
from Common.Helper import Helper
3+
from Database.CommonSqliteActions import CommonSqliteActions
4+
import datetime
5+
6+
def fidelitySellUpdate(input_rb, label_response):
7+
tickers = input_rb.get("1.0",'end-1c')
8+
tickers = Helper.sanitizeList(tickers)
9+
sql = CommonSqliteActions()
10+
11+
try:
12+
sql.cursor.execute("DELETE FROM fidelity_sell")
13+
for ticker in tickers:
14+
if(ticker != ""):
15+
sql.cursor.execute("INSERT INTO fidelity_sell VALUES(\"{}\", \"{}\")"
16+
.format(datetime.datetime.now(),ticker))
17+
18+
sql.closeDb()
19+
20+
label_response.config(text = "Table updated")
21+
except sqlite3.Error as error:
22+
label_response.config(text = "Database Error: " + str(error.args))
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import sqlite3
2+
from Common.Helper import Helper
3+
from Database.CommonSqliteActions import CommonSqliteActions
4+
import datetime
5+
import Menu.MenuCommands as MenuCommands
6+
7+
async def prospectiveBuyUpdate(input_rb,tkroot):
8+
tickers = input_rb.get("1.0",'end-1c')
9+
tickers = Helper.sanitizeList(tickers)
10+
sql = CommonSqliteActions()
11+
12+
try:
13+
sql.cursor.execute("DELETE FROM prospective_buy")
14+
for ticker in tickers:
15+
if(ticker != ""):
16+
sql.cursor.execute("INSERT INTO prospective_buy VALUES(\"{}\", \"{}\")"
17+
.format(datetime.datetime.now(),ticker))
18+
19+
sql.closeDb()
20+
await MenuCommands.MenuCommands.showProspectiveBuyFrame(tkroot, "Table Updated")
21+
22+
except sqlite3.Error as error:
23+
await MenuCommands.MenuCommands.showProspectiveBuyFrame(tkroot, "Database Error: " + str(error.args))
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import sqlite3
2+
import datetime
3+
import Menu.MenuCommands as MenuCommands
4+
from Database.CommonSqliteActions import CommonSqliteActions
5+
import sqlite3
6+
7+
import Menu.MenuCommands as MenuCommands
8+
from Database.CommonSqliteActions import CommonSqliteActions
9+
10+
11+
def robinhoodBalanceUpdate(text_inputs,tkroot):
12+
_text_inputs = text_inputs.copy()
13+
for prop in _text_inputs:
14+
try:
15+
input_text = _text_inputs[prop].get("1.0", "end-1c").strip()
16+
_text_inputs[prop] = float(input_text)
17+
except ValueError:
18+
_text_inputs[prop] = "NULL"
19+
20+
sql = CommonSqliteActions()
21+
22+
try:
23+
sql.cursor.execute("INSERT INTO robinhood_account VALUES(\"{}\",{},{})".format(datetime.datetime.now(), _text_inputs["purchasingBalance"], _text_inputs["totalAccountBalance"]))
24+
sql.closeDb()
25+
MenuCommands.MenuCommands.showRobinhoodAccountBalanceFrame(tkroot, "Table Updated")
26+
27+
except sqlite3.Error as error:
28+
MenuCommands.MenuCommands.showRobinhoodAccountBalanceFrame(tkroot, "Database Error: " + str(error.args))
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import sqlite3
2+
from Common.Helper import Helper
3+
from Database.CommonSqliteActions import CommonSqliteActions
4+
import datetime
5+
import Menu.MenuCommands as MenuCommands
6+
7+
async def robinhoodBuyUpdate(input_rb,tkroot):
8+
tickers = input_rb.get("1.0",'end-1c')
9+
tickers = Helper.sanitizeList(tickers)
10+
sql = CommonSqliteActions()
11+
12+
try:
13+
sql.cursor.execute("DELETE FROM robinhood_buy")
14+
for ticker in tickers:
15+
if(ticker != ""):
16+
sql.cursor.execute("INSERT INTO robinhood_buy VALUES(\"{}\", \"{}\")"
17+
.format(datetime.datetime.now(),ticker))
18+
19+
sql.closeDb()
20+
await MenuCommands.MenuCommands.showRobinhoodBuyFrame(tkroot, "Table Updated")
21+
22+
except sqlite3.Error as error:
23+
await MenuCommands.MenuCommands.showRobinhoodBuyFrame(tkroot, "Database Error: " + str(error.args))

0 commit comments

Comments
 (0)