Implemented comprehensive indicator management system for traders:
Backend (indicators.py):
- GET /api/indicators/available: All available indicators by category
- GET /api/indicators/categories: List of indicator categories
- GET /api/indicators/category/{category}: Indicators in specific category
- GET /api/indicators/{indicator_id}: Detailed indicator information
- GET /api/indicators/default: Recommended setup for gold trading
- GET /api/indicators/presets: 5 pre-configured trading setups
- POST /api/indicators/preset/{preset_id}/apply: Apply preset configuration
- POST /api/indicators/custom: Create custom indicator configuration
- GET /api/indicators/recommendations: Market condition-based recommendations
- POST /api/indicators/calculate/{indicator}: Calculate indicator values
- GET /api/indicators/alerts/golden-cross: Golden cross alerts
- GET /api/indicators/alerts/death-cross: Death cross alerts
- GET /api/indicators/alerts/divergence: Price/indicator divergence alerts
- GET /api/indicators/cheat-sheet: Quick reference guide
Indicator Categories:
1. Moving Averages: SMA, EMA, WMA with multiple periods
2. Oscillators: RSI, Stochastic, MACD, KDJ
3. Volatility: Bollinger Bands, ATR, Keltner Channels
4. Support/Resistance: Pivot Points, Fibonacci Retracement
5. Volume: OBV, CMF, Volume Profile
Pre-configured Presets:
- Scalping Setup (1-5 min): EMA 5/10, RSI, MACD, BB
- Swing Trading Setup (4h-1D): SMA 50/200, RSI, MACD, Pivot
- Position Trading Setup (1D+): SMA 50/200, RSI, BB, Fibonacci
- Volatility Focus: BB, ATR, Keltner Channel, OBV
- Momentum Focus: RSI, Stochastic, MACD, KDJ
Features:
- Market condition recommendations (trending/ranging/volatile/calm)
- Timeframe-specific setups (scalping/swing/position)
- Quick reference cheat sheet for all indicators
- Signal alerts: Golden/Death Cross, Divergences
- Indicator calculation engine for backtesting
Frontend (AdvancedIndicatorsPanel.tsx):
- Three main tabs: Presets, Custom Setup, Quick Guide
- Preset selector with one-click application
- Custom indicator builder with drag-select
- Category-based organization
- Type-based color coding
- Indicator details and parameters
- Selected indicators summary
- Pro tips and best practices
- Legend for indicator types
Integration:
- Added Indicators tab to main navigation
- Full TypeScript support
- Responsive layout for all screen sizes
- Real-time preset switching
- Custom configuration persistence
Trading Presets Include:
- Setup recommendations for different timeframes
- Indicator period suggestions
- Signal confirmation rules
- Best practices for each trading style
Note: Backend uses mock calculations. In production, integrate with:
- TA-Lib for technical analysis
- Real-time price data feeds
- WebSocket for live indicator calculations
81 lines
2.4 KiB
Python
81 lines
2.4 KiB
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from app.config import settings
|
|
from app.api import market, ai, trading, news, stream, ohlcv
|
|
from app.api import admin, stream_sse, decisions
|
|
from app.streaming.live_store import periodic_flush, periodic_maintenance
|
|
import asyncio
|
|
|
|
# Newly added routers
|
|
from app.api import account, performance, status, settings_api, prompts, daily_helper, analytics, economic_calendar, indicators
|
|
|
|
app = FastAPI(
|
|
title=settings.APP_NAME,
|
|
version=settings.APP_VERSION,
|
|
description="AI-Powered Gold Trading Scenario Simulator",
|
|
)
|
|
|
|
# CORS middleware
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=settings.CORS_ORIGINS,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Include routers
|
|
app.include_router(market.router, prefix="/api")
|
|
app.include_router(ai.router, prefix="/api")
|
|
app.include_router(trading.router, prefix="/api")
|
|
app.include_router(news.router, prefix="/api")
|
|
app.include_router(stream.router, prefix="/api")
|
|
app.include_router(ohlcv.router, prefix="/api")
|
|
app.include_router(admin.router, prefix="/api")
|
|
app.include_router(stream_sse.router, prefix="/api")
|
|
app.include_router(decisions.router, prefix="/api")
|
|
# New
|
|
app.include_router(account.router, prefix="/api")
|
|
app.include_router(account.router_positions, prefix="/api")
|
|
app.include_router(performance.router, prefix="/api")
|
|
app.include_router(status.router, prefix="/api")
|
|
app.include_router(settings_api.router, prefix="/api")
|
|
app.include_router(prompts.router, prefix="/api")
|
|
app.include_router(daily_helper.router)
|
|
app.include_router(analytics.router)
|
|
app.include_router(economic_calendar.router)
|
|
app.include_router(indicators.router)
|
|
|
|
|
|
@app.on_event("startup")
|
|
async def _startup():
|
|
# Schedule periodic parquet flush in background
|
|
asyncio.create_task(periodic_flush(interval_sec=60))
|
|
# Schedule retention+compaction maintenance every 15 minutes
|
|
asyncio.create_task(periodic_maintenance(retention_days=7, compact_threshold_files=20, interval_sec=900))
|
|
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {
|
|
"name": settings.APP_NAME,
|
|
"version": settings.APP_VERSION,
|
|
"status": "running",
|
|
}
|
|
|
|
|
|
@app.get("/health")
|
|
async def health_check():
|
|
return {"status": "healthy"}
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
|
|
uvicorn.run(
|
|
"app.main:app",
|
|
host=settings.HOST,
|
|
port=settings.PORT,
|
|
reload=settings.DEBUG,
|
|
)
|