bbgo_origin/examples/max-rewards/main.go

50 lines
893 B
Go
Raw Permalink Normal View History

2021-02-22 10:45:44 +00:00
package main
import (
"context"
"log"
"os"
maxapi "github.com/c9s/bbgo/pkg/exchange/max/maxapi"
)
func main() {
key := os.Getenv("MAX_API_KEY")
secret := os.Getenv("MAX_API_SECRET")
api := maxapi.NewRestClient(maxapi.ProductionAPIURL)
api.Auth(key, secret)
ctx := context.Background()
2022-04-20 08:58:42 +00:00
var req *maxapi.GetRewardsRequest
2021-02-22 10:45:44 +00:00
if len(os.Args) > 1 {
pathType := os.Args[1]
rewardType, err := maxapi.ParseRewardType(pathType)
if err != nil {
log.Fatal(err)
}
2022-04-20 08:58:42 +00:00
req = api.RewardService.NewGetRewardsOfTypeRequest(rewardType)
2021-02-22 10:45:44 +00:00
} else {
2022-04-20 08:58:42 +00:00
req = api.RewardService.NewGetRewardsRequest()
2021-02-22 10:45:44 +00:00
}
2021-02-22 10:45:44 +00:00
// req.From(1613931192)
// req.From(1613240048)
// req.From(maxapi.TimestampSince)
// req.To(maxapi.TimestampSince + 3600 * 24)
req.Limit(100)
2021-02-22 10:45:44 +00:00
rewards, err := req.Do(ctx)
if err != nil {
log.Fatal(err)
}
for _, reward := range rewards {
log.Printf("%+v\n", reward)
}
}