Local changes: Updated model training, removed debug instrumentation, and configuration improvements

This commit is contained in:
kfox
2025-12-26 01:15:43 -05:00
commit cc60da49e7
388 changed files with 57127 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
Alert System
============
Alert system for price, indicator, risk, and system notifications.
Alert Engine
------------
.. automodule:: src.alerts.engine
:members:
:undoc-members:
:show-inheritance:
Alert Manager
-------------
.. automodule:: src.alerts.manager
:members:
:undoc-members:
:show-inheritance:
Alert Channels
--------------
.. automodule:: src.alerts.channels
:members:
:undoc-members:
:show-inheritance:

View File

@@ -0,0 +1,37 @@
Backtesting Engine
==================
The backtesting engine enables strategy evaluation on historical data.
Backtesting Engine
------------------
.. automodule:: src.backtesting.engine
:members:
:undoc-members:
:show-inheritance:
Performance Metrics
-------------------
.. automodule:: src.backtesting.metrics
:members:
:undoc-members:
:show-inheritance:
Slippage and Fees
-----------------
.. automodule:: src.backtesting.slippage
:members:
:undoc-members:
:show-inheritance:
Data Provider
-------------
.. automodule:: src.backtesting.data_provider
:members:
:undoc-members:
:show-inheritance:

80
docs/api/source/conf.py Normal file
View File

@@ -0,0 +1,80 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
import sys
import os
# Add the project root to the path
sys.path.insert(0, os.path.abspath('../../..'))
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
project = 'Crypto Trader'
copyright = '2025, kfox'
author = 'kfox'
release = '0.1.0'
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.viewcode',
'sphinx.ext.napoleon', # For Google-style docstrings
'sphinx_autodoc_typehints', # Type hints in docs
]
templates_path = ['_templates']
exclude_patterns = []
# Napoleon settings for Google-style docstrings
napoleon_google_docstring = True
napoleon_numpy_docstring = False
napoleon_include_init_with_doc = False
napoleon_include_private_with_doc = False
napoleon_include_special_with_doc = True
napoleon_use_admonition_for_examples = False
napoleon_use_admonition_for_notes = False
napoleon_use_admonition_for_references = False
napoleon_use_ivar = False
napoleon_use_param = True
napoleon_use_rtype = True
# Autodoc settings
autodoc_default_options = {
'members': True,
'undoc-members': True,
'show-inheritance': True,
'special-members': '__init__',
}
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']
html_theme_options = {
'collapse_navigation': False,
'display_version': True,
'logo_only': False,
}
# -- Options for intersphinx extension ---------------------------------------
# https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html#configuration
intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
'pandas': ('https://pandas.pydata.org/docs/', None),
'sqlalchemy': ('https://docs.sqlalchemy.org/en/latest/', None),
'ccxt': ('https://docs.ccxt.com/en/latest/', None),
}
# -- Options for todo extension ----------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/extensions/todo.html#configuration
todo_include_todos = True

94
docs/api/source/data.rst Normal file
View File

@@ -0,0 +1,94 @@
Data Collection and Indicators
================================
Data collection, storage, and technical indicator calculations.
Technical Indicators
--------------------
.. automodule:: src.data.indicators
:members:
:undoc-members:
:show-inheritance:
Data Collector
--------------
.. automodule:: src.data.collector
:members:
:undoc-members:
:show-inheritance:
Data Storage
------------
.. automodule:: src.data.storage
:members:
:undoc-members:
:show-inheritance:
Data Quality
------------
.. automodule:: src.data.quality
:members:
:undoc-members:
:show-inheritance:
Pricing Service
---------------
The unified pricing service manages multiple data providers with automatic failover.
.. automodule:: src.data.pricing_service
:members:
:undoc-members:
:show-inheritance:
Pricing Providers
-----------------
Base Provider Interface
~~~~~~~~~~~~~~~~~~~~~~~
.. automodule:: src.data.providers.base_provider
:members:
:undoc-members:
:show-inheritance:
CCXT Provider
~~~~~~~~~~~~~
.. automodule:: src.data.providers.ccxt_provider
:members:
:undoc-members:
:show-inheritance:
CoinGecko Provider
~~~~~~~~~~~~~~~~~~
.. automodule:: src.data.providers.coingecko_provider
:members:
:undoc-members:
:show-inheritance:
Cache Manager
-------------
Intelligent caching system for pricing data.
.. automodule:: src.data.cache_manager
:members:
:undoc-members:
:show-inheritance:
Health Monitor
--------------
Provider health monitoring and failover management.
.. automodule:: src.data.health_monitor
:members:
:undoc-members:
:show-inheritance:

View File

@@ -0,0 +1,40 @@
Exchange Adapters
=================
The exchange adapter system provides a unified interface for trading on multiple cryptocurrency exchanges.
Base Exchange Adapter
---------------------
.. automodule:: src.exchanges.base
:members:
:undoc-members:
:show-inheritance:
Exchange Factory
----------------
.. automodule:: src.exchanges.factory
:members:
:undoc-members:
:show-inheritance:
Coinbase Exchange
-----------------
.. automodule:: src.exchanges.coinbase
:members:
:undoc-members:
:show-inheritance:
WebSocket Support
-----------------
The Coinbase adapter includes WebSocket subscription methods:
- ``subscribe_ticker()``: Subscribe to real-time price updates
- ``subscribe_orderbook()``: Subscribe to order book changes
- ``subscribe_trades()``: Subscribe to trade executions
These methods support real-time data streaming for UI updates.

27
docs/api/source/index.rst Normal file
View File

@@ -0,0 +1,27 @@
Crypto Trader API Documentation
================================
Welcome to the Crypto Trader API documentation. This documentation provides comprehensive reference for all public APIs, classes, and functions in the Crypto Trader application.
.. toctree::
:maxdepth: 2
:caption: API Reference:
modules
exchanges
strategies
trading
backtesting
portfolio
risk
data
market_data
alerts
security
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

View File

@@ -0,0 +1,312 @@
Market Data API
===============
REST API endpoints for market data and pricing information.
Market Data Endpoints
---------------------
OHLCV Data
~~~~~~~~~~
**GET** ``/api/market-data/ohlcv/{symbol}``
Get OHLCV (Open, High, Low, Close, Volume) candlestick data for a symbol.
**Parameters:**
- ``symbol`` (path, required): Trading pair symbol (e.g., "BTC/USD")
- ``timeframe`` (query, optional): Timeframe for candles (default: "1h")
- Valid values: "1m", "5m", "15m", "30m", "1h", "4h", "1d", "1w"
- ``limit`` (query, optional): Number of candles to return (default: 100, max: 1000)
- ``exchange`` (query, optional): Exchange name (deprecated, uses pricing service)
**Response:**
.. code-block:: json
[
{
"time": 1609459200,
"open": 50000.0,
"high": 51000.0,
"low": 49000.0,
"close": 50000.0,
"volume": 1000.0
}
]
**Example:**
.. code-block:: bash
curl http://localhost:8000/api/market-data/ohlcv/BTC%2FUSD?timeframe=1h&limit=100
Ticker Data
~~~~~~~~~~~
**GET** ``/api/market-data/ticker/{symbol}``
Get current ticker data for a symbol, including price, volume, and provider information.
**Parameters:**
- ``symbol`` (path, required): Trading pair symbol (e.g., "BTC/USD")
**Response:**
.. code-block:: json
{
"symbol": "BTC/USD",
"bid": 50000.0,
"ask": 50001.0,
"last": 50000.5,
"high": 51000.0,
"low": 49000.0,
"volume": 1000000.0,
"timestamp": 1609459200000,
"provider": "CCXT-Kraken"
}
**Example:**
.. code-block:: bash
curl http://localhost:8000/api/market-data/ticker/BTC%2FUSD
Provider Health
~~~~~~~~~~~~~~~
**GET** ``/api/market-data/providers/health``
Get health status for pricing providers.
**Parameters:**
- ``provider`` (query, optional): Specific provider name to get health for
**Response:**
.. code-block:: json
{
"active_provider": "CCXT-Kraken",
"health": {
"CCXT-Kraken": {
"status": "healthy",
"last_check": "2025-01-01T12:00:00Z",
"last_success": "2025-01-01T12:00:00Z",
"success_count": 100,
"failure_count": 2,
"avg_response_time": 0.123,
"consecutive_failures": 0,
"circuit_breaker_open": false
}
}
}
**Example:**
.. code-block:: bash
curl http://localhost:8000/api/market-data/providers/health?provider=CCXT-Kraken
Provider Status
~~~~~~~~~~~~~~~
**GET** ``/api/market-data/providers/status``
Get detailed status for all pricing providers, including cache statistics.
**Response:**
.. code-block:: json
{
"active_provider": "CCXT-Kraken",
"providers": {
"CCXT-Kraken": {
"status": "healthy",
"last_check": "2025-01-01T12:00:00Z",
"success_count": 100,
"failure_count": 2,
"avg_response_time": 0.123
},
"CoinGecko": {
"status": "unknown",
"success_count": 0,
"failure_count": 0
}
},
"cache": {
"size": 50,
"max_size": 1000,
"hits": 1000,
"misses": 200,
"hit_rate": 83.33,
"evictions": 0,
"avg_age_seconds": 30.5
}
}
**Example:**
.. code-block:: bash
curl http://localhost:8000/api/market-data/providers/status
Provider Configuration
~~~~~~~~~~~~~~~~~~~~~~
**GET** ``/api/market-data/providers/config``
Get current provider configuration.
**Response:**
.. code-block:: json
{
"primary": [
{
"name": "kraken",
"enabled": true,
"priority": 1
},
{
"name": "coinbase",
"enabled": true,
"priority": 2
}
],
"fallback": {
"name": "coingecko",
"enabled": true,
"api_key": ""
},
"caching": {
"ticker_ttl": 2,
"ohlcv_ttl": 60,
"max_cache_size": 1000
},
"websocket": {
"enabled": true,
"reconnect_interval": 5,
"ping_interval": 30
}
}
**Example:**
.. code-block:: bash
curl http://localhost:8000/api/market-data/providers/config
Update Provider Configuration
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**PUT** ``/api/market-data/providers/config``
Update provider configuration.
**Request Body:**
.. code-block:: json
{
"primary": [
{
"name": "kraken",
"enabled": true,
"priority": 1
}
],
"caching": {
"ticker_ttl": 5,
"ohlcv_ttl": 120
}
}
**Response:**
.. code-block:: json
{
"message": "Configuration updated successfully",
"config": {
"primary": [...],
"fallback": {...},
"caching": {...},
"websocket": {...}
}
}
**Example:**
.. code-block:: bash
curl -X PUT http://localhost:8000/api/market-data/providers/config \
-H "Content-Type: application/json" \
-d '{"caching": {"ticker_ttl": 5}}'
WebSocket Updates
-----------------
The WebSocket endpoint at ``/ws`` broadcasts real-time price updates.
**Connection:**
.. code-block:: javascript
const ws = new WebSocket('ws://localhost:8000/ws');
ws.onopen = () => {
// Subscribe to symbol updates
ws.send(JSON.stringify({
type: 'subscribe',
symbol: 'BTC/USD'
}));
};
ws.onmessage = (event) => {
const message = JSON.parse(event.data);
if (message.type === 'price_update') {
console.log('Price update:', message);
}
};
**Message Types:**
- ``subscribe``: Subscribe to price updates for a symbol
- ``unsubscribe``: Unsubscribe from price updates
- ``price_update``: Price update broadcast (contains exchange, symbol, price, timestamp)
- ``provider_status_update``: Provider status change notification
**Price Update Message:**
.. code-block:: json
{
"type": "price_update",
"exchange": "pricing",
"symbol": "BTC/USD",
"price": "50000.50",
"timestamp": "2025-01-01T12:00:00Z"
}
Error Responses
---------------
All endpoints may return standard HTTP error codes:
- ``400 Bad Request``: Invalid request parameters
- ``404 Not Found``: Symbol or provider not found
- ``500 Internal Server Error``: Server error
Error response format:
.. code-block:: json
{
"detail": "Error message describing what went wrong"
}

View File

@@ -0,0 +1,18 @@
Modules
=====
.. automodule:: src.core
:members:
:undoc-members:
:show-inheritance:
Core Modules
------------
.. toctree::
:maxdepth: 2
core/config
core/database
core/logger

View File

@@ -0,0 +1,21 @@
Portfolio Management
====================
Portfolio tracking and analytics for monitoring trading performance.
Portfolio Tracker
-----------------
.. automodule:: src.portfolio.tracker
:members:
:undoc-members:
:show-inheritance:
Portfolio Analytics
-------------------
.. automodule:: src.portfolio.analytics
:members:
:undoc-members:
:show-inheritance:

37
docs/api/source/risk.rst Normal file
View File

@@ -0,0 +1,37 @@
Risk Management
===============
Risk management system for controlling trading exposure and losses.
Risk Manager
------------
.. automodule:: src.risk.manager
:members:
:undoc-members:
:show-inheritance:
Stop Loss
---------
.. automodule:: src.risk.stop_loss
:members:
:undoc-members:
:show-inheritance:
Position Sizing
---------------
.. automodule:: src.risk.position_sizing
:members:
:undoc-members:
:show-inheritance:
Risk Limits
-----------
.. automodule:: src.risk.limits
:members:
:undoc-members:
:show-inheritance:

View File

@@ -0,0 +1,29 @@
Security
========
Security features for API key management and encryption.
Encryption
----------
.. automodule:: src.security.encryption
:members:
:undoc-members:
:show-inheritance:
Key Manager
-----------
.. automodule:: src.security.key_manager
:members:
:undoc-members:
:show-inheritance:
Audit Logging
-------------
.. automodule:: src.security.audit
:members:
:undoc-members:
:show-inheritance:

View File

@@ -0,0 +1,120 @@
Strategy Framework
==================
The strategy framework enables creation and management of trading strategies.
Base Strategy
-------------
.. automodule:: src.strategies.base
:members:
:undoc-members:
:show-inheritance:
Strategy Registry
-----------------
.. automodule:: src.strategies.base
:members: StrategyRegistry
:undoc-members:
:show-inheritance:
Technical Strategies
--------------------
RSI Strategy
~~~~~~~~~~~
.. automodule:: src.strategies.technical.rsi_strategy
:members:
:undoc-members:
:show-inheritance:
MACD Strategy
~~~~~~~~~~~~~
.. automodule:: src.strategies.technical.macd_strategy
:members:
:undoc-members:
:show-inheritance:
Moving Average Strategy
~~~~~~~~~~~~~~~~~~~~~~~~
.. automodule:: src.strategies.technical.moving_avg_strategy
:members:
:undoc-members:
:show-inheritance:
DCA Strategy
~~~~~~~~~~~~
.. automodule:: src.strategies.dca.dca_strategy
:members:
:undoc-members:
:show-inheritance:
Grid Strategy
~~~~~~~~~~~~~
.. automodule:: src.strategies.grid.grid_strategy
:members:
:undoc-members:
:show-inheritance:
Momentum Strategy
~~~~~~~~~~~~~~~~~
.. automodule:: src.strategies.momentum.momentum_strategy
:members:
:undoc-members:
:show-inheritance:
Confirmed Strategy
~~~~~~~~~~~~~~~~~~
.. automodule:: src.strategies.technical.confirmed_strategy
:members:
:undoc-members:
:show-inheritance:
Divergence Strategy
~~~~~~~~~~~~~~~~~~~
.. automodule:: src.strategies.technical.divergence_strategy
:members:
:undoc-members:
:show-inheritance:
Bollinger Mean Reversion Strategy
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. automodule:: src.strategies.technical.bollinger_mean_reversion
:members:
:undoc-members:
:show-inheritance:
Consensus Strategy (Ensemble)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. automodule:: src.strategies.ensemble.consensus_strategy
:members:
:undoc-members:
:show-inheritance:
Timeframe Manager
-----------------
.. automodule:: src.strategies.timeframe_manager
:members:
:undoc-members:
:show-inheritance:
Strategy Scheduler
----------------
.. automodule:: src.strategies.scheduler
:members:
:undoc-members:
:show-inheritance:

View File

@@ -0,0 +1,45 @@
Trading Engine
==============
The trading engine handles order execution, position management, and exchange interactions.
Trading Engine
--------------
.. automodule:: src.trading.engine
:members:
:undoc-members:
:show-inheritance:
Order Manager
-------------
.. automodule:: src.trading.order_manager
:members:
:undoc-members:
:show-inheritance:
Paper Trading
-------------
.. automodule:: src.trading.paper_trading
:members:
:undoc-members:
:show-inheritance:
Advanced Orders
---------------
.. automodule:: src.trading.advanced_orders
:members:
:undoc-members:
:show-inheritance:
Futures Trading
---------------
.. automodule:: src.trading.futures
:members:
:undoc-members:
:show-inheritance: