Skip to main content

Auto Quant

Project description

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)

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/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

AutoQuant-1.1.0.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

AutoQuant-1.1.0-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

Details for the file AutoQuant-1.1.0.tar.gz.

File metadata

  • Download URL: AutoQuant-1.1.0.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.7

File hashes

Hashes for AutoQuant-1.1.0.tar.gz
Algorithm Hash digest
SHA256 3449b50f1123ffa320ebdcde80c48d460596395125b48a19ae489ea3e7b4a620
MD5 d321c56d34955bc339db9075fb837d90
BLAKE2b-256 66d38fc9204599184014b16e465e1cb64b20c18a47a45ffa01886a12c6077449

See more details on using hashes here.

File details

Details for the file AutoQuant-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: AutoQuant-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.7

File hashes

Hashes for AutoQuant-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dcf03f985640f8d0667035ddf2496a7cf5ed46572c1c8deb5e5b216e5e2cd3c8
MD5 ac70b57ac7d9bd8b7e4f64e9b987f0c5
BLAKE2b-256 4070c5fa7db153714d7e528a7e23ae63a49be5d714da9369367486fab21ac412

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page