Much of the literature for systematic trading focuses on testing different financial price forecasting models. What's wrong with forecasting financial time series?
-
Price forecasting doesn't align well with the objective of a trader. As a trader, I'm less interested in whether the price over the next
n
periods is going up, down, or sideways. What I'm truly interested in at any given point in time, is whether I should go long, short, or close out open positions. -
Financial time series are highly random. A nonexhaustive list of issues associated with price forecasting financial series includes:
Issues:
- Leptokurtic characteristic of price changes.
- Apparent nonstationarity or unstable sample variances across periods.
- Discontinuities in prices e.g. jump discontinuities at market open or close.
Solutions:
- Fractional price changes. Price changes are random while fractional price changes can exhibit serial dependence.
- Use of "trading time". Although price changes are highly leptokurtic, price changes over transaction or volume based windows can be nearly gaussian over longer periods.
The goal of this project is to create a modeling framework that aligns with the objective of a trader. The included methodology and code can be used for optimizing trading systems.
Assume we have some matrix
Given some risk constraint
- createEnv.sh - bash script for creating virtual python environment.
- backtest.py - class and methods used for FX trade label optimization and testing.
- backtest_futures.py - class and methods for trade label optimization and testing of futures contracts.
- main.ipynb - python notebook demonstrating usage and methodology.
Within the backtest.py
module, the method target_optimal
contains the
algorithm for optimizing trade labels. This can be used to generate different
potential solutions given some input target constraints. Then, the optimal model
can be found using time series cross validation.
- Within the project repo, run
pre-commit install
. - Then run
pre-commit autoupdate
. - To run pre-commit git hooks for flake8 and black run use
pre-commit run --all-files
.