Exemple #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)
}
Exemple #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
}
Exemple #3
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)
}
//SetSymbol sets Symbol, Tag 55
func (m NoRelatedSym) SetSymbol(v string) {
	m.Set(field.NewSymbol(v))
}
//SetSymbol sets Symbol, Tag 55
func (m OrderMassCancelRequest) SetSymbol(v string) {
	m.Set(field.NewSymbol(v))
}
//SetSymbol sets Symbol, Tag 55
func (m DontKnowTrade) SetSymbol(v string) {
	m.Set(field.NewSymbol(v))
}
Exemple #7
0
//SetSymbol sets Symbol, Tag 55
func (m IOI) SetSymbol(v string) {
	m.Set(field.NewSymbol(v))
}
//SetSymbol sets Symbol, Tag 55
func (m OrderCancelReplaceRequest) SetSymbol(v string) {
	m.Set(field.NewSymbol(v))
}
//SetSymbol sets Symbol, Tag 55
func (m QuoteStatusRequest) SetSymbol(v string) {
	m.Set(field.NewSymbol(v))
}
//SetSymbol sets Symbol, Tag 55
func (m SecurityDefinitionRequest) SetSymbol(v string) {
	m.Set(field.NewSymbol(v))
}
//SetSymbol sets Symbol, Tag 55
func (m NoOrders) SetSymbol(v string) {
	m.Set(field.NewSymbol(v))
}
//SetSymbol sets Symbol, Tag 55
func (m SecurityListRequest) SetSymbol(v string) {
	m.Set(field.NewSymbol(v))
}
//SetSymbol sets Symbol, Tag 55
func (m MarketDataSnapshotFullRefresh) SetSymbol(v string) {
	m.Set(field.NewSymbol(v))
}
//SetSymbol sets Symbol, Tag 55
func (m TradeCaptureReportRequest) SetSymbol(v string) {
	m.Set(field.NewSymbol(v))
}
//SetSymbol sets Symbol, Tag 55
func (m NewOrderList) SetSymbol(v string) {
	m.Set(field.NewSymbol(v))
}
//SetSymbol sets Symbol, Tag 55
func (m IndicationofInterest) SetSymbol(v string) {
	m.Set(field.NewSymbol(v))
}
Exemple #17
0
func querySymbol() field.SymbolField {
	return field.NewSymbol(queryString("Symbol"))
}
//SetSymbol sets Symbol, Tag 55
func (m OrderStatusRequest) SetSymbol(v string) {
	m.Set(field.NewSymbol(v))
}
//SetSymbol sets Symbol, Tag 55
func (m NoStrikes) SetSymbol(v string) {
	m.Set(field.NewSymbol(v))
}
//SetSymbol sets Symbol, Tag 55
func (m TradingSessionStatus) SetSymbol(v string) {
	m.Set(field.NewSymbol(v))
}
//SetSymbol sets Symbol, Tag 55
func (m Advertisement) SetSymbol(v string) {
	m.Set(field.NewSymbol(v))
}
//SetSymbol sets Symbol, Tag 55
func (m SecurityStatus) SetSymbol(v string) {
	m.Set(field.NewSymbol(v))
}
//SetSymbol sets Symbol, Tag 55
func (m NoQuoteEntries) SetSymbol(v string) {
	m.Set(field.NewSymbol(v))
}
//SetSymbol sets Symbol, Tag 55
func (m Allocation) SetSymbol(v string) {
	m.Set(field.NewSymbol(v))
}
//SetSymbol sets Symbol, Tag 55
func (m ExecutionReport) SetSymbol(v string) {
	m.Set(field.NewSymbol(v))
}
//SetSymbol sets Symbol, Tag 55
func (m Quote) SetSymbol(v string) {
	m.Set(field.NewSymbol(v))
}
//SetSymbol sets Symbol, Tag 55
func (m CrossOrderCancelRequest) SetSymbol(v string) {
	m.Set(field.NewSymbol(v))
}
//SetSymbol sets Symbol, Tag 55
func (m NewOrderSingle) SetSymbol(v string) {
	m.Set(field.NewSymbol(v))
}
Exemple #29
0
func main() {
	fmt.Println("hello world")

	msg := quickfix.NewMessage()

	group := NewNoOrdersRepeatingGroup()
	order1 := group.Add()
	order1.SetClOrdID(field.ClOrdIDField{FIXString: "1"})

	order2 := group.Add()
	order2.SetClOrdID(field.ClOrdIDField{FIXString: "2"})

	msg.Header.Set(field.NewBeginString(enum.BeginStringFIX42))
	msg.Header.Set(field.NewMsgType(enum.MsgType_NEW_ORDER_CROSS))
	msg.Body.SetGroup(group)

	b, _ := msg.Build()
	fmt.Println(string(b))

	m, err := quickfix.ParseMessage(b)
	if err != nil {
		panic(err)
	}

	g := NewNoOrdersRepeatingGroup()
	m.Body.GetGroup(g)

	fmt.Println(g.Len())

	clordid1, _ := g.Get(0).GetClOrdID()
	clordid2, _ := g.Get(1).GetClOrdID()

	fmt.Println(clordid1)
	fmt.Println(clordid2)

	m, err = quickfix.ParseMessage([]byte("8=FIX.4.29=10835=D34=249=TW52=20160421-14:43:5056=ISLD11=ID21=440=154=138=002000.0055=INTC60=20160421-14:43:5010=004"))
	//	m, err = quickfix.ParseMessage([]byte("8=FIX.4.29=10835=D34=249=TW52=20160421-14:43:5056=ISLD11=ID21=438=002000.0040=154=255=INTC60=20160421-14:43:5010=005"))
	//	m, err = quickfix.ParseMessage([]byte("8=FIX.4.29=11835=D34=249=TW52=20160421-14:43:5056=ISLD11=ID21=438=002000.0040=154=255=INTC58=oh hai60=20160421-14:43:5010=218"))

	if err != nil {
		panic(err)
	}

	nos := newordersingle.FromMessage(m)
	if side, err := nos.GetSide(); err != nil {
		panic(err)
	} else {
		fmt.Printf("Side is %v\n", side)
	}
	nos.SetSide(enum.Side_SELL)
	nos.Set(field.NewText("oh hai"))

	m = nos.ToMessage()
	b, err = m.Build()
	if err != nil {
		panic(err)
	}
	fmt.Println(string(b))

	newNos := newordersingle.New(
		field.NewClOrdID("1234"),
		field.NewHandlInst("1"),
		field.NewSymbol("TSLA"),
		field.NewSide(enum.Side_BUY),
		field.NewOrderQty(100.0),
		field.NewOrdType(enum.OrdType_MARKET),
	)

	//newNos.Set(field.NewTransactTime(time.Now()))
	newNos.Set(field.NewTransactTimeNoMillis(time.Now()))

	m = newNos.ToMessage()
	b, err = m.Build()
	if err != nil {
		panic(err)
	}
	fmt.Println(string(b))
}