softwarespartan / IB4m

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

Is there a way to record returns from eClientSocket.reqHeadTimestamp? #59

Closed ecpgieicg closed 4 years ago

ecpgieicg commented 4 years ago

Hi Abel,

Is there a way to record returns from eClientSocket.reqHeadTimestamp?

For example, if we put in

>> session = TWS.Session.getInstance();
>> session.eClientSocket.eConnect('127.0.0.1',7497,2);
>> contract = com.ib.client.Contract();
>> contract.symbol("AMD");contract.secType("OPT");contract.exchange("SMART");contract.currency("USD");contract.lastTradeDateOrContractMonth("20190719");contract.strike(33.5);contract.right("Call");
>> session.eClientSocket.reqHeadTimestamp(703,contract,'TRADES',1,1);

The API log file will show a return like

07:28:13:328 <- 87-703-0-AMD-OPT-20190719-33.5-Call--SMART--USD---0-1-TRADES-1-
07:28:13:372 -> ---88-703-20190624  13:50:36-

(Although said data will be removed from IB server after this weekend.)

However, session.eventBuffer does not show the returned entry.

How can we record that in the buffer?

I can't find HeadTimestamp in any of the .m files. I also can't find it in the source client in the .jar package. I tried adding that as an event name in TWS.Events and the associated .m file for its event wrapper. But that does not work.

Thanks a lot.

softwarespartan commented 4 years ago

Right now that is separate callback in the api and is not exposed at the moment. I think you can get that same info from ContractDetails. Let me know.

On Jul 21, 2019, at 7:38 AM, ecpgieicg notifications@github.com wrote:

Hi Abel,

Is there a way to record returns from eClientSocket.reqHeadTimestamp?

For example, if we put in

session = TWS.Session.getInstance(); session.eClientSocket.eConnect('127.0.0.1',7497,2); contract = com.ib.client.Contract(); contract.symbol("AMD");contract.secType("OPT");contract.exchange("SMART");contract.currency("USD");contract.lastTradeDateOrContractMonth("20190719");contract.strike(33.5);contract.right("Call"); session.eClientSocket.reqHeadTimestamp(703,contract,'TRADES',1,1); The API log file will show a return like

07:28:13:328 <- 87-703-0-AMD-OPT-20190719-33.5-Call--SMART--USD---0-1-TRADES-1- 07:28:13:372 -> ---�88-703-20190624 13:50:36- (Although said data will be removed from IB server after this weekend.)

However, session.eventBuffer does not show the returned entry.

How can we record that in the buffer?

I can't find HeadTimestamp in any of the .m files. I also can't find it in the source client in the .jar package. I tried adding that as an event name in TWS.Events and the associated .m file for its event wrapper. But that does not work.

Thanks a lot.

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

ecpgieicg commented 4 years ago

contractDetails doesn't have it. Below is what it prints.

>> bufc.get().data.iterator().next().contractDetails

ans =

conid   372057203
symbol  AMD
secType OPT
lastTradeDateOrContractMonth    20190719
strike  33.5
right   C
multiplier  100
exchange    SMART
currency    USD
localSymbol AMD   190719C00033500
tradingClass    AMD
marketName  AMD
minTick 0.01
priceMagnifier  1
orderTypes  ACTIVETIM,ADJUST,ALERT,ALGO,ALLOC,AON,AVGCOST,BASKET,COND,CONDORDER,DAY,DEACT,DEACTDIS,DEACTEOD,DIS,FOK,GAT,GTC,GTD,GTT,HID,ICE,IOC,LIT,LMT,MIT,MKT,MTL,NGCOMB,NONALGO,OCA,OPENCLOSE,PAON,PEGMIDVOL,PEGMKTVOL,PEGPRMVOL,PEGSRFVOL,POSTONLY,REL,RELSTK,SCALE,SCALERST,SMARTSTG,SNAPMID,SNAPMKT,SNAPREL,STP,STPLMT,TRAIL,TRAILLIT,TRAILLMT,TRAILMIT,VOLAT,WHATIF
validExchanges  SMART,AMEX,CBOE,PHLX,PSE,ISE,BOX,BATS,NASDAQOM,CBOE2,NASDAQBX,MIAX,GEMINI,EDGX,MERCURY,PEARL,EMERALD
underConId  4391
longName    ADVANCED MICRO DEVICES
contractMonth   201907
evMultiplier    0.0
mdSizeMultiplier    1
aggGroup    2
underSymbol AMD
underSecType    STK
marketRuleIds   32,109,109,109,109,109,109,109,32,109,32,109,109,109,109,109,109
realExpirationDate  20190719
callable    false
putable false
coupon  0.0
convertible false
nextOptionPartial   false

Aside, is there a way to access the .strike field? It'd be useful for auto-discovering valid option contracts.

softwarespartan commented 4 years ago

I see. I’ll try to add it in IB4m this week. I’m on the road traveling this week so you might have to be an alpha tester for this when it gets pushed to the repo :)

-abel

On Jul 22, 2019, at 1:28 AM, ecpgieicg notifications@github.com wrote:

contractDetails doesn't have it. Below is what it prints.

bufc.get().data.iterator().next().contractDetails

ans =

conid 372057203 symbol AMD secType OPT lastTradeDateOrContractMonth 20190719 strike 33.5 right C multiplier 100 exchange SMART currency USD localSymbol AMD 190719C00033500 tradingClass AMD marketName AMD minTick 0.01 priceMagnifier 1 orderTypes ACTIVETIM,ADJUST,ALERT,ALGO,ALLOC,AON,AVGCOST,BASKET,COND,CONDORDER,DAY,DEACT,DEACTDIS,DEACTEOD,DIS,FOK,GAT,GTC,GTD,GTT,HID,ICE,IOC,LIT,LMT,MIT,MKT,MTL,NGCOMB,NONALGO,OCA,OPENCLOSE,PAON,PEGMIDVOL,PEGMKTVOL,PEGPRMVOL,PEGSRFVOL,POSTONLY,REL,RELSTK,SCALE,SCALERST,SMARTSTG,SNAPMID,SNAPMKT,SNAPREL,STP,STPLMT,TRAIL,TRAILLIT,TRAILLMT,TRAILMIT,VOLAT,WHATIF validExchanges SMART,AMEX,CBOE,PHLX,PSE,ISE,BOX,BATS,NASDAQOM,CBOE2,NASDAQBX,MIAX,GEMINI,EDGX,MERCURY,PEARL,EMERALD underConId 4391 longName ADVANCED MICRO DEVICES contractMonth 201907 evMultiplier 0.0 mdSizeMultiplier 1 aggGroup 2 underSymbol AMD underSecType STK marketRuleIds 32,109,109,109,109,109,109,109,32,109,32,109,109,109,109,109,109 realExpirationDate 20190719 callable false putable false coupon 0.0 convertible false nextOptionPartial false Aside, is there a way to access the .strike field? It'd be useful for auto-discovering valid option contracts.

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

ecpgieicg commented 4 years ago

Sounds good :)

softwarespartan commented 4 years ago

@ecpgieicg I have committed updates for headtimestamp today. Can you please test and let me know if any issues on your end.

ecpgieicg commented 4 years ago

@softwarespartan Hey, sorry for my delayed response. .eClientSocket.reqHeadTimestamp() works as intended with the event/listener created by TWS.Events.HEADTIMESTAMP().

Thank you!