Spaces:
Running
Running
Update app_routes.py
Browse files- app_routes.py +4 -4
app_routes.py
CHANGED
|
@@ -1,10 +1,9 @@
|
|
| 1 |
from fastapi import APIRouter, Request
|
| 2 |
from fastapi.responses import StreamingResponse
|
| 3 |
import aiosqlite, asyncio, random, json, logging
|
| 4 |
-
from npc_core import
|
| 5 |
-
ALL_TICKERS, TRADING_STRATEGIES, IDENTITY_STRATEGY_MAP,
|
| 6 |
-
NPCTargetPriceEngine, NPCElasticityEngine, GroqAIClient,)
|
| 7 |
from npc_trading import (
|
|
|
|
| 8 |
get_all_prices, get_ticker_positions, get_trading_leaderboard, get_trading_stats,
|
| 9 |
MarketDataFetcher, STOCK_TICKERS, CRYPTO_TICKERS,
|
| 10 |
record_profit_snapshots, backfill_profit_snapshots, get_hall_of_fame_data,
|
|
@@ -12,6 +11,7 @@ from npc_trading import (
|
|
| 12 |
purchase_research, get_research_stats, get_market_pulse,)
|
| 13 |
from npc_intelligence import (
|
| 14 |
MarketIndexCollector, ScreeningEngine, NPCResearchEngine,
|
|
|
|
| 15 |
load_indices_from_db, save_indices_to_db, load_news_from_db,
|
| 16 |
save_analysis_to_db, load_analysis_from_db, load_all_analyses_from_db,)
|
| 17 |
from npc_memory_evolution import get_npc_evolution_stats, get_evolution_leaderboard
|
|
@@ -509,4 +509,4 @@ async def api_recent_events(limit: int = 20):
|
|
| 509 |
trades = [{'user': r[1], 'identity': r[2], 'ticker': r[3], 'dir': r[4], 'gpu': r[5], 'leverage': r[6], 'time': r[7]} for r in await cursor.fetchall()]
|
| 510 |
cursor2 = await db.execute("SELECT p.agent_id, n.username, p.ticker, p.direction, p.gpu_bet, p.leverage, p.profit_gpu, p.profit_pct, p.liquidated, p.closed_at FROM npc_positions p JOIN npc_agents n ON p.agent_id = n.agent_id WHERE p.status IN ('closed', 'liquidated') AND p.closed_at > datetime('now', '-1 hour') ORDER BY p.closed_at DESC LIMIT ?", (limit,))
|
| 511 |
settlements = [{'user': r[1], 'ticker': r[2], 'dir': r[3], 'gpu': r[4], 'leverage': r[5], 'pnl': r[6], 'pnl_pct': r[7], 'liquidated': bool(r[8]), 'time': r[9]} for r in await cursor2.fetchall()]
|
| 512 |
-
return {"trades": trades, "settlements": settlements, "sse_clients": _EventBus.get().client_count}
|
|
|
|
| 1 |
from fastapi import APIRouter, Request
|
| 2 |
from fastapi.responses import StreamingResponse
|
| 3 |
import aiosqlite, asyncio, random, json, logging
|
| 4 |
+
from npc_core import GroqAIClient
|
|
|
|
|
|
|
| 5 |
from npc_trading import (
|
| 6 |
+
ALL_TICKERS, TRADING_STRATEGIES, IDENTITY_STRATEGY_MAP,
|
| 7 |
get_all_prices, get_ticker_positions, get_trading_leaderboard, get_trading_stats,
|
| 8 |
MarketDataFetcher, STOCK_TICKERS, CRYPTO_TICKERS,
|
| 9 |
record_profit_snapshots, backfill_profit_snapshots, get_hall_of_fame_data,
|
|
|
|
| 11 |
purchase_research, get_research_stats, get_market_pulse,)
|
| 12 |
from npc_intelligence import (
|
| 13 |
MarketIndexCollector, ScreeningEngine, NPCResearchEngine,
|
| 14 |
+
NPCTargetPriceEngine, NPCElasticityEngine,
|
| 15 |
load_indices_from_db, save_indices_to_db, load_news_from_db,
|
| 16 |
save_analysis_to_db, load_analysis_from_db, load_all_analyses_from_db,)
|
| 17 |
from npc_memory_evolution import get_npc_evolution_stats, get_evolution_leaderboard
|
|
|
|
| 509 |
trades = [{'user': r[1], 'identity': r[2], 'ticker': r[3], 'dir': r[4], 'gpu': r[5], 'leverage': r[6], 'time': r[7]} for r in await cursor.fetchall()]
|
| 510 |
cursor2 = await db.execute("SELECT p.agent_id, n.username, p.ticker, p.direction, p.gpu_bet, p.leverage, p.profit_gpu, p.profit_pct, p.liquidated, p.closed_at FROM npc_positions p JOIN npc_agents n ON p.agent_id = n.agent_id WHERE p.status IN ('closed', 'liquidated') AND p.closed_at > datetime('now', '-1 hour') ORDER BY p.closed_at DESC LIMIT ?", (limit,))
|
| 511 |
settlements = [{'user': r[1], 'ticker': r[2], 'dir': r[3], 'gpu': r[4], 'leverage': r[5], 'pnl': r[6], 'pnl_pct': r[7], 'liquidated': bool(r[8]), 'time': r[9]} for r in await cursor2.fetchall()]
|
| 512 |
+
return {"trades": trades, "settlements": settlements, "sse_clients": _EventBus.get().client_count}
|