1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- package main
- import "tickserver/api/fix"
- import "fmt"
- import "os"
- import "time"
- func main() {
- 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()
- req := &fix.OrderRequest{}
- req.BookID = "4001"
- req.ClOrdID = app.GetTC().ClOrdID()
- req.Side = fix.Side_SELL
- req.OrderType = fix.OrdType_LIMIT
- req.Qty = 1.0
- req.Price = 1.3174
- req.TimeInForce = fix.TimeInForce_GOOD_TILL_CANCEL
- app.SendOrder(req, func (event interface{}) {
- switch event.(type) {
- case *fix.OrderStatus : {
- data := event.(*fix.OrderStatus)
- fmt.Println("send", data)
- }
- }
- })
- time.Sleep(10 * time.Second)
- app.CancleOrder(req.ClOrdID, 0.5, func (event interface{}) {
- 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")
- }
|