move glassnode to datasource

This commit is contained in:
なるみ 2022-04-26 18:51:06 +08:00
parent 0ec8ec6498
commit c67bfc9a71
37 changed files with 8 additions and 8 deletions

View File

@ -4,25 +4,25 @@ import (
"context" "context"
"time" "time"
"github.com/c9s/bbgo/pkg/glassnode/glassnodeapi" "github.com/c9s/bbgo/pkg/datasource/glassnode/glassnodeapi"
) )
type Glassnode struct { type DataSource struct {
client *glassnodeapi.RestClient client *glassnodeapi.RestClient
} }
func New(apiKey string) *Glassnode { func New(apiKey string) *DataSource {
client := glassnodeapi.NewRestClient() client := glassnodeapi.NewRestClient()
client.Auth(apiKey) client.Auth(apiKey)
return &Glassnode{client: client} return &DataSource{client: client}
} }
// query last futures open interest // query last futures open interest
// https://docs.glassnode.com/api/derivatives#futures-open-interest // https://docs.glassnode.com/api/derivatives#futures-open-interest
func (g *Glassnode) QueryFuturesOpenInterest(ctx context.Context, currency string) (float64, error) { func (d *DataSource) QueryFuturesOpenInterest(ctx context.Context, currency string) (float64, error) {
req := glassnodeapi.DerivativesRequest{ req := glassnodeapi.DerivativesRequest{
Client: g.client, Client: d.client,
Asset: currency, Asset: currency,
// 25 hours ago // 25 hours ago
Since: time.Now().Add(-25 * time.Hour).Unix(), Since: time.Now().Add(-25 * time.Hour).Unix(),
@ -40,9 +40,9 @@ func (g *Glassnode) QueryFuturesOpenInterest(ctx context.Context, currency strin
// query last market cap in usd // query last market cap in usd
// https://docs.glassnode.com/api/market#market-cap // https://docs.glassnode.com/api/market#market-cap
func (g *Glassnode) QueryMarketCapInUSD(ctx context.Context, currency string) (float64, error) { func (d *DataSource) QueryMarketCapInUSD(ctx context.Context, currency string) (float64, error) {
req := glassnodeapi.MarketRequest{ req := glassnodeapi.MarketRequest{
Client: g.client, Client: d.client,
Asset: currency, Asset: currency,
// 25 hours ago // 25 hours ago
Since: time.Now().Add(-25 * time.Hour).Unix(), Since: time.Now().Add(-25 * time.Hour).Unix(),