Example #1
0
func queryNewOrderSingle43() (fix43nos.MessageBuilder, error) {
	var builder fix43nos.MessageBuilder

	clOrdID, err := queryClOrdID()
	if err != nil {
		return builder, err
	}

	side, err := querySide()
	if err != nil {
		return builder, err
	}

	ordType, err := queryOrdType()
	if err != nil {
		return builder, err
	}

	transactTime := &field.TransactTimeField{}

	builder = fix43nos.Builder(clOrdID, field.NewHandlInst("1"), side, transactTime, ordType)

	symbol, err := querySymbol()
	if err != nil {
		return builder, err
	}
	builder.Body().Set(symbol)

	orderQty, err := queryOrderQty()
	if err != nil {
		return builder, err
	}
	builder.Body().Set(orderQty)

	timeInForce, err := queryTimeInForce()
	if err != nil {
		return builder, err
	}

	builder.Body().Set(timeInForce)
	if ordType.Value == enum.OrdType_LIMIT || ordType.Value == enum.OrdType_STOP_LIMIT {
		price, err := queryPrice()
		if err != nil {
			return builder, err
		}
		builder.Body().Set(price)
	}

	if ordType.Value == enum.OrdType_STOP || ordType.Value == enum.OrdType_STOP_LIMIT {
		stopPx, err := queryStopPx()
		if err != nil {
			return builder, err
		}
		builder.Body().Set(stopPx)
	}

	queryHeader(builder.Header())

	return builder, nil
}
Example #2
0
func main() {
	flag.Parse()

	cfg, err := os.Open(*fixconfig)
	if err != nil {
		log.Fatal(err)
	}

	appSettings, err := quickfix.ParseSettings(cfg)
	if err != nil {
		log.Fatal(err)
	}

	// logFactory, err := quickfix.NewFileLogFactory(appSettings)
	logFactory := quickfix.NewNullLogFactory()
	if err != nil {
		log.Fatal(err)
	}

	storeFactory := quickfix.NewMemoryStoreFactory()

	initiator, err := quickfix.NewInitiator(app, storeFactory, appSettings, logFactory)
	if err != nil {
		log.Fatal(err)
	}
	if err = initiator.Start(); err != nil {
		log.Fatal(err)
	}

	<-start

	for i := 0; i < *sampleSize; i++ {
		order := newordersingle.Builder(
			field.NewClOrdID("100"),
			field.NewHandlInst("1"),
			field.NewSymbol("TSLA"),
			field.NewSide(enum.Side_BUY),
			&field.TransactTimeField{},
			field.NewOrdType(enum.OrdType_MARKET))

		quickfix.SendToTarget(order, SessionID)
		// time.Sleep(1 * time.Millisecond)
	}

	time.Sleep(2 * time.Second)
}