Exemplo n.º 1
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)
}
Exemplo n.º 2
0
func querySide() (*field.SideField, error) {

	fmt.Println()
	fmt.Println("1) Buy")
	fmt.Println("2) Sell")
	fmt.Println("3) Sell Short")
	fmt.Println("4) Sell Short Exempt")
	fmt.Println("5) Cross")
	fmt.Println("6) Cross Short")
	fmt.Println("7) Cross Short Exempt")
	fmt.Print("Side: ")

	scanner := bufio.NewScanner(os.Stdin)
	if !scanner.Scan() {
		return nil, scanner.Err()
	}

	switch scanner.Text() {
	case "1":
		return field.NewSide(enum.Side_BUY), nil
	case "2":
		return field.NewSide(enum.Side_SELL), nil
	case "3":
		return field.NewSide(enum.Side_SELL_SHORT), nil
	case "4":
		return field.NewSide(enum.Side_SELL_SHORT_EXEMPT), nil
	case "5":
		return field.NewSide(enum.Side_CROSS), nil
	case "6":
		return field.NewSide(enum.Side_CROSS_SHORT), nil
	case "7":
		return field.NewSide("A"), nil
	}

	return nil, fmt.Errorf("unknown side choice: %v", scanner.Text())
}