fixes in quotes
This commit is contained in:
@ -115,7 +115,12 @@ func (m *Manager) onLogout(sessionID quickfix.SessionID) {
|
||||
}
|
||||
|
||||
// SendQuote implements domain.FIXSender.
|
||||
func (m *Manager) SendQuote(clOrdID, quoteID, symbol, currency string, bidPx, offerPx, bidSize, offerSize decimal.Decimal) error {
|
||||
func (m *Manager) SendQuote(
|
||||
clOrdID, quoteID, symbol string,
|
||||
secIDSource string,
|
||||
currency string,
|
||||
bidPx, offerPx decimal.Decimal,
|
||||
) error {
|
||||
m.sessionsMu.RLock()
|
||||
var sessionID quickfix.SessionID
|
||||
var ok bool
|
||||
@ -134,28 +139,34 @@ func (m *Manager) SendQuote(clOrdID, quoteID, symbol, currency string, bidPx, of
|
||||
}
|
||||
|
||||
q := quote.New(
|
||||
field.NewQuoteID(quoteID),
|
||||
field.NewQuoteID("NONREF"),
|
||||
field.NewQuoteType(enum.QuoteType_INDICATIVE),
|
||||
field.NewTransactTime(time.Now()),
|
||||
)
|
||||
|
||||
q.SetSymbol(symbol)
|
||||
sIDSource := enum.SecurityIDSource_ISIN_NUMBER
|
||||
if secIDSource == "1" {
|
||||
sIDSource = enum.SecurityIDSource_CUSIP
|
||||
}
|
||||
|
||||
q.SetSymbol("[N/A]")
|
||||
q.SetSecurityID(symbol)
|
||||
q.SetSecurityIDSource(sIDSource)
|
||||
q.SetQuoteID(quoteID)
|
||||
|
||||
if currency != "" {
|
||||
q.SetCurrency(currency)
|
||||
}
|
||||
|
||||
q.SetBidPx(bidPx, 8)
|
||||
q.SetOfferPx(offerPx, 8)
|
||||
|
||||
if !bidSize.IsZero() {
|
||||
q.SetBidSize(bidSize, 8)
|
||||
if !bidPx.IsZero() {
|
||||
q.SetBidPx(bidPx, 8)
|
||||
q.SetSide(enum.Side_SELL)
|
||||
} else {
|
||||
q.SetOfferPx(offerPx, 8)
|
||||
q.SetSide(enum.Side_BUY)
|
||||
}
|
||||
|
||||
if !offerSize.IsZero() {
|
||||
q.SetOfferSize(offerSize, 8)
|
||||
}
|
||||
q.SetPriceType(enum.PriceType_PERCENTAGE)
|
||||
|
||||
if err := quickfix.SendToTarget(q, sessionID); err != nil {
|
||||
err = tracerr.Errorf("error sending FIX quote: %s", err)
|
||||
@ -177,18 +188,46 @@ func (m *Manager) handleQuoteRequest(msg quoterequest.QuoteRequest, sessionID qu
|
||||
return
|
||||
}
|
||||
|
||||
var symbol, currency string
|
||||
var (
|
||||
symbol, currency string
|
||||
side enum.Side
|
||||
secIDSource enum.SecurityIDSource
|
||||
)
|
||||
|
||||
relatedSyms, relErr := msg.GetNoRelatedSym()
|
||||
if relErr == nil && relatedSyms.Len() > 0 {
|
||||
sym := relatedSyms.Get(0)
|
||||
symbol, _ = sym.GetSymbol()
|
||||
symbol, _ = sym.GetSecurityID()
|
||||
secIDSource, _ = sym.GetSecurityIDSource()
|
||||
currency, _ = sym.GetCurrency()
|
||||
side, _ = sym.GetSide()
|
||||
}
|
||||
|
||||
price := decimal.NewFromFloat(99.6)
|
||||
bidPx, offerPx := decimal.Zero, decimal.Zero
|
||||
|
||||
if sendErr := m.SendQuote(quoteReqID, quoteReqID, symbol, currency, price, price, decimal.Zero, decimal.Zero); sendErr != nil {
|
||||
if side == enum.Side_BUY {
|
||||
offerPx = price
|
||||
} else {
|
||||
bidPx = price
|
||||
}
|
||||
|
||||
var sIDSource string
|
||||
if secIDSource == enum.SecurityIDSource_ISIN_NUMBER {
|
||||
sIDSource = "4"
|
||||
} else {
|
||||
sIDSource = "1"
|
||||
}
|
||||
|
||||
if sendErr := m.SendQuote(
|
||||
quoteReqID,
|
||||
quoteReqID,
|
||||
symbol,
|
||||
sIDSource,
|
||||
currency,
|
||||
bidPx,
|
||||
offerPx,
|
||||
); sendErr != nil {
|
||||
slog.Error("handleQuoteRequest: failed to send quote", "quoteReqID", quoteReqID, "error", sendErr.Error())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user