Exemple #1
0
func main() {
	app := &EchoApplication{}
	app.log = log.New(ioutil.Discard, "", log.LstdFlags)
	//app.log = log.New(os.Stdout, "", log.LstdFlags)

	router.AddRoute(fix40nos.Route(app.OnFIX40NewOrderSingle))
	router.AddRoute(fix41nos.Route(app.OnFIX41NewOrderSingle))
	router.AddRoute(fix42nos.Route(app.OnFIX42NewOrderSingle))
	router.AddRoute(fix43nos.Route(app.OnFIX43NewOrderSingle))
	router.AddRoute(fix44nos.Route(app.OnFIX44NewOrderSingle))
	router.AddRoute(fix50nos.Route(app.OnFIX50NewOrderSingle))
	router.AddRoute(fix50sp1nos.Route(app.OnFIX50SP1NewOrderSingle))
	router.AddRoute(fix50sp2nos.Route(app.OnFIX50SP2NewOrderSingle))

	router.AddRoute(fix42secdef.Route(app.OnFIX42SecurityDefinition))
	router.AddRoute(fix43secdef.Route(app.OnFIX43SecurityDefinition))
	router.AddRoute(fix44secdef.Route(app.OnFIX44SecurityDefinition))
	router.AddRoute(fix50secdef.Route(app.OnFIX50SecurityDefinition))
	router.AddRoute(fix50sp1secdef.Route(app.OnFIX50SP1SecurityDefinition))
	router.AddRoute(fix50sp2secdef.Route(app.OnFIX50SP2SecurityDefinition))

	cfg, err := os.Open(os.Args[1])
	if err != nil {
		fmt.Printf("Error opening %v, %v\n", os.Args[1], err)
		return
	}

	appSettings, err := quickfix.ParseSettings(cfg)
	if err != nil {
		fmt.Println("Error reading cfg:", err)
		return
	}

	fileLogFactory, err := quickfix.NewFileLogFactory(appSettings)

	if err != nil {
		fmt.Println("Error creating file log factory:", err)
		return
	}

	acceptor, err := quickfix.NewAcceptor(app, quickfix.NewMemoryStoreFactory(), appSettings, fileLogFactory)
	if err != nil {
		fmt.Println("Unable to create Acceptor: ", err)
		return
	}

	if err = acceptor.Start(); err != nil {
		fmt.Println("Unable to start Acceptor: ", err)
		return
	}

	interrupt := make(chan os.Signal)
	signal.Notify(interrupt)
	<-interrupt

	acceptor.Stop()
}
Exemple #2
0
func main() {
	app := &EchoApplication{}
	app.log = log.New(ioutil.Discard, "", log.LstdFlags)
	//app.log = log.New(os.Stdout, "", log.LstdFlags)

	router.AddRoute(enum.BeginStringFIX40, "D", app.processMsg)
	router.AddRoute(enum.BeginStringFIX41, "D", app.processMsg)
	router.AddRoute(enum.BeginStringFIX42, "D", app.processMsg)
	router.AddRoute(enum.BeginStringFIX43, "D", app.processMsg)
	router.AddRoute(enum.BeginStringFIX44, "D", app.processMsg)
	router.AddRoute(string(enum.ApplVerID_FIX50), "D", app.processMsg)
	router.AddRoute(string(enum.ApplVerID_FIX50SP1), "D", app.processMsg)
	router.AddRoute(string(enum.ApplVerID_FIX50SP2), "D", app.processMsg)

	router.AddRoute(enum.BeginStringFIX42, "d", app.processMsg)
	router.AddRoute(enum.BeginStringFIX43, "d", app.processMsg)
	router.AddRoute(enum.BeginStringFIX44, "d", app.processMsg)
	router.AddRoute(string(enum.ApplVerID_FIX50), "d", app.processMsg)
	router.AddRoute(string(enum.ApplVerID_FIX50SP1), "d", app.processMsg)
	router.AddRoute(string(enum.ApplVerID_FIX50SP2), "d", app.processMsg)

	cfg, err := os.Open(os.Args[1])
	if err != nil {
		fmt.Printf("Error opening %v, %v\n", os.Args[1], err)
		return
	}

	appSettings, err := quickfix.ParseSettings(cfg)
	if err != nil {
		fmt.Println("Error reading cfg:", err)
		return
	}

	fileLogFactory, err := quickfix.NewFileLogFactory(appSettings)

	if err != nil {
		fmt.Println("Error creating file log factory:", err)
		return
	}

	acceptor, err := quickfix.NewAcceptor(app, quickfix.NewMemoryStoreFactory(), appSettings, fileLogFactory)
	if err != nil {
		fmt.Println("Unable to create Acceptor: ", err)
		return
	}

	if err = acceptor.Start(); err != nil {
		fmt.Println("Unable to start Acceptor: ", err)
		return
	}

	interrupt := make(chan os.Signal)
	signal.Notify(interrupt)
	<-interrupt

	acceptor.Stop()
}
Exemple #3
0
func main() {
	flag.Parse()

	if *cpuprofile != "" {
		f, err := os.Create(*cpuprofile)
		if err != nil {
			log.Fatal(err)
		}

		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	}

	log.Print("NumCPU: ", runtime.NumCPU())
	log.Print("GOMAXPROCS: ", runtime.GOMAXPROCS(-1))

	metrics = make(stat.IntSlice, *sampleSize)

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

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

	logFactory := quickfix.NewNullLogFactory()
	storeFactory := quickfix.NewMemoryStoreFactory()

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

	<-allDone
	elapsed := time.Since(t0)

	metricsUS := make(stat.Float64Slice, *sampleSize)
	for i, durationNS := range metrics {
		metricsUS[i] = float64(durationNS) / 1000.0
	}

	mean := stat.Mean(metricsUS)
	max, maxIndex := stat.Max(metricsUS)
	stdev := stat.Sd(metricsUS)

	log.Printf("Sample mean is %g us", mean)
	log.Printf("Sample max is %g us (%v)", max, maxIndex)
	log.Printf("Standard Dev is %g us", stdev)
	log.Printf("Processed %d msg in %v [effective rate: %.4f msg/s]", count, elapsed, float64(count)/float64(elapsed)*float64(time.Second))
}
Exemple #4
0
func main() {
	flag.Parse()

	cfgFileName := "ordermatch.cfg"
	if flag.NArg() > 0 {
		cfgFileName = flag.Arg(0)
	}

	cfg, err := os.Open(cfgFileName)
	if err != nil {
		fmt.Printf("Error opening %v, %v\n", cfgFileName, err)
		return
	}

	appSettings, err := quickfix.ParseSettings(cfg)
	if err != nil {
		fmt.Println("Error reading cfg,", err)
		return
	}

	logFactory := quickfix.NewScreenLogFactory()
	app := newApplication()

	acceptor, err := quickfix.NewAcceptor(app, quickfix.NewMemoryStoreFactory(), appSettings, logFactory)
	if err != nil {
		fmt.Printf("Unable to create Acceptor: %s\n", err)
		return
	}

	err = acceptor.Start()
	if err != nil {
		fmt.Printf("Unable to start Acceptor: %s\n", err)
		return
	}

	interrupt := make(chan os.Signal)
	signal.Notify(interrupt, os.Interrupt, os.Kill)
	go func() {
		<-interrupt
		acceptor.Stop()
		os.Exit(0)
	}()

	scanner := bufio.NewScanner(os.Stdin)
	for {
		scanner.Scan()

		switch value := scanner.Text(); value {
		case "#symbols":
			app.Display()
		default:
			app.DisplayMarket(value)
		}
	}
}
Exemple #5
0
func main() {
	app := app.NewAcceptorApp()

	cfg, _ := os.Open("whygo/cfg/acceptor.cfg")
	storeFactory := quickfix.NewMemoryStoreFactory()
	appSettings, _ := quickfix.ParseSettings(cfg)
	logFactory, _ := quickfix.NewFileLogFactory(appSettings)
	acceptor, _ := quickfix.NewAcceptor(app, storeFactory, appSettings, logFactory)
	acceptor.Start()

	interrupt := make(chan os.Signal)
	signal.Notify(interrupt)
	<-interrupt
}
Exemple #6
0
func main() {
	flag.Parse()
	if *cpuprofile != "" {
		defer pprof.StopCPUProfile()
	}

	log.Print("NumCPU: ", runtime.NumCPU())
	log.Print("GOMAXPROCS: ", runtime.GOMAXPROCS(-1))

	metrics = make(stat.IntSlice, *sampleSize)

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

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

	logFactory := quickfix.NewNullLogFactory()

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

	<-allDone

	metricsUS := make(stat.Float64Slice, *sampleSize)
	for i, durationNS := range metrics {
		metricsUS[i] = float64(durationNS) / 1000.0
	}

	mean := stat.Mean(metricsUS)
	max, maxIndex := stat.Max(metricsUS)
	stdev := stat.Sd(metricsUS)

	log.Printf("Sample mean is %g us", mean)
	log.Printf("Sample max is %g us (%v)", max, maxIndex)
	log.Printf("Standard Dev is %g us", stdev)
}
Exemple #7
0
func main() {
	flag.Parse()

	cfgFileName := path.Join("config", "executor.cfg")
	if flag.NArg() > 0 {
		cfgFileName = flag.Arg(0)
	}

	cfg, err := os.Open(cfgFileName)
	if err != nil {
		fmt.Printf("Error opening %v, %v\n", cfgFileName, err)
		return
	}

	appSettings, err := quickfix.ParseSettings(cfg)
	if err != nil {
		fmt.Println("Error reading cfg,", err)
		return
	}

	logFactory := quickfix.NewScreenLogFactory()
	app := newExecutor()

	acceptor, err := quickfix.NewAcceptor(app, quickfix.NewMemoryStoreFactory(), appSettings, logFactory)
	if err != nil {
		fmt.Printf("Unable to create Acceptor: %s\n", err)
		return
	}

	err = acceptor.Start()
	if err != nil {
		fmt.Printf("Unable to start Acceptor: %s\n", err)
		return
	}

	interrupt := make(chan os.Signal)
	signal.Notify(interrupt, os.Interrupt, os.Kill)
	<-interrupt

	acceptor.Stop()
}
Exemple #8
0
func main() {
	cfgFileName := "executor.cfg"
	cfg, err := os.Open(cfgFileName)
	if err != nil {
		fmt.Printf("Error opening %v, %v\n", cfgFileName, err)
		return
	}

	appSettings, err := quickfix.ParseSettings(cfg)
	if err != nil {
		fmt.Println("Error reading cfg,", err)
		return
	}

	fileLogFactory, err := quickfix.NewFileLogFactory(appSettings)

	if err != nil {
		fmt.Println("Error creating file log factory,", err)
		return
	}

	app := NewExecutor()

	acceptor, err := quickfix.NewAcceptor(app, quickfix.NewMemoryStoreFactory(), appSettings, fileLogFactory)
	if err != nil {
		fmt.Printf("Unable to create Acceptor: %s\n", err)
		return
	}

	acceptor.Start()

	interrupt := make(chan os.Signal)
	signal.Notify(interrupt)
	<-interrupt

	acceptor.Stop()
}
Exemple #9
0
func NewSellSideSimulator(logger string) *SellSideSimulator {
	mc := &SellSideSimulator{}

	// QuickFIX settings
	appSettings := quickfix.NewSettings()
	var settings *quickfix.SessionSettings
	settings = appSettings.GlobalSettings()
	settings.Set("SocketAcceptPort", "5001")
	settings.Set("SenderCompID", "CORP")
	settings.Set("TargetCompID", "CYAN")
	settings.Set("ResetOnLogon", "Y")
	settings.Set("FileLogPath", "tmp")
	settings = quickfix.NewSessionSettings()
	settings.Set("BeginString", "FIX.4.4")
	appSettings.AddSession(settings)

	app := NewExecutor()

	var logFactory quickfix.LogFactory
	switch logger {
	case "console":
		logFactory = quickfix.NewScreenLogFactory()
	default:
		logFactory = quickfix.NewNullLogFactory()

	}

	acceptor, err := quickfix.NewAcceptor(app, quickfix.NewMemoryStoreFactory(), appSettings, logFactory)
	if err != nil {
		log.Panic(err)
	}

	mc.acceptor = acceptor

	return mc
}