-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
51 lines (43 loc) · 1.65 KB
/
main.py
File metadata and controls
51 lines (43 loc) · 1.65 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import schedule
import time
from datetime import datetime
from config import CHECK_TIMES, ANALYSIS_TIME, TELEGRAM_TOKEN, AI_PROVIDER
import monitor
import analysis
import telegram_bot
def _market_day() -> bool:
"""Vrai si aujourd'hui est un jour de semaine (lundi–vendredi)."""
return datetime.now().weekday() < 5 # 0=lundi … 4=vendredi
def run_scheduler():
for t in CHECK_TIMES:
schedule.every().day.at(t).do(
lambda: monitor.check_positions(telegram_bot.send) if _market_day() else None
)
schedule.every().day.at(ANALYSIS_TIME).do(
lambda: analysis.morning_briefing(telegram_bot.send) if _market_day() else None
)
schedule.every().monday.at("09:10").do(
lambda: analysis.weekly_swap_analysis(telegram_bot.send)
)
schedule.every().day.at("09:15").do(
lambda: analysis.monthly_breach_review(telegram_bot.send)
if _market_day() and datetime.now().day == 1 else None
)
print(f" Checks: {', '.join(CHECK_TIMES)} | Briefing: {ANALYSIS_TIME} | Swap: lundi 09:10 | Revue SL: 1er du mois 09:15 (heure Paris)")
while True:
schedule.run_pending()
time.sleep(30)
if __name__ == "__main__":
print("=" * 40)
print(" TradingBot")
print("=" * 40)
print(f" Telegram : {'OK' if TELEGRAM_TOKEN else 'MANQUANT (.env)'}")
print(f" AI : {AI_PROVIDER}")
import portfolio
data = portfolio.load()
positions = data.get("positions", {})
print(f" Cash : {data.get('cash_available', 0)}€")
print(f" Positions: {list(positions.keys()) or 'aucune'}")
print("=" * 40)
telegram_bot.start_polling()
run_scheduler()