From 58e9f366b20f883bae2217201c7b03530ca97a94 Mon Sep 17 00:00:00 2001 From: Dectrick McGee Date: Wed, 19 Feb 2025 22:09:49 +0000 Subject: [PATCH] pages update --- docs/_layouts/default.html | 69 ++++++++-- docs/assets/css/main.scss | 108 +++++++++++++++- docs/backtesting.html | 229 +++++++++++++++++++++++++++------ docs/charts_display.html | 252 +++++++++++++++++++++++++++++++------ docs/data_server.html | 252 ++++++++++++++++++++++++++++++------- docs/index.html | 198 ++++++++++++++++++++++++----- 6 files changed, 937 insertions(+), 171 deletions(-) diff --git a/docs/_layouts/default.html b/docs/_layouts/default.html index 6749a13..d4abf03 100644 --- a/docs/_layouts/default.html +++ b/docs/_layouts/default.html @@ -1,20 +1,63 @@ - - -{% include head.html %} - - + + + + + {{ page.title }} - Trading Pal Documentation + + + + + + - {% include topnav.html %} +
+
+ +
+
+ {{ content }} +
+
+
+
-
-
- {{ content }} +
+
+ Trading Pal Documentation
-
+ - {% include footer.html %} - {% include js_files.html %} + + + - diff --git a/docs/assets/css/main.scss b/docs/assets/css/main.scss index d526be8..3879df4 100755 --- a/docs/assets/css/main.scss +++ b/docs/assets/css/main.scss @@ -1,5 +1,109 @@ --- --- -@import "minima"; -// Add any custom styles below this line +// Custom styles +.content { + pre { + background: #1a1a1a; + padding: 1rem; + border-radius: 0.5rem; + margin: 1.5rem 0; + } + + code { + color: #e83e8c; + } + + h1, h2, h3, h4, h5, h6 { + margin-top: 2rem; + margin-bottom: 1rem; + color: #fff; + } + + p { + line-height: 1.7; + margin-bottom: 1.5rem; + } +} + +.sidebar { + position: sticky; + top: 2rem; + + .list-group-item { + &:hover { + background-color: #2d2d2d !important; + } + + &.active { + background-color: #0d6efd !important; + } + } +} + +.navbar { + box-shadow: 0 2px 4px rgba(0,0,0,.2); +} + +// API endpoint styling +.api-endpoint { + background: #2d2d2d; + padding: 1rem; + border-radius: 0.5rem; + margin: 1rem 0; + + .method { + color: #0d6efd; + font-weight: bold; + } + + .path { + color: #28a745; + } +} + +// Documentation sections +.doc-section { + margin-bottom: 3rem; + + .section-title { + border-bottom: 2px solid #0d6efd; + padding-bottom: 0.5rem; + margin-bottom: 1.5rem; + } +} + +// Table styling +table { + width: 100%; + margin-bottom: 1rem; + background-color: #2d2d2d; + border-radius: 0.5rem; + overflow: hidden; + + th, td { + padding: 1rem; + border-bottom: 1px solid #1a1a1a; + } + + th { + background-color: #1a1a1a; + color: #fff; + } +} + +// Code block improvements +.language-json { + .token.property { + color: #9cdcfe; + } + .token.string { + color: #ce9178; + } + .token.number { + color: #b5cea8; + } + .token.boolean { + color: #569cd6; + } +} diff --git a/docs/backtesting.html b/docs/backtesting.html index 88b5272..a8e47a8 100644 --- a/docs/backtesting.html +++ b/docs/backtesting.html @@ -1,40 +1,189 @@ - - - - - - Trading Pal Documentation - Backtesting - - -
-

Trading Pal Backtesting and Natural Language Trading Logic

-

Trading Pal's backtesting engine uses historical market data to simulate trading strategies. This document details the backtesting process and how to interpret the results.

- -

Backtesting Process

-
    -
  1. Data Acquisition: The backtesting engine retrieves historical market data from the data server.
  2. -
  3. Strategy Simulation: The engine simulates the specified trading strategy using the historical data.
  4. -
  5. Performance Evaluation: The engine evaluates the performance of the strategy based on various metrics (e.g., Sharpe ratio, maximum drawdown).
  6. -
  7. Results Presentation: The engine presents the results in a clear and concise format, including charts and tables.
  8. -
- -

Interpreting Results

-

The backtesting results provide valuable insights into the performance of a trading strategy. Key metrics to consider include:

-
    -
  • Total Return: The overall profit or loss of the strategy.
  • -
  • Sharpe Ratio: A measure of risk-adjusted return.
  • -
  • Maximum Drawdown: The largest peak-to-trough decline in the strategy's value.
  • -
  • Win Rate: The percentage of trades that were profitable.
  • -
- -

Examples

-

Backtesting Results

-

-Total Return: 10%
-Sharpe Ratio: 1.5
-Maximum Drawdown: 5%
-Win Rate: 60%
-    
-
- - +--- +layout: default +title: Backtesting +--- + +
+

Trading Pal Backtesting Engine

+

Trading Pal's advanced backtesting engine combines natural language processing with sophisticated market analysis to test trading strategies across multiple asset classes. Our AI-powered system enables traders to define strategies in plain English while providing comprehensive performance metrics and risk analysis.

+
+ +
+

Natural Language Strategy Definition

+
+

Example Strategy Commands

+
"Buy when the 20-day moving average crosses above the 50-day moving average and RSI is below 70"
+
+"Sell if price drops below the lower Bollinger Band and volume is above the 20-day average"
+
+"Long entry when MACD histogram turns positive and price is above 200-day MA"
+
+"Place a buy order for 100 shares when RSI drops below 30"
+
+"Execute short position if price breaks below support with increased volume"
+
+
+ +
+

Multi-Market Testing

+
+
+
+
+
Stocks (via Alpaca)
+
    +
  • ✓ US Equities
  • +
  • ✓ Real-time data
  • +
  • ✓ Historical prices
  • +
  • ✓ Volume analysis
  • +
+
+
+
+
+
+
+
Forex (via OANDA)
+
    +
  • ✓ Major pairs
  • +
  • ✓ Minor pairs
  • +
  • ✓ Tick data
  • +
  • ✓ Spread analysis
  • +
+
+
+
+
+
+
+
Crypto (via Alpaca)
+
    +
  • ✓ Major cryptocurrencies
  • +
  • ✓ 24/7 trading
  • +
  • ✓ Order book data
  • +
  • ✓ Market depth
  • +
+
+
+
+
+
+ +
+

AI-Powered Analysis

+
+
+
+
+

Strategy Validation

+

Our AI agents validate trading strategies by analyzing:

+
    +
  • ✓ Historical performance
  • +
  • ✓ Risk metrics
  • +
  • ✓ Market conditions
  • +
  • ✓ Correlation analysis
  • +
+
+
+
+
+
+
+

Performance Metrics

+
{
+  "totalReturn": "25.8%",
+  "sharpeRatio": 1.85,
+  "maxDrawdown": "12.3%",
+  "winRate": "62.5%",
+  "profitFactor": 1.75,
+  "averageTrade": "$245.50",
+  "tradeCount": 156
+}
+
+
+
+
+
+ +
+

Advanced Features

+
+
+
+
+
Multi-Broker Testing
+

Test strategies across different brokers and markets simultaneously, with unified reporting and analysis.

+
+
+
+
+
+
+
AI Strategy Optimization
+

Machine learning algorithms optimize strategy parameters based on historical performance.

+
+
+
+
+
+
+
Risk Analysis
+

Comprehensive risk assessment including VaR, correlation analysis, and stress testing.

+
+
+
+
+
+ +
+

Natural Language Commands

+
+

Available Commands

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Command TypeExampleDescription
Strategy Definition"Buy when RSI is oversold and MACD crosses up"Define trading rules in plain English
Performance Analysis"Show me the strategy performance for last month"Request specific performance metrics
Risk Management"Set stop loss at 2% per trade"Configure risk parameters
Portfolio Management"Optimize position sizes for maximum Sharpe ratio"Portfolio optimization commands
+
+
+ +
+

Integration with Trading Pal Agent

+
+

AI Agent Capabilities

+

The Trading Pal AI agent enhances backtesting by:

+
    +
  • Validating strategy logic and parameters
  • +
  • Suggesting optimizations based on historical performance
  • +
  • Monitoring for potential risks and correlations
  • +
  • Providing natural language insights and recommendations
  • +
  • Automating strategy deployment across multiple brokers
  • +
+
+
diff --git a/docs/charts_display.html b/docs/charts_display.html index 59a98b1..330284b 100644 --- a/docs/charts_display.html +++ b/docs/charts_display.html @@ -1,42 +1,220 @@ - - - - - - Trading Pal Documentation - Charts Display - - -
-

Trading Pal Charts Display Logic

-

Trading Pal uses a client-side charting library to display market data. This document details the features and customization options of the charting library.

- -

Features

-
    -
  • Multiple chart types: Candlestick, line, bar, area.
  • -
  • Technical indicators: Moving averages, RSI, MACD, Bollinger Bands.
  • -
  • Customizable appearance: Colors, styles, fonts.
  • -
  • Interactive features: Zooming, panning, crosshairs.
  • -
- -

Customization

-

The charting library can be customized through various configuration options. See the examples below.

- -

Examples

-

Basic Candlestick Chart

-

+---
+layout: default
+title: Charts Display
+---
+
+
+

Trading Pal Charts Display

+

Trading Pal's charting system provides a powerful visualization platform that integrates with our AI trading agent and multiple data sources. The system supports real-time data from both Alpaca and OANDA, enabling comprehensive market analysis across stocks, forex, and cryptocurrencies.

+
+ +
+

Chart Types

+
+
+
+
+
Candlestick
+

Japanese candlestick charts with customizable colors and styles for price action analysis.

+
+
+
+
+
+
+
Line
+

Clean line charts ideal for trend analysis and price movement tracking.

+
+
+
+
+
+
+
Bar
+

Traditional OHLC bar charts with optional volume indicators.

+
+
+
+
+
+
+
Area
+

Filled area charts for visualizing cumulative data and volume analysis.

+
+
+
+
+
+ +
+

Market Coverage

+
+
+
+
+

Stocks (Alpaca)

+
    +
  • ✓ US Equities
  • +
  • ✓ Real-time Level 2 Data
  • +
  • ✓ Pre/Post Market Data
  • +
  • ✓ Historical OHLCV
  • +
+
+
+
+
+
+
+

Forex (OANDA)

+
    +
  • ✓ Major/Minor Pairs
  • +
  • ✓ Tick-by-Tick Data
  • +
  • ✓ Spread Information
  • +
  • ✓ Position Book Data
  • +
+
+
+
+
+
+
+

Crypto (Alpaca)

+
    +
  • ✓ Major Cryptocurrencies
  • +
  • ✓ 24/7 Market Data
  • +
  • ✓ Order Book Depth
  • +
  • ✓ Trade History
  • +
+
+
+
+
+
+ +
+

Technical Indicators

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CategoryIndicatorsCustomization
TrendMoving Averages (SMA, EMA, WMA), MACD, ADX, Parabolic SARPeriods, Colors, Styles
MomentumRSI, Stochastic, CCI, Williams %ROverbought/Oversold Levels
VolatilityBollinger Bands, ATR, Standard DeviationDeviation Multiplier, Period
VolumeOBV, Volume Profile, Money Flow IndexTime Periods, Display Style
+
+
+ +
+

AI Integration

+
+

Natural Language Chart Control

+

Control charts using natural language commands:

+
"Show me a 1-hour candlestick chart for EUR/USD"
+"Add Bollinger Bands with 20-period and 2 standard deviations"
+"Display RSI in a separate panel below"
+"Zoom to the last 5 trading days"
+"Save this chart layout as 'Forex Analysis'"
+
+
+ +
+

Interactive Features

+
+
+
+
+
Chart Controls
+
    +
  • 🖱️ Mouse wheel zoom
  • +
  • 👆 Click and drag to pan
  • +
  • 📏 Drawing tools
  • +
  • 📊 Multi-timeframe analysis
  • +
  • 🎯 Price alerts
  • +
+
+
+
+
+
+
+
Trading Integration
+
    +
  • 💼 One-click trading
  • +
  • 📈 Position visualization
  • +
  • ⚡ Real-time order updates
  • +
  • 💰 P&L tracking
  • +
  • 🎚️ Risk management overlays
  • +
+
+
+
+
+
+ +
+

Chart Configurations

+
// Example chart configuration
 const chart = new Chart({
   type: 'candlestick',
   data: {
-    labels: ['2025-02-12', '2025-02-13'],
-    datasets: [{
-      data: [
-        { open: 149.50, high: 150.00, low: 149.00, close: 149.75 },
-        { open: 149.75, high: 150.50, low: 149.50, close: 150.25 }
-      ]
+    symbol: 'NASDAQ:AAPL',
+    timeframe: '1H',
+    indicators: [{
+      type: 'ema',
+      period: 20,
+      color: '#2196f3'
+    }, {
+      type: 'bollinger',
+      period: 20,
+      stdDev: 2,
+      fill: 'rgba(33, 150, 243, 0.1)'
     }]
+  },
+  options: {
+    theme: 'dark',
+    autoScale: true,
+    volume: true,
+    crosshair: true
   }
-});
-    
-
- - +});
+
+ +
+

Advanced Features

+
+

Trading Pal Integration

+

The charting system integrates with Trading Pal's core features:

+
    +
  • AI-powered pattern recognition and alerts
  • +
  • Automated strategy visualization
  • +
  • Multi-broker order management
  • +
  • Real-time position tracking
  • +
  • Custom indicator development
  • +
  • Chart-based backtesting
  • +
+
+
diff --git a/docs/data_server.html b/docs/data_server.html index b884366..82d8421 100644 --- a/docs/data_server.html +++ b/docs/data_server.html @@ -1,51 +1,209 @@ - - - - - - Trading Pal Documentation - Data Server - - -
-

Trading Pal Data Server

-

The Trading Pal data server provides real-time market data via a REST API. This document details the API endpoints and data formats.

- -

API Endpoints

-
    -
  • /data/{symbol}: Returns real-time data for the specified symbol. `symbol` should be in the format `exchange:symbol` (e.g., `NASDAQ:AAPL`).
  • -
  • /historical/{symbol}/{start}/{end}: Returns historical data for the specified symbol between the given start and end dates. Dates should be in YYYY-MM-DD format.
  • -
- -

Data Formats

-

All data is returned in JSON format. The structure of the data will vary depending on the endpoint. See the examples below.

- -

Examples

-

Real-time Data

-

-{
+---
+layout: default
+title: Data Server
+---
+
+
+

Trading Pal Data Server

+

The Trading Pal data server is an experimental high-performance service that provides real-time market data to support various platform functionalities. This separate server architecture enables multi-functional capabilities including charting, algorithmic trading, AI analysis, and custom indicators.

+
+ +
+

Server Architecture

+
+
+
+
+

Core Features

+
    +
  • ✓ High-performance data processing
  • +
  • ✓ Real-time market data streaming
  • +
  • ✓ Historical data aggregation
  • +
  • ✓ Multi-source data integration
  • +
  • ✓ Custom data feed support
  • +
+
+
+
+
+
+
+

Integration Points

+
    +
  • ✓ Interactive charting system
  • +
  • ✓ AI trading algorithms
  • +
  • ✓ Technical indicators
  • +
  • ✓ Backtesting engine
  • +
  • ✓ Real-time analytics
  • +
+
+
+
+
+
+ +
+

API Endpoints

+ +
+

GET /data/{symbol}

+

Returns real-time market data for the specified symbol.

+ +

Parameters

+ + + + + + + + + + + + + + + +
ParameterTypeDescription
symbolstringTrading symbol in format exchange:symbol (e.g., NASDAQ:AAPL, OANDA:EUR_USD)
+ +

Example Response

+
{
   "symbol": "NASDAQ:AAPL",
   "timestamp": "2025-02-13T10:32:00Z",
   "price": 150.25,
-  "volume": 10000
-}
-    
-

Historical Data

-

-[
-  {
-    "symbol": "NASDAQ:AAPL",
-    "timestamp": "2025-02-12T10:00:00Z",
-    "price": 149.50,
-    "volume": 5000
-  },
-  {
-    "symbol": "NASDAQ:AAPL",
-    "timestamp": "2025-02-12T10:01:00Z",
-    "price": 149.75,
-    "volume": 6000
+  "volume": 10000,
+  "bid": 150.20,
+  "ask": 150.30,
+  "high": 151.00,
+  "low": 149.50,
+  "indicators": {
+    "rsi": 45.67,
+    "macd": {
+      "line": 0.35,
+      "signal": 0.28,
+      "histogram": 0.07
+    }
   }
-]
-    
-
- - +}
+
+ +
+

GET /historical/{symbol}/{start}/{end}

+

Returns historical market data for the specified symbol and date range.

+ +

Parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterTypeDescription
symbolstringTrading symbol in format exchange:symbol
startstringStart date in YYYY-MM-DD format
endstringEnd date in YYYY-MM-DD format
+
+
+ +
+

Data Sources

+
+
+
+
+

Alpaca Integration

+
    +
  • ✓ US Stock market data
  • +
  • ✓ Cryptocurrency data
  • +
  • ✓ Real-time updates
  • +
  • ✓ Historical data
  • +
+
+
+
+
+
+
+

OANDA Integration

+
    +
  • ✓ Forex market data
  • +
  • ✓ CFD data
  • +
  • ✓ Tick-by-tick data
  • +
  • ✓ Historical rates
  • +
+
+
+
+
+
+
+

Custom Data Feeds

+
    +
  • ✓ Alternative data
  • +
  • ✓ Economic indicators
  • +
  • ✓ Market sentiment
  • +
  • ✓ News feeds
  • +
+
+
+
+
+
+ +
+

Platform Integration

+
+

Multi-Functional Support

+

The data server enables various Trading Pal features:

+
+
+
    +
  • Interactive charting with real-time updates
  • +
  • AI-powered trading algorithms
  • +
  • Custom technical indicators
  • +
  • Backtesting simulations
  • +
+
+
+
    +
  • Market analysis tools
  • +
  • Portfolio tracking
  • +
  • Risk management systems
  • +
  • Performance analytics
  • +
+
+
+
+
+ +
+

Future Development

+
+

Upcoming Features

+

The experimental data server is continuously evolving with planned enhancements:

+
    +
  • Enhanced real-time data processing
  • +
  • Additional data sources and markets
  • +
  • Advanced caching mechanisms
  • +
  • Machine learning data preprocessing
  • +
  • Custom indicator development API
  • +
+
+
diff --git a/docs/index.html b/docs/index.html index 46d77c1..08d8a31 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,36 +1,170 @@ - - - - - - Trading Pal Documentation - - -
-

Trading Pal Documentation

+--- +layout: default +title: Home +--- -
-

Capabilities

-

Trading Pal offers a comprehensive suite of tools for algorithmic trading, including:

+
+

Trading Pal Documentation

+

Trading Pal is an advanced AI-powered trading platform that combines natural language processing, multi-broker integration, and comprehensive market analysis capabilities. Our platform enables traders to interact naturally with their trading environment while leveraging powerful data analysis and automated trading features.

+
+ +
+

Core Components

+
+
+
+
+

AI Trading Agent

+

Our intelligent trading agent understands natural language commands and can execute complex trading operations across multiple brokers and markets.

+
    +
  • ✓ Natural language order execution
  • +
  • ✓ Multi-broker account management
  • +
  • ✓ Automated trading strategies
  • +
  • ✓ Real-time market analysis
  • +
+
+ Example Commands:
+ "Show me my account details"
+ "Place a buy order for 100 shares of AAPL"
+ "Get the latest EUR/USD price" +
+
+
+
+
+
+
+

Broker Integration

+

Seamless integration with major brokers providing access to multiple markets and asset classes.

+
+
+
Alpaca
+
    +
  • ✓ US Stocks
  • +
  • ✓ Cryptocurrencies
  • +
  • ✓ Options Trading (Coming Soon)
  • +
+
+
+
OANDA
+
    +
  • ✓ Forex Trading
  • +
  • ✓ CFDs
  • +
  • ✓ Commodities
  • +
+
+
+
+
+
+
+
+ +
+

Platform Features

+
+
+
+
+

Data Server

+

Experimental high-performance data server providing:

+
    +
  • ✓ Real-time market data
  • +
  • ✓ Historical price data
  • +
  • ✓ Custom data feeds
  • +
  • ✓ API integration
  • +
+ Learn More +
+
+
+
+
+
+

Technical Analysis

+

Advanced charting and analysis tools:

+
    +
  • ✓ Multiple chart types
  • +
  • ✓ Technical indicators
  • +
  • ✓ Drawing tools
  • +
  • ✓ Real-time updates
  • +
+ Learn More +
+
+
+
+
+
+

Strategy Testing

+

Comprehensive backtesting capabilities:

+
    +
  • ✓ Natural language strategies
  • +
  • ✓ Performance metrics
  • +
  • ✓ Risk analysis
  • +
  • ✓ Portfolio optimization
  • +
+ Learn More +
+
+
+
+
+ +
+

Future Developments

+
+

Upcoming Features

+

Trading Pal is continuously evolving with new capabilities:

    -
  • Backtesting engine
  • -
  • Data server with real-time market data
  • -
  • Interactive charting library
  • -
  • Dual Broker System (Alpaca, Oanda) for comprehensive market coverage (Forex, Crypto, Stocks)
  • -
  • Natural Language Trading
  • -
  • User-friendly interface
  • +
  • Suite of AI LLM agents for advanced trading validation
  • +
  • Enhanced market analysis algorithms
  • +
  • Advanced risk management systems
  • +
  • Options trading integration
  • +
  • Expanded broker support
-
+
+ -
-

Getting Started

-

To get started with Trading Pal, follow these steps:

-
    -
  1. Install the necessary dependencies: pip install -r requirements.txt
  2. -
  3. Configure your broker credentials in user_config.py
  4. -
  5. Run the application: python main.py
  6. -
-
- - - +
+

Getting Started

+
+
+
+
+

Quick Start

+
    +
  1. Configure your broker API keys (Alpaca/OANDA)
  2. +
  3. Connect to the data server
  4. +
  5. Start interacting with the AI agent using natural language
  6. +
+
+
+
+
+
+
+

System Requirements

+ + + + + + + + + + + + + + + + + +
CPU4+ cores recommended
RAM8+ GB recommended
Storage20+ GB recommended
Network10+ Mbps stable connection
+
+
+
+
+