softwarespartan / IB4m

Interactive Brokers API for Matlab
GNU General Public License v2.0
62 stars 21 forks source link

Only account summary works #67

Open dakr001 opened 4 years ago

dakr001 commented 4 years ago

First of all, thank you so much Abel Brown. This is amazing work.

Hoping someone can point me in the right direction with my issue. Have set up TWS and Matlab as per quick start guide.

I ran AccountSummaryExample and it seems to work fine, returning the correct account balance. However when I run HistoricalDataExample, I get the following error:

Error using HistoricalDataExample (line 37) Java exception occurred: org.apache.commons.collections.BufferUnderflowException: The buffer is already empty at org.apache.commons.collections.buffer.BoundedFifoBuffer.get(BoundedFifoBuffer.java:261)

Running ScannerSubscriptionExample gave similar error:

Error using ScannerSubscriptionExample (line 60) Java exception occurred: org.apache.commons.collections.BufferUnderflowException: The buffer is already empty at org.apache.commons.collections.buffer.BoundedFifoBuffer.get(BoundedFifoBuffer.java:261)

I have data subscriptions below and running the example at 12.45pm NY time Monday so market is open. I have matlab 2018b and 2019b.

Data subscriptions: US Equity and Options Add-On Streaming Bundle - North America IDEAL FX - Global US and EU Bond Quotes - Global US Securities Snapshot and Futures Value Bundle - North America IEX Depth of Book - North America US Reg NMS Snapshot - North America

Thanks.

softwarespartan commented 4 years ago

Thanks for reaching out

this is just an “error” telling you that the buffer is empty.

if you call “get” on an empty buffer an exception is thrown.

Certainly can pause for longer and wait for reply from TWS. I think the pause of 0.5 second is usually ok but depends on where you are geographically from the servers etc.

To alleviate the error just do something simple like “if buf.size() >0; e = buf.get()”

Cheers -abel

On Sep 23, 2019, at 12:53 PM, dakr001 notifications@github.com wrote:

First of all, thank you so much Abel Brown. This is amazing work.

Hoping someone can point me in the right direction with my issue. Have set up TWS and Matlab as per quick start guide.

I ran AccountSummaryExample and it seems to work fine, returning the correct account balance. However when I run HistoricalDataExample, I get the following error:

Error using HistoricalDataExample (line 37) Java exception occurred: org.apache.commons.collections.BufferUnderflowException: The buffer is already empty at org.apache.commons.collections.buffer.BoundedFifoBuffer.get(BoundedFifoBuffer.java:261)

Running ScannerSubscriptionExample gave similar error:

Error using ScannerSubscriptionExample (line 60) Java exception occurred: org.apache.commons.collections.BufferUnderflowException: The buffer is already empty at org.apache.commons.collections.buffer.BoundedFifoBuffer.get(BoundedFifoBuffer.java:261)

I have data subscriptions below and running the example at 12.45pm NY time Monday so market is open. I have matlab 2018b and 2019b.

Data subscriptions: US Equity and Options Add-On Streaming Bundle - North America IDEAL FX - Global US and EU Bond Quotes - Global US Securities Snapshot and Futures Value Bundle - North America IEX Depth of Book - North America US Reg NMS Snapshot - North America

Thanks.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/softwarespartan/IB4m/issues/67?email_source=notifications&email_token=ABC2VVH6IUX3XNZEAJQ6USLQLDYBRA5CNFSM4IZNJMH2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HNC4JJQ, or mute the thread https://github.com/notifications/unsubscribe-auth/ABC2VVA6RWIKO4NJQNWPIPTQLDYBRANCNFSM4IZNJMHQ.

dakr001 commented 4 years ago

Cheers Abel, managed to get the historical data now. However the scanner subscription is still problematic even after I added some pauses. Error below. Any tips on this one?

Unrecognized function or variable 'm_summary'.

Error in ScannerSubscriptionExample>@(sd)fprintf('%5s: %3d\n',char(sd.contractDetails.m_summary.m_symbol),sd.rank) (line 57) f = @(sd)fprintf('%5s: %3d\n',char(sd.contractDetails.m_summary.m_symbol),sd.rank);

Error in ScannerSubscriptionExample>@(e)f(e) (line 60) cellfun(@(e)f(e),collection2cell(buf.get.data));

Error in ScannerSubscriptionExample (line 60) cellfun(@(e)f(e),collection2cell(buf.get.data));

softwarespartan commented 4 years ago

This just needs updated for new +9.72 API (i.e. "contractDetails.contract().symbol”)

See the docs here

http://interactivebrokers.github.io/tws-api/classIBApi_1_1ContractDetails.html http://interactivebrokers.github.io/tws-api/classIBApi_1_1ContractDetails.html

-abel

On Sep 23, 2019, at 1:09 PM, dakr001 notifications@github.com wrote:

Cheers Able, managed to get the historical data now. However the scanner subscription is still problematic even after I added some pauses. Error below. Any tips on this one?

Unrecognized function or variable 'm_summary'.

Error in ScannerSubscriptionExample>@(sd)fprintf('%5s: %3d\n',char(sd.contractDetails.m_summary.m_symbol),sd.rank) (line 57) f = @(sd)fprintf('%5s: %3d\n',char(sd.contractDetails.m_summary.m_symbol),sd.rank);

Error in ScannerSubscriptionExample>@(e)f(e) (line 60) cellfun(@(e)f(e),collection2cell(buf.get.data));

Error in ScannerSubscriptionExample (line 60) cellfun(@(e)f(e),collection2cell(buf.get.data));

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/softwarespartan/IB4m/issues/67?email_source=notifications&email_token=ABC2VVFYEJ45UBSLQWP77FDQLDZ6HA5CNFSM4IZNJMH2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7LSN4A#issuecomment-534193904, or mute the thread https://github.com/notifications/unsubscribe-auth/ABC2VVEHPSHEXJNJP6LAS2DQLDZ6HANCNFSM4IZNJMHQ.

dakr001 commented 4 years ago

Thank you, I got it working now :)

By the way, the quickstarts says the code/examples have been updated for v9.73+.