-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrade.go
More file actions
35 lines (28 loc) · 719 Bytes
/
trade.go
File metadata and controls
35 lines (28 loc) · 719 Bytes
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
package main
import (
"log"
"os"
"strconv"
"time"
client2 "tradingClient/client"
)
const hostname = "localhost"
const login = "test"
const password = "test"
func main() {
tradeDuration := parseArgTradeDuration()
client := client2.NewClient(hostname, login, password)
client.Observe(time.Now().Add(2 * time.Second))
client.Trade(time.Now().Add(tradeDuration))
}
func parseArgTradeDuration() time.Duration {
tradeDuration := 1 * time.Minute
if len(os.Args) > 1 {
minutes, err := strconv.Atoi(os.Args[1])
if err != nil {
log.Fatalf("failed to parse trading duration (minutes) '%v': %v\n", os.Args[1], err)
}
tradeDuration = time.Duration(minutes * int(time.Minute))
}
return tradeDuration
}