フィルターのクリア

Problem getting data from ibtws

3 ビュー (過去 30 日間)
Will
Will 2018 年 12 月 21 日
コメント済み: Annie Leonhart 2020 年 3 月 21 日
Hi guys,
I was testing out the trading toolbox with interactive brokers. I established the connection and tried to run the following code:
ib = ibtws('',7496)
ibContract = ib.Handle.createContract;
ibContract.symbol = 'AAPL';
ibContract.secType = 'STK';
ibContract.exchange = 'SMART';
ibContract.primaryExchange = 'NASDAQ';
ibContract.currency = 'USD';
startdate = floor(now) - 5;
enddate = floor(now);
d = history(ib,ibContract,startdate,enddate)
It returned:
ib =
ibtws with properties:
ClientId: 0
Handle: [1×1 COM.TWS_TwsCtrl]
Host: ''
Port: 7496
d =
'Unable to read beyond the end of the stream.'
Does anyone know why?
  4 件のコメント
Rosanna Campagna
Rosanna Campagna 2019 年 7 月 28 日
Same problem, could you help me?
Oliver Rubicon
Oliver Rubicon 2019 年 12 月 28 日
Same problem, can someone help?

サインインしてコメントする。

回答 (2 件)

Will
Will 2019 年 1 月 7 日
Anyone?

Annie Leonhart
Annie Leonhart 2019 年 12 月 1 日
Please set the primaryExchange to 'SMART', they cannot be different from my testing. In some cases you need to run the command twice, becasue Matlab isn't accounting for the time needed for the API to connect to the historical data feed.
I am using Matlab 2019a: Trading Toolbox 3.5.1 & TWS Api 9.76
ib = ibtws('',4001, 0)
ibContract = ib.Handle.createContract;
ibContract.symbol = 'AAPL';
ibContract.secType = 'STK';
ibContract.exchange = 'SMART';
ibContract.primaryExchange = 'SMART';
ibContract.currency = 'USD';
startdate = floor(now) - 5;
enddate = floor(now);
d = history(ib,ibContract,startdate,enddate)
Screenshot_4.jpg
  9 件のコメント
Sandro Hantke
Sandro Hantke 2020 年 3 月 21 日
Annie,
I just solved the problem! IBContract.exchange=IBIS
Annie Leonhart
Annie Leonhart 2020 年 3 月 21 日
That’s right. SMART only works for stocks. Futures, bonds, etc you must specify the exact exchange.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeTransaction Cost Analysis についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by