コード例 #1
0
func print_error_or_json(in interface{}, err error) {
	if err != nil {
		fmt.Println(err)
		return
	}
	gofighter.PrintJSON(in)
}
コード例 #2
0
func reset(args []string) {
	var err error
	info.BaseURL = OFFICIAL_URL
	info.ApiKey, err = gofighter.LoadAPIKey("api_key.txt")
	if err != nil {
		fmt.Println(err)
	}
	info.Account = "EXB123456"
	info.Venue = "TESTEX"
	info.Symbol = "FOOBAR"
	order.Direction = "buy"
	order.OrderType = "limit"
	order.Qty = 100
	order.Price = 5000

	gofighter.PrintJSON(info)
	gofighter.PrintJSON(order)
}
コード例 #3
0
func main() {

	// First we use the list of known levels to get a level name from the user.

	levelname := gofighter.NameFromUser("known_levels.json")

	// We load the original response we got when we started the game, this is
	// located in the /gm/ directory and contains the instance ID.

	level, _ := gofighter.LoadGMfile(levelname)

	stop, _ := gofighter.GMstop("", level.InstanceId) // When given "", the function will use the API key from api_key.txt
	gofighter.PrintJSON(stop)
}
コード例 #4
0
func main() {

	// First we use the list of known levels to get a level name from the user.
	// Then we call the gamemaster to start that level.

	levelname := gofighter.NameFromUser("known_levels.json")
	start, _ := gofighter.GMstart("", levelname) // When given "", the function will use the API key from api_key.txt

	// The response is saved in the /gm/ folder so that we can load the essential
	// info (account, venue, symbol) in the trading program, or whatever.

	gofighter.SaveGMfile(levelname, start)

	info := gofighter.TradingInfoFromName(levelname)
	gofighter.PrintJSON(info)
}
コード例 #5
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)
}
コード例 #6
0
func load(args []string) {
	info = gofighter.GetUserSelection("known_levels.json")
	gofighter.PrintJSON(info)
}
コード例 #7
0
func print(args []string) {
	gofighter.PrintJSON(info)
	gofighter.PrintJSON(order)
}