package main import "tickserver/api/fix" import "fmt" import "time" func main() { path := "E:/svn/gofix/src/fix/test/SessionCfg.cfg" //path := os.Getenv("GOPATH") + "/bin/data/trade.cfg" fmt.Println(path) ss , err := fix.NewSessionSettings(path) if err != nil { panic(err) } app := fix.NewOrderApp() wait := make(chan int) go func() { app.WaitReady() fmt.Println("begin---------------") req := &fix.OrderRequest{} req.BookID = "510050" req.ClOrdID = app.GetTC().ClOrdID() req.Side = fix.Side_BUY req.OrderType = fix.OrdType_LIMIT req.Qty = 100 req.Price = 1.650 req.HandInst = '1' req.Account = "20410767" req.SecurityType = "CS" req.SecurityExchange = "XSHG" req.Currency = "CNY" app.SendOrder(req, func (event interface{}) { fmt.Println("send ok---------------") switch event.(type) { case *fix.OrderStatus : { data := event.(*fix.OrderStatus) fmt.Println("send", data) } } }) time.Sleep(10 * time.Second) fmt.Println("+9999999") app.CancleOrder(req.ClOrdID, 100, func (event interface{}) { fmt.Println("888888888888888888888888") switch event.(type) { case *fix.OrderStatus : { data := event.(*fix.OrderStatus) fmt.Println("cancle", data) } } }) wait <- 1 }() trade, err := fix.NewAppTradeClient(app, ss) if err != nil { panic(err) } fmt.Println("run start") trade.Start() trade.Run() <-wait fmt.Println("run end") trade.Stop() trade.Free() fmt.Println("stop") /* path := "E:/svn/gofix/src/fix/test/SessionCfg.cfg" fmt.Println(path) ss , err := fix.NewSessionSettings(path) if err != nil { panic(err) } sourdatach := make(chan *fix.TickFull) //fix.InitBroadcast(sourdatach) app := fix.NewMarketInfoApp(sourdatach) trade, err := fix.NewAppTradeClient(app, ss) if err != nil { panic(err) } fmt.Println("run start") trade.Start() trade.Run() fmt.Println("run end") trade.Stop() trade.Free() fmt.Println("stop") */ /* path := "E:/svn/gofix/src/fix/test/SessionCfg.cfg" ss , err := fix.NewSessionSettings(path) if err != nil { panic(err) } app := &fix.AppBase{} trade, err := fix.NewAppTradeClient(app, ss) if err != nil { panic(err) } trade.Start() fmt.Println("run start") trade.Run() fmt.Println("run end") trade.Stop() trade.Free() fmt.Println("stop") */ }