28 lines
712 B
Python
28 lines
712 B
Python
# Utility script to port from flatfile to database
|
|
|
|
import config as cfg
|
|
import flatfile as f
|
|
import mongo as m
|
|
import json
|
|
|
|
with open(cfg.database) as f:
|
|
data = json.loads(f.read())
|
|
|
|
for user in data.keys():
|
|
print("\n\nUser:", user)
|
|
print("[1] Portfolio")
|
|
|
|
for stock in data[user]["portfolio"].keys():
|
|
ticker = stock
|
|
amount = data[user]["portfolio"][stock]
|
|
print(" ", ticker, amount)
|
|
m.add_stock(user, ticker, amount)
|
|
|
|
print("[2] Watchlist")
|
|
for stock in data[user]["watchlist"].keys():
|
|
ticker = stock
|
|
amount = data[user]["watchlist"][stock]
|
|
print(" ", ticker, amount)
|
|
m.watch(user, ticker, amount)
|
|
|
|
print("[*] Done!")
|