Skip to main content

事件驅動式的 Python 金融投資工具回測套件

Project description

套件簡介

這是一個自製的 Python 套件,實作了 backtesting 功能。 參考OREILLY的Python演算法交易該書本中所描述,以事件觸發導向的交易策略回測。 此回測方法是這麼多種回測方法中,作者認為最為細緻且彈性與變化度最高的方法。

此套件結合finlab package,方便取得台股市場的相關資料數據,方便投資人回測。

安裝方式

pip install tbacktest

指令範例

動能突破策略,以ETF:00713為例

from tbacktest import BacktestLongOnly

clo713 = BacktestLongOnly(symbol='00713', start='20171001', newest_day='20250512',amount=1000000,
                          datasource='finlab',
                          finlab_password='finlab_api_token')
#將LongOnly類別實體化出clo713

clo713.run_break_high_strategy(Hday=10, Lday=10,SMA1=5,SMA2=10)
#執行該類別下的方法,及突破進場買進ETF,跌破平倉出場ETF。

clo713.plot_backtest()  
#將策略結果圖示化
clo713.plot_data()
#將原本資料畫出來

clo713.show_backtest_all_information()
#顯示所有回測結果時間序列

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

tbacktest-0.1.4.dev6.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

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

tbacktest-0.1.4.dev6-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file tbacktest-0.1.4.dev6.tar.gz.

File metadata

  • Download URL: tbacktest-0.1.4.dev6.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for tbacktest-0.1.4.dev6.tar.gz
Algorithm Hash digest
SHA256 fb3df799c2fb35e9f60262ffa1232e1c5b7d0f5dd7be5e3884fd0ebb14af899d
MD5 c38cb9078776d8f2de22700fabadbfb7
BLAKE2b-256 769683dc9de0c00b828d8027dde7379200d09dccc711fb2be2c7f491b8bb7cd7

See more details on using hashes here.

File details

Details for the file tbacktest-0.1.4.dev6-py3-none-any.whl.

File metadata

  • Download URL: tbacktest-0.1.4.dev6-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for tbacktest-0.1.4.dev6-py3-none-any.whl
Algorithm Hash digest
SHA256 7c04ad69120fae906ef840710f8c09e79312fda6a8fdd6887c553b04da7a8254
MD5 7d6b2288513938d3ebffb0f7ca0afef7
BLAKE2b-256 8a1ef3bd3b56381719b88c3403bd512ac821a603998bc0a1b6e3f4d6c6e7f5f4

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