https://github.com/nymath/torchqtm
TorchQuantum is a backtesting framework that integrates the structure of PyTorch and WorldQuant's Operator for efficient quantitative financial analysis.
https://github.com/nymath/torchqtm
alpha-model deep-learning function-approximation quantitative-finance
Last synced: 8 months ago
JSON representation
TorchQuantum is a backtesting framework that integrates the structure of PyTorch and WorldQuant's Operator for efficient quantitative financial analysis.
- Host: GitHub
- URL: https://github.com/nymath/torchqtm
- Owner: nymath
- License: mit
- Created: 2023-05-20T06:50:30.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-13T07:00:23.000Z (over 2 years ago)
- Last Synced: 2024-05-21T13:57:28.737Z (over 1 year ago)
- Topics: alpha-model, deep-learning, function-approximation, quantitative-finance
- Language: Cython
- Homepage: https://nymath.github.io/torchqtm/navigate/
- Size: 29.2 MB
- Stars: 27
- Watchers: 5
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-systematic-trading - torchquantum - TorchQuantum is a backtesting framework that integrates the structure of PyTorch and WorldQuant's Operator for efficient quantitative financial analysis. (Alpha Collections / Expression based alpha)
README

# torchquantum
TorchQuantum is a backtesting framework that integrates
the structure of PyTorch and WorldQuant's Operator for
efficient quantitative financial analysis.
## Contents
- [Installation](#installation)
- [Features](#features)
- [Contribution](#contribution)
## Installation
for Unix:
```shell
cd /path/to/your/directory
git clone git@github.com:nymath/torchquantum.git
cd ./torchquantum
```
Before running examples, you should compile the cython code.
```shell
python setup.py build_ext --inplace
```
Now you can run examples
```shell
python ./examples/main.py
```
If you are not downloading the dataset, then you should
```shell
cd ./examples
mkdir largedata
cd ./largedata
wget https://github.com/nymath/torchquantum/releases/download/V0.1/stocks_f64.pkl.zip
unzip stocks_f64.pkl.zip
rm stocks_f64.pkl.zip
cd ../
cd ../
git checkout dev
```
## Example
You can easily create an alpha through torchquantum!
```python
import torchqtm.op as op
import torchqtm.op.functional as F
class NeutralizePE(op.Fundamental):
def __init__(self, env):
super().__init__(env)
self.lag = op.Parameter(5, required_optim=False, feasible_region=None)
def forward(self):
self.data = F.divide(1, self.env.PE)
self.data = F.winsorize(self.data, 'std', 4)
self.data = F.normalize(self.data)
self.data = F.group_neutralize(self.data, self.env.Sector)
self.data = F.regression_neut(self.data, self.env.MktVal)
self.data = F.ts_mean(self.data, self.lag)
return self.data
```
- `F` is library that contains the operators defined by WorldQuant.
- `op.Fundamental` implies the NeutralizePE belongs to fundamental alpha.
- `self.lag` is the parameter of rolling mean, which can be optimized through grid search.
## Features
- High-speed backtesting framework (most of the operators are implemented through cython)
- A revised gplearn library that is compatible with Alpha mining.
- CNN and other state of the art models for mining alphas.
- Event Driven backtesting framework is available.
## Contribution
For more information, we refer to [Documentation](https://nymath.github.io/torchquantum/navigate).
## Join us
If you are interested in quantitative finance and are committed to devoting
your life to alpha mining, you can contact me through WeChat at Ny_math.
## References
[quantopian/alphalens](https://github1s.com/quantopian/alphalens/blob/HEAD/alphalens/performance.py)
[quantopian/zipline](https://github1s.com/quantopian/zipline/blob/HEAD/zipline/performance.py)