Skip to main content

Analyzing stock has never been easier.

Project description

FinLab

瞬間的閃念之中,揭示過去十年2000支股票的歷史數據,這就是finlab package!不僅如此,它與pandas無縫整合,讓你在策略創建的旅程中,如同進行一場華麗的交響樂演奏。其語法之簡潔,讓你撰寫策略時有如神助。

你只需要撰寫人類懂得邏輯,而程式會自動融合各種頻率的歷史數據來選股,這不僅是程式設計上的巧思,更是對簡潔的極致追求。當你以為這已經是頂峰,它的詳細回測結果,又將你帶入更深一層的分析維度,每一筆數據都讓你的決策更加精準。 在幾秒鐘之內,2000支股票的回測,這速度,這效率,它不僅是一個 package,這是一個交易者的夢想加速器!這是finlab,一個為熱血操盤手量身打造的回測神器!

功能

  • 📊 快速存取龐大資料集:單一指令即可取得2000支股票過去十年的歷史數據。
  • 🐼 Pandas整合:利用熟悉且功能強大的pandas函式庫,輕鬆設計交易策略。
  • 🔍 用戶友好的語法✍️:採用簡潔直觀編碼語法。
  • 🕒 多頻率數據處理:自動整合管理不同時間頻率的歷史數據。
  • 🔬 全面的回測分析:透過詳細的回測報告,獲得深入的洞察。
  • 🚀 高速計算:得益於 Cython 優化的性能,幾秒鐘內即可執行2000支股票的回測。
  • 🤖 機器學習:結合 qlib 研發機器學習策略。

相關連結

簡易教學

下載資料

輸入以下程式碼,即可下載資料。可以查詢有哪些歷史資料可以下載。

from finlab import data

data.get('price:收盤價')
date 0015 0050 0051 0052 0053
2007-04-23 9.54 57.85 32.83 38.4 nan
2007-04-24 9.54 58.1 32.99 38.65 nan
2007-04-25 9.52 57.6 32.8 38.59 nan
2007-04-26 9.59 57.7 32.8 38.6 nan
2007-04-27 9.55 57.5 32.72 38.4 nan

撰寫策略

可以用非常簡單的 Pandas 語法來撰寫策略邏輯,以創新高的策略來說,可以用以下的寫法:

from finlab import data

close = data.get('price:收盤價')

# 創三百個交易日新高
position = close >= close.rolling(300).max()
position
date 0015 0050 0051 0052 0053
2007-04-23 00:00:00 False False False False False
2007-04-24 00:00:00 False False False False False
2007-04-25 00:00:00 False False False False False
2007-04-26 00:00:00 False False False True False
2007-04-27 00:00:00 False False False False False

這邊的 position 是一個 False/True 的查詢表,當數值為 True ,代表該股票在當天有創新高,而數字 False 則代表沒有創新高。由於創新高的股票很少,上面的範例中,只有少數股票的數值會是 True。

假設我們希望每個月底,搜尋上表中數值為 True 的股票並且買入持有一個月,可以用以下的語法:

回測績效

from finlab import backtest

report = backtest.sim(position, resample='M')
report.display()

image

Project details


Release history Release notifications | RSS feed

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 Distributions

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

finlab-2.0.9-cp314-cp314-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.14Windows x86-64

finlab-2.0.9-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (6.7 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

finlab-2.0.9-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (6.5 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

finlab-2.0.9-cp314-cp314-macosx_10_15_universal2.whl (2.6 MB view details)

Uploaded CPython 3.14macOS 10.15+ universal2 (ARM64, x86-64)

finlab-2.0.9-cp313-cp313-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.13Windows x86-64

finlab-2.0.9-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (6.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

finlab-2.0.9-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (6.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

finlab-2.0.9-cp313-cp313-macosx_10_15_universal2.whl (2.6 MB view details)

Uploaded CPython 3.13macOS 10.15+ universal2 (ARM64, x86-64)

finlab-2.0.9-cp312-cp312-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.12Windows x86-64

finlab-2.0.9-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (6.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

finlab-2.0.9-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (6.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

finlab-2.0.9-cp312-cp312-macosx_10_15_universal2.whl (2.6 MB view details)

Uploaded CPython 3.12macOS 10.15+ universal2 (ARM64, x86-64)

finlab-2.0.9-cp311-cp311-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.11Windows x86-64

finlab-2.0.9-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (6.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

finlab-2.0.9-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (6.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

finlab-2.0.9-cp311-cp311-macosx_10_15_universal2.whl (2.6 MB view details)

Uploaded CPython 3.11macOS 10.15+ universal2 (ARM64, x86-64)

finlab-2.0.9-cp310-cp310-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.10Windows x86-64

finlab-2.0.9-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (6.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

finlab-2.0.9-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (6.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

finlab-2.0.9-cp310-cp310-macosx_10_15_universal2.whl (2.6 MB view details)

Uploaded CPython 3.10macOS 10.15+ universal2 (ARM64, x86-64)

File details

Details for the file finlab-2.0.9-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: finlab-2.0.9-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for finlab-2.0.9-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 f4a43c6ab9975a418688cea09a3e82815f10ab0233eb00780a8ce93d7fb3b577
MD5 ce1f066403e9f325717fa0f651bc02d0
BLAKE2b-256 c0369d2452cd30a314fc3839707769b2698227df2fb45060ddb019dea24dfe38

See more details on using hashes here.

File details

Details for the file finlab-2.0.9-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for finlab-2.0.9-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 dffa699b8845fc421de6de666efc5b3dc22d39c5b03bb714d1ccf0e8ef11a34c
MD5 bce35963f552883cabae9c46e84f0e61
BLAKE2b-256 48fc1515be8ec816cf995340aeded42e95178d24ccbcfca6252a931ce29a27e2

See more details on using hashes here.

File details

Details for the file finlab-2.0.9-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for finlab-2.0.9-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 91a87f90e222253a03ffca86be8e5d8f2ab21dcd0dfd556cc10a0f680262cc7f
MD5 480d020d5ece0573c79f5cd4d4cf0aa3
BLAKE2b-256 a1455f02430f7ba6e6c1f1ad8764ee8e15600bcde25f371792d03f0f10131ef3

See more details on using hashes here.

File details

Details for the file finlab-2.0.9-cp314-cp314-macosx_10_15_universal2.whl.

File metadata

File hashes

Hashes for finlab-2.0.9-cp314-cp314-macosx_10_15_universal2.whl
Algorithm Hash digest
SHA256 23761d9c373de1e21467b36f0a947fdcc115ccb2b4e7aaf7afd00b6beb8d9986
MD5 9926c0bbc403f6f3335d19184e5f700d
BLAKE2b-256 4c9f248e55a16e6c46a63c1598c600c72456217ad4f746d2775390061c89b4e4

See more details on using hashes here.

File details

Details for the file finlab-2.0.9-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: finlab-2.0.9-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for finlab-2.0.9-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 58880015913ad14e4d8f07ba25a8837e48ec567da5064752d9d316193f4533a7
MD5 724975820c5390730754091b705c5236
BLAKE2b-256 49e3bac6292795116cf46f5e98b06ff58378667133459c05cffd40b6e531a562

See more details on using hashes here.

File details

Details for the file finlab-2.0.9-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for finlab-2.0.9-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e655bdb6eaddb275b95d87e62ec58ba1822d8eb036e47fa775f1ef580d937720
MD5 e47b438dec465de2e9fb7923d28ede32
BLAKE2b-256 812540b7d71d076f79b282967d0f7ffbb99469e547b3d00fe5e7f9d1339febbb

See more details on using hashes here.

File details

Details for the file finlab-2.0.9-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for finlab-2.0.9-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 901c2ac718dc235c0bb17c73f0ea6083b050ac8c76e51655b056d20a23bd8e1a
MD5 cb3a10c16a777b1ec4a05754bd962951
BLAKE2b-256 70078e51514abe711b4f299aeb46a6a5d805e58eb22b422b6e334851373e16a5

See more details on using hashes here.

File details

Details for the file finlab-2.0.9-cp313-cp313-macosx_10_15_universal2.whl.

File metadata

File hashes

Hashes for finlab-2.0.9-cp313-cp313-macosx_10_15_universal2.whl
Algorithm Hash digest
SHA256 578e7e5efe1db3b4669265c996052fd92ad74595afa99e7f72e29b29f369c542
MD5 203339fc0315128654e4be4b678bfb69
BLAKE2b-256 44c139559c7296f08d60bfaa070a5bf34b3e8c5180dcfba0503052bbc7e4a296

See more details on using hashes here.

File details

Details for the file finlab-2.0.9-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: finlab-2.0.9-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for finlab-2.0.9-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 bce9036a90a71e4c9a2989405dc2fbee498b9fc1f10a1e0ddea55c7836786c5d
MD5 41f1b4632cfd7bcbe29f1d78ad243ddb
BLAKE2b-256 d231d4eb52c844e5ac643f4e8d59f46d060867446499225ece55768501be948e

See more details on using hashes here.

File details

Details for the file finlab-2.0.9-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for finlab-2.0.9-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e191e8aefb64105e09b6c5f0e9913dc6699cff325f24d300a164efaaeb00a3d1
MD5 bdcaf51ef49745895671838495581c6c
BLAKE2b-256 11fec0d390838f4162f11c4fa1a27bcd9fe4189a60d973cb943181af5adaf61e

See more details on using hashes here.

File details

Details for the file finlab-2.0.9-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for finlab-2.0.9-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e08bcc16cc1f70f413e5e0bcf1b19662a962ef3eeaa5c84dfafb0308cd5e1c5e
MD5 b0caab009b4abc216e8b16148fafcad0
BLAKE2b-256 44d5ddc80c082108e56c2d2ee6fbd7b919544d8b186ccf1605776a76c9f6efc4

See more details on using hashes here.

File details

Details for the file finlab-2.0.9-cp312-cp312-macosx_10_15_universal2.whl.

File metadata

File hashes

Hashes for finlab-2.0.9-cp312-cp312-macosx_10_15_universal2.whl
Algorithm Hash digest
SHA256 555005b5e42950a6122f5227f239f6f098f47b4cbc98e3cc2e00cd33d6148e08
MD5 f8e5399a73e70d7586d9d6eeaea1ab35
BLAKE2b-256 cbbd8f142dff02e3ed22f40a825fdba8f34c7ff95247c7f4ee5d43125a9bd633

See more details on using hashes here.

File details

Details for the file finlab-2.0.9-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: finlab-2.0.9-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for finlab-2.0.9-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a8122331da9e37dfff1f2bfdbd7f6dd56271790dec904964b0080409fa21c5e7
MD5 dbfbed93adc7de83fc14a051f3799dd4
BLAKE2b-256 8611ec51cff0b194ec9363a376d9a310f09addecd3a5c2d5957278cf453b5689

See more details on using hashes here.

File details

Details for the file finlab-2.0.9-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for finlab-2.0.9-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 dbd056dee5cc6e62529fb45f029d79c462fcefc4b1931dfd3671f907c54c39b7
MD5 17fe65c14ab033c13bf1f74452479782
BLAKE2b-256 0ff4d46f3949424a305d9c964e1c5775fd1cb2367b820a091ae72c364e7dc437

See more details on using hashes here.

File details

Details for the file finlab-2.0.9-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for finlab-2.0.9-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9011f5107d66de3e5862fcad51434377799c31d0d357ebcb0c1d2ad33b4a17d6
MD5 39d7895c68b844d95c2dc374ba5088e8
BLAKE2b-256 70b02b12a295c5cce2b07482dee7a59b3a781aa9894782fdd735692eebfc4772

See more details on using hashes here.

File details

Details for the file finlab-2.0.9-cp311-cp311-macosx_10_15_universal2.whl.

File metadata

File hashes

Hashes for finlab-2.0.9-cp311-cp311-macosx_10_15_universal2.whl
Algorithm Hash digest
SHA256 3e31bc4a7fd34ce576b232f566dfee0777301b47be74d18cdedf04d262d34faa
MD5 f72ef262b129857df9d973a41279351b
BLAKE2b-256 386484a513482d71013c4b76e0280b1e315f30f6bbb184386bde6d6968e90f83

See more details on using hashes here.

File details

Details for the file finlab-2.0.9-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: finlab-2.0.9-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for finlab-2.0.9-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2031529a92f386cb51f57613f30eb492230f5cc4bd95841735010e7e99ae243f
MD5 1d59b63215672e43c99755e9a6b449ff
BLAKE2b-256 2edd45872a16559f704950437ec6ee9c1b85d34ee26e221ed1a65c7f95a55d39

See more details on using hashes here.

File details

Details for the file finlab-2.0.9-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for finlab-2.0.9-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2dc894ac7e3d341b9bc1ce989a9fd85ce00eaed03e51999309552bc7db28a770
MD5 fa6a076bd0a42228a8d3d23e93b938dd
BLAKE2b-256 abe29df54c77564c1d98413493c1465bd9ebbaf0d1aaf61a340777d84f0dd7b5

See more details on using hashes here.

File details

Details for the file finlab-2.0.9-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for finlab-2.0.9-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 35d3a599e537ea0b101bce3af8cc7fd03decc2f1394105e3e9b92279526b05c3
MD5 3eaa184cb24bf70d25b925e0a947adc7
BLAKE2b-256 e338d2a014d61a61b5712e8885e2b1597e5d6f0f5fa200b40aea5d34636db7c3

See more details on using hashes here.

File details

Details for the file finlab-2.0.9-cp310-cp310-macosx_10_15_universal2.whl.

File metadata

File hashes

Hashes for finlab-2.0.9-cp310-cp310-macosx_10_15_universal2.whl
Algorithm Hash digest
SHA256 cfc177b997d4872ae53284424d149ec36e7741cd0fe0700a4945008ceed0a787
MD5 1c0b1c6e025bad013ac7d08a0da17fa7
BLAKE2b-256 71aeaaab0458b52cb8a673431174692ddba818bbbbf3e23e4172f867bb05724a

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