Debugged and Enhanced Backtrader Trading Strategy
- Day: 2024-01-16
- Time: 15:55 to 16:40
- Project: Dev
- Workspace: WP 2: Operational
- Status: Completed
- Priority: MEDIUM
- Assignee: Matías Nehuen Iglesias
- Tags: Backtrader, Debugging, Data Processing, Trading Strategy, Visualization
Description
Session Goal
The session aimed to debug and enhance a trading strategy using Backtrader, focusing on data fetching, error handling, and visualization.
Key Activities
- Debugging OLSResiduals Indicator: Addressed issues with an unpopulated
pricesarray by troubleshooting data feed loading, verifying the window period, and refining data fetching methods. - Implementing Robust Data Fetching: Improved the trading strategy by implementing direct data slicing for price fetching and ensuring valid log prices calculations.
- Adjusting Code for Historical Data Access: Modified the
nextmethod and used thegetmethod to fetch historical data accurately. - Handling OLS Residuals: Calculated OLS residuals from price data, handling non-positive values and ensuring error management.
- Manual Construction of Prices Array: Created a prices array from historical close prices to resolve data fetching issues.
- Plotting Simulation Results: Used Matplotlib to plot Backtrader simulation results, including saving plots in headless environments.
- Advanced Plotting Techniques: Explored advanced plotting techniques, integrating financial data from Yahoo Finance, and customizing plot settings.
Achievements
- Successfully debugged the
OLSResidualsindicator and improved data fetching methods. - Enhanced error handling and data processing in the trading strategy.
- Implemented advanced plotting techniques for better visualization of trading results.
Pending Tasks
- Further testing of the modified trading strategy to ensure robustness.
- Exploration of additional data sources for integration into Backtrader.
Evidence
- source_file=2024-01-16.sessions.jsonl, line_number=4, event_count=0, session_id=3582fe9d344b9e78576e045657cd253cb62b918c03289a853908187b73c77512
- event_ids: []