func order_and_cancel(info gofighter.TradingInfo, order gofighter.ShortOrder) { res, err := gofighter.Execute(info, order, nil) if err != nil { fmt.Println(err) return } time.Sleep(5 * time.Second) id := res.Id gofighter.Cancel(info, id) }
func cancel(args []string) { if len(args) != 2 { fmt.Println("Wrong number of args for cancel") return } id, err := strconv.Atoi(args[1]) if err != nil { fmt.Println(err) return } result, err := gofighter.Cancel(info, id) print_error_or_json(result, err) }
func order_cancel_report(info gofighter.TradingInfo, order gofighter.ShortOrder, move_chan chan gofighter.Movement) { res, err := gofighter.Execute(info, order, nil) if err != nil { fmt.Println(err) move_chan <- gofighter.Movement{} // For consistency, send message even on failure return } time.Sleep(5 * time.Second) id := res.Id res, err = gofighter.Cancel(info, id) if err != nil { fmt.Println(err) move_chan <- gofighter.Movement{} // For consistency, send message even on failure return } move_chan <- gofighter.MoveFromOrder(res) return }