82c68fa8b0
- Switch to oil stocks (USO, XLE, OXY, CVX, XOM, SLB, HAL, DVN, MPC, VLO) - Add JPY/USD forex pairs for Japan targeting - 7-action RL space: long, short, close (was 5 long-only actions) - Bollinger Band mean-reversion scalp entries both directions - 5-minute candles with 60-second cycles for scalping - 35 features (added VWAP, fast RSI, fast ROC for scalping) - Short position support in backtest, executor, and RL environment - GA tuned for scalping: tighter SL/TP, shorter hold times Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
52 lines
1.8 KiB
Python
52 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Read BIGGFISH trade history from SQLite database for Krystie."""
|
|
import sqlite3, sys
|
|
|
|
DB = "/opt/biggfish/src/data/biggfish.db"
|
|
LIMIT = int(sys.argv[1]) if len(sys.argv) > 1 else 20
|
|
|
|
try:
|
|
db = sqlite3.connect(DB)
|
|
db.row_factory = sqlite3.Row
|
|
except Exception as e:
|
|
print("BIGGFISH database not found at", DB)
|
|
sys.exit(1)
|
|
|
|
rows = db.execute("""
|
|
SELECT symbol, side, amount, entry_price, exit_price,
|
|
entry_time, exit_time, pnl, pnl_pct, status, strategy_id
|
|
FROM trades
|
|
ORDER BY entry_time DESC
|
|
LIMIT ?
|
|
""", (LIMIT,)).fetchall()
|
|
|
|
if not rows:
|
|
print("No trades recorded yet.")
|
|
sys.exit(0)
|
|
|
|
print("=== BIGGFISH TRADE HISTORY (last {}) ===".format(len(rows)))
|
|
print()
|
|
print("{:<10} {:<6} {:>10} {:>10} {:>10} {:>8} {:<10} {:<20}".format(
|
|
"Symbol", "Side", "Entry", "Exit", "P&L", "P&L%", "Status", "Time"))
|
|
print("-" * 90)
|
|
|
|
for r in rows:
|
|
entry = "${:.4f}".format(r["entry_price"]) if r["entry_price"] else "-"
|
|
exit_p = "${:.4f}".format(r["exit_price"]) if r["exit_price"] else "-"
|
|
pnl = "${:+.2f}".format(r["pnl"]) if r["pnl"] is not None else "-"
|
|
pnl_pct = "{:+.1f}%".format(r["pnl_pct"]) if r["pnl_pct"] is not None else "-"
|
|
print("{:<10} {:<6} {:>10} {:>10} {:>10} {:>8} {:<10} {:<20}".format(
|
|
r["symbol"], r["side"], entry, exit_p, pnl, pnl_pct,
|
|
r["status"], str(r["entry_time"])[:19]))
|
|
|
|
closed = [r for r in rows if r["status"] == "closed" and r["pnl"] is not None]
|
|
if closed:
|
|
total_pnl = sum(r["pnl"] for r in closed)
|
|
wins = sum(1 for r in closed if r["pnl"] > 0)
|
|
losses = sum(1 for r in closed if r["pnl"] <= 0)
|
|
print()
|
|
print("Summary: {} closed trades | {} wins | {} losses | Total P&L: ${:+.2f}".format(
|
|
len(closed), wins, losses, total_pnl))
|
|
|
|
db.close()
|