- Add advanced metrics dashboard with trade analytics - Add new trading components (EntryTypeAnalysis, MultiDayPositionTracker, NewsEventTracker, etc.) - Add strategy mode selector and trend confirmation - Add risk automation panel and slippage correlation analysis - Add daily trading plan enhancements with modal components - Add custom hooks (useApi, useLocalStorage, useAdvancedTradeMetrics) - Add broker service integration and trading API - Add test setup and vitest configuration - Include parquet data files for live market data - Add comprehensive documentation in docs/ folder
61 lines
1.5 KiB
Python
61 lines
1.5 KiB
Python
from fastapi.testclient import TestClient
|
|
from app.main import app
|
|
|
|
client = TestClient(app)
|
|
|
|
def pr(resp):
|
|
try:
|
|
print(resp.status_code)
|
|
print(resp.json())
|
|
except Exception:
|
|
print(resp.status_code)
|
|
print(resp.text)
|
|
|
|
print('Resetting simulation')
|
|
resp = client.post('/api/trading/reset')
|
|
pr(resp)
|
|
|
|
print('\nPortfolio BEFORE trade')
|
|
resp = client.get('/api/trading/portfolio')
|
|
pr(resp)
|
|
|
|
print('\nExecute BUY')
|
|
resp = client.post('/api/trading/execute', json={'action': 'BUY', 'quantity': 10, 'price': 2050})
|
|
pr(resp)
|
|
|
|
print('\nPortfolio AFTER BUY')
|
|
resp = client.get('/api/trading/portfolio')
|
|
pr(resp)
|
|
|
|
print('\nTrade History')
|
|
resp = client.get('/api/trading/history')
|
|
pr(resp)
|
|
|
|
print('\nExecute SELL partial')
|
|
resp = client.post('/api/trading/execute', json={'action': 'SELL', 'quantity': 5, 'price': 2060})
|
|
pr(resp)
|
|
|
|
print('\nPortfolio AFTER SELL')
|
|
resp = client.get('/api/trading/portfolio')
|
|
pr(resp)
|
|
|
|
print('\nPerformance metrics')
|
|
resp = client.get('/api/performance/performance')
|
|
pr(resp)
|
|
|
|
print('\nEquity history')
|
|
resp = client.get('/api/performance/equity-history')
|
|
pr(resp)
|
|
|
|
print('\nPosition metrics')
|
|
resp = client.get('/api/positions/metrics?symbol=XAUUSD&timeframe=1m')
|
|
pr(resp)
|
|
|
|
print('\nAI analyze live')
|
|
resp = client.post('/api/ai/analyze/live', json={'symbol': 'XAUUSD', 'timeframe': '1m', 'limit': 200})
|
|
pr(resp)
|
|
|
|
print('\nAI generate plan')
|
|
resp = client.post('/api/ai/generate-plan', json={'symbol': 'XAUUSD', 'timeframe': '1m', 'limit': 200, 'current_price': 2050, 'user_capital': 100000})
|
|
pr(resp)
|