Market Watch: multiplayer GARP paper trading simulator
- Game engine with multiplayer support (create games, join, leaderboard) - GARP stock screener (S&P 500 + 400 MidCap, 900+ tickers) - Automated trading logic for AI player (Case) - Web portal at marketwatch.local:8889 with dark theme - Systemd timer for Mon-Fri market hours - Telegram alerts on trades and daily summary - Stock analysis deep dive data (BAC, CFG, FITB, INCY) - Expanded scan results (22 GARP candidates) - Craigslist account setup + credentials
This commit is contained in:
51
projects/market-watch/portfolio.py
Executable file
51
projects/market-watch/portfolio.py
Executable file
@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Portfolio module — backward-compatible wrapper around game_engine.
|
||||
|
||||
All operations now delegate to game_engine using the default game and 'case' player.
|
||||
"""
|
||||
|
||||
import json
|
||||
import game_engine
|
||||
|
||||
INITIAL_CASH = 100_000.0
|
||||
|
||||
|
||||
def _default():
|
||||
"""Get default game ID."""
|
||||
return game_engine.get_default_game_id() or game_engine.ensure_default_game()
|
||||
|
||||
|
||||
def buy(ticker, shares, price, reason="GARP signal"):
|
||||
return game_engine.buy(_default(), "case", ticker, shares, price, reason)
|
||||
|
||||
|
||||
def sell(ticker, shares=None, price=None, reason="GARP exit"):
|
||||
return game_engine.sell(_default(), "case", ticker, shares, price, reason)
|
||||
|
||||
|
||||
def update_price(ticker, price):
|
||||
game_engine.update_price(_default(), "case", ticker, price)
|
||||
|
||||
|
||||
def get_portfolio():
|
||||
return game_engine.get_portfolio(_default(), "case")
|
||||
|
||||
|
||||
def get_history():
|
||||
return game_engine.get_trades(_default(), "case")
|
||||
|
||||
|
||||
def daily_snapshot():
|
||||
return game_engine.daily_snapshot(_default(), "case")
|
||||
|
||||
|
||||
def get_snapshots():
|
||||
return game_engine.get_snapshots(_default(), "case")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
p = get_portfolio()
|
||||
if p:
|
||||
print(json.dumps(p, indent=2))
|
||||
else:
|
||||
print("No default game found. Run: python3 game_engine.py")
|
||||
Reference in New Issue
Block a user