Ejemplo n.º 1
0
func (a *Application) updateOrder(order internal.Order, status enum.OrdStatus) {
	execReport := executionreport.New(
		field.NewOrderID(order.ClOrdID),
		field.NewExecID(a.genExecID()),
		field.NewExecTransType(enum.ExecTransType_NEW),
		field.NewExecType(enum.ExecType(status)),
		field.NewOrdStatus(status),
		field.NewSymbol(order.Symbol),
		field.NewSide(order.Side),
		field.NewLeavesQty(order.OpenQuantity(), 2),
		field.NewCumQty(order.ExecutedQuantity, 2),
		field.NewAvgPx(order.AvgPx, 2),
	)
	execReport.SetOrderQty(order.Quantity, 2)
	execReport.SetClOrdID(order.ClOrdID)

	switch status {
	case enum.OrdStatus_FILLED, enum.OrdStatus_PARTIALLY_FILLED:
		execReport.SetLastShares(order.LastExecutedQuantity, 2)
		execReport.SetLastPx(order.LastExecutedPrice, 2)
	}

	execReport.Header.SetTargetCompID(order.SenderCompID)
	execReport.Header.SetSenderCompID(order.TargetCompID)

	quickfix.Send(execReport)
}
Ejemplo n.º 2
0
func (e *executor) OnFIX41NewOrderSingle(msg fix41nos.NewOrderSingle, sessionID quickfix.SessionID) (err quickfix.MessageRejectError) {
	ordType, err := msg.GetOrdType()
	if err != nil {
		return
	}
	if ordType != enum.OrdType_LIMIT {
		return quickfix.ValueIsIncorrect(tag.OrdType)
	}

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

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

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

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

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

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

	quickfix.SendToTarget(execReport, sessionID)

	return
}
Ejemplo n.º 3
0
func (e *executor) OnFIX41NewOrderSingle(msg fix41nos.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 := fix41er.New(
		e.genOrderID(),
		e.genExecID(),
		field.NewExecTransType(enum.ExecTransType_NEW),
		field.NewExecType(enum.ExecType_FILL),
		field.NewOrdStatus(enum.OrdStatus_FILLED),
		symbol,
		side,
		orderQty,
		field.NewLastShares(orderQty.Float64()),
		field.NewLastPx(price.Float64()),
		field.NewLeavesQty(0),
		field.NewCumQty(orderQty.Float64()),
		field.NewAvgPx(price.Float64()),
	)

	quickfix.SendToTarget(execReport, sessionID)

	return
}
Ejemplo n.º 4
0
func (a *Application) updateOrder(order Order, status string) {
	execReport := executionreport.New(
		field.NewOrderID(order.ClOrdID),
		field.NewExecID(a.genExecID()),
		field.NewExecTransType(enum.ExecTransType_NEW),
		field.NewExecType(status),
		field.NewOrdStatus(status),
		field.NewSymbol(order.Symbol),
		field.NewSide(order.Side),
		field.NewLeavesQty(order.OpenQuantity()),
		field.NewCumQty(order.ExecutedQuantity),
		field.NewAvgPx(order.AvgPx),
	)

	execReport.SetOrderQty(order.Quantity)
	execReport.SetClOrdID(order.ClOrdID)
	execReport.Header.SetTargetCompID(order.SenderCompID)
	execReport.Header.SetSenderCompID(order.TargetCompID)

	quickfix.Send(execReport)
}
Ejemplo n.º 5
0
//SetCumQty sets CumQty, Tag 14
func (m NoOrders) SetCumQty(value decimal.Decimal, scale int32) {
	m.Set(field.NewCumQty(value, scale))
}
Ejemplo n.º 6
0
//SetCumQty sets CumQty, Tag 14
func (m NoOrders) SetCumQty(v float64) {
	m.Set(field.NewCumQty(v))
}
//SetCumQty sets CumQty, Tag 14
func (m ExecutionReport) SetCumQty(value decimal.Decimal, scale int32) {
	m.Set(field.NewCumQty(value, scale))
}
Ejemplo n.º 8
0
//SetCumQty sets CumQty, Tag 14
func (m ExecutionReport) SetCumQty(v float64) {
	m.Set(field.NewCumQty(v))
}
Ejemplo n.º 9
0
func (e *executor) OnFIX50NewOrderSingle(msg fix50nos.NewOrderSingle, sessionID quickfix.SessionID) (err 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
	}

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

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

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

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

	execReport := fix50er.New(
		e.genOrderID(),
		e.genExecID(),
		field.NewExecType(enum.ExecType_FILL),
		field.NewOrdStatus(enum.OrdStatus_FILLED),
		field.NewSide(side),
		field.NewLeavesQty(decimal.Zero, 2),
		field.NewCumQty(orderQty, 2),
	)

	execReport.SetClOrdID(clOrdID)
	execReport.SetSymbol(symbol)
	execReport.SetOrderQty(orderQty, 2)
	execReport.SetLastQty(orderQty, 2)
	execReport.SetLastPx(price, 2)
	execReport.SetAvgPx(price, 2)

	if msg.HasAccount() {
		acct, err := msg.GetAccount()
		if err != nil {
			return err
		}
		execReport.SetAccount(acct)
	}

	quickfix.SendToTarget(execReport, sessionID)

	return
}
Ejemplo n.º 10
0
func (e *executor) OnFIX50NewOrderSingle(msg fix50nos.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
	}

	var clOrdID field.ClOrdIDField
	if clOrdID, err = msg.GetClOrdID(); err != nil {
		return
	}

	execReport := fix50er.New(
		e.genOrderID(),
		e.genExecID(),
		field.NewExecType(enum.ExecType_FILL),
		field.NewOrdStatus(enum.OrdStatus_FILLED),
		side,
		field.NewLeavesQty(0),
		field.NewCumQty(orderQty.Float64()),
	)

	execReport.Set(clOrdID)
	execReport.Set(symbol)
	execReport.Set(orderQty)
	execReport.SetLastQty(orderQty.Float64())
	execReport.SetLastPx(price.Float64())
	execReport.SetAvgPx(price.Float64())

	if msg.HasAccount() {
		var acct field.AccountField
		if acct, err = msg.GetAccount(); err != nil {
			return err
		}
		execReport.Set(acct)
	}

	quickfix.SendToTarget(execReport, sessionID)

	return
}