glassnode: query futures open interest

This commit is contained in:
なるみ 2022-04-26 01:25:42 +08:00
parent b87eda3bbb
commit 0ec8ec6498

View File

@ -18,6 +18,28 @@ func New(apiKey string) *Glassnode {
return &Glassnode{client: client}
}
// query last futures open interest
// https://docs.glassnode.com/api/derivatives#futures-open-interest
func (g *Glassnode) QueryFuturesOpenInterest(ctx context.Context, currency string) (float64, error) {
req := glassnodeapi.DerivativesRequest{
Client: g.client,
Asset: currency,
// 25 hours ago
Since: time.Now().Add(-25 * time.Hour).Unix(),
Interval: glassnodeapi.Interval24h,
Metric: "futures_open_interest_sum",
}
resp, err := req.Do(ctx)
if err != nil {
return 0, err
}
return resp.Last().Value, nil
}
// query last market cap in usd
// https://docs.glassnode.com/api/market#market-cap
func (g *Glassnode) QueryMarketCapInUSD(ctx context.Context, currency string) (float64, error) {
req := glassnodeapi.MarketRequest{
Client: g.client,