@@ -703,6 +703,11 @@ func (c *EClient) TWSConnectionTime() string {
703703// mktDataOptions is for internal use only.Use default value XYZ.
704704func (c * EClient ) ReqMktData (reqID TickerID , contract * Contract , genericTickList string , snapshot bool , regulatorySnapshot bool , mktDataOptions []TagValue ) {
705705
706+ if c .useProtoBuf (REQ_MKT_DATA ) {
707+ c .reqMarketDataProtoBuf (createMarketDataRequestProto (reqID , contract , genericTickList , snapshot , regulatorySnapshot , mktDataOptions ))
708+ return
709+ }
710+
706711 if ! c .IsConnected () {
707712 c .wrapper .Error (reqID , currentTimeMillis (), NOT_CONNECTED .Code , NOT_CONNECTED .Msg , "" )
708713 return
@@ -784,9 +789,40 @@ func (c *EClient) ReqMktData(reqID TickerID, contract *Contract, genericTickList
784789 c .reqChan <- me .Bytes ()
785790}
786791
792+ func (c * EClient ) reqMarketDataProtoBuf (marketDataRequestProto * protobuf.MarketDataRequest ) {
793+
794+ reqID := NO_VALID_ID
795+ if marketDataRequestProto .ReqId != nil {
796+ reqID = int64 (* marketDataRequestProto .ReqId )
797+ }
798+
799+ if ! c .IsConnected () {
800+ c .wrapper .Error (reqID , currentTimeMillis (), NOT_CONNECTED .Code , NOT_CONNECTED .Msg , "" )
801+ return
802+ }
803+
804+ me := NewMsgEncoder (30 , c )
805+ me .encodeMsgID (REQ_MKT_DATA + PROTOBUF_MSG_ID )
806+
807+ msg , err := proto .Marshal (marketDataRequestProto )
808+ if err != nil {
809+ c .wrapper .Error (reqID , currentTimeMillis (), 0 , "Failed to marshal MarketDataRequest: " + err .Error (), "" )
810+ return
811+ }
812+
813+ me .encodeProto (msg )
814+
815+ c .reqChan <- me .Bytes ()
816+ }
817+
787818// CancelMktData stops the market data flow for the specified TickerId.
788819func (c * EClient ) CancelMktData (reqID TickerID ) {
789820
821+ if c .useProtoBuf (CANCEL_MKT_DATA ) {
822+ c .cancelMarketDataProtoBuf (createCancelMarketDataProto (reqID ))
823+ return
824+ }
825+
790826 if ! c .IsConnected () {
791827 c .wrapper .Error (reqID , currentTimeMillis (), NOT_CONNECTED .Code , NOT_CONNECTED .Msg , "" )
792828 return
@@ -801,6 +837,32 @@ func (c *EClient) CancelMktData(reqID TickerID) {
801837 c .reqChan <- me .Bytes ()
802838}
803839
840+ func (c * EClient ) cancelMarketDataProtoBuf (cancelMarketDataProto * protobuf.CancelMarketData ) {
841+
842+ reqID := NO_VALID_ID
843+ if cancelMarketDataProto .ReqId != nil {
844+ reqID = int64 (* cancelMarketDataProto .ReqId )
845+ }
846+
847+ if ! c .IsConnected () {
848+ c .wrapper .Error (reqID , currentTimeMillis (), NOT_CONNECTED .Code , NOT_CONNECTED .Msg , "" )
849+ return
850+ }
851+
852+ me := NewMsgEncoder (3 , c )
853+ me .encodeMsgID (CANCEL_MKT_DATA + PROTOBUF_MSG_ID )
854+
855+ msg , err := proto .Marshal (cancelMarketDataProto )
856+ if err != nil {
857+ c .wrapper .Error (reqID , currentTimeMillis (), 0 , "Failed to marshal CancelMarketData: " + err .Error (), "" )
858+ return
859+ }
860+
861+ me .encodeProto (msg )
862+
863+ c .reqChan <- me .Bytes ()
864+ }
865+
804866// ReqMarketDataType changes the market data type.
805867//
806868// The API can receive frozen market data from Trader Workstation. Frozen market data is the last data recorded in our system.
@@ -815,6 +877,11 @@ func (c *EClient) CancelMktData(reqID TickerID) {
815877// 4 -> delayed frozen market data
816878func (c * EClient ) ReqMarketDataType (marketDataType int64 ) {
817879
880+ if c .useProtoBuf (REQ_MARKET_DATA_TYPE ) {
881+ c .reqMarketDataTypeProtoBuf (createMarketDataTypeRequestProto (marketDataType ))
882+ return
883+ }
884+
818885 if ! c .IsConnected () {
819886 c .wrapper .Error (NO_VALID_ID , currentTimeMillis (), NOT_CONNECTED .Code , NOT_CONNECTED .Msg , "" )
820887 return
@@ -839,6 +906,27 @@ func (c *EClient) ReqMarketDataType(marketDataType int64) {
839906 c .reqChan <- me .Bytes ()
840907}
841908
909+ func (c * EClient ) reqMarketDataTypeProtoBuf (marketDataTypeRequestProto * protobuf.MarketDataTypeRequest ) {
910+
911+ if ! c .IsConnected () {
912+ c .wrapper .Error (NO_VALID_ID , currentTimeMillis (), NOT_CONNECTED .Code , NOT_CONNECTED .Msg , "" )
913+ return
914+ }
915+
916+ me := NewMsgEncoder (3 , c )
917+ me .encodeMsgID (REQ_MARKET_DATA_TYPE + PROTOBUF_MSG_ID )
918+
919+ msg , err := proto .Marshal (marketDataTypeRequestProto )
920+ if err != nil {
921+ c .wrapper .Error (NO_VALID_ID , currentTimeMillis (), 0 , "Failed to marshal MarketDataTypeRequest: " + err .Error (), "" )
922+ return
923+ }
924+
925+ me .encodeProto (msg )
926+
927+ c .reqChan <- me .Bytes ()
928+ }
929+
842930// ReqSmartComponents request the smartComponents.
843931func (c * EClient ) ReqSmartComponents (reqID int64 , bboExchange string ) {
844932
@@ -1855,13 +1943,14 @@ func (c *EClient) PlaceOrder(orderID OrderID, contract *Contract, order *Order)
18551943 if contract .Exchange == "IBKRATS" {
18561944 me .encodeIntMax (order .MinTradeQty )
18571945 }
1858- if order .OrderType == "PEG BEST" {
1946+ switch order .OrderType {
1947+ case "PEG BEST" :
18591948 me .encodeIntMax (order .MinCompeteSize )
18601949 me .encodeFloatMax (order .CompeteAgainstBestOffset )
18611950 if order .CompeteAgainstBestOffset == COMPETE_AGAINST_BEST_OFFSET_UP_TO_MID {
18621951 sendMidOffsets = true
18631952 }
1864- } else if order . OrderType == "PEG MID" {
1953+ case "PEG MID" :
18651954 sendMidOffsets = true
18661955 }
18671956 if sendMidOffsets {
@@ -2809,6 +2898,11 @@ func (c *EClient) ReqMktDepthExchanges() {
28092898// mktDepthOptions is for internal use only. Use default value XYZ.
28102899func (c * EClient ) ReqMktDepth (reqID int64 , contract * Contract , numRows int , isSmartDepth bool , mktDepthOptions []TagValue ) {
28112900
2901+ if c .useProtoBuf (REQ_MKT_DEPTH ) {
2902+ c .reqMarketDepthProtoBuf (createMarketDepthRequestProto (reqID , contract , int64 (numRows ), isSmartDepth , mktDepthOptions ))
2903+ return
2904+ }
2905+
28122906 if ! c .IsConnected () {
28132907 c .wrapper .Error (NO_VALID_ID , currentTimeMillis (), NOT_CONNECTED .Code , NOT_CONNECTED .Msg , "" )
28142908 return
@@ -2878,9 +2972,40 @@ func (c *EClient) ReqMktDepth(reqID int64, contract *Contract, numRows int, isSm
28782972 c .reqChan <- me .Bytes ()
28792973}
28802974
2975+ func (c * EClient ) reqMarketDepthProtoBuf (marketDepthRequestProto * protobuf.MarketDepthRequest ) {
2976+
2977+ reqID := NO_VALID_ID
2978+ if marketDepthRequestProto .ReqId != nil {
2979+ reqID = int64 (* marketDepthRequestProto .ReqId )
2980+ }
2981+
2982+ if ! c .IsConnected () {
2983+ c .wrapper .Error (reqID , currentTimeMillis (), NOT_CONNECTED .Code , NOT_CONNECTED .Msg , "" )
2984+ return
2985+ }
2986+
2987+ me := NewMsgEncoder (17 , c )
2988+ me .encodeMsgID (REQ_MKT_DEPTH + PROTOBUF_MSG_ID )
2989+
2990+ msg , err := proto .Marshal (marketDepthRequestProto )
2991+ if err != nil {
2992+ c .wrapper .Error (reqID , currentTimeMillis (), 0 , "Failed to marshal MarketDepthRequest: " + err .Error (), "" )
2993+ return
2994+ }
2995+
2996+ me .encodeProto (msg )
2997+
2998+ c .reqChan <- me .Bytes ()
2999+ }
3000+
28813001// CancelMktDepth cancels market depth updates.
28823002func (c * EClient ) CancelMktDepth (reqID int64 , isSmartDepth bool ) {
28833003
3004+ if c .useProtoBuf (CANCEL_MKT_DEPTH ) {
3005+ c .cancelMarketDepthProtoBuf (createCancelMarketDepthProto (reqID , isSmartDepth ))
3006+ return
3007+ }
3008+
28843009 if ! c .IsConnected () {
28853010 c .wrapper .Error (NO_VALID_ID , currentTimeMillis (), NOT_CONNECTED .Code , NOT_CONNECTED .Msg , "" )
28863011 return
@@ -2906,6 +3031,32 @@ func (c *EClient) CancelMktDepth(reqID int64, isSmartDepth bool) {
29063031 c .reqChan <- me .Bytes ()
29073032}
29083033
3034+ func (c * EClient ) cancelMarketDepthProtoBuf (cancelMarketDepthProto * protobuf.CancelMarketDepth ) {
3035+
3036+ reqID := NO_VALID_ID
3037+ if cancelMarketDepthProto .ReqId != nil {
3038+ reqID = int64 (* cancelMarketDepthProto .ReqId )
3039+ }
3040+
3041+ if ! c .IsConnected () {
3042+ c .wrapper .Error (reqID , currentTimeMillis (), NOT_CONNECTED .Code , NOT_CONNECTED .Msg , "" )
3043+ return
3044+ }
3045+
3046+ me := NewMsgEncoder (4 , c )
3047+ me .encodeMsgID (REQ_MKT_DEPTH + PROTOBUF_MSG_ID )
3048+
3049+ msg , err := proto .Marshal (cancelMarketDepthProto )
3050+ if err != nil {
3051+ c .wrapper .Error (reqID , currentTimeMillis (), 0 , "Failed to marshal CancelMarketDepth: " + err .Error (), "" )
3052+ return
3053+ }
3054+
3055+ me .encodeProto (msg )
3056+
3057+ c .reqChan <- me .Bytes ()
3058+ }
3059+
29093060// ##########################################################################
29103061// # News Bulletins
29113062// ##########################################################################
0 commit comments