Beispiel #1
0
func QueryMarketDataRequest() error {
	beginString, err := queryVersion()
	if err != nil {
		return err
	}

	var req quickfix.Messagable
	switch beginString {
	case enum.BeginStringFIX42:
		req = queryMarketDataRequest42()

	case enum.BeginStringFIX43:
		req = queryMarketDataRequest43()

	case enum.BeginStringFIX44:
		req = queryMarketDataRequest44()

	case enum.BeginStringFIXT11:
		req = queryMarketDataRequest50()

	default:
		return fmt.Errorf("No test for version %v", beginString)
	}

	if queryConfirm("Send MarketDataRequest") {
		return quickfix.Send(req)
	}

	return nil
}
Beispiel #2
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)
}
Beispiel #3
0
func queryEnterOrder() error {
	beginString, err := queryVersion()
	if err != nil {
		return err
	}

	var order *quickfix.MessageBuilder
	switch beginString.Value {
	case fix.BeginString_FIX40:
		fix40Order, err := queryNewOrderSingle40()
		if err != nil {
			return err
		}
		order = &(fix40Order.MessageBuilder)

	case fix.BeginString_FIX41:
		fix41Order, err := queryNewOrderSingle41()
		if err != nil {
			return err
		}
		order = &(fix41Order.MessageBuilder)

	case fix.BeginString_FIX42:
		fix42Order, err := queryNewOrderSingle42()
		if err != nil {
			return err
		}
		order = &(fix42Order.MessageBuilder)

	case fix.BeginString_FIX43:
		fix43Order, err := queryNewOrderSingle43()
		if err != nil {
			return err
		}
		order = &(fix43Order.MessageBuilder)

	case fix.BeginString_FIX44:
		fix44Order, err := queryNewOrderSingle44()
		if err != nil {
			return err
		}
		order = &(fix44Order.MessageBuilder)

	case fix.BeginString_FIXT11:
		fix50Order, err := queryNewOrderSingle50()
		if err != nil {
			return err
		}
		order = &(fix50Order.MessageBuilder)
	}

	return quickfix.Send(*order)
}
Beispiel #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)
}
Beispiel #5
0
func QueryCancelOrder() (err error) {
	defer func() {
		if e := recover(); e != nil {
			err = e.(error)
		}
	}()

	var beginString string
	beginString, err = queryVersion()
	if err != nil {
		return err
	}

	var cxl quickfix.Message
	switch beginString {
	case enum.BeginStringFIX40:
		cxl = queryOrderCancelRequest40()

	case enum.BeginStringFIX41:
		cxl = queryOrderCancelRequest41()

	case enum.BeginStringFIX42:
		cxl = queryOrderCancelRequest42()

	case enum.BeginStringFIX43:
		cxl = queryOrderCancelRequest43()

	case enum.BeginStringFIX44:
		cxl = queryOrderCancelRequest44()

	case enum.BeginStringFIXT11:
		cxl = queryOrderCancelRequest50()
	}

	if queryConfirm("Send Cancel") {
		return quickfix.Send(cxl)
	}

	return
}
Beispiel #6
0
func QueryEnterOrder() (err error) {
	defer func() {
		if e := recover(); e != nil {
			err = e.(error)
		}
	}()

	var beginString string
	beginString, err = queryVersion()
	if err != nil {
		return err
	}

	var order quickfix.Messagable
	switch beginString {
	case enum.BeginStringFIX40:
		order = queryNewOrderSingle40()

	case enum.BeginStringFIX41:
		order = queryNewOrderSingle41()

	case enum.BeginStringFIX42:
		order = queryNewOrderSingle42()

	case enum.BeginStringFIX43:
		order = queryNewOrderSingle43()

	case enum.BeginStringFIX44:
		order = queryNewOrderSingle44()

	case enum.BeginStringFIXT11:
		order = queryNewOrderSingle50()
	}

	return quickfix.Send(order)
}