盈透證券 (IB) 允許透過其 TWS API 連接其交易軟體 Trader Workstation (TWS)。
您首先需要在電腦上啟動 TWS,並在設定選單中為連接埠 7496 上的「localhost」網路介面 (127.0.0.1) 啟用 TWS API 存取。下。這允許在執行 TWS 的同一台電腦上執行腳本。
您也可以使用 IB 閘道來取代 IB TWS。預設使用連接埠 4002 進行模擬交易(模擬/測試帳戶),使用 4001 連接埠進行活躍/真實/真實帳戶。
檢查這個:https://interactivebrokers.github.io/tws-api/initial_setup.html。
一旦您啟動連接到您的交易平台的腳本,您也可以在您的交易平台上看到一個新分頁「API」。
盈透證券的官方 TWS API 軟體可在 https://www.interactivebrokers.com/en/trading/ib-api.php 上找到。
關於 TWS API 的討論最好在 https://groups.io/g/twsapi 上進行。
另請參閱常見問題:https://dimon.ca/dmitrys-tws-api-faq/。
ib_async 是另一個Python API,用於透過https://ib-api-reloaded.github.io/ib_async/api.html 上的文件連接到您的TWS,並在https://groups.io/g/ insync 上進行討論。 (原始專案位於 https://github.com/erdewit/ib_insync。)
要安裝 ib_async,首先安裝 python3,然後執行:
pip3 安裝 ib_async
若要稍後更新 ib_async,請執行:
pip3 install --升級 ib_async
pandas 是一個有用的附加 Python 函式庫,用於資料分析和操作。
在 Debian 或 Ubuntu Linux 上安裝:
sudo apt-get install python3-pandas
或者你可以透過 pip3 安裝:
pip3安裝pandas
對於更新運行:
pip3 install --升級 pandas
下載 DOW、SP500 和 Nasdaq100 指數所有公司的歷史股票資料的範例腳本。
資料預設儲存在子目錄「data」中,因此請在呼叫此腳本之前建立該目錄。
請參閱 stock-hist-data-download.py。
如何更新SP500和Nasdaq100指數列表:
python3 stock-hist-data-download.py --list-index > TMPFILE diff -u stock-hist-data-download.py TMPFILE
另請參閱 https://github.com/deltaray-io/ib_dl。
自動執行 IB TWS:https://github.com/IbcAlpha/IBC
https://groups.io/g/ibcalpha
值得一看的 Github 主題:
https://github.com/topics/interactive-brokers
https://github.com/topics/tws
https://github.com/topics/tws-api
https://github.com/topics/ib-api
https://github.com/topics/ibapi
IB 紅寶石:https://github.com/ib-ruby
https://github.com/andrey-zotov/ib_console
https://github.com/pavanmullapudy/InteractiveBrokers_TWS_API
https://github.com/pavanmullapudy/InteractiveBrokers_TWS_API/blob/master/futures%20and%20options/NIFTY%20ORB%20Trading%20System/tech_indicators.py
與 TWS API 有點不同的是靈活查詢和下載/解析它們。
這裡有一些圍繞這個的項目:
https://github.com/MikePia/structjour