diff --git a/client.go b/client.go index 02fb432..bd58bcd 100644 --- a/client.go +++ b/client.go @@ -31,7 +31,7 @@ type IbClient struct { writer *bufio.Writer wrapper IbWrapper decoder *ibDecoder - connectOption []byte + connectOptions string reqIDSeq int64 reqChan chan []byte errChan chan error @@ -68,7 +68,7 @@ func (ic *IbClient) ConnState() int { func (ic *IbClient) setConnState(connState int) { OldConnState := ic.conn.state ic.conn.state = connState - log.Infof("connState: %v -> %v", OldConnState, connState) + log.Infof("ConnState: %v -> %v", OldConnState, connState) } // GetReqID before request data or place order @@ -89,6 +89,11 @@ func (ic *IbClient) SetContext(ctx context.Context) { ic.ctx = ctx } +// Set the Connection Options to IbClient +func (ic *IbClient) SetConnectionOptions(opts string) { + ic.connectOptions = opts +} + // Connect try to connect the TWS or IB GateWay, after this, handshake should be call to get the connection done func (ic *IbClient) Connect(host string, port int, clientID int64) error { @@ -136,7 +141,7 @@ func (ic *IbClient) startAPI() error { startAPI = makeMsgBytes(int64(mSTART_API), int64(v), ic.clientID) } - log.Info("Start API:", startAPI) + log.Debug("Start API:", startAPI) if _, err := ic.writer.Write(startAPI); err != nil { return err } @@ -155,7 +160,12 @@ func (ic *IbClient) HandShake() error { head := []byte("API\x00") minVer := []byte(strconv.FormatInt(int64(MIN_CLIENT_VER), 10)) maxVer := []byte(strconv.FormatInt(int64(MAX_CLIENT_VER), 10)) + connectOptions := []byte("") + if ic.connectOptions != "" { + connectOptions = []byte(" " + ic.connectOptions) + } + clientVersion := bytes.Join([][]byte{[]byte("v"), minVer, []byte(".."), maxVer, connectOptions}, []byte("")) sizeofCV := make([]byte, 4) binary.BigEndian.PutUint32(sizeofCV, uint32(len(clientVersion))) @@ -171,7 +181,7 @@ func (ic *IbClient) HandShake() error { return err } - log.Info("Recv ServerInitInfo...") + log.Debug("Recv Server Init Info...") if msgBytes, err = readMsgBytes(ic.reader); err != nil { return err } @@ -229,7 +239,7 @@ comfirmReadyLoop: } func (ic *IbClient) reset() { - log.Info("reset IbClient.") + log.Info("Reset IbClient.") ic.reqIDSeq = 0 ic.conn = &IbConnection{} ic.conn.reset() @@ -2585,8 +2595,8 @@ func (ic *IbClient) ReqCompletedOrders(apiOnly bool) { //--------------------------three major goroutine ----------------------------------------------------- //goRequest will get the req from reqChan and send it to TWS func (ic *IbClient) goRequest() { - log.Info("Start goRequest!") - defer log.Info("End goRequest!") + log.Info("Requester START!") + defer log.Info("Requester END!") defer ic.wg.Done() ic.wg.Add(1) @@ -2618,11 +2628,11 @@ requestLoop: //goReceive receive the msg from the socket, get the fields and put them into msgChan //goReceive handle the msgBuf which is different from the offical.Not continuously read, but split first and then decode func (ic *IbClient) goReceive() { - log.Info("Start goReceive!") - defer log.Info("End goReceive!") + log.Info("Receiver START!") + defer log.Info("Receiver END!") defer func() { if err := recover(); err != nil { - log.Errorf("goReceive has unexpected error: %v", err) + log.Errorf("Receiver got unexpected error: %v", err) } }() defer ic.wg.Done() @@ -2644,22 +2654,22 @@ scanLoop: err := scanner.Err() if err, ok := err.(*net.OpError); ok && !err.Temporary() { - log.Panicf("errgoReceive: %v", err) + log.Panicf("Receiver Panic: %v", err) return } else if err != nil { - log.Errorf("errgoReceive Temporary: %v", err) + log.Errorf("Receiver Temporary Error: %v", err) ic.errChan <- err ic.reader.Reset(ic.conn) goto scanLoop } else { - panic(scanner.Err()) + log.Panicf("Scanner Panic: %v", scanner.Err()) } } //goDecode decode the fields received from the msgChan func (ic *IbClient) goDecode() { - log.Info("Start goDecode!") - defer log.Info("End goDecode!") + log.Info("Decoder START!") + defer log.Info("Decoder END!") defer ic.wg.Done() ic.wg.Add(1) diff --git a/client_test.go b/client_test.go index bbb0b91..8edfb36 100644 --- a/client_test.go +++ b/client_test.go @@ -19,6 +19,7 @@ func TestClient(t *testing.T) { return } + ic.SetConnectionOptions("+PACEAPI") err = ic.HandShake() if err != nil { log.Println("HandShake failed:", err) @@ -26,13 +27,13 @@ func TestClient(t *testing.T) { } ic.Run() - // ic.ReqCurrentTime() + ic.ReqCurrentTime() // ic.ReqAutoOpenOrders(true) // ic.ReqAccountUpdates(true, "") // ic.ReqExecutions(ic.GetReqID(), ExecutionFilter{}) hsi2003 := Contract{ContractID: 376399002, Symbol: "HSI", SecurityType: "FUT", Exchange: "HKFE"} - // ic.ReqHistoricalData(ic.GetReqID(), &hsi1909, "", "4800 S", "1 min", "TRADES", false, 1, true, nil) + ic.ReqHistoricalData(ic.GetReqID(), &hsi2003, "", "4800 S", "1 min", "TRADES", false, 1, true, nil) // ic.ReqMktDepth(ic.GetReqID(), &hsi1909, 5, true, nil) ic.ReqContractDetails(ic.GetReqID(), &hsi2003) // ic.ReqAllOpenOrders() diff --git a/common.go b/common.go index 305722b..2a10443 100644 --- a/common.go +++ b/common.go @@ -15,7 +15,7 @@ type TickAttrib struct { } func (t TickAttrib) String() string { - return fmt.Sprintf("CanAutoExecute: %t, PastLimit: %t, PreOpen: %t", + return fmt.Sprintf("TickAttrib", t.CanAutoExecute, t.PastLimit, t.PreOpen) @@ -30,13 +30,17 @@ type TagValue struct { } func (tv TagValue) String() string { - return fmt.Sprintf("%s=%s;", tv.Tag, tv.Value) + return fmt.Sprintf("TagValue<%s=%s>", tv.Tag, tv.Value) } type OrderComboLeg struct { Price float64 `default:"UNSETFLOAT"` } +func (o OrderComboLeg) String() string { + return fmt.Sprintf("OrderComboLeg;", o.Price) +} + // ------------ComboLeg-------------------- type ComboLegOpenClose int64 type ComboLegShortSaleSlot int64 @@ -64,7 +68,7 @@ type ComboLeg struct { } func (c ComboLeg) String() string { - return fmt.Sprintf("%d, %d, %s, %s, %d, %d, %s, %d", + return fmt.Sprintf("ComboLeg<%d, %d, %s, %s, %d, %d, %s, %d>", c.ContractID, c.Ratio, c.Action, @@ -99,7 +103,7 @@ type BarData struct { } func (b BarData) String() string { - return fmt.Sprintf("Date: %s, Open: %f, High: %f, Low: %f, Close: %f, Volume: %f, Average: %f, BarCount: %d", + return fmt.Sprintf("BarData", b.Date, b.Open, b.High, @@ -123,7 +127,7 @@ type RealTimeBar struct { } func (rb RealTimeBar) String() string { - return fmt.Sprintf("Time: %d, Open: %f, High: %f, Low: %f, Close: %f, Volume: %d, Wap: %f, Count: %d", + return fmt.Sprintf("RealTimeBar", rb.Time, rb.Open, rb.High, @@ -144,7 +148,7 @@ type CommissionReport struct { } func (cr CommissionReport) String() string { - return fmt.Sprintf("ExecId: %v, Commission: %v, Currency: %v, RealizedPnL: %v, Yield: %v, YieldRedemptionDate: %v", + return fmt.Sprintf("CommissionReport", cr.ExecId, cr.Commission, cr.Currency, @@ -159,7 +163,7 @@ type FamilyCode struct { } func (f FamilyCode) String() string { - return fmt.Sprintf("AccountId: %s, FamilyCodeStr: %s", + return fmt.Sprintf("FamilyCode", f.AccountID, f.FamilyCode) } @@ -171,7 +175,7 @@ type SmartComponent struct { } func (s SmartComponent) String() string { - return fmt.Sprintf("BitNumber: %d, Exchange: %s, ExchangeLetter: %s", + return fmt.Sprintf("SmartComponent", s.BitNumber, s.Exchange, s.ExchangeLetter) @@ -191,7 +195,7 @@ func (d DepthMktDataDescription) String() string { aggGroup = string(d.AggGroup) } - return fmt.Sprintf("Exchange: %s, SecType: %s, ListingExchange: %s, ServiceDataType: %s, AggGroup: %s ", + return fmt.Sprintf("DepthMktDataDescription", d.Exchange, d.SecurityType, d.ListingExchange, @@ -205,7 +209,7 @@ type NewsProvider struct { } func (np NewsProvider) String() string { - return fmt.Sprintf("Code: %s, Name: %s", + return fmt.Sprintf("NewsProvider", np.Code, np.Name) } @@ -216,7 +220,7 @@ type HistogramData struct { } func (hgd HistogramData) String() string { - return fmt.Sprintf("Price: %f, Count: %d", + return fmt.Sprintf("HistogramData", hgd.Price, hgd.Count) } @@ -227,7 +231,7 @@ type PriceIncrement struct { } func (p PriceIncrement) String() string { - return fmt.Sprintf("LowEdge: %f, Increment: %f", + return fmt.Sprintf("PriceIncrement", p.LowEdge, p.Increment) } @@ -239,7 +243,7 @@ type HistoricalTick struct { } func (h HistoricalTick) String() string { - return fmt.Sprintf("Time: %d, Price: %f, Size: %d", + return fmt.Sprintf("Tick", h.Time, h.Price, h.Size) @@ -255,7 +259,7 @@ type HistoricalTickBidAsk struct { } func (h HistoricalTickBidAsk) String() string { - return fmt.Sprintf("Time: %d, TickAttriBidAsk: %s, PriceBid: %f, PriceAsk: %f, SizeBid: %d, SizeAsk: %d", + return fmt.Sprintf("TickBidAsk", h.Time, h.TickAttirbBidAsk, h.PriceBid, @@ -270,7 +274,7 @@ type TickAttribBidAsk struct { } func (t TickAttribBidAsk) String() string { - return fmt.Sprintf("BidPastLow: %t, AskPastHigh: %t", + return fmt.Sprintf("TickAttribBidAsk", t.BidPastLow, t.AskPastHigh) } @@ -285,7 +289,7 @@ type HistoricalTickLast struct { } func (h HistoricalTickLast) String() string { - return fmt.Sprintf("Time: %d, TickAttribLast: %s, Price: %f, Size: %d, Exchange: %s, SpecialConditions: %s", + return fmt.Sprintf("TickLast", h.Time, h.TickAttribLast, h.Price, @@ -300,7 +304,7 @@ type TickAttribLast struct { } func (t TickAttribLast) String() string { - return fmt.Sprintf("PastLimit: %t, Unreported: %t", + return fmt.Sprintf("TickAttribLast", t.PastLimit, t.Unreported) } diff --git a/contract.go b/contract.go index 5fcb8d3..8dc0547 100644 --- a/contract.go +++ b/contract.go @@ -29,7 +29,7 @@ type Contract struct { } func (c Contract) String() string { - basicStr := fmt.Sprintf("CondID: %d , Symbol: %s, SecurityType: %s, Exchange: %s, Currency: %s, ", + basicStr := fmt.Sprintf("Contract", c.Expiry, c.Multiplier, c.SecurityID, c.SecurityIDType) case "OPT": - basicStr += fmt.Sprintf("Expiry: %s, Strike: %f, Right: %s, SecurityID: %s, SecurityIDType:%s", c.Expiry, c.Strike, c.Right, c.SecurityID, c.SecurityIDType) + basicStr += fmt.Sprintf(", Expiry: %s, Strike: %f, Right: %s, SecurityID: %s, SecurityIDType: %s>", c.Expiry, c.Strike, c.Right, c.SecurityID, c.SecurityIDType) + default: + basicStr += fmt.Sprint(">") } for i, leg := range c.ComboLegs { - basicStr += fmt.Sprintf(";Leg<%d>-%s", i, leg) + basicStr += fmt.Sprintf("-Leg<%d>: %s", i, leg) } if c.DeltaNeutralContract != nil { - basicStr += fmt.Sprintf(";DeltaNeutralContract-%s", c.DeltaNeutralContract) + basicStr += fmt.Sprintf("-%s", c.DeltaNeutralContract) } return basicStr @@ -61,7 +63,7 @@ type DeltaNeutralContract struct { } func (c DeltaNeutralContract) String() string { - return fmt.Sprintf("CondID: %d , Delta: %f, Price: %f", + return fmt.Sprintf("DeltaNeutralContract", c.ContractID, c.Delta, c.Price) @@ -116,7 +118,7 @@ type ContractDetails struct { } func (c ContractDetails) String() string { - return fmt.Sprintf("Contract: %s, MarketName: %s, UnderContractID: %d, TradingHours: %s", c.Contract, c.MarketName, c.UnderContractID, c.TradingHours) + return fmt.Sprintf("ContractDetails", c.Contract, c.MarketName, c.UnderContractID, c.LongName) } type ContractDescription struct { diff --git a/order.go b/order.go index 509554e..a59af32 100644 --- a/order.go +++ b/order.go @@ -202,7 +202,7 @@ type Order struct { } func (o Order) String() string { - s := fmt.Sprintf("%d, %d, %d: %s %s %.2f@%f %s ", + s := fmt.Sprintf("Order -- <%s %s %.2f@%f %s> --", o.OrderID, o.ClientID, o.PermID, @@ -213,11 +213,11 @@ func (o Order) String() string { o.TIF) for i, leg := range o.OrderComboLegs { - s += fmt.Sprintf(" CMB<%d>-%v)", i, leg) + s += fmt.Sprintf(" CMB<%d>-%s", i, leg) } for i, cond := range o.Conditions { - s += fmt.Sprintf(" COND<%d>-%v)", i, cond) + s += fmt.Sprintf(" COND<%d>-%s", i, cond) } return s @@ -251,7 +251,7 @@ type SoftDollarTier struct { } func (s SoftDollarTier) String() string { - return fmt.Sprintf("Name: %s, Value: %s, DisplayName: %s", + return fmt.Sprintf("SoftDollarTier", s.Name, s.Value, s.DisplayName) diff --git a/wrapper.go b/wrapper.go index 80f076c..14f3f34 100644 --- a/wrapper.go +++ b/wrapper.go @@ -104,237 +104,237 @@ func (w *Wrapper) GetNextOrderID() (i int64) { } func (w Wrapper) ConnectAck() { - log.Printf("...") + log.Printf("...") } func (w *Wrapper) NextValidID(reqID int64) { atomic.StoreInt64(&w.orderID, reqID) - log.WithField("reqID", reqID).Printf(": %v.", reqID) + log.WithField("reqID", reqID).Printf(": %v.", reqID) } func (w Wrapper) ManagedAccounts(accountsList []string) { - log.Printf(": %v.", accountsList) + log.Printf(": %v.", accountsList) } func (w Wrapper) TickPrice(reqID int64, tickType int64, price float64, attrib TickAttrib) { - log.WithField("reqID", reqID).Printf(": tickType: %v price: %v.", tickType, price) + log.WithField("reqID", reqID).Printf(": tickType: %v price: %v.", tickType, price) } func (w Wrapper) UpdateAccountTime(accTime time.Time) { - log.Printf(": %v", accTime) + log.Printf(": %v", accTime) } func (w Wrapper) UpdateAccountValue(tag string, value string, currency string, account string) { - log.WithFields(log.Fields{"account": account, tag: value, "currency": currency}).Print("") + log.WithFields(log.Fields{"account": account, tag: value, "currency": currency}).Print("") } func (w Wrapper) AccountDownloadEnd(accName string) { - log.Printf(": %v", accName) + log.Printf(": %v", accName) } func (w Wrapper) AccountUpdateMulti(reqID int64, account string, modelCode string, tag string, value string, currency string) { - log.WithFields(log.Fields{"reqID": reqID, "account": account, tag: value, "currency": currency, "modelCode": modelCode}).Print("") + log.WithFields(log.Fields{"reqID": reqID, "account": account, tag: value, "currency": currency, "modelCode": modelCode}).Print("") } func (w Wrapper) AccountUpdateMultiEnd(reqID int64) { - log.WithField("reqID", reqID).Print("") + log.WithField("reqID", reqID).Print("") } func (w Wrapper) AccountSummary(reqID int64, account string, tag string, value string, currency string) { - log.WithFields(log.Fields{"reqID": reqID, "account": account, tag: value, "currency": currency}).Print("") + log.WithFields(log.Fields{"reqID": reqID, "account": account, tag: value, "currency": currency}).Print("") } func (w Wrapper) AccountSummaryEnd(reqID int64) { - log.WithField("reqID", reqID).Print("") + log.WithField("reqID", reqID).Print("") } func (w Wrapper) VerifyMessageAPI(apiData string) { - log.Printf(": apiData: %v", apiData) + log.Printf(": apiData: %v", apiData) } func (w Wrapper) VerifyCompleted(isSuccessful bool, err string) { - log.Printf(": isSuccessful: %v error: %v", isSuccessful, err) + log.Printf(": isSuccessful: %v error: %v", isSuccessful, err) } func (w Wrapper) VerifyAndAuthMessageAPI(apiData string, xyzChallange string) { - log.Printf(": apiData: %v xyzChallange: %v", apiData, xyzChallange) + log.Printf(": apiData: %v xyzChallange: %v", apiData, xyzChallange) } func (w Wrapper) VerifyAndAuthCompleted(isSuccessful bool, err string) { - log.Printf(": isSuccessful: %v error: %v", isSuccessful, err) + log.Printf(": isSuccessful: %v error: %v", isSuccessful, err) } func (w Wrapper) DisplayGroupList(reqID int64, groups string) { - log.WithField("reqID", reqID).Printf(": groups: %v", groups) + log.WithField("reqID", reqID).Printf(": groups: %v", groups) } func (w Wrapper) DisplayGroupUpdated(reqID int64, contractInfo string) { - log.WithField("reqID", reqID).Printf(": contractInfo: %v", contractInfo) + log.WithField("reqID", reqID).Printf(": contractInfo: %v", contractInfo) } func (w Wrapper) PositionMulti(reqID int64, account string, modelCode string, contract *Contract, position float64, avgCost float64) { - log.WithField("reqID", reqID).Printf(": account: %v modelCode: %v contract: <%v> position: %v avgCost: %v", account, modelCode, contract, position, avgCost) + log.WithField("reqID", reqID).Printf(": account: %v modelCode: %v contract: <%v> position: %v avgCost: %v", account, modelCode, contract, position, avgCost) } func (w Wrapper) PositionMultiEnd(reqID int64) { - log.WithField("reqID", reqID).Print("") + log.WithField("reqID", reqID).Print("") } func (w Wrapper) UpdatePortfolio(contract *Contract, position float64, marketPrice float64, marketValue float64, averageCost float64, unrealizedPNL float64, realizedPNL float64, accName string) { - log.Printf(": contract: %v pos: %v marketPrice: %v averageCost: %v unrealizedPNL: %v realizedPNL: %v", contract.LocalSymbol, position, marketPrice, averageCost, unrealizedPNL, realizedPNL) + log.Printf(": contract: %v pos: %v marketPrice: %v averageCost: %v unrealizedPNL: %v realizedPNL: %v", contract.LocalSymbol, position, marketPrice, averageCost, unrealizedPNL, realizedPNL) } func (w Wrapper) Position(account string, contract *Contract, position float64, avgCost float64) { - log.Printf(": account: %v, contract: %v position: %v, avgCost: %v", account, contract, position, avgCost) + log.Printf(": account: %v, contract: %v position: %v, avgCost: %v", account, contract, position, avgCost) } func (w Wrapper) PositionEnd() { - log.Printf("") + log.Printf("") } func (w Wrapper) Pnl(reqID int64, dailyPnL float64, unrealizedPnL float64, realizedPnL float64) { - log.WithField("reqID", reqID).Printf(": dailyPnL: %v unrealizedPnL: %v realizedPnL: %v", dailyPnL, unrealizedPnL, realizedPnL) + log.WithField("reqID", reqID).Printf(": dailyPnL: %v unrealizedPnL: %v realizedPnL: %v", dailyPnL, unrealizedPnL, realizedPnL) } func (w Wrapper) PnlSingle(reqID int64, position int64, dailyPnL float64, unrealizedPnL float64, realizedPnL float64, value float64) { - log.WithField("reqID", reqID).Printf(": position: %v dailyPnL: %v unrealizedPnL: %v realizedPnL: %v value: %v", position, dailyPnL, unrealizedPnL, realizedPnL, value) + log.WithField("reqID", reqID).Printf(": position: %v dailyPnL: %v unrealizedPnL: %v realizedPnL: %v value: %v", position, dailyPnL, unrealizedPnL, realizedPnL, value) } func (w Wrapper) OpenOrder(orderID int64, contract *Contract, order *Order, orderState *OrderState) { - log.WithField("orderID", orderID).Printf(": orderId: %v contract: <%v> order: %v orderState: %v.", orderID, contract, order.OrderID, orderState.Status) + log.WithField("orderID", orderID).Printf(": orderId: %v contract: <%v> order: %v orderState: %v.", orderID, contract, order.OrderID, orderState.Status) } func (w Wrapper) OpenOrderEnd() { - log.Printf("") + log.Print("") } func (w Wrapper) OrderStatus(orderID int64, status string, filled float64, remaining float64, avgFillPrice float64, permID int64, parentID int64, lastFillPrice float64, clientID int64, whyHeld string, mktCapPrice float64) { - log.WithField("orderID", orderID).Printf(": orderId: %v status: %v filled: %v remaining: %v avgFillPrice: %v.", orderID, status, filled, remaining, avgFillPrice) + log.WithField("orderID", orderID).Printf(": orderId: %v status: %v filled: %v remaining: %v avgFillPrice: %v.", orderID, status, filled, remaining, avgFillPrice) } func (w Wrapper) ExecDetails(reqID int64, contract *Contract, execution *Execution) { - log.WithField("reqID", reqID).Printf(": contract: %v execution: %v.", contract, execution) + log.WithField("reqID", reqID).Printf(": contract: %v execution: %v.", contract, execution) } func (w Wrapper) ExecDetailsEnd(reqID int64) { - log.WithField("reqID", reqID).Print("") + log.WithField("reqID", reqID).Print("") } func (w Wrapper) DeltaNeutralValidation(reqID int64, deltaNeutralContract DeltaNeutralContract) { - log.WithField("reqID", reqID).Printf(": deltaNeutralContract: %v", deltaNeutralContract) + log.WithField("reqID", reqID).Printf(": deltaNeutralContract: %v", deltaNeutralContract) } func (w Wrapper) CommissionReport(commissionReport CommissionReport) { - log.Printf(": commissionReport: %v", commissionReport) + log.Printf(": commissionReport: %v", commissionReport) } func (w Wrapper) OrderBound(reqID int64, apiClientID int64, apiOrderID int64) { - log.WithField("reqID", reqID).Printf(": apiClientID: %v apiOrderID: %v", apiClientID, apiOrderID) + log.WithField("reqID", reqID).Printf(": apiClientID: %v apiOrderID: %v", apiClientID, apiOrderID) } func (w Wrapper) ContractDetails(reqID int64, conDetails *ContractDetails) { - log.WithField("reqID", reqID).Printf(": contractDetails: %v", conDetails) + log.WithField("reqID", reqID).Printf(": contractDetails: %v", conDetails) } func (w Wrapper) ContractDetailsEnd(reqID int64) { - log.WithField("reqID", reqID).Print("") + log.WithField("reqID", reqID).Print("") } func (w Wrapper) BondContractDetails(reqID int64, conDetails *ContractDetails) { - log.WithField("reqID", reqID).Printf(": contractDetails: %v", conDetails) + log.WithField("reqID", reqID).Printf(": contractDetails: %v", conDetails) } func (w Wrapper) SymbolSamples(reqID int64, contractDescriptions []ContractDescription) { - log.WithField("reqID", reqID).Printf(": contractDescriptions: %v", contractDescriptions) + log.WithField("reqID", reqID).Printf(": contractDescriptions: %v", contractDescriptions) } func (w Wrapper) SmartComponents(reqID int64, smartComps []SmartComponent) { - log.WithField("reqID", reqID).Printf(": smartComponents: %v", smartComps) + log.WithField("reqID", reqID).Printf(": smartComponents: %v", smartComps) } func (w Wrapper) MarketRule(marketRuleID int64, priceIncrements []PriceIncrement) { - log.WithField("marketRuleID", marketRuleID).Printf(": marketRuleID: %v priceIncrements: %v", marketRuleID, priceIncrements) + log.WithField("marketRuleID", marketRuleID).Printf(": marketRuleID: %v priceIncrements: %v", marketRuleID, priceIncrements) } func (w Wrapper) RealtimeBar(reqID int64, time int64, open float64, high float64, low float64, close float64, volume int64, wap float64, count int64) { - log.WithField("reqID", reqID).Printf(": time: %v [O: %v H: %v, L: %v C: %v] volume: %v wap: %v count: %v", time, open, high, low, close, volume, wap, count) + log.WithField("reqID", reqID).Printf(": time: %v [O: %v H: %v, L: %v C: %v] volume: %v wap: %v count: %v", time, open, high, low, close, volume, wap, count) } func (w Wrapper) HistoricalData(reqID int64, bar *BarData) { - log.WithField("reqID", reqID).Printf(": bar: %v", bar) + log.WithField("reqID", reqID).Printf(": bar: %v", bar) } func (w Wrapper) HistoricalDataEnd(reqID int64, startDateStr string, endDateStr string) { - log.WithField("reqID", reqID).Printf(": startDate: %v endDate: %v", startDateStr, endDateStr) + log.WithField("reqID", reqID).Printf(": startDate: %v endDate: %v", startDateStr, endDateStr) } func (w Wrapper) HistoricalDataUpdate(reqID int64, bar *BarData) { - log.WithField("reqID", reqID).Printf(": bar: %v", bar) + log.WithField("reqID", reqID).Printf(": bar: %v", bar) } func (w Wrapper) HeadTimestamp(reqID int64, headTimestamp string) { - log.WithField("reqID", reqID).Printf(": headTimestamp: %v", headTimestamp) + log.WithField("reqID", reqID).Printf(": headTimestamp: %v", headTimestamp) } func (w Wrapper) HistoricalTicks(reqID int64, ticks []HistoricalTick, done bool) { - log.WithField("reqID", reqID).Printf(": done: %v", done) + log.WithField("reqID", reqID).Printf(": done: %v", done) } func (w Wrapper) HistoricalTicksBidAsk(reqID int64, ticks []HistoricalTickBidAsk, done bool) { - log.WithField("reqID", reqID).Printf(": done: %v", done) + log.WithField("reqID", reqID).Printf(": done: %v", done) } func (w Wrapper) HistoricalTicksLast(reqID int64, ticks []HistoricalTickLast, done bool) { - log.WithField("reqID", reqID).Printf(": done: %v", done) + log.WithField("reqID", reqID).Printf(": done: %v", done) } func (w Wrapper) TickSize(reqID int64, tickType int64, size int64) { - log.WithField("reqID", reqID).Printf(": tickType: %v size: %v.", tickType, size) + log.WithField("reqID", reqID).Printf(": tickType: %v size: %v.", tickType, size) } func (w Wrapper) TickSnapshotEnd(reqID int64) { - log.WithField("reqID", reqID).Print("") + log.WithField("reqID", reqID).Print("") } func (w Wrapper) MarketDataType(reqID int64, marketDataType int64) { - log.WithField("reqID", reqID).Printf(": marketDataType: %v", marketDataType) + log.WithField("reqID", reqID).Printf(": marketDataType: %v", marketDataType) } func (w Wrapper) TickByTickAllLast(reqID int64, tickType int64, time int64, price float64, size int64, tickAttribLast TickAttribLast, exchange string, specialConditions string) { - log.WithField("reqID", reqID).Printf(":tickType: %v time: %v price: %v size: %v", tickType, time, price, size) + log.WithField("reqID", reqID).Printf(":tickType: %v time: %v price: %v size: %v", tickType, time, price, size) } func (w Wrapper) TickByTickBidAsk(reqID int64, time int64, bidPrice float64, askPrice float64, bidSize int64, askSize int64, tickAttribBidAsk TickAttribBidAsk) { - log.WithField("reqID", reqID).Printf(": time: %v bidPrice: %v askPrice: %v bidSize: %v askSize: %v", time, bidPrice, askPrice, bidSize, askSize) + log.WithField("reqID", reqID).Printf(": time: %v bidPrice: %v askPrice: %v bidSize: %v askSize: %v", time, bidPrice, askPrice, bidSize, askSize) } func (w Wrapper) TickByTickMidPoint(reqID int64, time int64, midPoint float64) { - log.WithField("reqID", reqID).Printf(": time: %v midPoint: %v ", time, midPoint) + log.WithField("reqID", reqID).Printf(": time: %v midPoint: %v ", time, midPoint) } func (w Wrapper) TickString(reqID int64, tickType int64, value string) { - log.WithField("reqID", reqID).Printf(": tickType: %v value: %v.", tickType, value) + log.WithField("reqID", reqID).Printf(": tickType: %v value: %v.", tickType, value) } func (w Wrapper) TickGeneric(reqID int64, tickType int64, value float64) { - log.WithField("reqID", reqID).Printf(":tickType: %v value: %v.", tickType, value) + log.WithField("reqID", reqID).Printf(":tickType: %v value: %v.", tickType, value) } func (w Wrapper) TickEFP(reqID int64, tickType int64, basisPoints float64, formattedBasisPoints string, totalDividends float64, holdDays int64, futureLastTradeDate string, dividendImpact float64, dividendsToLastTradeDate float64) { - log.WithField("reqID", reqID).Printf(": tickType: %v basisPoints: %v.", tickType, basisPoints) + log.WithField("reqID", reqID).Printf(": tickType: %v basisPoints: %v.", tickType, basisPoints) } func (w Wrapper) TickReqParams(tickerID int64, minTick float64, bboExchange string, snapshotPermissions int64) { - log.WithField("tickerID", tickerID).Printf(": tickerId: %v", tickerID) + log.WithField("tickerID", tickerID).Printf(": tickerId: %v", tickerID) } func (w Wrapper) MktDepthExchanges(depthMktDataDescriptions []DepthMktDataDescription) { - log.Printf(": depthMktDataDescriptions: %v", depthMktDataDescriptions) + log.Printf(": depthMktDataDescriptions: %v", depthMktDataDescriptions) } /*Returns the order book. @@ -349,103 +349,103 @@ side - 0 for ask, 1 for bid price - the order's price size - the order's size*/ func (w Wrapper) UpdateMktDepth(reqID int64, position int64, operation int64, side int64, price float64, size int64) { - log.WithField("reqID", reqID).Printf(": position: %v operation: %v side: %v price: %v size: %v", position, operation, side, price, size) + log.WithField("reqID", reqID).Printf(": position: %v operation: %v side: %v price: %v size: %v", position, operation, side, price, size) } func (w Wrapper) UpdateMktDepthL2(reqID int64, position int64, marketMaker string, operation int64, side int64, price float64, size int64, isSmartDepth bool) { - log.WithField("reqID", reqID).Printf(": position: %v marketMaker: %v operation: %v side: %v price: %v size: %v isSmartDepth: %v", position, marketMaker, operation, side, price, size, isSmartDepth) + log.WithField("reqID", reqID).Printf(": position: %v marketMaker: %v operation: %v side: %v price: %v size: %v isSmartDepth: %v", position, marketMaker, operation, side, price, size, isSmartDepth) } func (w Wrapper) TickOptionComputation(reqID int64, tickType int64, impliedVol float64, delta float64, optPrice float64, pvDiviedn float64, gamma float64, vega float64, theta float64, undPrice float64) { - log.WithField("reqID", reqID).Printf(": tickType: %v ", tickType) + log.WithField("reqID", reqID).Printf(": tickType: %v ", tickType) } func (w Wrapper) FundamentalData(reqID int64, data string) { - log.WithField("reqID", reqID).Printf(":data: %v", data) + log.WithField("reqID", reqID).Printf(":data: %v", data) } func (w Wrapper) ScannerParameters(xml string) { - log.Printf(": xml: %v", xml) + log.Printf(": xml: %v", xml) } func (w Wrapper) ScannerData(reqID int64, rank int64, conDetails *ContractDetails, distance string, benchmark string, projection string, legs string) { - log.WithField("reqID", reqID).Printf(": rank: %v", rank) + log.WithField("reqID", reqID).Printf(": rank: %v", rank) } func (w Wrapper) ScannerDataEnd(reqID int64) { - log.WithField("reqID", reqID).Print("") + log.WithField("reqID", reqID).Print("") } func (w Wrapper) HistogramData(reqID int64, histogram []HistogramData) { - log.WithField("reqID", reqID).Printf(": histogram: %v", histogram) + log.WithField("reqID", reqID).Printf(": histogram: %v", histogram) } func (w Wrapper) RerouteMktDataReq(reqID int64, contractID int64, exchange string) { - log.WithField("reqID", reqID).Printf(": contractID: %v exchange: %v", contractID, exchange) + log.WithField("reqID", reqID).Printf(": contractID: %v exchange: %v", contractID, exchange) } func (w Wrapper) RerouteMktDepthReq(reqID int64, contractID int64, exchange string) { - log.WithField("reqID", reqID).Printf(": contractID: %v", contractID) + log.WithField("reqID", reqID).Printf(": contractID: %v", contractID) } func (w Wrapper) SecurityDefinitionOptionParameter(reqID int64, exchange string, underlyingContractID int64, tradingClass string, multiplier string, expirations []string, strikes []float64) { - log.WithField("reqID", reqID).Printf(": underlyingContractID: %v expirations: %v striker: %v", underlyingContractID, expirations, strikes) + log.WithField("reqID", reqID).Printf(": underlyingContractID: %v expirations: %v striker: %v", underlyingContractID, expirations, strikes) } func (w Wrapper) SecurityDefinitionOptionParameterEnd(reqID int64) { - log.WithField("reqID", reqID).Print("") + log.WithField("reqID", reqID).Print("") } func (w Wrapper) SoftDollarTiers(reqID int64, tiers []SoftDollarTier) { - log.WithField("reqID", reqID).Printf(": tiers: %v", tiers) + log.WithField("reqID", reqID).Printf(": tiers: %v", tiers) } func (w Wrapper) FamilyCodes(famCodes []FamilyCode) { - log.Printf(": familyCodes: %v", famCodes) + log.Printf(": familyCodes: %v", famCodes) } func (w Wrapper) NewsProviders(newsProviders []NewsProvider) { - log.Printf(": newsProviders: %v", newsProviders) + log.Printf(": newsProviders: %v", newsProviders) } func (w Wrapper) TickNews(tickerID int64, timeStamp int64, providerCode string, articleID string, headline string, extraData string) { - log.WithField("tickerID", tickerID).Printf(": tickerID: %v timeStamp: %v", tickerID, timeStamp) + log.WithField("tickerID", tickerID).Printf(": tickerID: %v timeStamp: %v", tickerID, timeStamp) } func (w Wrapper) NewsArticle(reqID int64, articleType int64, articleText string) { - log.WithField("reqID", reqID).Printf(": articleType: %v articleText: %v", articleType, articleText) + log.WithField("reqID", reqID).Printf(": articleType: %v articleText: %v", articleType, articleText) } func (w Wrapper) HistoricalNews(reqID int64, time string, providerCode string, articleID string, headline string) { - log.WithField("reqID", reqID).Printf(": time: %v providerCode: %v articleID: %v, headline: %v", time, providerCode, articleID, headline) + log.WithField("reqID", reqID).Printf(": time: %v providerCode: %v articleID: %v, headline: %v", time, providerCode, articleID, headline) } func (w Wrapper) HistoricalNewsEnd(reqID int64, hasMore bool) { - log.WithField("reqID", reqID).Printf(": hasMore: %v", hasMore) + log.WithField("reqID", reqID).Printf(": hasMore: %v", hasMore) } func (w Wrapper) UpdateNewsBulletin(msgID int64, msgType int64, newsMessage string, originExch string) { - log.WithField("msgID", msgID).Printf(": msgID: %v", msgID) + log.WithField("msgID", msgID).Printf(": msgID: %v", msgID) } func (w Wrapper) ReceiveFA(faData int64, cxml string) { - log.Printf(": faData: %v", faData) + log.Printf(": faData: %v", faData) } func (w Wrapper) CurrentTime(t time.Time) { - log.Printf(": %v.", t) + log.Printf(": %v.", t) } func (w Wrapper) Error(reqID int64, errCode int64, errString string) { - log.WithFields(log.Fields{"reqID": reqID, "errCode": errCode, "errString": errString}).Error("Wrapper Error!") + log.WithFields(log.Fields{"reqID": reqID, "errCode": errCode}).Errorf(": errString: %s", errString) } func (w Wrapper) CompletedOrder(contract *Contract, order *Order, orderState *OrderState) { - log.Printf(": contract: %v order: %v orderState: %v", contract, order, orderState) + log.Printf(": contract: %v order: %v orderState: %v", contract, order, orderState) } func (w Wrapper) CompletedOrdersEnd() { - log.Println(":") + log.Println(":") }