mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
move glassnode to datasource
This commit is contained in:
parent
0ec8ec6498
commit
c67bfc9a71
|
@ -4,25 +4,25 @@ import (
|
|||
"context"
|
||||
"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
|
||||
}
|
||||
|
||||
func New(apiKey string) *Glassnode {
|
||||
func New(apiKey string) *DataSource {
|
||||
client := glassnodeapi.NewRestClient()
|
||||
client.Auth(apiKey)
|
||||
|
||||
return &Glassnode{client: client}
|
||||
return &DataSource{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) {
|
||||
func (d *DataSource) QueryFuturesOpenInterest(ctx context.Context, currency string) (float64, error) {
|
||||
req := glassnodeapi.DerivativesRequest{
|
||||
Client: g.client,
|
||||
Client: d.client,
|
||||
Asset: currency,
|
||||
// 25 hours ago
|
||||
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
|
||||
// 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{
|
||||
Client: g.client,
|
||||
Client: d.client,
|
||||
Asset: currency,
|
||||
// 25 hours ago
|
||||
Since: time.Now().Add(-25 * time.Hour).Unix(),
|
Loading…
Reference in New Issue
Block a user