2.0 KiB
2.0 KiB
Swing Trading Project with EUR/USD Using Oanda and scikit-learn
Step 1: Environment Setup
Install Python
Ensure Python 3.8+ is installed.
Create a Virtual Environment
Navigate to your project directory and run:
python -m venv venv
source venv/bin/activate # Unix/macOS
venv\Scripts\activate # Windows
Install Essential Libraries
Create requirements.txt with the following content:
pandas
numpy
matplotlib
seaborn
scikit-learn
jupyterlab
oandapyV20
requests
Install with pip install -r requirements.txt.
Step 2: Project Structure
Organize your directory as follows:
swing_trading_project/
├── data/
├── notebooks/
├── src/
│ ├── __init__.py
│ ├── data_fetcher.py
│ ├── feature_engineering.py
│ ├── model.py
│ └── backtester.py
├── tests/
├── requirements.txt
└── README.md
Step 3: Fetch Historical Data
- Sign up for an Oanda practice account and get an API key.
- Use
oandapyV20indata_fetcher.pyto request historical EUR/USD data. Consider H4 or D granularity. - Save the data to
data/as CSV.
Step 4: Exploratory Data Analysis
- Create a new Jupyter notebook in
notebooks/. - Load the CSV with
pandasand perform initial exploration. Plot closing prices and moving averages.
Step 5: Basic Feature Engineering
- In the notebook, add technical indicators as features (e.g., SMA 50, SMA 200, RSI) using
pandas. - Investigate the relationship between these features and price movements.
Step 6: Initial Model Training
- In
model.py, fit a simplescikit-learnmodel (e.g., LinearRegression, LogisticRegression) to predict price movements. - Split data into training and testing sets to evaluate the model's performance.
Step 7: Documentation
- Document your project's setup, objectives, and findings in
README.md.
Next Steps
- Refine features, try different models, and develop a backtesting framework as you progress.