Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Consider using release 2.1.1 instead.
Reason given by maintainers: Regression: plain DataFrame * FinlabDataFrame uses intersection alignment; use 2.0.21 or >=2.0.24

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

Release files for finlab 2.0.22

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

Built distributions (wheels)

Table of built distributions (wheels) for finlab 2.0.22
File
finlab-2.0.22-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
finlab-2.0.22-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 Details
finlab-2.0.22-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl CPython 3.14 CPython 3.14 Linux glibc 2.28+ ARM64, Linux glibc 2.24+ ARM64 Details
finlab-2.0.22-cp314-cp314-macosx_10_15_universal2.whl CPython 3.14 CPython 3.14 macOS 10.15+ universal2 (ARM64, x86-64) Details
finlab-2.0.22-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
finlab-2.0.22-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 Details
finlab-2.0.22-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ ARM64, Linux glibc 2.24+ ARM64 Details
finlab-2.0.22-cp313-cp313-macosx_10_15_universal2.whl CPython 3.13 CPython 3.13 macOS 10.15+ universal2 (ARM64, x86-64) Details
finlab-2.0.22-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
finlab-2.0.22-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 Details
finlab-2.0.22-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ ARM64, Linux glibc 2.24+ ARM64 Details
finlab-2.0.22-cp312-cp312-macosx_10_15_universal2.whl CPython 3.12 CPython 3.12 macOS 10.15+ universal2 (ARM64, x86-64) Details
finlab-2.0.22-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
finlab-2.0.22-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 Details
finlab-2.0.22-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ ARM64, Linux glibc 2.24+ ARM64 Details
finlab-2.0.22-cp311-cp311-macosx_10_15_universal2.whl CPython 3.11 CPython 3.11 macOS 10.15+ universal2 (ARM64, x86-64) Details
finlab-2.0.22-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
finlab-2.0.22-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 Details
finlab-2.0.22-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ ARM64, Linux glibc 2.24+ ARM64 Details
finlab-2.0.22-cp310-cp310-macosx_10_15_universal2.whl CPython 3.10 CPython 3.10 macOS 10.15+ universal2 (ARM64, x86-64) Details

Total release size: 92.4 MB

Release files / finlab-2.0.22-cp314-cp314-win_amd64.whl

Download URL finlab-2.0.22-cp314-cp314-win_amd64.whl
Size 2.1 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
bbb9d359cf67d305e292cf6239e0228394270570aa1023e276e39a1323b6e6c6
BLAKE2b-256 checksum
How to use checksums
fbe59ba4e86279b6c0bd1867f4008b44325df783e15e8b4cbff6f768e99bf06c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / finlab-2.0.22-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL finlab-2.0.22-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 7.0 MB
Tags CPython 3.14 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
c6620cad400e3a7905f64fda7a0ac34d6d6ebd979ce098c52e5478a2415daab5
BLAKE2b-256 checksum
How to use checksums
a5cfb2a95b76518cc6a9e901b990a5ae0553ed80d6d3251bfb44fede84f99a00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / finlab-2.0.22-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL finlab-2.0.22-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 6.8 MB
Tags CPython 3.14 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
c725ca96bee9eddf6877432589468067f8d625d4233ded50dab2aa42279b1310
BLAKE2b-256 checksum
How to use checksums
8e4029e690fe9fdae5c755d75c8a0f45252f86bf97f545ff515927fb979707a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / finlab-2.0.22-cp314-cp314-macosx_10_15_universal2.whl

Download URL finlab-2.0.22-cp314-cp314-macosx_10_15_universal2.whl
Size 2.7 MB
Tags CPython 3.14 macOS 10.15+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
352516ef3a524c36eacf63687227dd50ee2c88b871d4246a320f4a351ffdd26c
BLAKE2b-256 checksum
How to use checksums
6858b7f1d327b03af6ed073fd817db0374abd8321f7ffd0f71d5d35c6903fc87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / finlab-2.0.22-cp313-cp313-win_amd64.whl

Download URL finlab-2.0.22-cp313-cp313-win_amd64.whl
Size 2.1 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
cced450e19f4372e5e76e4970b3e5712d94c21445a1eda680a76bac255c4081a
BLAKE2b-256 checksum
How to use checksums
4afb25daadfa26cf9bad902c081802429ac1e0bfa334c45bc62f5b6dc7a7fd95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / finlab-2.0.22-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL finlab-2.0.22-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 7.0 MB
Tags CPython 3.13 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
631172eada7c9f42a5af9c45be6d1361f75d5fa0a06cce02b3d24518d9000432
BLAKE2b-256 checksum
How to use checksums
37f3bb7ecdf005a51a2d35d231382e689f8bf5e46ca671a26b4a8411e701c060
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / finlab-2.0.22-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL finlab-2.0.22-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 6.8 MB
Tags CPython 3.13 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
3de003aeac723d8ac09c8e707a8dcb1b2168e70d41751f6cdc3ce398b41f0e7c
BLAKE2b-256 checksum
How to use checksums
4de0b4ce70bfec882f0928453197a02e4fd949c5630c56559ff42a8d09c078ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / finlab-2.0.22-cp313-cp313-macosx_10_15_universal2.whl

Download URL finlab-2.0.22-cp313-cp313-macosx_10_15_universal2.whl
Size 2.7 MB
Tags CPython 3.13 macOS 10.15+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
9ec54be011ec4c3823f9f6d78b87cab309cc9844916b2c435212bc7e0f02cb25
BLAKE2b-256 checksum
How to use checksums
ff52134baedfdab543a534840af71992b10714a090759dc51c8f6e2360226e07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / finlab-2.0.22-cp312-cp312-win_amd64.whl

Download URL finlab-2.0.22-cp312-cp312-win_amd64.whl
Size 2.1 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
d2e7dd48be60333fbaf18517f6af0f8aa58a53d8b6c6c8f57a964b8d14a4a885
BLAKE2b-256 checksum
How to use checksums
02aa338166024e2462248a34d7622c3d9e1c3216475a9cfab82bf7b4040f2516
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / finlab-2.0.22-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL finlab-2.0.22-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 7.0 MB
Tags CPython 3.12 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
db1246096d4ac90147b197f5359073bf2b3b4a0da6d002bc6bf070efe4e50d55
BLAKE2b-256 checksum
How to use checksums
886b83551c13a3bcf13145a9bb5cee43677d803349f87efbbf87d45ccd8958da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / finlab-2.0.22-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL finlab-2.0.22-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 6.7 MB
Tags CPython 3.12 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
4269802e04d8accd618a12c2e19bd4509381b2e5a0e6276543effa070862b5b7
BLAKE2b-256 checksum
How to use checksums
b8d16b8a40d1d74ddf3e4c415b7d6efd95c4272338b2d34f70d7df7b40f1f7a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / finlab-2.0.22-cp312-cp312-macosx_10_15_universal2.whl

Download URL finlab-2.0.22-cp312-cp312-macosx_10_15_universal2.whl
Size 2.8 MB
Tags CPython 3.12 macOS 10.15+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
9fceaee824d26ade2a399be230aa5a58e53b1c56c78ac4a116a68ae111542cc6
BLAKE2b-256 checksum
How to use checksums
6433edbdd60007cf3cde6f9ca373d71e6c463c6a761eb1984b2988f34d09682c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / finlab-2.0.22-cp311-cp311-win_amd64.whl

Download URL finlab-2.0.22-cp311-cp311-win_amd64.whl
Size 2.1 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
8e11f3ec3ec12527444ca2b2e11ba8394bfcfde611506987b08c3c965cc7047e
BLAKE2b-256 checksum
How to use checksums
421cb7ff0e1486442c3f47a7770bc142cb887af312bb855d718f5e7ba9bc1c9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / finlab-2.0.22-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL finlab-2.0.22-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 7.1 MB
Tags CPython 3.11 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
605044ec4cd172a8dc12cc7f9670c5d7b74639f8b153026122fae8e0ad133f54
BLAKE2b-256 checksum
How to use checksums
91b269db3ed48f4989b062f5e44e0eb368b3fb5c97c6c004efa0c4cd5c0d5356
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / finlab-2.0.22-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL finlab-2.0.22-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 6.8 MB
Tags CPython 3.11 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
1cb122a1077f0ea1b8e489443564c7fa5caef7871092ae01729f61f4728d4a96
BLAKE2b-256 checksum
How to use checksums
39cfcc206f38e49a9f4d934bf6e357f294f5101690d7991836fb36587b541c57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / finlab-2.0.22-cp311-cp311-macosx_10_15_universal2.whl

Download URL finlab-2.0.22-cp311-cp311-macosx_10_15_universal2.whl
Size 2.8 MB
Tags CPython 3.11 macOS 10.15+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
d9304e43e2ba96bf51acbcb3a093439a4d9c713f29cd28027fa528fbf63979ad
BLAKE2b-256 checksum
How to use checksums
4bab91034ec06ed50c398a1adf3b06b12fdc3dd9084ba00d873e2e52e71dfb62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / finlab-2.0.22-cp310-cp310-win_amd64.whl

Download URL finlab-2.0.22-cp310-cp310-win_amd64.whl
Size 2.1 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
f48866020a1ede4e71bee97222900fa2c3ed2c27a7af5cdffba0255ef33937ea
BLAKE2b-256 checksum
How to use checksums
4dfd4880042a00c745fbcc645b9f270981f3095d7ec74e1a11ec6fb1490725f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / finlab-2.0.22-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL finlab-2.0.22-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 6.6 MB
Tags CPython 3.10 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
f8860517e7a1a417f6165443b681ffbd09325c77069c64f33fbeb9f73a1134a5
BLAKE2b-256 checksum
How to use checksums
b46a04f5a142d03bb5cccfed522d3487ee632d33f90418f25d9d3a654828156a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / finlab-2.0.22-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL finlab-2.0.22-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 6.4 MB
Tags CPython 3.10 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
8a7845232c00a8cae643eadf994e4f65738ae5ce2a56a1a9fb0f1bc3505f2c81
BLAKE2b-256 checksum
How to use checksums
6dfd78acf85da84bc3796bf36c8ed41cf51930678afef3fb00646751b1ebd518
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / finlab-2.0.22-cp310-cp310-macosx_10_15_universal2.whl

Download URL finlab-2.0.22-cp310-cp310-macosx_10_15_universal2.whl
Size 2.8 MB
Tags CPython 3.10 macOS 10.15+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
ab016c70d703099a475d82b54ee96edcf7af112dc4a738f0c277e2594b81530e
BLAKE2b-256 checksum
How to use checksums
92eff1946a7a62a1dac1b4c1efcb57126edd407c588eea0b7b1ef27781cbb2cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release history Release notifications | RSS feed

2.1.1

20 release files

2.1.0

20 release files

This release

2.0.22 This release

20 release files

2.0.9

20 release files

2.0.8

20 release files

2.0.7

20 release files

2.0.3

20 release files

2.0.2

24 release files

2.0.1

25 release files

2.0.0

24 release files

1.5.7

24 release files

1.5.6

28 release files

1.5.5

28 release files

1.5.4

26 release files

1.4.0

24 release files

1.2.6

30 release files

1.2.5

30 release files

1.2.4

30 release files

1.2.3

28 release files

1.2.2

30 release files

1.2.1

30 release files

1.2.0

30 release files

1.1.6

30 release files

1.1.5

30 release files

1.1.4

30 release files

1.1.3

23 release files

1.1.2

30 release files

1.1.1

30 release files

1.0.9

30 release files

1.0.8

30 release files

1.0.7

30 release files

1.0.6

30 release files

1.0.5

30 release files

1.0.4

30 release files

1.0.3

30 release files

1.0.2

30 release files

1.0.1

30 release files

1.0.0

30 release files

0.5.3

25 release files

0.5.2

25 release files

0.5.1

25 release files

0.5.0

25 release files

0.4.6

25 release files

0.4.4

25 release files

0.4.3

25 release files

0.4.2

25 release files

0.4.1

16 release files

0.3.9

23 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