respond automatically to quote requests

This commit is contained in:
Ramiro Paz
2026-03-12 17:10:31 -03:00
parent 1f1c0afb9a
commit 3998726100
2 changed files with 36 additions and 5 deletions

View File

@ -13,6 +13,7 @@ import (
"quantex.com/qfixdpl/quickfix/gen/enum"
"quantex.com/qfixdpl/quickfix/gen/field"
"quantex.com/qfixdpl/quickfix/gen/fix50sp2/quote"
"quantex.com/qfixdpl/quickfix/gen/fix50sp2/quoterequest"
"quantex.com/qfixdpl/quickfix/store/file"
"quantex.com/qfixdpl/src/app"
"quantex.com/qfixdpl/src/common/tracerr"
@ -43,6 +44,7 @@ func (m *Manager) Start() error {
fixApp := newApplication(m.notify)
fixApp.onLogon = m.onLogon
fixApp.onLogout = m.onLogout
fixApp.onQuoteRequest = m.handleQuoteRequest
m.app = fixApp
f, err := os.Open(m.cfg.SettingsFile)
@ -166,3 +168,27 @@ func (m *Manager) SendQuote(clOrdID, quoteID, symbol, currency string, bidPx, of
return nil
}
// handleQuoteRequest auto-responds to an incoming QuoteRequest with a quote at price 99.6.
func (m *Manager) handleQuoteRequest(msg quoterequest.QuoteRequest, sessionID quickfix.SessionID) {
quoteReqID, err := msg.GetQuoteReqID()
if err != nil {
slog.Error("handleQuoteRequest: missing QuoteReqID", "error", err.Error())
return
}
var symbol, currency string
relatedSyms, relErr := msg.GetNoRelatedSym()
if relErr == nil && relatedSyms.Len() > 0 {
sym := relatedSyms.Get(0)
symbol, _ = sym.GetSymbol()
currency, _ = sym.GetCurrency()
}
price := decimal.NewFromFloat(99.6)
if sendErr := m.SendQuote(quoteReqID, quoteReqID, symbol, currency, price, price, decimal.Zero, decimal.Zero); sendErr != nil {
slog.Error("handleQuoteRequest: failed to send quote", "quoteReqID", quoteReqID, "error", sendErr.Error())
}
}