A comprehensive algorithmic trading system built with .NET 8, designed for developing, testing, and executing trading strategies across multiple markets.
The system includes comprehensive documentation in the docs/ directory:
- Trading principles and core concepts
- Market-specific parameters and configurations
- Book references and study materials
- Implementation guidelines
- Detailed endpoint specifications
- Request/response schemas
- Authentication requirements
- Rate limits
- Installation instructions
- Configuration guidelines
- Environment setup
- Deployment procedures
- System architecture
- Component interactions
- Data flow diagrams
- Design decisions
- Backtesting methodology (
docs/backtesting/) - Risk management parameters (
docs/risk/) - Trading principles (
docs/principles/) - Example configurations (
docs/examples/)
The system is organized into several key layers, following the principles defined in our reference documentation:
- Core domain models and interfaces
- Shared utilities and extensions
- Cross-cutting concerns
- Core business logic
- Trading system coordination
- Strategy execution engine
- Data persistence
- External service integrations
- Repository implementations
- Strategy generation and optimization
- Backtesting engine
- Performance analysis
- Live trading execution
- Exchange integrations
- Risk management
- Market data processing
- Command-line interface
- System configuration
- Trading operations
- Flexible strategy definition framework
- Multiple timeframe support
- Custom indicator development
- Signal generation and filtering
- Genetic algorithm optimization
- Parameter space exploration
- Multi-objective optimization
- Performance metrics analysis
- Historical data simulation
- Transaction cost modeling
- Risk metrics calculation
- Performance reporting
- Multiple exchange support
- Order management
- Position tracking
- Risk control
- Market data streaming
- Swagger UI integration
- Interactive API testing
- Endpoint documentation
- Request/response schema documentation
The system exposes the following REST API endpoints for trading:
POST /api/Trading/place-order
Content-Type: application/json
{
"symbol": "BTCUSD",
"quantity": 0.1,
"price": 50000,
"isLong": true,
"orderType": 0
}GET /api/Trading/open-ordersPOST /api/Trading/close-order/{orderId}GET /api/Trading/market-data/{symbol}GET /api/Trading/balance?asset=USDT- Start the system:
dotnet run --project src/TradingSystem.Console/TradingSystem.Console.csproj- Place a test order:
curl -X POST http://localhost:3000/api/Trading/place-order \
-H "Content-Type: application/json" \
-d '{"symbol":"BTCUSD","quantity":0.1,"price":50000,"isLong":true,"orderType":0}'- View open orders:
curl http://localhost:3000/api/Trading/open-orders- Close an order (replace {orderId} with actual ID):
curl -X POST http://localhost:3000/api/Trading/close-order/{orderId}- Check market data:
curl http://localhost:3000/api/Trading/market-data/BTCUSDThe system includes a simulated exchange adapter for testing that:
- Maintains simulated prices for BTCUSD, ETHUSD, and XRPUSD
- Generates realistic order books and market data
- Simulates trade execution with PnL calculation
- Provides a test balance of 10,000 USDT
- Historical data storage
- Real-time data processing
- Market statistics calculation
- Data normalization
- Position sizing (following reference configuration parameters)
- Stop loss management with market-specific adjustments
- Portfolio allocation based on risk metrics
- Exposure monitoring with configurable limits
- Market-specific volatility adjustments
- .NET 8 SDK
- PostgreSQL 14+
- Docker (optional)
- Clone the repository:
git clone https://github.com/yourusername/tradingsystem.git
cd tradingsystem- Install dependencies:
dotnet restore- Set up the database:
cd src/Infrastructure
dotnet ef database update- Configure settings:
a. Set up application settings:
cp src/TradingSystem.Console/appsettings.json src/TradingSystem.Console/appsettings.Development.jsonb. Set up secrets:
cp config/secrets.template.json config/secrets.jsonc. Generate secure keys and passwords:
# On Unix/Linux/macOS
./scripts/generate-secrets.sh
# On Windows
.\scripts\generate-secrets.ps1The secrets configuration includes:
- Database credentials
- User: PostgreSQL username
- Password: Generated secure password
- Name: Database name
- Redis password for caching
- PgAdmin credentials
- Email: Admin email
- Password: Generated secure password
- Monitoring
- Grafana admin password
- Security
- JWT secret for authentication
- API key for external integrations
d. Load the secrets into your environment:
# On Unix/Linux/macOS
source scripts/load-secrets.sh
# On Windows
.\scripts\load-secrets.ps1- Build the solution:
dotnet buildStart the console application:
cd src/TradingSystem.Console
dotnet runAccess the API documentation:
- Navigate to
http://localhost/swaggerin your browser when running in Development environment - Interactive documentation of all API endpoints
- Test API endpoints directly from the Swagger UI
- Create a new strategy class:
public class MyStrategy : ITradingStrategy
{
public async Task<bool?> ShouldEnter(List<MarketData> data)
{
// Implement entry logic
}
public async Task<bool?> ShouldExit(List<MarketData> data)
{
// Implement exit logic
}
}- Register the strategy:
services.AddScoped<ITradingStrategy, MyStrategy>();- Implement the IExchangeAdapter interface:
public class MyExchangeAdapter : IExchangeAdapter
{
// Implement exchange-specific methods
}- Register the adapter:
services.AddScoped<IExchangeAdapter, MyExchangeAdapter>();Run unit tests:
dotnet testRun integration tests:
dotnet test --filter Category=IntegrationKey configuration files:
appsettings.json: Application settingstrading-config.json: Trading parametersrisk-config.json: Risk management settings
- Build for production:
dotnet publish -c Release- Deploy using Docker:
docker build -t tradingsystem .
docker run tradingsystem- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support, email support@tradingsystem.com or join our Discord channel.
- Machine learning integration
- Web interface
- Mobile app
- Additional exchange support
- Advanced portfolio management
- Real-time analytics dashboard