AAUto is a sophisticated automated trading and investment system that integrates multiple strategies, technical analysis, machine learning, and risk management to execute trades in financial markets.
- Multi-strategy approach: Combines trading, investments, and freelancing strategies
- Technical Analysis: Built-in indicators including RSI, MACD, EMA, and trend analysis
- Machine Learning: Price prediction and pattern recognition models
- Risk Management: Position sizing, stop-loss calculation, and drawdown management
- News Analysis: Market sentiment analysis from financial news
- Performance Metrics: Comprehensive tracking and visualization of trading performance
- Python 3.8 or higher
- Git
-
Clone the repository:
git clone <repository-url> cd AAUto
-
Create and activate a virtual environment:
python -m venv venv # On Windows venv\Scripts\activate # On macOS/Linux source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Copy the sample configuration file:
cp config.sample.json config.json
-
Update the configuration with your API credentials and preferences (see Configuration section)
The system is configured via the config.json file, which includes the following sections:
{
"api": {
"alpha_vantage": {
"api_key": "YOUR_API_KEY_HERE",
"base_url": "https://www.alphavantage.co/query",
"rate_limit": {
"calls_per_minute": 5,
"calls_per_day": 500
},
"cache": {
"enabled": true,
"expiry_hours": 24
}
}
}
}{
"risk": {
"max_position_size_percent": 5.0,
"max_total_risk_percent": 20.0,
"default_stop_loss_percent": 2.0,
"default_take_profit_percent": 6.0,
"max_drawdown_percent": 15.0
}
}{
"trading": {
"base_currency": "USD",
"symbols": ["AAPL", "MSFT", "GOOG", "AMZN"],
"default_timeframe": "1d",
"trading_hours": {
"start": "09:30",
"end": "16:00",
"timezone": "America/New_York"
},
"strategies": ["momentum", "reversal", "trend_following"]
}
}{
"ml": {
"model_type": "random_forest",
"features": ["rsi", "macd", "ema", "volume", "sentiment"],
"training": {
"lookback_days": 365,
"validation_split": 0.2,
"retraining_frequency_days": 30
}
}
}To start the trading system:
python src/main.pypython src/main.py --config custom_config.json --debug --backtest 2023-01-01 2023-06-30Available options:
--config: Specify a custom configuration file (default: config.json)--debug: Enable debug logging--backtest: Run in backtest mode with start and end dates--paper-trading: Run in paper trading mode (no real trades)--portfolio: Show current portfolio status and exit
python src/main.py --paper-tradingpython src/main.py --backtest 2022-01-01 2022-12-31 --strategy momentumpython src/main.py --risk-max-position 3.0 --risk-stop-loss 1.5Handles all interactions with the Alpha Vantage API, including rate limiting and response caching.
from src.api.alpha_vantage import AlphaVantageAPI
# Example usage
api = AlphaVantageAPI(api_key="YOUR_KEY")
data = api.get_daily_adjusted("AAPL")Calculates and interprets technical indicators for trading signals.
from src.analytics.technical import TechnicalAnalyzer
# Example usage
analyzer = TechnicalAnalyzer()
rsi = analyzer.calculate_rsi(prices, period=14)
is_overbought = analyzer.is_overbought(rsi, threshold=70)Manages position sizing and risk parameters.
from src.risk.manager import RiskManager
# Example usage
risk_manager = RiskManager(account_balance=10000)
position_size = risk_manager.calculate_position_size("AAPL", risk_percent=1.0)Provides price prediction and pattern recognition.
from src.ml.predictor import MachineLearning
# Example usage
ml = MachineLearning()
ml.train(historical_data)
prediction = ml.predict_price("AAPL", days_ahead=5)Core trading logic that integrates all components.
from src.core.trader import Trader
# Example usage
trader = Trader(config_path="config.json")
trader.run()- Never commit your API keys to version control
- Use environment variables or a secure vault for sensitive credentials
- Create a
.envfile for local development (add to.gitignore)
- Start with small position sizes (1-2% of portfolio)
- Use stop losses for every trade
- Monitor drawdown and be prepared to stop trading if it exceeds your threshold
- Diversify across multiple symbols and strategies
- Regularly check logs for errors and warnings
- Back up your database and configuration regularly
- Monitor system resource usage, especially during high-frequency trading
- Periodically retrain machine learning models with fresh data
- Review trading performance weekly and monthly
- Compare strategy performance against benchmarks (e.g., S&P 500)
- Analyze losing trades to identify patterns or improvements
- Consider adjusting parameters based on changing market conditions
Run the test suite:
# Run all tests
pytest
# Run specific test modules
pytest tests/test_api.py tests/test_technical.py
# Run with coverage report
pytest --cov=srcFor testing, you can use the --mock-api flag to avoid making real API calls:
python src/main.py --paper-trading --mock-api- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please make sure to update tests as appropriate and adhere to the coding style guidelines.
This project is licensed under the MIT License - see the LICENSE file for details.