ib_insync(pyton으로 Interactive Brokers API를 조작하는 프로그램 라이브러리)의 설치 및 사용
ib_인스타그램 소개
이것은 python으로 Interactive Brokers API를 조작하는 프로그램 라이브러리입니다.
GitHub - erdewit/ib_insync: Python sync/async framework for Interactive Brokers API
쓰기 편해서 쓰고 싶었는데 잠깐 빠져서 적어놨어요.
필요 환경
내 환경
$ cat /etc/lsb-release
DISTRIB_ID=LinuxMint
DISTRIB_RELEASE=18.1
DISTRIB_CODENAME=serena
DISTRIB_DESCRIPTION="Linux Mint 18.1 Serena"
차리다
Download
Interactive Brokers - API SoftwareVersion: API 9.73.06 이상. (2018/03/16 현재 DL LATEST 버전. Stable 안 됨)
Install
IB API LATEST 설치 .(윈도우즈에 설치 프로그램이 있는 것 같은데 그걸 따라가도 될까요?)
$ cd /tmp
$ unzip twsapi_macunix.972.18.zip -d $HOME/
# file が解凍されているか確認
$ cd ~/IBJts
# owner を確認
~/IBJts $ ls -alt
drwxr-xr-x 2 root root 4096 3月 14 11:52 ibapi
drwxr-xr-x 2 root root 4096 12月 28 18:35 tests
....
....
# もし,↑のようにowner が root なら,自分に変更する
~/IBJts $ sudo chown -R shineitaro:shineitaro ./
# pythonclient の setup.py を実行
$ cd ~/IBJts/source/pythonclient
~/IBJts/source/pythonclient $ pip install .
최신 IB 게이트웨이 설치
$ cd /tmp
$ chmod u+x ibgateway-latest-standalone-linux-x64.sh
$ ./ibgateway-latest-standalone-linux-x64.sh
ib_insync 설치
$ pip install -U ib_insync
시험해 보다
IB Gatwy 설정
IB 게이트웨이를 설치한 후 데모 계정을 통해 로그인합니다.
jupter notebook에서histoical 데이터 가져오기
# version は 3.6 以上か確認
import sys
print(sys.version)
# 3.6.4 ~~~
from ib_insync import *
# Jupyter Notebook で実行するときは必ずイベントループをスタートさせる必要があります.
# (ターミナルでは不要.)
util.startLoop()
# IB に接続
ib = IB()
# clientIdは適当な数値.
ib.connect('127.0.0.1', 4002, clientId=3)
contract = Index('SPX', exchange="CBOE", currency='USD', )
ib.reqHistoricalData(contract,
endDateTime='',
durationStr='10 D',
barSizeSetting='1 day',
whatToShow='TRADES',
useRTH=True,
formatDate=1)
#[BarData(date=datetime.date(2018, 3, 2), open=2660.42, high=2696.13, low=2647.79, close=2691.25, barCount=10119),
# BarData(date=datetime.date(2018, 3, 5), open=2684.75, high=2727.97, low=2675.9, close=2720.94, barCount=6243),
# BarData(date=datetime.date(2018, 3, 6), open=2728.86, high=2731.36, low=2711.55, close=2728.12, barCount=5745),
# ......
푹 꺼진 곳
본가github가 설치할 때 psyhoncient의 setup입니다.py를 실행해야 한다고 쓰지 않았습니다. py를 실행하지 않으면
No module named ‘ibapi’ / IB API from http://interactivebrokers.github.io is required
오류가 발생합니다. util.startLoop()
시용해 보다
Reference
이 문제에 관하여(ib_insync(pyton으로 Interactive Brokers API를 조작하는 프로그램 라이브러리)의 설치 및 사용), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/shinseitaro/items/56d591c3f9d2d775f3ea텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)