func main() {

	// The following assumes game_start.exe has already been called, and thus that
	// there exists a file in the /gm/ directory which contains info about the level.

	info := gofighter.GetUserSelection("known_levels.json")

	// The Ticker goroutine called below is the direct interface to the server WebSocket.
	// It simply sends executions down a channel at us.

	ex_chan := make(chan gofighter.Execution)
	go gofighter.Tracker(info, ex_chan)

	for n := 0; ; n++ {
		msg := <-ex_chan
		fmt.Printf("%s %s %d @ %d\n", msg.Account, msg.Order.Direction, msg.Filled, msg.Price)
	}

	return
}
Exemplo n.º 2
0
func main() {

	// The following assumes game_start.exe has already been called, and thus that
	// there exists a file in the /gm/ directory which contains info about the level.

	info := gofighter.GetUserSelection("known_levels.json")

	// The info var above now contains account, venue, and symbol. So we just need
	// the following pieces of information; the ShortOrder type is designed for this.

	order := gofighter.ShortOrder{
		Direction: "buy",
		OrderType: "limit",
		Qty:       100,
		Price:     10000,
	}

	result, _ := gofighter.Execute(info, order, nil)
	gofighter.PrintJSON(result)
}
func main() {

	// The following assumes game_start.exe has already been called, and thus that
	// there exists a file in the /gm/ directory which contains info about the level.

	info := gofighter.GetUserSelection("known_levels.json")

	// The Ticker goroutine called below is the direct interface to the server WebSocket.
	// It simply sends quotes down a channel at us.

	ticker_results := make(chan gofighter.Quote, 64)
	go gofighter.Ticker(info, ticker_results)

	for n := 0; ; n++ {
		msg := <-ticker_results
		fmt.Printf("%d ", n)
		s, _ := json.MarshalIndent(msg, "", "  ")
		fmt.Println(string(s))
	}

	return
}
func main() {

	// The following assumes game_start.exe has already been called, and thus that
	// there exists a file in the /gm/ directory which contains info about the level.

	info := gofighter.GetUserSelection("known_levels.json")

	position_queries := make(chan chan gofighter.Position)
	go gofighter.PositionWatch(info, position_queries)

	// How this works: the goroutine PositionWatch uses a WebSocket to keep track of
	// the position, and when we send a channel to it via its input channel, it sends
	// a copy of the position back to us along the channel we provided.

	for {
		position := gofighter.GetPosition(position_queries) // Behind the scenes, this sends a
		// one-time channel to the goroutine

		fmt.Printf(time.Now().Format("2006-01-02 15:04:05 ... "))
		fmt.Printf("Shares: %d, Dollars: $%d\n", position.Shares, position.Cents/100)

		time.Sleep(2 * time.Second)
	}
}
func main() {

	// The following assumes game_start.exe has already been called, and thus that
	// there exists a file in the /gm/ directory which contains info about the level.

	info := gofighter.GetUserSelection("known_levels.json")

	market_queries := make(chan chan gofighter.Market)
	go gofighter.MarketWatch(info, market_queries)

	// How this works: the goroutine MarketWatch uses a WebSocket to keep track of
	// the market, and when we send a channel to it via its input channel, it sends
	// a copy of the market back to us along the channel we provided.

	for {
		market := gofighter.GetMarket(market_queries) // Behind the scenes, this sends a
		// one-time channel to the goroutine

		fmt.Printf(time.Now().Format("2006-01-02 15:04:05 ... "))
		market.Print()

		time.Sleep(2 * time.Second)
	}
}
Exemplo n.º 6
0
func load(args []string) {
	info = gofighter.GetUserSelection("known_levels.json")
	gofighter.PrintJSON(info)
}