-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
61 lines (47 loc) · 1.02 KB
/
main.go
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"math/rand"
"time"
"github.com/Simon-Busch/go_crypto_exchange/client"
"github.com/Simon-Busch/go_crypto_exchange/mm"
"github.com/Simon-Busch/go_crypto_exchange/server"
)
func main() {
go server.StartServer()
time.Sleep(1 * time.Second)
clt := client.NewClient()
cfg := mm.Config{
UserID: 9,
OrderSize: 10,
MinSpread: 20, // ordersize * 2 would be good
SeedOffset: 40,
ExchangeClient: clt,
MakeInterval: 1 * time.Second,
PriceOffset: 10,
}
maker := mm.NewMarketMaker(cfg)
maker.Start()
time.Sleep(1 * time.Second)
go marketOrderPlacer(clt)
select {}
}
func marketOrderPlacer(c *client.Client) {
ticker := time.NewTicker(200 * time.Millisecond)
for {
randomint := rand.Intn(10)
bid := true
if randomint > 3 { // The higher, more buying pressure -- price going up
bid = false
}
order := &client.PlaceOrderParams{
UserID: 1,
Bid: bid,
Size: 1,
}
_, err := c.PlaceMarketOrder(order)
if err != nil {
panic(err)
}
<- ticker.C
}
}