-
Notifications
You must be signed in to change notification settings - Fork 220
/
main.go
49 lines (40 loc) · 866 Bytes
/
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
package main
import (
"fmt"
"log"
"os"
"github.com/bitfinexcom/bitfinex-api-go/pkg/models/position"
"github.com/bitfinexcom/bitfinex-api-go/v2/rest"
"github.com/davecgh/go-spew/spew"
)
// Set BFX_API_KEY and BFX_API_SECRET:
//
// export BFX_API_KEY=<your-api-key>
// export BFX_API_SECRET=<your-api-secret>
//
// you can obtain it from https://www.bitfinex.com/api
func main() {
key := os.Getenv("BFX_API_KEY")
secret := os.Getenv("BFX_API_SECRET")
c := rest.NewClient().Credentials(key, secret)
all(c)
claim(c)
}
func all(c *rest.Client) {
p, err := c.Positions.All()
if err != nil {
log.Fatalf("All: %s", err)
}
for _, ps := range p.Snapshot {
fmt.Println(ps)
}
}
func claim(c *rest.Client) {
pc, err := c.Positions.Claim(&position.ClaimRequest{
Id: 36228736,
})
if err != nil {
log.Fatalf("Claim: %s", err)
}
spew.Dump(pc)
}