-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgm.go
More file actions
42 lines (35 loc) · 1.53 KB
/
gm.go
File metadata and controls
42 lines (35 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package stockfighter
import "fmt"
const (
GMURL = "/gm"
)
type InstanceResponse struct {
StockfighterResponse
Account string `json:"account"`
Balances map[string]int `json:"balances"`
InstanceID int `json:"instanceId"`
Instructions map[string]string `json:"instructions"`
SecondsPerTradingDay int `json:"secondsPerTradingDay"`
Tickers []string `json:"tickers"`
Venues []string `json:"venues"`
}
func (s StockfighterClient) StartLevel(level string) (InstanceResponse, error) {
instanceResponse := InstanceResponse{}
err := s.Do("POST", fmt.Sprintf(GMURL+"/levels/%v", level), nil, &instanceResponse)
return instanceResponse, err
}
func (s StockfighterClient) RestartInstance(instance int) (InstanceResponse, error) {
instanceResponse := InstanceResponse{}
err := s.Do("POST", fmt.Sprintf(GMURL+"/instances/%v/restart", instance), nil, &instanceResponse)
return instanceResponse, err
}
func (s StockfighterClient) ResumeInstance(instance int) (InstanceResponse, error) {
instanceResponse := InstanceResponse{}
err := s.Do("POST", fmt.Sprintf(GMURL+"/instances/%v/resume", instance), nil, &instanceResponse)
return instanceResponse, err
}
func (s StockfighterClient) StopInstance(instance int) (StockfighterResponse, error) {
stockfighterResponse := StockfighterResponse{}
err := s.Do("POST", fmt.Sprintf(GMURL+"/instances/%v/stop", instance), nil, &stockfighterResponse)
return stockfighterResponse, err
}