borsa / sync_eligibility.py
veteroner's picture
feat: live position monitoring with charts + trading system production ready
656ac31
#!/usr/bin/env python3
"""Sync BIST100 scan results into stock_eligibility.json."""
import json
from datetime import datetime, timezone
scan = json.loads(open('paper_trading/bist100_scan_results.json').read())
s2 = scan.get('stage2', {})
eligibility = {
'stocks': {},
'last_refresh': datetime.now(timezone.utc).isoformat(),
'source': 'bist100_scan',
}
for sym, v in s2.items():
eligibility['stocks'][sym] = {
'symbol': sym,
'eligible': v.get('eligible', False),
'dir_acc': v.get('dir_acc', 0),
'sharpe': v.get('sharpe', 0),
'hit_rate': v.get('hit_rate', 0),
'total_return_pct': v.get('total_return_pct', 0),
'trades': v.get('trades', 0),
'reason': v.get('reason', 'unknown'),
'evaluated_at': v.get('evaluated_at', ''),
}
with open('paper_trading/stock_eligibility.json', 'w') as f:
json.dump(eligibility, f, indent=2, default=str)
elig = [s for s, v in eligibility['stocks'].items() if v['eligible']]
print(f'Updated stock_eligibility.json with {len(eligibility["stocks"])} stocks')
print(f'Eligible: {len(elig)} - {sorted(elig)}')