from investmentalg.algorithm import Algorithm
from investmentalg.portfolio import Portfolio
from investmentalg.init_db import create_db, current_sql_file, backup_db, undo
import os
# python -m unittest discover <test_directory>
# if os.path.isfile(current_sql_file()):
#     os.remove(current_sql_file())
p = Portfolio(current_sql_file())
prt = p.create_portfolio()
# print('prt: ', prt)
# print('--------------------------------------------------------------')
# alg = Algorithm(current_sql_file(), prt[0])
# # print('alg.portfolio_total_fund: ', alg.portfolio_total_fund)
# # print('--------------------------------------------------------------')
# accounts = alg.add_account(name='farhan', fee=0 , risk=0.7 , profit=0.7, fund=0.0)
# backup_db(max_backup=10)
# alg = Algorithm(current_sql_file(), prt[0])
# # print('alg.portfolio_total_fund: ', alg.portfolio_total_fund)
# # print(f'accounts: {accounts}')
# # print('--------------------------------------------------------------')
# accounts = alg.add_account(name='saeid', fee=0 , risk=0.3 , profit=0.9, fund=100.0)
# backup_db(max_backup=10)
# alg = Algorithm(current_sql_file(), prt[0])
# # print('alg.portfolio_total_fund: ', alg.portfolio_total_fund)
# # print(f'accounts: {accounts}')
# # print('--------------------------------------------------------------')
# accounts = alg.make_transaction(name='farhan', fund=2000000)
# backup_db(max_backup=10)
# alg = Algorithm(current_sql_file(), prt[0])
# # print('alg.portfolio_total_fund: ', alg.portfolio_total_fund)
# # print(f'accounts: {accounts}')
# # print('--------------------------------------------------------------')
#
# # alg = Algorithm(SQL_FILE, 1)
# alg.list_my_accounts_funds()
# # print('--------------------------------------------------------------')
# k = alg.add_account("neda joon", fee=0, risk=0.3 , profit=0.9, fund=100.0,  is_main=True)
# backup_db(max_backup=10)
# alg = Algorithm(current_sql_file(), prt[0])
# # print(k)
# # print('--------------------------------------------------------------')
# p = alg.update_total_fund(alg.portfolio_total_fund * 2)
# backup_db(max_backup=10)
# alg = Algorithm(current_sql_file(), prt[0])
# # print(p)
# # print('--------------------------------------------------------------')
# print(alg.list_my_accounts_funds())
# print('--------------------------------------------------------------')
# alg.remove_main()
# p = alg.update_total_fund(alg.portfolio_total_fund * 2)
# backup_db(max_backup=10)
# alg = Algorithm(current_sql_file(), prt[0])
# print(alg.list_my_accounts_funds())
# print('--------------------------------------------------------------')
# print(alg.list_account_funds('farhan'))
# print(alg.list_account_transactions('farhan'))
# print('--------------------------------------------------------------')
# alg.make_transaction('farhan', -1500000)
# backup_db(max_backup=10)
# alg = Algorithm(current_sql_file(), prt[0])
#
# print(alg.list_account_funds('farhan'))
# print(alg.list_account_transactions('farhan'))
# alg.chart_account_funds("farhan")
# alg.chart_portfolio_acounts()
