forked from minhlucvan/strategy-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_portfolio.py
32 lines (26 loc) · 974 Bytes
/
update_portfolio.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import datetime
import vectorbt as vbt
from utils.portfolio import Portfolio
from telegram.ext import CommandHandler
import toml
import logging
logging.basicConfig(level=logging.INFO) # enable logging
def update_portfolio():
portfolio = Portfolio()
logging.info("--Update portfolio.")
if portfolio.updateAll():
logging.info("--Update portfolio sucessfully.")
print("Update portfolios sucessfully.")
check_df = portfolio.check_records(dt=datetime.date.today())
# send the notification to telegram users
if len(check_df) == 0:
print("No signal found.")
else:
print(f"Found {len(check_df)} signal.")
for i, row in check_df.iterrows():
symbol_str = str(i+1) + '.' + row['name'] + ' : ' + row['records']
print(symbol_str)
else:
logging.error("--Failed to update portfolio.")
if __name__ == '__main__':
update_portfolio()