gemini

package
v0.0.0-...-cbc9d59 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPollInterval = 30 * time.Second
)

Variables

This section is empty.

Functions

func BuildNonceWithPayload

func BuildNonceWithPayload(authData authdata.AuthData, endpoint string) (sig, payload string)

Types

type AuthConfig

type AuthConfig struct {
	ApiKey    string `json:"api_key" yaml:"api_key"`
	ApiSecret string `json:"api_secret" yaml:"api_secret"`
}

func (AuthConfig) Account

func (c AuthConfig) Account() string

func (AuthConfig) Key

func (c AuthConfig) Key() string

func (AuthConfig) Secret

func (c AuthConfig) Secret() string

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a superficial wrapper around API functions in this package, allowing users to call those functions without passing an authdata.AuthData object for every call.

func NewClient

func NewClient(authData authdata.AuthData) *Client

NewClient returns a Client instance.

func (Client) PriceFeed

func (c Client) PriceFeed(ctx context.Context) (*PriceFeedResponse, error)

func (*Client) SetHttpTimeout

func (c *Client) SetHttpTimeout(timeout time.Duration) *Client

SetHttpTimeout sets the timeout of the Client's http.Client instance. By default, this is set to 10 seconds.

func (Client) SymbolDetails

func (c Client) SymbolDetails(ctx context.Context, symbol string) (*SymbolDetailsResponse, error)

func (Client) Symbols

func (c Client) Symbols(ctx context.Context) (*SymbolsResponse, error)

func (Client) Ticker

func (c Client) Ticker(ctx context.Context, symbol string) (*TickerResponse, error)

func (Client) TickerV2

func (c Client) TickerV2(ctx context.Context, symbol string) (*TickerV2Response, error)

type Config

type Config struct {
	Auth          *AuthConfig         `json:"auth,omitempty" yaml:"auth,omitempty" toml:"Auth"`
	Notifications NotificationsConfig `json:"notifications" yaml:"notifications" toml:"Notifications"`
	PollInterval  time.Duration       `json:"poll_interval" yaml:"poll_interval" toml:"PollInterval"`
}

func DefaultConfig

func DefaultConfig() *Config

func LoadConfig

func LoadConfig(confPath string) (conf Config, err error)

LoadConfig reads configuration data from the file at the passed path and returns it as a fully loaded Config. `confPath` is expected to be an absolute file path. Supported file types: json, yaml, toml

type NoncePayload

type NoncePayload struct {
	Request string `json:"request"`
	Nonce   string `json:"nonce"`
}

func (NoncePayload) Encode

func (np NoncePayload) Encode() (encoded []byte)

func (NoncePayload) EncodeString

func (np NoncePayload) EncodeString() (encoded string)

func (NoncePayload) HashHmac

func (np NoncePayload) HashHmac(key string) (sig string)

func (NoncePayload) Serialize

func (np NoncePayload) Serialize() []byte

type NotificationsConfig

type NotificationsConfig struct {
	SpotPrice []SpotPriceNotificationsConfig `json:"spot_price,omitempty" yaml:"spot_price,omitempty" toml:"SpotPrice,omitempty"`
}

type OrderBookStatus

type OrderBookStatus string
const (
	Open       OrderBookStatus = "open"
	Closed     OrderBookStatus = "closed"
	CancelOnly OrderBookStatus = "cancel_only"
	PostOnly   OrderBookStatus = "post_only"
	LimitOnly  OrderBookStatus = "limit_only"
)

type PriceFeedData

type PriceFeedData struct {
	Pair              string          `json:"pair"`
	Price             decimal.Decimal `json:"price"`
	PercentChange24Hr decimal.Decimal `json:"percentChange24h"`
}

type PriceFeedResponse

type PriceFeedResponse []PriceFeedData

func PriceFeed

func PriceFeed(ctx context.Context, authData authdata.AuthData) (*PriceFeedResponse, error)

type SpotPriceNotificationsConfig

type SpotPriceNotificationsConfig struct {
	Symbol        *string          `json:"symbol,omitempty" yaml:"symbol,omitempty" toml:"Symbol,omitempty"`
	BaseAmount    *decimal.Decimal `json:"base_amount,omitempty" yaml:"base_amount,omitempty" toml:"BaseAmount,omitempty"`
	BaseCurrency  string           `json:"base_currency" yaml:"base_currency" toml:"BaseCurrency"`
	QuoteCurrency string           `json:"quote_currency" yaml:"quote_currency" toml:"QuoteCurrency"`
}

func (SpotPriceNotificationsConfig) BaseAmt

func (SpotPriceNotificationsConfig) CurrencySymbol

func (c SpotPriceNotificationsConfig) CurrencySymbol() string

type SubscribeTradesResponse

type SubscribeTradesResponse struct {
	Events []TradeEvent `json:"events"`
	WebsocketResponse
}

type SymbolDetailsResponse

type SymbolDetailsResponse struct {
	Symbol         string          `json:"symbol"`
	BaseCurrency   string          `json:"base_currency"`
	QuoteCurrency  string          `json:"quote_currency"`
	TickSize       decimal.Decimal `json:"tick_size"`
	QuoteIncrement decimal.Decimal `json:"quote_increment"`
	MinOrderSize   decimal.Decimal `json:"min_order_size"`
	Status         OrderBookStatus `json:"status"`
	WrapEnabled    bool            `json:"wrap_enabled"`
}

func SymbolDetails

func SymbolDetails(ctx context.Context, authData authdata.AuthData, symbol string) (*SymbolDetailsResponse, error)

type SymbolsResponse

type SymbolsResponse []string

func Symbols

func Symbols(ctx context.Context, authData authdata.AuthData) (*SymbolsResponse, error)

type TickerResponse

type TickerResponse struct {
	Volume TickerVolume    `json:"volume"`
	Bid    decimal.Decimal `json:"bid"`
	Ask    decimal.Decimal `json:"ask"`
	Last   decimal.Decimal `json:"last"`
}

func Ticker

func Ticker(ctx context.Context, authData authdata.AuthData, symbol string) (*TickerResponse, error)

type TickerV2Response

type TickerV2Response struct {
	Symbol  string            `json:"symbol"`
	Open    decimal.Decimal   `json:"open"`
	High    decimal.Decimal   `json:"high"`
	Low     decimal.Decimal   `json:"low"`
	Close   decimal.Decimal   `json:"close"`
	Bid     decimal.Decimal   `json:"bid"`
	Ask     decimal.Decimal   `json:"ask"`
	Changes []decimal.Decimal `json:"changes"`
}

func TickerV2

func TickerV2(ctx context.Context, authData authdata.AuthData, symbol string) (*TickerV2Response, error)

type TickerVolume

type TickerVolume struct {
	Timestamp time.Time `json:"timestamp"`
	// contains filtered or unexported fields
}

func (*TickerVolume) UnmarshalJSON

func (tv *TickerVolume) UnmarshalJSON(data []byte) error

func (TickerVolume) Volume

func (tv TickerVolume) Volume(symbol string) decimal.Decimal

Volume returns the trading volume denominated in the passed symbol.

type TradeEvent

type TradeEvent struct {
	Type      string          `json:"type"`
	Price     decimal.Decimal `json:"price"`
	Amount    decimal.Decimal `json:"amount"`
	MakerSide string          `json:"makerSide"`
	Tid       int64           `json:"tid"`
}

type WebsocketResponse

type WebsocketResponse struct {
	Timestamp      time.Time `json:"timestamp"`
	TimestampMs    time.Time `json:"timestampms"`
	Type           string    `json:"type"`
	EventId        int64     `json:"eventId"`
	SocketSequence int64     `json:"socket_sequence"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL