Python 量化金融都需要用到哪些庫?最全匯總!

本文匯總了定量金融的大量三方庫,按功能進(jìn)行分類,覆蓋數(shù)值運算,衍生品定價,回溯檢驗,風(fēng)險管理,數(shù)據(jù)爬取,可視化等多個子領(lǐng)域,供每個Python程序員參考。
不要重復(fù)造輪子,明確要解決的問題,然后尋找相應(yīng)的工具。很多著名的包如 Numpy,Pandas,Seaborn,backtrader 等已經(jīng)被證明高度有效,即便沒有找到符合應(yīng)用場景的包,類似的工具也能夠為創(chuàng)建自己的解決方案提供參考。
內(nèi)容來源于Github項目《Awesome Quant》,由Wilson Freitas創(chuàng)作
項目鏈接:Awesome Quant[1]
科學(xué)運算和數(shù)據(jù)結(jié)構(gòu)
numpy[2] - 進(jìn)行數(shù)值運算的基礎(chǔ)包,scipy和numpy令Python進(jìn)行有效的矩陣運算成為可能 scipy[3] - 科學(xué)計算生態(tài)系統(tǒng),廣泛應(yīng)用于數(shù)學(xué),物理學(xué)和工程學(xué)等自然科學(xué)領(lǐng)域 pandas[4] - 提供了高性能的數(shù)據(jù)結(jié)構(gòu)和數(shù)據(jù)分析工具 quantdsl[5] - 金融/交易領(lǐng)域進(jìn)行定量分析的領(lǐng)域特定語言 statistics[6] - 進(jìn)行基礎(chǔ)統(tǒng)計運算 sympy[7] - 專門用于符號數(shù)學(xué) pymc3[8] - 用Python實現(xiàn)概率編程,貝葉斯建模,用Theano實現(xiàn)概率機器學(xué)習(xí)
金融工具和定價
PyQL[9] - Quantlib的Python接口 pyfin[10] - 期權(quán)定價 vollib[11] - 計算期權(quán)價格,隱含波動率和希臘值 QuantPy[12] - 定量金融分析 Finance-Python[13] - 定量金融分析 ffn[14] - 拓展Pandas,提供一系列函數(shù)進(jìn)行基礎(chǔ)的量化分析 pynance[15] - 獲取股票和衍生品市場的數(shù)據(jù),分析和可視化 hasura/base-python-dash[16] - 快速入門部署Dash應(yīng)用,Dash基于Flask,Plotly.js和React.js,允許用戶用純Python快速搭建強大的數(shù)據(jù)科學(xué)網(wǎng)頁App hasura/base-python-bokeh[17] - 如何用Bokeh實現(xiàn)數(shù)據(jù)可視化 pysabr[18] - 用Python實現(xiàn)SABR模型
技術(shù)指標(biāo)
pandas_talib[19] - 整合Pandas和Talib,用pandas計算技術(shù)指標(biāo) finta[20] - 用Pandas計算常見的技術(shù)指標(biāo) Tulipy[21] - 技術(shù)指標(biāo)庫(tulipindicators的Python綁定)
量化交易/回溯檢驗
TA-Lib[22] - 計算技術(shù)指標(biāo),跟Numpy深度整合 trade[23] - 用于開發(fā)金融應(yīng)用的基礎(chǔ)包 zipline[24] - 強大的回溯檢驗框架,被很多量化交易平臺作為底層技術(shù),包括Qauntopian, 聚寬等 QuantSoftware Toolkit[25] - 創(chuàng)建和管理投資組合 quantitative[26] - 定量金融的基礎(chǔ)工具,回溯檢驗 analyzer[27] - 接收實時報價并回溯檢驗 bt[28] - 回溯檢驗框架,比Zipline更靈活 backtrader[29] - 回溯檢驗框架,支持實盤交易,過去幾年快速崛起,已成為最流行的量化工具之一 pythalesians[30] - 回溯檢驗框架 pybacktest[31] - 向量化回溯檢驗框架,向量化允許進(jìn)行快速的回溯,但檢驗精度不高 pyalgotrade[32] - 回溯檢驗框架 tradingWithPython[33] - 提供一系列函數(shù)和自定義類來管理量化交易 Pandas TA[34] - 拓展Pandas,包含115種技術(shù)指標(biāo),快速創(chuàng)建交易策略 ta[35] - 用Pandas計算技術(shù)指標(biāo) algobroker[36] - 算法交易的部署引擎 pysentosa[37] - sentosa交易系統(tǒng)的Python接口 finmarketpy[38] - 分析市場數(shù)據(jù),支持簡單回溯檢驗 binary-martingale[39] - 自動化交易程序,用馬丁格爾策略交易二元期權(quán) fooltrader[40] - 利用大數(shù)據(jù)技術(shù)進(jìn)行量化分析,包含回溯檢驗 zvt[41] - 提供統(tǒng)一和靈活的方式來獲取數(shù)據(jù),計算因子,選股,回溯檢驗和實盤交易 pylivetrader[42] - 兼容zipline的實時交易庫 pipeline-live[43] - zipline擴展庫,用于實盤交易 zipline-extensions[44] - Zipline擴展,適配QuantRocket moonshot[45] - 向量化回溯檢驗和交易引擎 PyPortfolioOpt[46] - 金融投資組合優(yōu)化,包括創(chuàng)建有效邊界和其它高級算法 riskparity.py[47] - 用TensorFlow設(shè)計風(fēng)險平價投資組合 mlfinlab[48] - 《金融機器學(xué)習(xí)應(yīng)用》一書的實現(xiàn) pyqstrat[49] - 快速地回測交易策略 pinkfish[50] - 證券分析 aat[51] - 異步算法交易引擎 Backtesting.py[52] - 回溯檢驗框架 catalyst[53] - 回溯檢驗框架,專門用于數(shù)字貨幣市場 quantstats[54] - 投資組合分析 qtpylib[55] - 回溯檢驗框架,支持實盤交易 freqtrade[56] - 開源數(shù)字貨幣交易機器人 algorithmic-trading-with-python[57] - 《Python算法交易》一書的源碼和數(shù)據(jù) DeepDow[58] - 用深度學(xué)習(xí)優(yōu)化投資組合
風(fēng)險分析
pyfolio[59] - 計算投資組合和交易策略的業(yè)績指標(biāo) empyrical[60] - 計算常用的風(fēng)險和業(yè)績指標(biāo) fecon235[61] - 金融計量經(jīng)濟工具包,包括leptokurtotic風(fēng)險高斯混合模型,自適應(yīng)Boltzmann投資組合 finance[62] - 計算金融風(fēng)險 qfrm[63] - 定量金融風(fēng)險管理 visualize-wealth[64] - 構(gòu)建投資組合和定量分析 VisualPortfolio[65] - 可視化投資組合表現(xiàn)
因子分析
alphalens[66] - 分析預(yù)測性因子的表現(xiàn)
時間序列
ARCH[67] - Python實現(xiàn)ARCH模型 statsmodels[68] - 計量經(jīng)濟模型庫,用于創(chuàng)建回歸模型,統(tǒng)計檢驗,時序模型 dynts[69] - 操縱和分析時間序列 PyFlux[70] - 時間序列模型和因果推斷 tsfresh[71] - 從時間序列中提取有意義的特征 hasura/quandl-metabase[72] - 可視化Quandl的時間序列數(shù)據(jù)集
日歷
trading_calendars[73] - 股票交易所財經(jīng)日歷 bizdays[74] - 工作日計算和效用工具 pandas_market_calendars[75] - 拓展Pandas,股票交易所財經(jīng)日歷
數(shù)據(jù)源
findatapy[76] - 獲取彭博終端,Quandl和雅虎財經(jīng)的數(shù)據(jù) googlefinance[77] - 從谷歌財經(jīng)獲取實時股票價格 yahoo-finance[78] - 從雅虎財經(jīng)下載股票報價,歷史價格,產(chǎn)品信息和財務(wù)報表 pandas-datareader[79] - 從多個數(shù)據(jù)源獲取經(jīng)濟/金融時間序列,包括谷歌財經(jīng),雅虎財經(jīng),圣路易斯聯(lián)儲(FRED),OECD, Fama/French,世界銀行,歐元區(qū)統(tǒng)計局等,是Pandas生態(tài)系統(tǒng)的重要組成 pandas-finance[80] - 提供高級接口下載和分析金融時間序列 pyhoofinance[81] - 從雅虎財經(jīng)批量獲取股票數(shù)據(jù) yfinanceapi[82] - 從雅虎財經(jīng)獲取數(shù)據(jù) yql-finance[83] - 從雅虎財經(jīng)獲取數(shù)據(jù) ystockquote[84] - 從雅虎財經(jīng)獲取實時報價 wallstreet[85] - 實時股票和期權(quán)報價 stock_extractor[86] - 從網(wǎng)絡(luò)上爬取股票信息 Stockex[87] - 從雅虎財經(jīng)獲取數(shù)據(jù) finsymbols[88] - 獲取全美證券交易所,紐約證券交易所和納斯達(dá)克上市公司的詳細(xì)數(shù)據(jù) inquisitor[89] - 從Econdb獲取經(jīng)濟數(shù)據(jù),Econdb是全球經(jīng)濟指標(biāo)聚合器 chinesestockapi[90] - 獲取A股數(shù)據(jù) exchange[91] - 獲取最新的匯率報價 ticks[92] - 命令行程序,獲取股票報價 pybbg[93] - 彭博終端COM的Python接口 ccy[94] - 獲取外匯數(shù)據(jù) tushare[95] - 獲取中國股票,基金,債券和期貨市場的歷史數(shù)據(jù) jsm[96] - 獲取日本股票市場的歷史數(shù)據(jù) cn_stock_src[97] - 從不同數(shù)據(jù)源獲取中國的股票數(shù)據(jù) coinmarketcap[98] - 從coinmarketcap獲取數(shù)字貨幣數(shù)據(jù) after-hours[99] - 獲取美股盤前和盤后的市場價格 bronto-python[100] - 整合Bronto API接 pytdx[101] - 獲取中國國內(nèi)股票的實時報價 pdblp[102] - 整合Pandas和彭博終端的公共接口 tiingo[103] - 從Tiingo平臺獲取股票日K線和實時報價/新聞流 IEX[104] - 從IEX交易所獲取股票的實時報價和歷史數(shù)據(jù) alpaca-trade-api[105] - 從Alpaca平臺獲取股票實時報價和歷史數(shù)據(jù),并提供交易接口交易美股 metatrader5[106] - 集成Python和MQL5交易平臺,適合外匯交易 akshare[107] - 獲取中國股票,基金,債券和宏觀經(jīng)濟數(shù)據(jù) yahooquery[108] - 從雅虎財經(jīng)獲取數(shù)據(jù) investpy[109] - 從英為財經(jīng)(Investing.com)獲取數(shù)據(jù) yliveticker[110] - 從雅虎財經(jīng)通過Websocket獲取實時報價
Excel集成
xlwings[111] - 深度整合Python和Excel openpyxl[112] - 讀取/寫入Excel 2007 xlsx/xlsm文件 xlrd[113] - 從Excel電子表格提取數(shù)據(jù) xlsxwriter[114] - 將數(shù)據(jù)寫入Excel電子表格 xlwt[115] - 創(chuàng)建跨平臺和向后兼容的電子表格 DataNitro[116] - 深度整合Python和Excel,可免費試用,商業(yè)付費軟件 xlloop[117] - 創(chuàng)建Excel用戶自定義函數(shù) expy[118] - Excel插件,允許用戶從電子表格中執(zhí)行Python代碼和定義自定義函數(shù) pyxll[119] - Excel插件,從Excel中執(zhí)行Python代碼
可視化
Matplotlib[120] - Python數(shù)據(jù)可視化的基礎(chǔ)包,從二維圖表到三維圖表 Seaborn[121] - 基于Matplotlib,快速創(chuàng)建美觀的統(tǒng)計圖表 Plotly[122] - 創(chuàng)建動態(tài)和交互式的圖表 Altair[123] - 統(tǒng)計可視化工具,同時支持靜態(tài)和交互式圖表 D-Tale[124] - 可視化Pandas數(shù)據(jù)結(jié)構(gòu)
地址鏈接
Awesome Quant: https//github.com/wilsonfreitas/awesome-quant
[2]numpy: https//www.numpy.org/
[3]scipy: https//www.scipy.org/
[4]pandas: https//pandas.pydata.org/
[5]quantdsl: https//github.com/johnbywater/quantdsl
[6]statistics: https//docs.python.org/3/library/statistics.html
[7]sympy: https//www.sympy.org/
[8]pymc3: https//docs.pymc.io/
[9]PyQL: https//github.com/enthought/pyql
[10]pyfin: https//github.com/opendoor-labs/pyfin
[11]vollib: https//github.com/vollib/vollib
[12]QuantPy: https//github.com/jsmidt/QuantPy
[13]Finance-Python: https//github.com/alpha-miner/Finance-Python
[14]ffn: https//github.com/pmorissette/ffn
[15]pynance: https//pynance.net/
[16]hasura/base-python-dash: https//platform.hasura.io/hub/projects/hasura/base-python-dash
[17]hasura/base-python-bokeh: https//platform.hasura.io/hub/projects/hasura/base-python-bokeh
[18]pysabr: https//github.com/ynouri/pysabr
[19]pandas_talib: https//github.com/femtotrader/pandas_talib
[20]finta: https//github.com/peerchemist/finta
[21]Tulipy: https//github.com/cirla/tulipy
[22]TA-Lib: https//ta-lib.org/
[23]trade: https//github.com/rochars/trade
[24]zipline: https//www.zipline.io/
[25]QuantSoftware Toolkit: https//github.com/QuantSoftware/QuantSoftwareToolkit
[26]quantitative: https//github.com/jeffrey-liang/quantitative
[27]analyzer: https//github.com/llazzaro/analyzer
[28]bt: https//github.com/pmorissette/bt
[29]backtrader: https//github.com/backtrader/backtrader
[30]pythalesians: https//github.com/thalesians/pythalesians
[31]pybacktest: https//github.com/ematvey/pybacktest
[32]pyalgotrade: https//github.com/gbeced/pyalgotrade
[33]tradingWithPython: https//pypi.org/project/tradingWithPython/
[34]Pandas TA: https//github.com/twopirllc/pandas-ta
[35]ta: https//github.com/bukosabino/ta
[36]algobroker: https//github.com/joequant/algobroker
[37]pysentosa: https//pypi.org/project/pysentosa/
[38]finmarketpy: https//github.com/cuemacro/finmarketpy
[39]binary-martingale: https//github.com/metaperl/binary-martingale
[40]fooltrader: https//github.com/foolcage/fooltrader
[41]zvt: https//github.com/zvtvz/zvt
[42]pylivetrader: https//github.com/alpacahq/pylivetrader
[43]pipeline-live: https//github.com/alpacahq/pipeline-live
[44]zipline-extensions: https//github.com/quantrocket-llc/zipline-extensions
[45]moonshot: https//github.com/quantrocket-llc/moonshot
[46]PyPortfolioOpt: https//github.com/robertmartin8/PyPortfolioOpt
[47]riskparity.py: https//github.com/dppalomar/riskparity.py
[48]mlfinlab: https//github.com/hudson-and-thames/mlfinlab
[49]pyqstrat: https//github.com/abbass2/pyqstrat
[50]pinkfish: https//github.com/fja05680/pinkfish
[51]aat: https//github.com/timkpaine/aat
[52]Backtesting.py: https//kernc.github.io/backtesting.py/
[53]catalyst: https//github.com/enigmampc/catalyst
[54]quantstats: https//github.com/ranaroussi/quantstats
[55]qtpylib: https//github.com/ranaroussi/qtpylib
[56]freqtrade: https//github.com/freqtrade/freqtrade
[57]algorithmic-trading-with-python: https//github.com/chrisconlan/algorithmic-trading-with-python
[58]DeepDow: https//github.com/jankrepl/deepdow
[59]pyfolio: https//github.com/quantopian/pyfolio
[60]empyrical: https//github.com/quantopian/empyrical
[61]fecon235: https//github.com/rsvp/fecon235
[62]finance: https//pypi.org/project/finance/
[63]qfrm: https//pypi.org/project/qfrm/
[64]visualize-wealth: https//github.com/benjaminmgross/visualize-wealth
[65]VisualPortfolio: https//github.com/wegamekinglc/VisualPortfolio
[66]alphalens: https//github.com/quantopian/alphalens
[67]ARCH: https//github.com/bashtage/arch
[68]statsmodels: https://link.zhihu.com/?target=http%3A//statsmodels.sourceforge.net/
[69]dynts: https//github.com/quantmind/dynts
[70]PyFlux: https//github.com/RJT1990/pyflux
[71]tsfresh: https//github.com/blue-yonder/tsfresh
[72]hasura/quandl-metabase: https//platform.hasura.io/hub/projects/anirudhm/quandl-metabase-time-series
[73]trading_calendars: https//github.com/quantopian/trading_calendars
[74]bizdays: https//github.com/wilsonfreitas/python-bizdays
[75]pandas_market_calendars: https//github.com/rsheftel/pandas_market_calendars
[76]findatapy: https//github.com/cuemacro/findatapy
[77]googlefinance: https//github.com/hongtaocai/googlefinance
[78]yahoo-finance: https//github.com/lukaszbanasiak/yahoo-finance
[79]pandas-datareader: https//github.com/pydata/pandas-datareader
[80]pandas-finance: https//github.com/davidastephens/pandas-finance
[81]pyhoofinance: https//github.com/innes213/pyhoofinance
[82]yfinanceapi: https//github.com/Karthik005/yfinanceapi
[83]yql-finance: https//github.com/slawek87/yql-finance
[84]ystockquote: https//github.com/cgoldberg/ystockquote
[85]wallstreet: https//github.com/mcdallas/wallstreet
[86]stock_extractor: https//github.com/ZachLiuGIS/stock_extractor
[87]Stockex: https//github.com/cttn/Stockex
[88]finsymbols: https//github.com/skillachie/finsymbols
[89]inquisitor: https//github.com/econdb/inquisitor
[90]chinesestockapi: https//pypi.org/project/chinesestockapi/
[91]exchange: https//github.com/akarat/exchange
[92]ticks: https//github.com/jamescnowell/ticks
[93]pybbg: https//github.com/bpsmith/pybbg
[94]ccy: https//github.com/lsbardel/ccy
[95]tushare: https//pypi.org/project/tushare/
[96]jsm: https//pypi.org/project/jsm/
[97]cn_stock_src: https//github.com/jealous/cn_stock_src
[98]coinmarketcap: https//github.com/barnumbirr/coinmarketcap
[99]after-hours: https//github.com/datawrestler/after-hours
[100]bronto-python: https//pypi.org/project/bronto-python/
[101]pytdx: https//github.com/rainx/pytdx
[102]pdblp: https//github.com/matthewgilbert/pdblp
[103]tiingo: https//github.com/hydrosquall/tiingo-python
[104]IEX: https//github.com/addisonlynch/iexfinance
[105]alpaca-trade-api: https//github.com/alpacahq/alpaca-trade-api-python
[106]metatrader5: https//pypi.org/project/MetaTrader5/
[107]akshare: https//github.com/jindaxiang/akshare
[108]yahooquery: https//github.com/dpguthrie/yahooquery
[109]investpy: https//github.com/alvarobartt/investpy
[110]yliveticker: https//github.com/yahoofinancelive/yliveticker
[111]xlwings: https//www.xlwings.org/
[112]openpyxl: https//openpyxl.readthedocs.io/en/latest/
[113]xlrd: https//github.com/python-excel/xlrd
[114]xlsxwriter: https//xlsxwriter.readthedocs.io/
[115]xlwt: https//github.com/python-excel/xlwt
[116]DataNitro: https//datanitro.com/
[117]xlloop: https://link.zhihu.com/?target=http%3A//xlloop.sourceforge.net/
[118]expy: https://link.zhihu.com/?target=http%3A//www.bnikolic.co.uk/expy/expy.html
[119]pyxll: https//www.pyxll.com/
[120]Matplotlib: https//matplotlib.org/tutorials/index.html
[121]Seaborn: https//seaborn.pydata.org/
[122]Plotly: https//plotly.com/python/
[123]Altair: https//altair-viz.github.io/index.html
[124]D-Tale: https//github.com/man-group/dtale
來源:網(wǎng)絡(luò) 編輯:【數(shù)據(jù)STUDIO】云朵君
僅做學(xué)術(shù)分享,若有侵權(quán),清聯(lián)系刪除!
