func queryOrdType() (*field.OrdTypeField, error) { fmt.Println() fmt.Println("1) Market") fmt.Println("2) Limit") fmt.Println("3) Stop") fmt.Println("4) Stop Limit") fmt.Print("OrdType: ") scanner := bufio.NewScanner(os.Stdin) if !scanner.Scan() { return nil, scanner.Err() } switch scanner.Text() { case "1": return field.NewOrdType(enum.OrdType_MARKET), nil case "2": return field.NewOrdType(enum.OrdType_LIMIT), nil case "3": return field.NewOrdType(enum.OrdType_STOP), nil case "4": return field.NewOrdType(enum.OrdType_STOP_LIMIT), nil } return nil, fmt.Errorf("invalid ordtype choice: %v", scanner.Text()) }
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) }