Skip to main content

backtest utils

Project description

quantrading

  • 백테스팅 유틸 라이브러리입니다.

설치

$ pip install quantrading

사용 예시

example -> simple_stock_8_bond_2_strategy.py 참고

import quantrading as qt
from datetime import datetime
import pandas as pd


class MyStrategy(qt.Strategy):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

    def on_data(self):
        today_date = self.date

        allocation = {
            'MSCI_WORLD_ACWI': 0.8,
            'IEF_BOND_7_10_INDEX': 0.2
        }

        print(today_date, allocation)

        allocation_series = pd.Series(allocation)
        self.reserve_order(allocation_series)


if __name__ == "__main__":
    market_df = pd.read_csv("./stock_bond_data.csv", index_col=0, parse_dates=True)
    market_df = market_df.ffill()

    simulation_args = {
        "market_close_df": market_df,
        "name": "Strategy 주식8 채권2 전략",
        "start_date": datetime(2005, 1, 1),
        "end_date": datetime(2020, 7, 31),
        "rebalancing_periodic": "monthly",
        "rebalancing_moment": "first",
        "benchmark_ticker": "MSCI_WORLD_ACWI"
    }

    strategy = MyStrategy(**simulation_args)
    strategy.run()
    strategy.print_result_log(display_image=True)
    strategy.result_to_excel(folder_path="simulation_result")

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quantrading-0.1.39-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

Details for the file quantrading-0.1.39-py3-none-any.whl.

File metadata

  • Download URL: quantrading-0.1.39-py3-none-any.whl
  • Upload date:
  • Size: 22.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.4

File hashes

Hashes for quantrading-0.1.39-py3-none-any.whl
Algorithm Hash digest
SHA256 91cb7e5c7d835986cc20df82e2ee4c33a87b842e3ed22451595f2a15827b789c
MD5 1294f20fc5d8a502b573420acaab92c1
BLAKE2b-256 6fec21736b863f4bade5ca95883578186e23e82dd52153605426feb12fe2aed8

See more details on using hashes here.

Supported by

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