Skip to main content

PypI Versions PyPI - Downloads Python Versions Platform

AutoQuant

AutoQuant is an out-of-the-box quantitative investment platform.

It contains the full ML pipeline of data processing, strategy building(includes AI & traditionals), back-testing, and covers the entire chain of quantitative investment: alpha seeking, risk modeling, portfolio optimization, and order execution.

With AutoQuant, users can easily try ideas to create better Quant investment strategies.

Quick Start

Installation

pip install --upgrade autoquant

Data Preparation

from autoquant.collector import Collector
from autoquant import Market
from datetime import date

collector = Collector.default()

data = collector.daily_prices(
    market=Market.SZ, 
    code='002594', 
    start=date(2021, 11, 1), 
    end=date(2021, 11, 5)
)

data = collector.quarter_statement(
    market=Market.SH, 
    code='601318', 
    quarter=date(2021, 9, 30)
)
    

Backtest

from autoquant.collector import Collector
from autoquant.workflow import Workflow
from autoquant.broker import Broker
from autoquant import Market
from datetime import date

from autoquant.workflow import Workflow
from autoquant.strategy import MA_CrossOver


class SmaCross(MA_CrossOver):
    params = dict(fast=5, slow=20)


collector = Collector.default()
broker = Broker.default(kick_start=100000, commission=0.01)

data = collector.daily_prices(market=Market.SZ, code='002594', start=date(2020, 1, 1), end=date(2021, 11, 1))
w = Workflow().with_broker(broker).with_strategy(SmaCross).backtest(data)

w.visualize()

Advanced Topics

Market

AutoQuant support Shanghai, Shenzhen, HongKong and US markets now. Use Market Enum in codes:

from autoquant import Market

Market.SZ
Market.SH
Market.HK
Market.CN
Market.US

Index

AutoQuant support the indexes in multiple markets now.

Use StocksIndex Enum in codes:

from autoquant import StocksIndex

StocksIndex.ZZ500
StocksIndex.HS300
StocksIndex.SZ50

Use FundsIndex Enum in codes:

from autoquant import FundsIndex

FundsIndex.CN_ALL
FundsIndex.CN_ETF
FundsIndex.CN_QDII
FundsIndex.HUAXIA_SECTOR_ETF

Indicators

Specific Indicators

  • ParityIndex
  • AdjustedMomentum

Backtrader Indicators

All the indicators in Backtrader are available in AutoQuant.

For Example, if you were using the indicators of Backtrader like this:

from backtrader.indicators import Momentum

You can simply change the import sentence to use the indicators in AutoQuant. The codes would be:

from autoquant.indicators import Momentum

Metrics

Specific Metrics

  • Gross Rate Of Return
  • CAGR(Compound Annual Growth Rate)

TA-Lib Metrics

All the metrics in TA-Lib are available in AutoQuant.

For Example, if you were using the metrics of TA-Lib like this:

from talib import SMA

close = numpy.random.random(100)
output = MOM(close, timeperiod=5)

You can simply change the import sentence to use the metrics in AutoQuant. The codes would be:

from AutoQuant import SMA

close = numpy.random.random(100)
output = MOM(close, timeperiod=5)

Providers

Price Provider

Provides List

  • BaostockProvider
  • TushareProvider
  • EastmoneyProvider

API

def daily_prices(self, market: Market, code: str, start: date, end: date, **kwargs)

Financial Statement Provider

Provides List

  • SnowballProvider

API

def quarter_statement(self, market: Market, code: str, quarter: date, **kwargs)

def yearly_balance_sheet(self, market: Market, code: str,  years: list, **kwargs)

def yearly_income_sheets(self, market: Market, code: str, years: list, **kwargs)

def yearly_flow_sheets(self, market: Market, code: str, years: list, **kwargs)

Index Provider

Provides List

  • BaostockProvider
  • EastmoneyProvider

API

def stocks_of_index(self, index: StocksIndex, **kwargs)

def funds_of_index(self, index: FundsIndex, **kwargs)

Contribution Guide

Test

Test all

PYTHONPATH=./ pytest

Test specified test

PYTHONPATH=./ pytest tests/<YOUR_DISIRE_FILE>.py -k "<YOUR_DISIRE_TEST_CASE>" -s

Development

Generate Requirements

pipreqs ./ --encoding=utf8 --force

Package Update

python3 -m build 
python3 -m twine upload dist/*

Metadata

Release files for AutoQuant 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for AutoQuant 1.1.1
File Size Uploaded
AutoQuant-1.1.1.tar.gz 18.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for AutoQuant 1.1.1
File Interpreter ABI Platform
AutoQuant-1.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 38.6 kB

Release files / AutoQuant-1.1.1.tar.gz

Download URL AutoQuant-1.1.1.tar.gz
Size 18.7 kB
Tags Source
SHA-256 checksum
How to use checksums
81e4019e3029e91f5b7af68b0369d4cb7e33c04b777fdbf1253633ea31fd261a
BLAKE2b-256 checksum
How to use checksums
628b14c6e6f043fd7c8f358be3671ab6210c7e295ab7b64b748aaa594e2ef986
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.7

Release files / AutoQuant-1.1.1-py3-none-any.whl

Download URL AutoQuant-1.1.1-py3-none-any.whl
Size 19.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
96da805a6318f5de1b0dc9538cb4bb7574e14a18fbc3da2a3d7c326b9e02a0c8
BLAKE2b-256 checksum
How to use checksums
75622f3bf7a577ac59f0a16afdb2ef157e59fe12fa1664625b76513839ef2b3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.7

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page