softwarespartan / IB4m

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

reqHistoricalData missing input in the example in documentation #53

Closed ecpgieicg closed 4 years ago

ecpgieicg commented 5 years ago

Hi Abel,

Thank you for creating and sharing this package.

FYI, v9.72+ reqHistoricalData() requires an additional boolean before the empty list in the input. (Stipulated here.) So in the example,

session.eClientSocket.reqHistoricalData(1000001,contract,'20141230 16:00:00','1 Y','1 day','TRADES',1,1,[]); pause(0.5);

would need to be replaced with

session.eClientSocket.reqHistoricalData(1000001,contract,'20141230 16:00:00','1 Y','1 day','TRADES',1,1,false,[]); pause(0.5);

Your package itself still works smoothly.

Cheers

GIL1105 commented 4 years ago

Indeed by adding "false" I get a better result

But still have a problem

I have connected Matlab to TWS, all seems OK because AccountSummaryExample returns all the info about my IB account

Then I execute contract = com.tws.ContractFactory.GenericStockContract('FB');

and get the variable contract well filled in:

val = conid 0 symbol FB strike 0.0 exchange SMART currency USD primaryExch ISLAND

Then I execute session.eClientSocket.reqHistoricalData(1000001,contract,'20141230 16:00:00','1 Y','1 day','TRADES',false,1,1,[]);

but get the following error:

1000001 321 Error validating request:-'bP' : cause - Please enter a valid security type

Why is the stock FB invalid here ?

ecpgieicg commented 4 years ago

You need to specify the security type. I am not with my computer atm. If memory serves, it's either STK or STOCK. Let me know if you can make it work.

GIL1105 commented 4 years ago

Thank you for helping I forced STK into contract and stopped getting the invalid security error, sounds good But I got another error: enddates not supported with live updates

Please see below my short session:

clear session = TWS.Session.getInstance(); session.eClientSocket.eConnect('127.0.0.1',7496,0); -1 2104 Market data farm connection is OK:hfarm

-1 2104 Market data farm connection is OK:eufarm

-1 2104 Market data farm connection is OK:usfarm.nj

-1 2104 Market data farm connection is OK:jfarm

-1 2104 Market data farm connection is OK:usfuture

-1 2104 Market data farm connection is OK:cashfarm

-1 2104 Market data farm connection is OK:usfarm

-1 2106 HMDS data farm connection is OK:euhmds

-1 2106 HMDS data farm connection is OK:fundfarm

-1 2106 HMDS data farm connection is OK:ushmds

[buf,lh] = TWS.initBufferForEvent(TWS.Events.HISTORICALDATA); contract = com.tws.ContractFactory.GenericStockContract('FB'); contract.secType('STK');

session.eClientSocket.reqHistoricalData(1000001,contract,'20181230 16:00:00','1 Y','1 day','TRADES',false,1,1,[]); 1000001 321 Error validating request:-'bP' : cause - End date not supported with live updates

softwarespartan commented 4 years ago

@GIL1105 You should follow the example in docs. Not sure why you are using contract factory. Please open a separate issue

On Fri, Jul 12, 2019 at 5:28 AM GIL1105 notifications@github.com wrote:

Thank you for helping I forced STK into contract and stopped getting the invalid security error, sounds good But I got another error: enddates not supported with live updates

Please see below my short session:

clear session = TWS.Session.getInstance(); session.eClientSocket.eConnect('127.0.0.1',7496,0); -1 2104 Market data farm connection is OK:hfarm

-1 2104 Market data farm connection is OK:eufarm

-1 2104 Market data farm connection is OK:usfarm.nj

-1 2104 Market data farm connection is OK:jfarm

-1 2104 Market data farm connection is OK:usfuture

-1 2104 Market data farm connection is OK:cashfarm

-1 2104 Market data farm connection is OK:usfarm

-1 2106 HMDS data farm connection is OK:euhmds

-1 2106 HMDS data farm connection is OK:fundfarm

-1 2106 HMDS data farm connection is OK:ushmds

[buf,lh] = TWS.initBufferForEvent(TWS.Events.HISTORICALDATA); contract = com.tws.ContractFactory.GenericStockContract('FB'); contract.secType('STK');

session.eClientSocket.reqHistoricalData(1000001,contract,'20181230 16:00:00','1 Y','1 day','TRADES',false,1,1,[]); 1000001 321 Error validating request:-'bP' : cause - End date not supported with live updates

— 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/53?email_source=notifications&email_token=ABC2VVEG2FLRXI2QSMJJITTP7BFDNA5CNFSM4H2VHP5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZZHWMI#issuecomment-510819121, or mute the thread https://github.com/notifications/unsubscribe-auth/ABC2VVBP54VJW6VJPG5VTYDP7BFDNANCNFSM4H2VHP5A .

softwarespartan commented 4 years ago

@GIL1105 Be sure to initialize contracts as specified in the docs and as we discussed in your email yesterday

contract = com.ib.client.Contract(); contract.symbol('FB') contract.exchange('SMART'); contract.primaryExch('ISLAND'); contract.currency('USD'); contract.secType('STK');

Sent from my iPhone

On Jul 12, 2019, at 5:28 AM, GIL1105 notifications@github.com wrote:

Thank you for helping I forced STK into contract and stopped getting the invalid security error, sounds good But I got another error: enddates not supported with live updates

Please see below my short session:

clear session = TWS.Session.getInstance(); session.eClientSocket.eConnect('127.0.0.1',7496,0); -1 2104 Market data farm connection is OK:hfarm

-1 2104 Market data farm connection is OK:eufarm

-1 2104 Market data farm connection is OK:usfarm.nj

-1 2104 Market data farm connection is OK:jfarm

-1 2104 Market data farm connection is OK:usfuture

-1 2104 Market data farm connection is OK:cashfarm

-1 2104 Market data farm connection is OK:usfarm

-1 2106 HMDS data farm connection is OK:euhmds

-1 2106 HMDS data farm connection is OK:fundfarm

-1 2106 HMDS data farm connection is OK:ushmds

[buf,lh] = TWS.initBufferForEvent(TWS.Events.HISTORICALDATA); contract = com.tws.ContractFactory.GenericStockContract('FB'); contract.secType('STK');

session.eClientSocket.reqHistoricalData(1000001,contract,'20181230 16:00:00','1 Y','1 day','TRADES',false,1,1,[]); 1000001 321 Error validating request:-'bP' : cause - End date not supported with live updates

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

softwarespartan commented 4 years ago

@ecpgieicg looks like I didn't update the html when I did the code updates for v9.73. The actual codes (*.m) in the docs folder have been updated but the html is stale. I'll try to get that regenerated soon. Apologies for the confusion.

ecpgieicg commented 4 years ago

Sounds good. Cheers