fix: resolve 9 bugs across configuration, backtest engine, strategies, and data pipeline - #93
Open
Abubakar-1214 wants to merge 1 commit into
Conversation
… strategies, and data pipeline
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes 9 bugs identified in the
bug-fixing-request_2report, covering configuration validation, environment hardening, backtest crash prevention, type correctness, import consistency, dataclass completeness, logging hygiene, import cleanup, and code formatting.Files Changed
.env.exampleMT5_TERMINAL_PATHfor Windows dotenv compatibilitysrc/backtest/backtest_engine.pybenchmark_tickers,benchmark_returnstype fixed topd.Series, removed unused imports, added docstringsrc/config/settings.pybridge_auth_tokennon-empty enforcementsrc/data/data_processor.pysrc/main.pysys.pathconvention (removedsrc.prefix)src/strategies/base_strategy.pymetadatafield toStrategyConfigdataclasssrc/strategies/execution_engine.pyprint()withlogging.getLogger()Bug Details
Bug 1 - Pydantic validator for
bridge_auth_token(src/config/settings.py)Added
@validator('bridge_auth_token')toMT5Settingsthat raisesValueErrorwhenbridge_enabledorstreaming_enabledisTruebut the token is empty/whitespace-only.Bug 2 -
MT5_TERMINAL_PATHquoting (.env.example)Hardened from bare backslashes to:
MT5_TERMINAL_PATH="C:\\Program Files\\MetaTrader 5\\terminal64.exe"Bug 3 -
benchmark_tickersNone crash (src/backtest/backtest_engine.py)[]inBacktestConfig.__post_init___get_benchmark_metricsBug 4 -
benchmark_returnstype (src/backtest/backtest_engine.py)Changed from
Dict[str, float]back toDict[str, pd.Series]with actual return series frompct_change().dropna().Bug 5 -
main.pyimport path consistency (src/main.py)Changed
from src.trading.all_in_one->from trading.all_in_oneandfrom src.run_trading->from run_tradingto match thesys.path.insert(0, str(Path(__file__).parent))convention.Bug 6 -
StrategyConfigmetadata field (src/strategies/base_strategy.py)Added
metadata: Dict[str, Any] = field(default_factory=dict)to enable named strategies to pass configuration metadata.Bug 7 -
print()to logger (src/strategies/execution_engine.py)Replaced
print(f'[CLOSE-ONLY]...')inExecutionManager.stepwithlogging.getLogger(f'{__name__}.{self.__class__.__name__}').info(...).Bug 8 - Clean up unused imports (
src/backtest/backtest_engine.py)Removed
import osandimport sys; added module docstring.Bug 9 - Excessive blank lines (
src/data/data_processor.py)Collapsed runs of 3+ consecutive blank lines to at most 2 (PEP8). File reduced from 14,454 to 13,972 chars.
Verification
.pyfiles passast.parse()syntax validation.env.examplechange verified by grep