How baptistedfr/predicting-oil-price-turning-points works
Overall Project Purpose & Type
• This project replicates research focused on using log‐periodic power law models and a variety of optimization algorithms (including multi-population genetic algorithms, particle swarm, simulated annealing, etc.) to predict turning points in oil prices.
• It is an algorithmic research framework that processes historical price data (as shown by the CSV files in the data directory), applies models (the LPPL and LPPLS models in the GQLib/Models directory), and uses various optimizers (in the GQLib/Optimizers directory) to generate prediction outputs and compare the performance of the algorithms.
Main Architectural Components
a. Data and Configuration Layer:
• Data input: CSV files located in the “data” directory for different markets (e.g., BTC, EURUSD, SSE, USO, WTI, SP500).
• Parameter configuration files in the “params” directory, which include JSON files (config_asset_classes.json, params_fa.json, params_mpga.json, etc.) defining algorithm parameters and settings.
b. Core Computation & Modeling Layer (GQLib):
• GQLib/Framework.py – likely orchestrates the prediction process and integrates different modules.
• GQLib/AssetProcessor.py – handles asset (price) data processing.
• GQLib/LombAnalysis.py – performs analysis tasks, perhaps related to time-series or spectral methods.
• GQLib/Models (LPPL.py, LPPLS.py) – contain implementations of the LPPL models used for prediction.
• GQLib/Optimizers – a collection of various optimization implementations (FA, MPGA, NELDER_MEAD, PSO, SA, SGA, TABU) plus an abstract optimizer to standardize interface across algorithms.
• The file “GQLib/enums.py” might be used to define enumerable constants to govern workflow or parameter settings.
• “GQLib/njitFunc.py” suggests the use of just-in-time (JIT) compilation (likely via Numba) for performance-critical functions.
c. Execution and Experimentation:
• The executable scripts “strat.py”, “test.py”, and the “Etude_USO_WTI.ipynb” notebook indicate that the project can be run both as a script-based analysis and an interactive exploratory workflow.
• The “Results” and “Results_strategy” directories store outputs of experiments with different optimization algorithms, and for different asset classes over various time intervals (daily/weekly). The JSON files stored therein represent the outcome of the prediction experiments.
d. Documentation:
• Documentation and research material are in the “Docs” folder and include the original research paper, final paper, and presentation slides.
Relationships and Data Flow
• Data flows from the Data and Params directories into the processing layer. Data is read (likely via AssetProcessor.py) and then fed into the Framework (GQLib/Framework.py) that coordinates which model (from GQLib/Models) and which optimizer (from GQLib/Optimizers) to use.
• The optimization algorithms compute the prediction models (using functions, including accelerated routines from njitFunc.py) and then generate result JSON files in the Results directory.
• Strat.py may combine model predictions into trading strategies, and test.py is used for validating components.
Architectural Patterns/Design Principles
• Modular design: Separating models, optimizers, and core simulation module (Framework) for maintainability and extensibility.
• Separation of concerns: Data management, computation logic, optimization strategies, and result storage are in distinct directories.
• Reusability and pluggability: Abstract interfaces (e.g., abstract_optimizer.py) suggest the addition of more algorithms without major changes to the core framework.
• Performance optimization: Use of JIT-compilation (njitFunc.py) to accelerate heavy computations.