GithubHelp home page GithubHelp logo

nymath / torchqtm Goto Github PK

View Code? Open in Web Editor NEW
27.0 5.0 9.0 29.88 MB

TorchQuantum is a backtesting framework that integrates the structure of PyTorch and WorldQuant's Operator for efficient quantitative financial analysis.

Home Page: https://nymath.github.io/torchqtm/navigate/

License: MIT License

Python 17.66% Cython 55.80% C 26.50% Makefile 0.03%
alpha-model deep-learning function-approximation quantitative-finance

torchqtm's Introduction

torchquantum

TorchQuantum is a backtesting framework that integrates the structure of PyTorch and WorldQuant's Operator for efficient quantitative financial analysis.

Contents

Installation

for Unix:

cd /path/to/your/directory
git clone [email protected]:nymath/torchquantum.git
cd ./torchquantum

Before running examples, you should compile the cython code.

python setup.py build_ext --inplace

Now you can run examples

python ./examples/main.py

If you are not downloading the dataset, then you should

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!

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.

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

quantopian/zipline

torchqtm's People

Contributors

nymath avatar youngyicheng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

torchqtm's Issues

@joblib.Memory('./.cache', verbose=0).cache报错

我在windows下运行main.py,报如下错误。
(qlib230908) E:\myquant\torchqtm\examples>E:/anaconda3/envs/qlib230908/python.exe e:/myquant/torchqtm/examples/main.py
Traceback (most recent call last):
File "e:/myquant/torchqtm/examples/main.py", line 11, in
from torchqtm.utils.universe import StaticUniverse, IndexComponents
File "E:\myquant\torchqtm\torchqtm\utils\universe.py", line 42
@joblib.Memory('./.cache', verbose=0).cache
^
SyntaxError: invalid syntax

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.