Beispiel #1
0
func (e *executor) OnFIX40NewOrderSingle(msg fix40nos.NewOrderSingle, sessionID quickfix.SessionID) (err quickfix.MessageRejectError) {
	var ordType field.OrdTypeField
	if ordType, err = msg.GetOrdType(); err != nil {
		return err
	}
	if ordType.String() != enum.OrdType_LIMIT {
		return quickfix.ValueIsIncorrect(tag.OrdType)
	}

	var symbol field.SymbolField
	if symbol, err = msg.GetSymbol(); err != nil {
		return
	}

	var side field.SideField
	if side, err = msg.GetSide(); err != nil {
		return
	}

	var orderQty field.OrderQtyField
	if orderQty, err = msg.GetOrderQty(); err != nil {
		return
	}

	var price field.PriceField
	if price, err = msg.GetPrice(); err != nil {
		return
	}

	execReport := fix40er.New(
		e.genOrderID(),
		e.genExecID(),
		field.NewExecTransType(enum.ExecTransType_NEW),
		field.NewOrdStatus(enum.OrdStatus_FILLED),
		symbol,
		side,
		orderQty,
		field.NewLastShares(orderQty.Float64()),
		field.NewLastPx(price.Float64()),
		field.NewCumQty(orderQty.Float64()),
		field.NewAvgPx(price.Float64()),
	)

	quickfix.SendToTarget(execReport, sessionID)

	return
}
Beispiel #2
0
func (e *executor) OnFIX40NewOrderSingle(msg fix40nos.NewOrderSingle, sessionID quickfix.SessionID) quickfix.MessageRejectError {
	ordType, err := msg.GetOrdType()
	if err != nil {
		return err
	}

	if ordType != enum.OrdType_LIMIT {
		return quickfix.ValueIsIncorrect(tag.OrdType)
	}

	symbol, err := msg.GetSymbol()
	if err != nil {
		return err
	}

	side, err := msg.GetSide()
	if err != nil {
		return err
	}

	orderQty, err := msg.GetOrderQty()
	if err != nil {
		return err
	}

	price, err := msg.GetPrice()
	if err != nil {
		return err
	}

	execReport := fix40er.New(
		e.genOrderID(),
		e.genExecID(),
		field.NewExecTransType(enum.ExecTransType_NEW),
		field.NewOrdStatus(enum.OrdStatus_FILLED),
		field.NewSymbol(symbol),
		field.NewSide(side),
		field.NewOrderQty(orderQty, 2),
		field.NewLastShares(orderQty, 2),
		field.NewLastPx(price, 2),
		field.NewCumQty(orderQty, 2),
		field.NewAvgPx(price, 2),
	)

	clOrdID, err := msg.GetClOrdID()
	if err != nil {
		return err
	}
	execReport.SetClOrdID(clOrdID)

	quickfix.SendToTarget(execReport, sessionID)

	return nil
}