coinbasepro

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2022 License: MIT Imports: 13 Imported by: 0

README

docs

Coinbase Pro API Wrapper

This package wraps the references defined by the Coinbase Cloud API, and can be installed using

go get github.com/alpine-hodler/web/pkg/coinbasepro

Creating a Client

The coinbasepro.Client type is a wrapper for the Go net/http standard library package. An http.RoundTripper is required to authenticate for Coinbase Pro requests. Currently the only method supported for Coinbase Pro authentication is API key authentication. See the examples for examples.

Rate Limits

Per the Coinbase Pro API FAQs:

For Public Endpoints, our rate limit is 3 requests per second, up to 6 requests per second in bursts. For Private Endpoints, our rate limit is 5 requests per second, up to 10 requests per second in bursts.

The HTTP package uses "golang.org/x/time/rate" to ensure that rate limits are honored. This data is lazy loaded to cut down on memory consumption.

Development

Notes on developing in this package.

Testing

You will need to create an account for the Coinbase Pro Sandbox and create a new API key for the Default Portfolio with View/Trade/Transfer permissions. Then populate the following data in pkg/coinbase/.simple-test.env:

CB_PRO_ACCESS_PASSPHRASE=
CB_PRO_ACCESS_KEY=
CB_PRO_SECRET=

Note that pkg/coinbase/.simple-test.env is an ignored file and should not be commitable to the repository. The Coinbase Pro Sandbox can be accessed here.

Documentation

Index

Examples

Constants

View Source
const (
	AccountHoldsPath rawPath
	AccountLedgerPath
	AccountPath
	AccountTransfersPath
	AccountsPath
	BookPath
	CancelOpenOrdersPath
	CancelOrderPath
	CandlesPath
	CoinbaseAccountDepositPath
	CoinbaseAccountWithdrawalPath
	ConvertCurrencyPath
	CreateOrderPath
	CreateProfilePath
	CreateProfileTransferPath
	CreateReportPath
	CryptoWithdrawalPath
	CurrenciesPath
	CurrencyConversionPath
	CurrencyPath
	DeleteProfilePath
	ExchangeLimitsPath
	FeesPath
	FillsPath
	GenerateCryptoAddressPath
	OrderPath
	OrdersPath
	PaymentMethodDepositPath
	PaymentMethodWithdrawalPath
	PaymentMethodsPath
	ProductPath
	ProductStatsPath
	ProductTickerPath
	ProductsPath
	ProfilePath
	ProfilesPath
	RenameProfilePath
	ReportPath
	ReportsPath
	SignedPricesPath
	TradesPath
	TransferPath
	TransfersPath
	WalletsPath
	WithdrawalFeeEstimatePath
)
View Source
const (
	AccountHoldsRatelimiter ratelimiter
	AccountLedgerRatelimiter
	AccountRatelimiter
	AccountTransfersRatelimiter
	AccountsRatelimiter
	BookRatelimiter
	CancelOpenOrdersRatelimiter
	CancelOrderRatelimiter
	CandlesRatelimiter
	CoinbaseAccountDepositRatelimiter
	CoinbaseAccountWithdrawalRatelimiter
	ConvertCurrencyRatelimiter
	CreateOrderRatelimiter
	CreateProfileRatelimiter
	CreateProfileTransferRatelimiter
	CreateReportRatelimiter
	CryptoWithdrawalRatelimiter
	CurrenciesRatelimiter
	CurrencyConversionRatelimiter
	CurrencyRatelimiter
	DeleteProfileRatelimiter
	ExchangeLimitsRatelimiter
	FeesRatelimiter
	FillsRatelimiter
	GenerateCryptoAddressRatelimiter
	OrderRatelimiter
	OrdersRatelimiter
	PaymentMethodDepositRatelimiter
	PaymentMethodWithdrawalRatelimiter
	PaymentMethodsRatelimiter
	ProductRatelimiter
	ProductStatsRatelimiter
	ProductTickerRatelimiter
	ProductsRatelimiter
	ProfileRatelimiter
	ProfilesRatelimiter
	RenameProfileRatelimiter
	ReportRatelimiter
	ReportsRatelimiter
	SignedPricesRatelimiter
	TradesRatelimiter
	TransferRatelimiter
	TransfersRatelimiter
	WalletsRatelimiter
	WithdrawalFeeEstimateRatelimiter
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Available      string `bson:"available" json:"available" sql:"available"`
	Balance        string `bson:"balance" json:"balance" sql:"balance"`
	Currency       string `bson:"currency" json:"currency" sql:"currency"`
	Hold           string `bson:"hold" json:"hold" sql:"hold"`
	ID             string `bson:"id" json:"id" sql:"id"`
	ProfileID      string `bson:"profile_id" json:"profile_id" sql:"profile_id"`
	TradingEnabled bool   `bson:"trading_enabled" json:"trading_enabled" sql:"trading_enabled"`
}

Account holds data for trading account from the profile of the API key

type AccountHold

type AccountHold struct {
	CreatedAt time.Time `bson:"created_at" json:"created_at" sql:"created_at"`
	ID        string    `bson:"id" json:"id" sql:"id"`
	Ref       string    `bson:"ref" json:"ref" sql:"ref"`
	Type      string    `bson:"type" json:"type" sql:"type"`
	UpdatedAt time.Time `bson:"updated_at" json:"updated_at" sql:"updated_at"`
}

AccountHold represents the hold on an account that belong to the same profile as the API key. Holds are placed on an account for any active orders or pending withdraw requests. As an order is filled, the hold amount is updated. If an order is canceled, any remaining hold is removed. For withdrawals, the hold is removed after it is completed.

type AccountHoldsOptions

type AccountHoldsOptions struct {
	// After is used for pagination and sets end cursor to `after` date.
	After *string `bson:"after" json:"after" sql:"after"`

	// Before is used for pagination and sets start cursor to `before` date.
	Before *string `bson:"before" json:"before" sql:"before"`

	// Limit puts a limit on number of results to return.
	Limit *int `bson:"limit" json:"limit" sql:"limit"`
}

AccountHoldsOptions are options for API requests.

func (*AccountHoldsOptions) EncodeBody

func (opts *AccountHoldsOptions) EncodeBody() (buf io.Reader, err error)

func (*AccountHoldsOptions) EncodeQuery

func (opts *AccountHoldsOptions) EncodeQuery(req *http.Request)

func (*AccountHoldsOptions) SetAfter

func (opts *AccountHoldsOptions) SetAfter(After string) *AccountHoldsOptions

SetAfter sets the After field on AccountHoldsOptions. After is used for pagination and sets end cursor to `after` date.

func (*AccountHoldsOptions) SetBefore

func (opts *AccountHoldsOptions) SetBefore(Before string) *AccountHoldsOptions

SetBefore sets the Before field on AccountHoldsOptions. Before is used for pagination and sets start cursor to `before` date.

func (*AccountHoldsOptions) SetLimit

func (opts *AccountHoldsOptions) SetLimit(Limit int) *AccountHoldsOptions

SetLimit sets the Limit field on AccountHoldsOptions. Limit puts a limit on number of results to return.

type AccountLedger

type AccountLedger struct {
	Amount    string               `bson:"amount" json:"amount" sql:"amount"`
	Balance   string               `bson:"balance" json:"balance" sql:"balance"`
	CreatedAt time.Time            `bson:"created_at" json:"created_at" sql:"created_at"`
	Details   AccountLedgerDetails `bson:"details" json:"details" sql:"details"`
	ID        string               `bson:"id" json:"id" sql:"id"`
	Type      EntryType            `bson:"type" json:"type" sql:"type"`
}

AccountLedger lists ledger activity for an account. This includes anything that would affect the accounts balance - transfers, trades, fees, etc.

type AccountLedgerDetails

type AccountLedgerDetails struct {
	OrderID   string `bson:"order_id" json:"order_id" sql:"order_id"`
	ProductID string `bson:"product_id" json:"product_id" sql:"product_id"`
	TradeID   string `bson:"trade_id" json:"trade_id" sql:"trade_id"`
}

AccountLedgerDetails are the details for account history.

type AccountLedgerOptions

type AccountLedgerOptions struct {
	// After is used for pagination. Sets end cursor to `after` date.
	After *int `bson:"after" json:"after" sql:"after"`

	// Before is used for pagination. Sets start cursor to `before` date.
	Before *int `bson:"before" json:"before" sql:"before"`

	// EndDate will filter results by maximum posted date.
	EndDate *string `bson:"end_date" json:"end_date" sql:"end_date"`

	// Limit puts a limit on number of results to return.
	Limit *int `bson:"limit" json:"limit" sql:"limit"`

	// StartDate will filter results by minimum posted date.
	StartDate *string `bson:"start_date" json:"start_date" sql:"start_date"`
	ProfileID *string `bson:"profile_id" json:"profile_id" sql:"profile_id"`
}

AccountLedgerOptions are options for API requests.

func (*AccountLedgerOptions) EncodeBody

func (opts *AccountLedgerOptions) EncodeBody() (buf io.Reader, err error)

func (*AccountLedgerOptions) EncodeQuery

func (opts *AccountLedgerOptions) EncodeQuery(req *http.Request)

func (*AccountLedgerOptions) SetAfter

func (opts *AccountLedgerOptions) SetAfter(After int) *AccountLedgerOptions

SetAfter sets the After field on AccountLedgerOptions. After is used for pagination. Sets end cursor to `after` date.

func (*AccountLedgerOptions) SetBefore

func (opts *AccountLedgerOptions) SetBefore(Before int) *AccountLedgerOptions

SetBefore sets the Before field on AccountLedgerOptions. Before is used for pagination. Sets start cursor to `before` date.

func (*AccountLedgerOptions) SetEndDate

func (opts *AccountLedgerOptions) SetEndDate(EndDate string) *AccountLedgerOptions

SetEndDate sets the EndDate field on AccountLedgerOptions. EndDate will filter results by maximum posted date.

func (*AccountLedgerOptions) SetLimit

func (opts *AccountLedgerOptions) SetLimit(Limit int) *AccountLedgerOptions

SetLimit sets the Limit field on AccountLedgerOptions. Limit puts a limit on number of results to return.

func (*AccountLedgerOptions) SetProfileID

func (opts *AccountLedgerOptions) SetProfileID(ProfileID string) *AccountLedgerOptions

SetProfileID sets the ProfileID field on AccountLedgerOptions.

func (*AccountLedgerOptions) SetStartDate

func (opts *AccountLedgerOptions) SetStartDate(StartDate string) *AccountLedgerOptions

SetStartDate sets the StartDate field on AccountLedgerOptions. StartDate will filter results by minimum posted date.

type AccountTransferDetails

type AccountTransferDetails struct {
	CoinbaseAccountID       string `bson:"coinbase_account_id" json:"coinbase_account_id" sql:"coinbase_account_id"`
	CoinbasePaymentMethodID string `bson:"coinbase_payment_method_id" json:"coinbase_payment_method_id" sql:"coinbase_payment_method_id"`
	CoinbaseTransactionID   string `bson:"coinbase_transaction_id" json:"coinbase_transaction_id" sql:"coinbase_transaction_id"`
}

AccountTransferDetails are the details for an account transfer.

type AccountTransfersOptions

type AccountTransfersOptions struct {
	// After is used for pagination. Sets end cursor to `after` date.
	After *string `bson:"after" json:"after" sql:"after"`

	// Before is used for pagination. Sets start cursor to `before` date.
	Before *string `bson:"before" json:"before" sql:"before"`

	// Limit puts a limit on number of results to return.
	Limit *int            `bson:"limit" json:"limit" sql:"limit"`
	Type  *TransferMethod `bson:"type" json:"type" sql:"type"`
}

AccountTransfersOptions are options for API requests.

func (*AccountTransfersOptions) EncodeBody

func (opts *AccountTransfersOptions) EncodeBody() (buf io.Reader, err error)

func (*AccountTransfersOptions) EncodeQuery

func (opts *AccountTransfersOptions) EncodeQuery(req *http.Request)

func (*AccountTransfersOptions) SetAfter

SetAfter sets the After field on AccountTransfersOptions. After is used for pagination. Sets end cursor to `after` date.

func (*AccountTransfersOptions) SetBefore

func (opts *AccountTransfersOptions) SetBefore(Before string) *AccountTransfersOptions

SetBefore sets the Before field on AccountTransfersOptions. Before is used for pagination. Sets start cursor to `before` date.

func (*AccountTransfersOptions) SetLimit

func (opts *AccountTransfersOptions) SetLimit(Limit int) *AccountTransfersOptions

SetLimit sets the Limit field on AccountTransfersOptions. Limit puts a limit on number of results to return.

func (*AccountTransfersOptions) SetType

SetType sets the Type field on AccountTransfersOptions.

type AsyncTicker

type AsyncTicker struct {
	Errors *errgroup.Group
	// contains filtered or unexported fields
}

AsyncTicker is an object that helps maintain state when trying to stream product ticker data. It starts an underlying worker and queues versions of itself to stream from the websocket connection.

func (*AsyncTicker) Channel

func (ticker *AsyncTicker) Channel() TickerChannel

Channel returns the ticker channel for streaming

func (*AsyncTicker) Close

func (ticker *AsyncTicker) Close() error

Close unsubscribes the message from the websocket and closes the channel. The Close routine can be called multiple times safely. This method is run asyncronously, relying on the worker to not enqueue jobs where the previous iteration has not been closed. The asynchronous nature of the function allows the user to "Close" the job without waiting on the closing channel to be resolved.

func (*AsyncTicker) Open

func (ticker *AsyncTicker) Open() *AsyncTicker

Open starts the websocket stream, streaming it into the AsyncTicker.channel. This method is idempotent, so if you call it multiple times successively without closing the websocket it will close the ws for you in each successive run and re-make the channels to stream over.f the calls need to return without starting the go-routing.

type Auction

type Auction struct {
	AuctionState string    `bson:"auction_state" json:"auction_state" sql:"auction_state"`
	BestAskPrice string    `bson:"best_ask_price" json:"best_ask_price" sql:"best_ask_price"`
	BestAskSize  string    `bson:"best_ask_size" json:"best_ask_size" sql:"best_ask_size"`
	BestBidPrice string    `bson:"best_bid_price" json:"best_bid_price" sql:"best_bid_price"`
	BestBidSize  string    `bson:"best_bid_size" json:"best_bid_size" sql:"best_bid_size"`
	CanOpen      string    `bson:"can_open" json:"can_open" sql:"can_open"`
	OpenPrice    string    `bson:"open_price" json:"open_price" sql:"open_price"`
	OpenSize     string    `bson:"open_size" json:"open_size" sql:"open_size"`
	Time         time.Time `bson:"time" json:"time" sql:"time"`
}

Auction is an object of data concerning a book request.

type AvailableBalance

type AvailableBalance struct {
	Amount   string `bson:"amount" json:"amount" sql:"amount"`
	Currency string `bson:"currency" json:"currency" sql:"currency"`
	Scale    string `bson:"scale" json:"scale" sql:"scale"`
}

AvailableBalance is the available balance on the coinbase account

type Balance

type Balance struct {
	Amount   string `bson:"amount" json:"amount" sql:"amount"`
	Currency string `bson:"currency" json:"currency" sql:"currency"`
}

Balance is the balance for picker data

type BankCountry

type BankCountry struct {
	Code string `bson:"code" json:"code" sql:"code"`
	Name string `bson:"name" json:"name" sql:"name"`
}

BankCountry are the name and code for the bank's country associated with a wallet

type BidAsk

type BidAsk []byte

BidAsk is a slice of bytes that represents the bids or asks for a given product. The term "bid" refers to the highest price a buyer will pay to buy a specified number of shares of a stock at any given time. The term "ask" refers to the lowest price at which a seller will sell the stock. The bid price will almost always be lower than the ask or “offer,” price.

func (*BidAsk) UnmarshalJSON

func (ba *BidAsk) UnmarshalJSON(b []byte) error

UnmarshalJSON will deserialize bytes into a BidAsk model

type Book

type Book struct {
	Asks        BidAsk  `bson:"asks" json:"asks" sql:"asks"`
	Auction     Auction `bson:"auction" json:"auction" sql:"auction"`
	AuctionMode bool    `bson:"auction_mode" json:"auction_mode" sql:"auction_mode"`
	Bids        BidAsk  `bson:"bids" json:"bids" sql:"bids"`
	Sequence    float64 `bson:"sequence" json:"sequence" sql:"sequence"`
}

Book is a list of open orders for a product. The amount of detail shown can be customized with the level parameter.

type BookOptions

type BookOptions struct {
	// Levels 1 and 2 are aggregated. The size field is the sum of the size of the orders at that price, and num-orders is
	// the count of orders at that price; size should not be multiplied by num-orders. Level 3 is non-aggregated and returns
	// the entire order book. While the book is in an auction, the L1, L2 and L3 book will also contain the most recent
	// indicative quote disseminated during the auction, and auction_mode will be set to true. These indicative quote
	// messages are sent on an interval basis (approximately once a second) during the collection phase of an auction and
	// includes information about the tentative price and size affiliated with the completion. Level 1 and Level 2 are
	// recommended for polling. For the most up-to-date data, consider using the websocket stream. Level 3 is only
	// recommended for users wishing to maintain a full real-time order book using the websocket stream. Abuse of Level 3
	// via polling will cause your access to be limited or blocked.
	Level *int32 `bson:"level" json:"level" sql:"level"`
}

BookOptions are options for API requests.

func (*BookOptions) EncodeBody

func (opts *BookOptions) EncodeBody() (buf io.Reader, err error)

func (*BookOptions) EncodeQuery

func (opts *BookOptions) EncodeQuery(req *http.Request)

func (*BookOptions) SetLevel

func (opts *BookOptions) SetLevel(Level int32) *BookOptions

SetLevel sets the Level field on BookOptions. Levels 1 and 2 are aggregated. The size field is the sum of the size of the orders at that price, and num-orders is the count of orders at that price; size should not be multiplied by num-orders. Level 3 is non-aggregated and returns the entire order book. While the book is in an auction, the L1, L2 and L3 book will also contain the most recent indicative quote disseminated during the auction, and auction_mode will be set to true. These indicative quote messages are sent on an interval basis (approximately once a second) during the collection phase of an auction and includes information about the tentative price and size affiliated with the completion. Level 1 and Level 2 are recommended for polling. For the most up-to-date data, consider using the websocket stream. Level 3 is only recommended for users wishing to maintain a full real-time order book using the websocket stream. Abuse of Level 3 via polling will cause your access to be limited or blocked.

type CancelAfter

type CancelAfter string

CancelAfter is the timeframe in which to cancel an order if it hasn't been filled

const (
	CancelAfterMin  CancelAfter = "min"
	CancelAfterHour CancelAfter = "hour"
	CancelAfterDay  CancelAfter = "day"
)

func (*CancelAfter) String

func (CancelAfter *CancelAfter) String() string

String will convert a CancelAfter into a string.

type CancelOpenOrdersOptions

type CancelOpenOrdersOptions struct {
	ProductID *string `bson:"product_id" json:"product_id" sql:"product_id"`
	ProfileID *string `bson:"profile_id" json:"profile_id" sql:"profile_id"`
}

CancelOpenOrdersOptions are options for API requests.

func (*CancelOpenOrdersOptions) EncodeBody

func (opts *CancelOpenOrdersOptions) EncodeBody() (buf io.Reader, err error)

func (*CancelOpenOrdersOptions) EncodeQuery

func (opts *CancelOpenOrdersOptions) EncodeQuery(req *http.Request)

func (*CancelOpenOrdersOptions) SetProductID

func (opts *CancelOpenOrdersOptions) SetProductID(ProductID string) *CancelOpenOrdersOptions

SetProductID sets the ProductID field on CancelOpenOrdersOptions.

func (*CancelOpenOrdersOptions) SetProfileID

func (opts *CancelOpenOrdersOptions) SetProfileID(ProfileID string) *CancelOpenOrdersOptions

SetProfileID sets the ProfileID field on CancelOpenOrdersOptions.

type Candle

type Candle struct {
	// PriceClose is the closing price (last trade) in the bucket interval.
	PriceClose float64 `bson:"price_close" json:"price_close" sql:"price_close"`

	// PriceHigh is the highest price during the bucket interval.
	PriceHigh float64 `bson:"price_high" json:"price_high" sql:"price_high"`

	// PriceLow is the lowest price during the bucket interval.
	PriceLow float64 `bson:"price_low" json:"price_low" sql:"price_low"`

	// PriceOpen is the opening price (first trade) in the bucket interval.
	PriceOpen float64 `bson:"price_open" json:"price_open" sql:"price_open"`

	// ProductID is the productID for the candle, e.g. BTC-ETH. This is not through the Coinbase Pro web API and is inteded
	// for use in data layers and business logic.
	ProductID string `bson:"product_id" json:"product_id" sql:"product_id"`

	// Unix is the bucket start time as an int64 Unix value.
	Unix int64 `bson:"unix" json:"unix" sql:"unix"`

	// Volumes is the volume of trading activity during the bucket interval.
	Volume float64 `bson:"volume" json:"volume" sql:"volume"`
}

Candle represents the historic rate for a product at a point in time.

type Candles

type Candles []*Candle

Candles are the historic rates for a product. Rates are returned in grouped buckets. Candle schema is of the form `[timestamp, price_low, price_high, price_open, price_close]`

func (*Candles) UnmarshalJSON

func (candles *Candles) UnmarshalJSON(bytes []byte) error

UnmarshalJSON will deserialize bytes into a Candles model

type CandlesOptions

type CandlesOptions struct {
	// End is a timestamp for ending range of aggregations.
	End *string `bson:"end" json:"end" sql:"end"`

	// Granularity is one of the following values: {60, 300, 900, 3600, 21600, 86400}. Otherwise, your request will be
	// rejected. These values correspond to timeslices representing one minute, five minutes, fifteen minutes, one hour, six
	// hours, and one day, respectively.
	Granularity *Granularity `bson:"granularity" json:"granularity" sql:"granularity"`

	// Start is a timestamp for starting range of aggregations.
	Start *string `bson:"start" json:"start" sql:"start"`
}

CandlesOptions are options for API requests.

func (*CandlesOptions) EncodeBody

func (opts *CandlesOptions) EncodeBody() (buf io.Reader, err error)

func (*CandlesOptions) EncodeQuery

func (opts *CandlesOptions) EncodeQuery(req *http.Request)

func (*CandlesOptions) SetEnd

func (opts *CandlesOptions) SetEnd(End string) *CandlesOptions

SetEnd sets the End field on CandlesOptions. End is a timestamp for ending range of aggregations.

func (*CandlesOptions) SetGranularity

func (opts *CandlesOptions) SetGranularity(Granularity Granularity) *CandlesOptions

SetGranularity sets the Granularity field on CandlesOptions. Granularity is one of the following values: {60, 300, 900, 3600, 21600, 86400}. Otherwise, your request will be rejected. These values correspond to timeslices representing one minute, five minutes, fifteen minutes, one hour, six hours, and one day, respectively.

func (*CandlesOptions) SetStart

func (opts *CandlesOptions) SetStart(Start string) *CandlesOptions

SetStart sets the Start field on CandlesOptions. Start is a timestamp for starting range of aggregations.

type Client

type Client struct{ http.Client }

Client is a wrapper for http.Client.

func NewClient

func NewClient(_ context.Context, roundtripper transport.T) (*Client, error)

NewClient will return a new HTTP client to interface with the Coinbase Pro API.

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("A Coinbase Pro client: %v", client)
}
Output:

func (*Client) Account

func (c *Client) Account(accountId string) (m *Account, _ error)

Account will return data for a single account. Use this endpoint when you know the account_id. API key must belong to the same profile as the account.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccount

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get the account ID to look up.
	accountID := os.Getenv("CB_PRO_ACCOUNT_ID")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	account, err := client.Account(accountID)
	if err != nil {
		log.Fatalf("Error fetching account: %v", err)
	}
	fmt.Printf("account: %+v\n", account)
}
Output:

func (*Client) AccountHolds

func (c *Client) AccountHolds(accountId string, opts *AccountHoldsOptions) (m []*AccountHold, _ error)

AccountHolds will return the holds of an account that belong to the same profile as the API key. Holds are placed on an account for any active orders or pending withdraw requests. As an order is filled, the hold amount is updated. If an order is canceled, any remaining hold is removed. For withdrawals, the hold is removed after it is completed.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccountholds

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get the account ID to look up.
	accountID := os.Getenv("CB_PRO_ACCOUNT_ID")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	// Since the order above will forever be in an "active" status, we should
	// have a hold value waiting for us.
	holds, err := client.AccountHolds(accountID, new(coinbasepro.AccountHoldsOptions).
		SetLimit(1).
		SetBefore("2010-01-01").
		SetAfter("2080-01-01"))
	if err != nil {
		log.Fatalf("Error fetching holds: %v", err)
	}
	fmt.Printf("holds: %+v\n", holds)
}
Output:

func (*Client) AccountLedger

func (c *Client) AccountLedger(accountId string, opts *AccountLedgerOptions) (m []*AccountLedger, _ error)

AccountLedger returns ledger activity for an account. This includes anything that would affect the accounts balance - transfers, trades, fees, etc. This endpoint requires either the "view" or "trade" permission.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccountledger

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get the account ID and profile ID for request.
	accountID := os.Getenv("CB_PRO_ACCOUNT_ID")
	profileID := os.Getenv("CB_PRO_PROFILE_ID")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	ledger, err := client.AccountLedger(accountID, new(coinbasepro.AccountLedgerOptions).
		SetStartDate("2010-01-01").
		SetEndDate("2080-01-01").
		SetAfter(1526365354).
		SetLimit(1).
		SetProfileID(profileID))
	if err != nil {
		log.Fatalf("Error fetching ledger: %v", err)
	}
	fmt.Printf("ledger: %+v\n", ledger)
}
Output:

func (*Client) AccountTransfers

func (c *Client) AccountTransfers(accountId string, opts *AccountTransfersOptions) (m []*Transfer, _ error)

AccountTransfers returns past withdrawals and deposits for an account.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccounttransfers

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get the account ID for request.
	accountID := os.Getenv("CB_PRO_ACCOUNT_ID")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	// Get the resulting Account Transfers.
	transfers, err := client.AccountTransfers(accountID, new(coinbasepro.AccountTransfersOptions).
		SetBefore("2010-01-01").
		SetAfter("2080-01-01").
		SetType(coinbasepro.TransferMethodDeposit).
		SetLimit(1))
	if err != nil {
		log.Fatalf("Error fetching account transfers: %v", err)
	}
	fmt.Printf("account transfers: %+v\n", transfers)
}
Output:

func (*Client) Accounts

func (c *Client) Accounts() (m []*Account, _ error)

Accounts will return a list of trading accounts from the profile of the API key.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccounts

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	accounts, err := client.Accounts()
	if err != nil {
		log.Fatalf("Error fetching accounts: %v", err)
	}
	fmt.Printf("accounts: %+v\n", accounts)
}
Output:

func (*Client) Book

func (c *Client) Book(productId string, opts *BookOptions) (m *Book, _ error)

Book will return a list of open orders for a product. The amount of detail shown can be customized with the level parameter.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproductbook

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	book, err := client.Book("BTC-USD", new(coinbasepro.BookOptions).SetLevel(1))
	if err != nil {
		log.Fatalf("Error fetching book: %v", err)
	}
	fmt.Printf("book: %+v\n", book)
}
Output:

func (*Client) CancelOpenOrders

func (c *Client) CancelOpenOrders(opts *CancelOpenOrdersOptions) (m []*string, _ error)

CancelOpenOrders will try with best effort to cancel all open orders. This may require you to make the request multiple times until all of the open orders are deleted.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_deleteorders

Example
package main

import (
	"context"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get the profile ID for request.
	profileID := os.Getenv("CB_PRO_PROFILE_ID")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	// Cancel the order by simply cancelling all BTC-USD orders for some profile ID.
	_, err = client.CancelOpenOrders(new(coinbasepro.CancelOpenOrdersOptions).
		SetProductID("BTC-USD").
		SetProfileID(profileID))
	if err != nil {
		log.Fatalf("Error canceling open orders: %v", err)
	}
}
Output:

func (*Client) CancelOrder

func (c *Client) CancelOrder(orderId string) (m string, _ error)

CancelOrder will cancel a single open order by order id.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_deleteorder

Example
package main

import (
	"context"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get an orderID for cancellation
	orderID := os.Getenv("CB_PRO_ORDER_ID_FOR_CANCELLATION")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	// Cancel the order by using the order's ID.
	_, err = client.CancelOrder(orderID)
	if err != nil {
		log.Fatalf("Error canceling order: %v", err)
	}
}
Output:

func (*Client) Candles

func (c *Client) Candles(productId string, opts *CandlesOptions) (m *Candles, _ error)

Candles will return historic rates for a product.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproductcandles

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"
	"time"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	startTimestamp := time.Date(2018, 11, 9, 17, 11, 8, 0, time.UTC).Format(time.RFC3339)
	endTimestamp := time.Date(2018, 11, 9, 18, 11, 8, 0, time.UTC).Format(time.RFC3339)

	candles, err := client.Candles("BTC-USD", new(coinbasepro.CandlesOptions).
		SetStart(startTimestamp).
		SetEnd(endTimestamp).
		SetGranularity(coinbasepro.Granularity60))
	if err != nil {
		log.Fatalf("Error canceling order: %v", err)
	}
	fmt.Printf("candle example: %+v\n", (*candles)[0])
}
Output:

func (*Client) CoinbaseAccountDeposit

func (c *Client) CoinbaseAccountDeposit(opts *CoinbaseAccountDepositOptions) (m *Deposit, _ error)

CoinbaseAccountDeposit funds from a www.coinbase.com wallet to the specified profile_id.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postdepositcoinbaseaccount

Example
package main

import (
	"context"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a profile ID to deposit into and a wallet ID to withdraw from.
	accountCurrency := os.Getenv("CB_PRO_ACCOUNT_CURRENCY")
	profileID := os.Getenv("CB_PRO_PROFILE_ID")
	walletID := os.Getenv("CB_PRO_WALLET_ID")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	// Make the deposit.
	_, err = client.CoinbaseAccountDeposit(new(coinbasepro.CoinbaseAccountDepositOptions).
		SetProfileID(profileID).
		SetCoinbaseAccountID(walletID).
		SetAmount(1).
		SetCurrency(accountCurrency))
	if err != nil {
		log.Fatalf("Error making deposit: %v", err)
	}
}
Output:

func (*Client) CoinbaseAccountWithdrawal

func (c *Client) CoinbaseAccountWithdrawal(opts *CoinbaseAccountWithdrawalOptions) (m *Withdrawal, _ error)

AccountWithdraws funds from the specified profile_id to a www.coinbase.com wallet. Withdraw funds to a coinbase account. You can move funds between your Coinbase accounts and your Coinbase Exchange trading accounts within your daily limits. Moving funds between Coinbase and Coinbase Exchange is instant and free. See the Coinbase Accounts section for retrieving your Coinbase accounts. This endpoint requires the "transfer" permission.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postwithdrawcoinbaseaccount

Example
package main

import (
	"context"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a profile ID to withdraw from and a wallet ID to deposit int.
	accountCurrency := os.Getenv("CB_PRO_ACCOUNT_CURRENCY")
	profileID := os.Getenv("CB_PRO_PROFILE_ID")
	walletID := os.Getenv("CB_PRO_WALLET_ID")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	// Withdraw the deposit.
	_, err = client.CoinbaseAccountWithdrawal(new(coinbasepro.CoinbaseAccountWithdrawalOptions).
		SetProfileID(profileID).
		SetCoinbaseAccountID(walletID).
		SetAmount(1).
		SetCurrency(accountCurrency))
	if err != nil {
		log.Fatalf("Error making withdrawal: %v", err)
	}
}
Output:

func (*Client) ConvertCurrency

func (c *Client) ConvertCurrency(opts *ConvertCurrencyOptions) (m *CurrencyConversion, _ error)

ConvertCurrency converts funds from from currency to to currency. Funds are converted on the from account in the profile_id profile. This endpoint requires the "trade" permission. A successful conversion will be assigned a conversion id. The corresponding ledger entries for a conversion will reference this conversion id

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postconversion

Example
package main

import (
	"context"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a profile ID for the request.
	profileID := os.Getenv("CB_PRO_PROFILE_ID")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	// Convert the USD into USDC.
	_, err = client.ConvertCurrency(new(coinbasepro.ConvertCurrencyOptions).
		SetAmount(1).
		SetFrom("USD").
		SetTo("USDC").
		SetProfileID(profileID))
	if err != nil {
		log.Fatalf("Error converting currency: %v", err)
	}
}
Output:

func (*Client) CreateOrder

func (c *Client) CreateOrder(opts *CreateOrderOptions) (m *CreateOrder, _ error)

CreateOrder will create a new an order. You can place two types of orders: limit and market. Orders can only be placed if your account has sufficient funds. Once an order is placed, your account funds will be put on hold for the duration of the order. How much and which funds are put on hold depends on the order type and parameters specified.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postorders

Example
package main

import (
	"context"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a profile ID for the request.
	profileID := os.Getenv("CB_PRO_PROFILE_ID")
	productID := os.Getenv("CB_PRO_PRODUCT_ID")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	order, err := client.CreateOrder(new(coinbasepro.CreateOrderOptions).
		SetProfileID(profileID).
		SetType(coinbasepro.OrderTypeLimit).
		SetSide(coinbasepro.SideSell).
		SetSTP(coinbasepro.STPDc).
		SetStop(coinbasepro.StopLoss).
		SetTimeInForce(coinbasepro.TimeInForceGTC).
		SetCancelAfter(coinbasepro.CancelAfterMin).
		SetProductID(productID).
		SetStopPrice(1.0).
		SetSize(1.0).
		SetPrice(1.0))
	if err != nil {
		log.Fatal(err)
	}

	// Cancel the order since it will almost definitely never get filled.
	if _, err := client.CancelOrder(order.ID); err != nil {
		log.Fatal(err)
	}
}
Output:

func (*Client) CreateProfile

func (c *Client) CreateProfile(opts *CreateProfileOptions) (m *Profile, _ error)

CreateProfile will create a new profile. Will fail if no name is provided or if user already has max number of profiles.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postprofile

Example
package main

import ()

func main() {
	// TODO: Figure out why we get a 403 HTTP Status
}
Output:

func (*Client) CreateProfileTransfer

func (c *Client) CreateProfileTransfer(opts *CreateProfileTransferOptions) error

CreateProfileTransfer will transfer an amount of currency from one profile to another. This endpoint requires the "transfer" permission.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postprofiletransfer

Example
package main

import ()

func main() {
	// TODO: Figure out why we get a 403 HTTP Status
}
Output:

func (*Client) CreateReport

func (c *Client) CreateReport(opts *CreateReportOptions) (m *CreateReport, _ error)

CreateReport generates a report. Reports are either for past account history or past fills on either all accounts or one product's account.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postreports

Example
package main

import (
	"context"
	"log"
	"os"
	"time"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a profile ID for the request.
	profileID := os.Getenv("CB_PRO_PROFILE_ID")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	startTimestamp := time.Date(2018, 11, 9, 17, 11, 8, 0, time.UTC).Format(time.RFC3339)
	endTimestamp := time.Date(2018, 11, 9, 18, 11, 8, 0, time.UTC).Format(time.RFC3339)

	_, err = client.CreateReport(new(coinbasepro.CreateReportOptions).
		SetType(coinbasepro.ReportTypeFills).
		SetFormat(coinbasepro.FileFormatPdf).
		SetProfileID(profileID).
		SetProductID("BTC-USD").
		SetStartDate(startTimestamp).
		SetEndDate(endTimestamp))
	if err != nil {
		log.Fatalf("Error creating report: %v", err)
	}
}
Output:

func (*Client) CryptoWithdrawal

func (c *Client) CryptoWithdrawal(opts *CryptoWithdrawalOptions) (m *Withdrawal, _ error)

CryptoWithdrawal funds from the specified profile_id to an external crypto address. This endpoint requires the "transfer" permission. API key must belong to default profile.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postwithdrawcrypto

Example
package main

import (
	"context"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a wallet ID for the request.
	walletID := os.Getenv("CB_PRO_WALLET_ID")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	// Get an address for the target wallet.
	address, _ := client.GenerateCryptoAddress(walletID)

	// Withdraw the funds using the generated USDC wallet address.
	_, err = client.CryptoWithdrawal(new(coinbasepro.CryptoWithdrawalOptions).
		SetCryptoAddress(address.Address).
		SetAmount(1).
		SetCurrency("USDC"))
	if err != nil {
		log.Fatalf("Error withdrawing crypto: %v", err)
	}
}
Output:

func (*Client) Currencies

func (c *Client) Currencies() (m []*Currency, _ error)

Currencies returns a list of all known currencies. Note: Not all currencies may be currently in use for trading.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getcurrencies

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	currencies, err := client.Currencies()
	if err != nil {
		log.Fatalf("Error listing currencies: %v", err)
	}
	fmt.Printf("currencies: %+v\n", currencies)
}
Output:

func (*Client) Currency

func (c *Client) Currency(currencyId string) (m *Currency, _ error)

Currency returns a single currency by id.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getcurrency

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a valid currency.
	accountCurrency := os.Getenv("CB_PRO_ACCOUNT_CURRENCY")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	currency, err := client.Currency(accountCurrency)
	if err != nil {
		log.Fatalf("Error fetching currency by ID: %v", err)
	}
	fmt.Printf("currency: %+v\n", currency)
}
Output:

func (*Client) CurrencyConversion

func (c *Client) CurrencyConversion(conversionId string, opts *CurrencyConversionOptions) (m *CurrencyConversion, _ error)

CurrencyConversion returns the currency conversion by conversion id (i.e. USD -> USDC).

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getconversion

func (*Client) DeleteProfile

func (c *Client) DeleteProfile(profileId string, opts *DeleteProfileOptions) error

DeleteProfile deletes the profile specified by profile_id and transfers all funds to the profile specified by to. Fails if there are any open orders on the profile to be deleted.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_putprofiledeactivate

Example
package main

import ()

func main() {
	// TODO: Figure out why we get a 403 HTTP Status
}
Output:

func (*Client) ExchangeLimits

func (c *Client) ExchangeLimits(userId string) (m *ExchangeLimits, _ error)

ExchangeLimits returns exchange limits information for a single user.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getuserexchangelimits

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a valid User ID from the account's profile.
	userID := os.Getenv("CB_PRO_USER_ID")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	exchangeLimits, err := client.ExchangeLimits(userID)
	if err != nil {
		log.Fatalf("Error fetching exchange limits: %v", err)
	}
	fmt.Printf("exchange limits: %+v\n", exchangeLimits)
}
Output:

func (*Client) Fees

func (c *Client) Fees() (m *Fees, _ error)

Fees returns fees rates and 30 days trailing volume.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getfees

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	fees, err := client.Fees()
	if err != nil {
		log.Fatalf("Error fetching fees: %v", err)
	}
	fmt.Printf("fees: %+v\n", fees)
}
Output:

func (*Client) Fills

func (c *Client) Fills(opts *FillsOptions) (m []*Fill, _ error)

Fills returns a list of fills. A fill is a partial or complete match on a specific order.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getfills

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a profile ID for the request.
	profileID := os.Getenv("CB_PRO_PROFILE_ID")
	productID := os.Getenv("CB_PRO_PRODUCT_ID")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	fills, err := client.Fills(new(coinbasepro.FillsOptions).
		SetAfter(1526365354).
		SetBefore(1652574195).
		SetLimit(1).
		SetProductID(productID).
		SetProfileID(profileID))
	if err != nil {
		log.Fatalf("Error fetching fills: %v", err)
	}
	fmt.Printf("fills: %+v\n", fills)
}
Output:

func (*Client) GenerateCryptoAddress

func (c *Client) GenerateCryptoAddress(accountId string) (m *CryptoAddress, _ error)

GenerateCryptoAddress will create a one-time crypto address for depositing crypto, using a wallet account id. This endpoint requires the "transfer" permission. API key must belong to default profile.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postcoinbaseaccountaddresses

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a wallet ID for the request.
	walletID := os.Getenv("CB_PRO_WALLET_ID")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	address, err := client.GenerateCryptoAddress(walletID)
	if err != nil {
		log.Fatalf("Error fetching address: %v", err)
	}
	fmt.Printf("USD wallet address: %+v\n", address)
}
Output:

func (*Client) Order

func (c *Client) Order(orderId string) (m *Order, _ error)

Order returns a single order by id.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getorder

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	// Lookup the order.
	order, _ := client.Order("your-order-id")
	fmt.Printf("order: %+v\n", order)
}
Output:

func (*Client) Orders

func (c *Client) Orders(opts *OrdersOptions) (m []*Order, _ error)

Orders will return your current open orders. Only open or un-settled orders are returned by default. As soon as an order is no longer open and settled, it will no longer appear in the default request. Open orders may change state between the request and the response depending on market conditions.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getorders

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"
	"time"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a profile ID for the request.
	profileID := os.Getenv("CB_PRO_PROFILE_ID")
	productID := os.Getenv("CB_PRO_PRODUCT_ID")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	startTimestamp := time.Date(2018, 11, 9, 17, 11, 8, 0, time.UTC).Format(time.RFC3339)
	endTimestamp := time.Date(2025, 11, 9, 18, 11, 8, 0, time.UTC).Format(time.RFC3339)

	// Lookup the order.
	orders, err := client.Orders(new(coinbasepro.OrdersOptions).
		SetAfter("2023-01-01").
		SetBefore("2010-01-01").
		SetStartDate(startTimestamp).
		SetEndDate(endTimestamp).
		SetLimit(1).
		SetProductID(productID).
		SetProfileID(profileID))
	if err != nil {
		log.Fatalf("Error fetching order: %v", err)
	}
	fmt.Printf("orders: %+v\n", orders)
}
Output:

func (*Client) PaymentMethodDeposit

func (c *Client) PaymentMethodDeposit(opts *PaymentMethodDepositOptions) (m *Deposit, _ error)

PaymentMethodDeposit will fund from a linked external payment method to the specified profile_id.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postdepositpaymentmethod

Example
package main

import ()

func main() {
	// TODO: Figure out why we get a 403 HTTP Status
}
Output:

func (*Client) PaymentMethodWithdrawal

func (c *Client) PaymentMethodWithdrawal(opts *PaymentMethodWithdrawalOptions) (m *Withdrawal, _ error)

PaymentMethodWithdrawal will fund from the specified profile_id to a linked external payment method. This endpoint requires the "transfer" permission. API key is restricted to the default profile.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postwithdrawpaymentmethod

Example
package main

import ()

func main() {
	// TODO: Figure out why we get a 403 HTTP Status
}
Output:

func (*Client) PaymentMethods

func (c *Client) PaymentMethods() (m []*PaymentMethod, _ error)

PaymentMethods returns a list of the user's linked payment methods.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getpaymentmethods

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	paymentMethods, err := client.PaymentMethods()
	if err != nil {
		log.Fatalf("Error fetching payment methods: %v", err)
	}
	fmt.Printf("payment methods: %+v\n", paymentMethods)
}
Output:

func (*Client) Product

func (c *Client) Product(productId string) (m *Product, _ error)

Product will return information on a single product.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproduct

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	product, err := client.Product("BTC-USD")
	if err != nil {
		log.Fatalf("Error fetching product: %v", err)
	}
	fmt.Printf("product: %+v\n", product)
}
Output:

func (*Client) ProductStats

func (c *Client) ProductStats(productId string) (m *ProductStats, _ error)

ProductStats will return 30day and 24hour stats for a product.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproductstats

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	stats, err := client.ProductStats("BTC-USD")
	if err != nil {
		log.Fatalf("Error fetching stats: %v", err)
	}
	fmt.Printf("stats: %+v\n", stats)
}
Output:

func (*Client) ProductTicker

func (c *Client) ProductTicker(productId string) (m *ProductTicker, _ error)

ProductTicker will return snapshot information about the last trade (tick), best bid/ask and 24h volume.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproductticker

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	ticker, err := client.ProductTicker("BTC-USD")
	if err != nil {
		log.Fatalf("Error fetching ticker: %v", err)
	}
	fmt.Printf("ticker: %+v\n", ticker)
}
Output:

func (*Client) Products

func (c *Client) Products(opts *ProductsOptions) (m []*Product, _ error)

Products will return a list of available currency pairs for trading.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproducts

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	products, err := client.Products(new(coinbasepro.ProductsOptions).SetType("USD-BTC"))
	if err != nil {
		log.Fatalf("Error fetching products: %v", err)
	}
	fmt.Printf("products: %+v\n", products)
}
Output:

func (*Client) Profile

func (c *Client) Profile(profileId string, opts *ProfileOptions) (m *Profile, _ error)

Profile returns information for a single profile. Use this endpoint when you know the profile_id. This endpoint requires the "view" permission and is accessible by any profile's API key.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getprofile

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a profile ID for the request.
	profileID := os.Getenv("CB_PRO_PROFILE_ID")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	profile, err := client.Profile(profileID, new(coinbasepro.ProfileOptions).SetActive(true))
	if err != nil {
		log.Fatalf("Error fetching profile: %v", err)
	}
	fmt.Printf("profile: %+v\n", profile)
}
Output:

func (*Client) Profiles

func (c *Client) Profiles(opts *ProfilesOptions) (m []*Profile, _ error)

Profiles returns a list of all of the current user's profiles.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getprofiles

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	profiles, err := client.Profiles(new(coinbasepro.ProfilesOptions).SetActive(true))
	if err != nil {
		log.Fatalf("Error fetching profiles: %v", err)
	}
	fmt.Printf("profiles: %+v\n", profiles)
}
Output:

func (*Client) RenameProfile

func (c *Client) RenameProfile(profileId string, opts *RenameProfileOptions) (m *Profile, _ error)

RenameProfile will rename a profile. Names 'default' and 'margin' are reserved.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_putprofile

Example
package main

import ()

func main() {
	// TODO: Figure out why we get a 403 HTTP Status
}
Output:

func (*Client) Report

func (c *Client) Report(reportId string) (m *Report, _ error)

Report will return a specific report by report_id.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getreport

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	report, _ := client.Report("your-report-id")
	fmt.Printf("report: %+v\n", report)
}
Output:

func (*Client) Reports

func (c *Client) Reports(opts *ReportsOptions) (m []*Report, _ error)

Reports returns a list of past fills/account reports.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getreports

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"
	"time"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a profile ID for the request.
	profileID := os.Getenv("CB_PRO_PROFILE_ID")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	afterTimestamp := time.Date(2018, 11, 9, 17, 11, 8, 0, time.UTC).Format(time.RFC3339)

	reports, err := client.Reports(new(coinbasepro.ReportsOptions).
		SetAfter(afterTimestamp).
		SetIgnoredExpired(true).
		SetLimit(1).
		SetPortfolioID(profileID).
		SetType(coinbasepro.ReportTypeAccounts))
	if err != nil {
		log.Fatalf("Error fetching reports: %v", err)
	}
	fmt.Printf("reports: %+v\n", reports)
}
Output:

func (*Client) SignedPrices

func (c *Client) SignedPrices() (m *Oracle, _ error)

SignedPrices returns cryptographically signed prices ready to be posted on-chain using Compound's Open Oracle smart contract.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getcoinbasepriceoracle

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	prices, err := client.SignedPrices()
	if err != nil {
		log.Fatalf("Error fetching prices: %v", err)
	}
	fmt.Printf("prices: %+v\n", prices)
}
Output:

func (*Client) Trades

func (c *Client) Trades(productId string, opts *TradesOptions) (m []*Trade, _ error)

Trades retruns a list the latest trades for a product.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproducttrades

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	trades, err := client.Trades("BTC-USD", new(coinbasepro.TradesOptions).
		SetAfter(1526365354).
		SetBefore(1652574165).
		SetLimit(1))
	if err != nil {
		log.Fatalf("Error fetching prices: %v", err)
	}
	fmt.Printf("prices: %+v\n", trades)
}
Output:

func (*Client) Transfer

func (c *Client) Transfer(transferId string) (m *Transfer, _ error)

AccountTransfer returns information on a single transfer.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_gettransfer

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	// Lookup the deposit.
	transfer, _ := client.Transfer("some-transfer-id")
	fmt.Printf("transfer: %+v\n", transfer)
}
Output:

func (*Client) Transfers

func (c *Client) Transfers() (m []*Transfer, _ error)

Transfers is a list of in-progress and completed transfers of funds in/out of any of the user's accounts.

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_gettransfers

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	transfers, err := client.Transfers()
	if err != nil {
		log.Fatalf("Error fetching transfers: %v", err)
	}
	fmt.Printf("transfers: %+v\n", transfers)
}
Output:

func (*Client) Wallets

func (c *Client) Wallets() (m []*Wallet, _ error)

Wallets will return all the user's available Coinbase wallets (These are the wallets/accounts that are used for buying and selling on www.coinbase.com)

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getcoinbaseaccounts

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	wallets, err := client.Wallets()
	if err != nil {
		log.Fatalf("Error fetching wallets: %v", err)
	}
	fmt.Printf("wallets: %+v\n", wallets)
}
Output:

func (*Client) WithdrawalFeeEstimate

func (c *Client) WithdrawalFeeEstimate(opts *WithdrawalFeeEstimateOptions) (m *WithdrawalFeeEstimate, _ error)

WithdrawalFeeEstimate will return the fee estimate for the crypto withdrawal to crypto address

source: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getwithdrawfeeestimate

Example
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/transport"
)

func main() {
	// Read credentials from environment variables.
	url := os.Getenv("CB_PRO_URL")
	passphrase := os.Getenv("CB_PRO_ACCESS_PASSPHRASE")
	key := os.Getenv("CB_PRO_ACCESS_KEY")
	secret := os.Getenv("CB_PRO_SECRET")

	// Get a USD Wallet ID for the request.
	walletID := os.Getenv("CB_PRO_USDC_WALLET_ID")

	// Get a new client using an API Key for authentication.
	client, err := coinbasepro.NewClient(context.TODO(), transport.NewAPIKey().
		SetKey(key).
		SetPassphrase(passphrase).
		SetSecret(secret).
		SetURL(url))
	if err != nil {
		log.Fatalf("Error creating client: %v", err)
	}

	address, err := client.GenerateCryptoAddress(walletID)
	if err != nil {
		log.Fatalf("Error generating crypto address: %v", err)
	}

	estimates, err := client.WithdrawalFeeEstimate(new(coinbasepro.WithdrawalFeeEstimateOptions).
		SetCryptoAddress(address.Address).
		SetCurrency("USDC"))
	if err != nil {
		log.Fatalf("Error fetching estimates: %v", err)
	}
	fmt.Printf("estimates: %+v\n", estimates)
}
Output:

type CoinbaseAccountDepositOptions

type CoinbaseAccountDepositOptions struct {
	Amount            float64 `bson:"amount" json:"amount" sql:"amount"`
	CoinbaseAccountID string  `bson:"coinbase_account_id" json:"coinbase_account_id" sql:"coinbase_account_id"`
	Currency          string  `bson:"currency" json:"currency" sql:"currency"`
	ProfileID         *string `bson:"profile_id" json:"profile_id" sql:"profile_id"`
}

CoinbaseAccountDepositOptions are options for API requests.

func (*CoinbaseAccountDepositOptions) EncodeBody

func (opts *CoinbaseAccountDepositOptions) EncodeBody() (buf io.Reader, err error)

func (*CoinbaseAccountDepositOptions) EncodeQuery

func (opts *CoinbaseAccountDepositOptions) EncodeQuery(req *http.Request)

func (*CoinbaseAccountDepositOptions) SetAmount

SetAmount sets the Amount field on CoinbaseAccountDepositOptions.

func (*CoinbaseAccountDepositOptions) SetCoinbaseAccountID

func (opts *CoinbaseAccountDepositOptions) SetCoinbaseAccountID(CoinbaseAccountID string) *CoinbaseAccountDepositOptions

SetCoinbaseAccountID sets the CoinbaseAccountID field on CoinbaseAccountDepositOptions.

func (*CoinbaseAccountDepositOptions) SetCurrency

SetCurrency sets the Currency field on CoinbaseAccountDepositOptions.

func (*CoinbaseAccountDepositOptions) SetProfileID

SetProfileID sets the ProfileID field on CoinbaseAccountDepositOptions.

type CoinbaseAccountWithdrawalOptions

type CoinbaseAccountWithdrawalOptions struct {
	Amount            float64 `bson:"amount" json:"amount" sql:"amount"`
	CoinbaseAccountID string  `bson:"coinbase_account_id" json:"coinbase_account_id" sql:"coinbase_account_id"`
	Currency          string  `bson:"currency" json:"currency" sql:"currency"`
	ProfileID         *string `bson:"profile_id" json:"profile_id" sql:"profile_id"`
}

CoinbaseAccountWithdrawalOptions are options for API requests.

func (*CoinbaseAccountWithdrawalOptions) EncodeBody

func (opts *CoinbaseAccountWithdrawalOptions) EncodeBody() (buf io.Reader, err error)

func (*CoinbaseAccountWithdrawalOptions) EncodeQuery

func (opts *CoinbaseAccountWithdrawalOptions) EncodeQuery(req *http.Request)

func (*CoinbaseAccountWithdrawalOptions) SetAmount

SetAmount sets the Amount field on CoinbaseAccountWithdrawalOptions.

func (*CoinbaseAccountWithdrawalOptions) SetCoinbaseAccountID

func (opts *CoinbaseAccountWithdrawalOptions) SetCoinbaseAccountID(CoinbaseAccountID string) *CoinbaseAccountWithdrawalOptions

SetCoinbaseAccountID sets the CoinbaseAccountID field on CoinbaseAccountWithdrawalOptions.

func (*CoinbaseAccountWithdrawalOptions) SetCurrency

SetCurrency sets the Currency field on CoinbaseAccountWithdrawalOptions.

func (*CoinbaseAccountWithdrawalOptions) SetProfileID

SetProfileID sets the ProfileID field on CoinbaseAccountWithdrawalOptions.

type ConvertCurrencyOptions

type ConvertCurrencyOptions struct {
	Amount    float64 `bson:"amount" json:"amount" sql:"amount"`
	From      string  `bson:"from" json:"from" sql:"from"`
	Nonce     *string `bson:"nonce" json:"nonce" sql:"nonce"`
	ProfileID *string `bson:"profile_id" json:"profile_id" sql:"profile_id"`
	To        string  `bson:"to" json:"to" sql:"to"`
}

ConvertCurrencyOptions are options for API requests.

func (*ConvertCurrencyOptions) EncodeBody

func (opts *ConvertCurrencyOptions) EncodeBody() (buf io.Reader, err error)

func (*ConvertCurrencyOptions) EncodeQuery

func (opts *ConvertCurrencyOptions) EncodeQuery(req *http.Request)

func (*ConvertCurrencyOptions) SetAmount

func (opts *ConvertCurrencyOptions) SetAmount(Amount float64) *ConvertCurrencyOptions

SetAmount sets the Amount field on ConvertCurrencyOptions.

func (*ConvertCurrencyOptions) SetFrom

SetFrom sets the From field on ConvertCurrencyOptions.

func (*ConvertCurrencyOptions) SetNonce

func (opts *ConvertCurrencyOptions) SetNonce(Nonce string) *ConvertCurrencyOptions

SetNonce sets the Nonce field on ConvertCurrencyOptions.

func (*ConvertCurrencyOptions) SetProfileID

func (opts *ConvertCurrencyOptions) SetProfileID(ProfileID string) *ConvertCurrencyOptions

SetProfileID sets the ProfileID field on ConvertCurrencyOptions.

func (*ConvertCurrencyOptions) SetTo

SetTo sets the To field on ConvertCurrencyOptions.

type CreateOrder

type CreateOrder struct {
	CreatedAt     time.Time   `bson:"created_at" json:"created_at" sql:"created_at"`
	DoneAt        time.Time   `bson:"done_at" json:"done_at" sql:"done_at"`
	DoneReason    string      `bson:"done_reason" json:"done_reason" sql:"done_reason"`
	ExpireTime    time.Time   `bson:"expire_time" json:"expire_time" sql:"expire_time"`
	FillFees      string      `bson:"fill_fees" json:"fill_fees" sql:"fill_fees"`
	FilledSize    string      `bson:"filled_size" json:"filled_size" sql:"filled_size"`
	FundingAmount string      `bson:"funding_amount" json:"funding_amount" sql:"funding_amount"`
	Funds         string      `bson:"funds" json:"funds" sql:"funds"`
	ID            string      `bson:"id" json:"id" sql:"id"`
	PostOnly      bool        `bson:"post_only" json:"post_only" sql:"post_only"`
	Price         string      `bson:"price" json:"price" sql:"price"`
	ProductID     string      `bson:"product_id" json:"product_id" sql:"product_id"`
	ProfileID     string      `bson:"profile_id" json:"profile_id" sql:"profile_id"`
	RejectReason  string      `bson:"reject_reason" json:"reject_reason" sql:"reject_reason"`
	Settled       bool        `bson:"settled" json:"settled" sql:"settled"`
	Side          Side        `bson:"side" json:"side" sql:"side"`
	Size          string      `bson:"size" json:"size" sql:"size"`
	SpecificFunds string      `bson:"specific_funds" json:"specific_funds" sql:"specific_funds"`
	Status        string      `bson:"status" json:"status" sql:"status"`
	Stop          Stop        `bson:"stop" json:"stop" sql:"stop"`
	StopPrice     string      `bson:"stop_price" json:"stop_price" sql:"stop_price"`
	TimeInForce   TimeInForce `bson:"time_in_force" json:"time_in_force" sql:"time_in_force"`
	Type          OrderType   `bson:"type" json:"type" sql:"type"`
}

CreateOrder is the server's response for placing a new order.

type CreateOrderOptions

type CreateOrderOptions struct {
	CancelAfter *CancelAfter `bson:"cancel_after" json:"cancel_after" sql:"cancel_after"`
	ClientOid   *string      `bson:"client_oid" json:"client_oid" sql:"client_oid"`
	Funds       *float64     `bson:"funds" json:"funds" sql:"funds"`
	PostOnly    *bool        `bson:"post_only" json:"post_only" sql:"post_only"`
	Price       *float64     `bson:"price" json:"price" sql:"price"`
	ProductID   string       `bson:"product_id" json:"product_id" sql:"product_id"`
	ProfileID   *string      `bson:"profile_id" json:"profile_id" sql:"profile_id"`
	STP         *STP         `bson:"stp" json:"stp" sql:"stp"`
	Side        Side         `bson:"side" json:"side" sql:"side"`
	Size        *float64     `bson:"size" json:"size" sql:"size"`
	Stop        *Stop        `bson:"stop" json:"stop" sql:"stop"`
	StopPrice   *float64     `bson:"stop_price" json:"stop_price" sql:"stop_price"`
	TimeInForce *TimeInForce `bson:"time_in_force" json:"time_in_force" sql:"time_in_force"`
	Type        *OrderType   `bson:"type" json:"type" sql:"type"`
}

CreateOrderOptions are options for API requests.

func (*CreateOrderOptions) EncodeBody

func (opts *CreateOrderOptions) EncodeBody() (buf io.Reader, err error)

func (*CreateOrderOptions) EncodeQuery

func (opts *CreateOrderOptions) EncodeQuery(req *http.Request)

func (*CreateOrderOptions) SetCancelAfter

func (opts *CreateOrderOptions) SetCancelAfter(CancelAfter CancelAfter) *CreateOrderOptions

SetCancelAfter sets the CancelAfter field on CreateOrderOptions.

func (*CreateOrderOptions) SetClientOid

func (opts *CreateOrderOptions) SetClientOid(ClientOid string) *CreateOrderOptions

SetClientOid sets the ClientOid field on CreateOrderOptions.

func (*CreateOrderOptions) SetFunds

func (opts *CreateOrderOptions) SetFunds(Funds float64) *CreateOrderOptions

SetFunds sets the Funds field on CreateOrderOptions.

func (*CreateOrderOptions) SetPostOnly

func (opts *CreateOrderOptions) SetPostOnly(PostOnly bool) *CreateOrderOptions

SetPostOnly sets the PostOnly field on CreateOrderOptions.

func (*CreateOrderOptions) SetPrice

func (opts *CreateOrderOptions) SetPrice(Price float64) *CreateOrderOptions

SetPrice sets the Price field on CreateOrderOptions.

func (*CreateOrderOptions) SetProductID

func (opts *CreateOrderOptions) SetProductID(ProductID string) *CreateOrderOptions

SetProductID sets the ProductID field on CreateOrderOptions.

func (*CreateOrderOptions) SetProfileID

func (opts *CreateOrderOptions) SetProfileID(ProfileID string) *CreateOrderOptions

SetProfileID sets the ProfileID field on CreateOrderOptions.

func (*CreateOrderOptions) SetSTP

func (opts *CreateOrderOptions) SetSTP(STP STP) *CreateOrderOptions

SetSTP sets the STP field on CreateOrderOptions.

func (*CreateOrderOptions) SetSide

func (opts *CreateOrderOptions) SetSide(Side Side) *CreateOrderOptions

SetSide sets the Side field on CreateOrderOptions.

func (*CreateOrderOptions) SetSize

func (opts *CreateOrderOptions) SetSize(Size float64) *CreateOrderOptions

SetSize sets the Size field on CreateOrderOptions.

func (*CreateOrderOptions) SetStop

func (opts *CreateOrderOptions) SetStop(Stop Stop) *CreateOrderOptions

SetStop sets the Stop field on CreateOrderOptions.

func (*CreateOrderOptions) SetStopPrice

func (opts *CreateOrderOptions) SetStopPrice(StopPrice float64) *CreateOrderOptions

SetStopPrice sets the StopPrice field on CreateOrderOptions.

func (*CreateOrderOptions) SetTimeInForce

func (opts *CreateOrderOptions) SetTimeInForce(TimeInForce TimeInForce) *CreateOrderOptions

SetTimeInForce sets the TimeInForce field on CreateOrderOptions.

func (*CreateOrderOptions) SetType

func (opts *CreateOrderOptions) SetType(Type OrderType) *CreateOrderOptions

SetType sets the Type field on CreateOrderOptions.

type CreateProfileOptions

type CreateProfileOptions struct {
	Name *string `bson:"name" json:"name" sql:"name"`
}

CreateProfileOptions are options for API requests.

func (*CreateProfileOptions) EncodeBody

func (opts *CreateProfileOptions) EncodeBody() (buf io.Reader, err error)

func (*CreateProfileOptions) EncodeQuery

func (opts *CreateProfileOptions) EncodeQuery(req *http.Request)

func (*CreateProfileOptions) SetName

func (opts *CreateProfileOptions) SetName(Name string) *CreateProfileOptions

SetName sets the Name field on CreateProfileOptions.

type CreateProfileTransferOptions

type CreateProfileTransferOptions struct {
	Amount   *string `bson:"amount" json:"amount" sql:"amount"`
	Currency *string `bson:"currency" json:"currency" sql:"currency"`
	From     *string `bson:"from" json:"from" sql:"from"`
	To       *string `bson:"to" json:"to" sql:"to"`
}

CreateProfileTransferOptions are options for API requests.

func (*CreateProfileTransferOptions) EncodeBody

func (opts *CreateProfileTransferOptions) EncodeBody() (buf io.Reader, err error)

func (*CreateProfileTransferOptions) EncodeQuery

func (opts *CreateProfileTransferOptions) EncodeQuery(req *http.Request)

func (*CreateProfileTransferOptions) SetAmount

SetAmount sets the Amount field on CreateProfileTransferOptions.

func (*CreateProfileTransferOptions) SetCurrency

SetCurrency sets the Currency field on CreateProfileTransferOptions.

func (*CreateProfileTransferOptions) SetFrom

SetFrom sets the From field on CreateProfileTransferOptions.

func (*CreateProfileTransferOptions) SetTo

SetTo sets the To field on CreateProfileTransferOptions.

type CreateReport

type CreateReport struct {
	ID     string     `bson:"id" json:"id" sql:"id"`
	Status Status     `bson:"status" json:"status" sql:"status"`
	Type   ReportType `bson:"type" json:"type" sql:"type"`
}

CreateReport represents information for a report created through the client.

type CreateReportOptions

type CreateReportOptions struct {
	// Account - required for account-type reports
	AccountID *string `bson:"account_id" json:"account_id" sql:"account_id"`

	// Email to send generated report to
	Email *string `bson:"email" json:"email" sql:"email"`

	// End date for items to be included in report
	EndDate *string `bson:"end_date" json:"end_date" sql:"end_date"`

	// Portfolio - Which portfolio to generate the report for
	ProfileID *string `bson:"profile_id" json:"profile_id" sql:"profile_id"`

	// Product - required for fills-type reports
	ProductID *string `bson:"product_id" json:"product_id" sql:"product_id"`

	// Start date for items to be included in report.
	StartDate *string `bson:"start_date" json:"start_date" sql:"start_date"`

	// required for 1099k-transaction-history-type reports
	Year   *string     `bson:"year" json:"year" sql:"year"`
	Format *FileFormat `bson:"format" json:"format" sql:"format"`
	Type   ReportType  `bson:"type" json:"type" sql:"type"`
}

CreateReportOptions are options for API requests.

func (*CreateReportOptions) EncodeBody

func (opts *CreateReportOptions) EncodeBody() (buf io.Reader, err error)

func (*CreateReportOptions) EncodeQuery

func (opts *CreateReportOptions) EncodeQuery(req *http.Request)

func (*CreateReportOptions) SetAccountID

func (opts *CreateReportOptions) SetAccountID(AccountID string) *CreateReportOptions

SetAccountID sets the AccountID field on CreateReportOptions. Account - required for account-type reports

func (*CreateReportOptions) SetEmail

func (opts *CreateReportOptions) SetEmail(Email string) *CreateReportOptions

SetEmail sets the Email field on CreateReportOptions. Email to send generated report to

func (*CreateReportOptions) SetEndDate

func (opts *CreateReportOptions) SetEndDate(EndDate string) *CreateReportOptions

SetEndDate sets the EndDate field on CreateReportOptions. End date for items to be included in report

func (*CreateReportOptions) SetFormat

func (opts *CreateReportOptions) SetFormat(Format FileFormat) *CreateReportOptions

SetFormat sets the Format field on CreateReportOptions.

func (*CreateReportOptions) SetProductID

func (opts *CreateReportOptions) SetProductID(ProductID string) *CreateReportOptions

SetProductID sets the ProductID field on CreateReportOptions. Product - required for fills-type reports

func (*CreateReportOptions) SetProfileID

func (opts *CreateReportOptions) SetProfileID(ProfileID string) *CreateReportOptions

SetProfileID sets the ProfileID field on CreateReportOptions. Portfolio - Which portfolio to generate the report for

func (*CreateReportOptions) SetStartDate

func (opts *CreateReportOptions) SetStartDate(StartDate string) *CreateReportOptions

SetStartDate sets the StartDate field on CreateReportOptions. Start date for items to be included in report.

func (*CreateReportOptions) SetType

func (opts *CreateReportOptions) SetType(Type ReportType) *CreateReportOptions

SetType sets the Type field on CreateReportOptions.

func (*CreateReportOptions) SetYear

func (opts *CreateReportOptions) SetYear(Year string) *CreateReportOptions

SetYear sets the Year field on CreateReportOptions. required for 1099k-transaction-history-type reports

type CryptoAccount

type CryptoAccount struct {
	ID           string `bson:"id" json:"id" sql:"id"`
	Resource     string `bson:"resource" json:"resource" sql:"resource"`
	ResourcePath string `bson:"resource_path" json:"resource_path" sql:"resource_path"`
}

CryptoAccount references a crypto account that a CoinbasePaymentMethod belongs to

type CryptoAddress

type CryptoAddress struct {
	Address        string                  `bson:"address" json:"address" sql:"address"`
	AddressInfo    CryptoAddressInfo       `bson:"address_info" json:"address_info" sql:"address_info"`
	CallbackURL    string                  `bson:"callback_url" json:"callback_url" sql:"callback_url"`
	CreateAt       time.Time               `bson:"create_at" json:"create_at" sql:"create_at"`
	DepositUri     string                  `bson:"deposit_uri" json:"deposit_uri" sql:"deposit_uri"`
	DestinationTag string                  `bson:"destination_tag" json:"destination_tag" sql:"destination_tag"`
	ID             string                  `bson:"id" json:"id" sql:"id"`
	LegacyAddress  string                  `bson:"legacy_address" json:"legacy_address" sql:"legacy_address"`
	Name           string                  `bson:"name" json:"name" sql:"name"`
	Network        string                  `bson:"network" json:"network" sql:"network"`
	Resource       string                  `bson:"resource" json:"resource" sql:"resource"`
	ResourcePath   string                  `bson:"resource_path" json:"resource_path" sql:"resource_path"`
	UpdatedAt      time.Time               `bson:"updated_at" json:"updated_at" sql:"updated_at"`
	UriScheme      string                  `bson:"uri_scheme" json:"uri_scheme" sql:"uri_scheme"`
	Warnings       []*CryptoAddressWarning `bson:"warnings" json:"warnings" sql:"warnings"`
}

CryptoAddress is used for a one-time crypto address for depositing crypto.

type CryptoAddressInfo

type CryptoAddressInfo struct {
	Address        string `bson:"address" json:"address" sql:"address"`
	DestinationTag string `bson:"destination_tag" json:"destination_tag" sql:"destination_tag"`
}

CryptoAddressInfo holds info for a crypto address

type CryptoAddressWarning

type CryptoAddressWarning struct {
	Details  string `bson:"details" json:"details" sql:"details"`
	ImageURL string `bson:"image_url" json:"image_url" sql:"image_url"`
	Title    string `bson:"title" json:"title" sql:"title"`
}

CryptoAddressWarning is a warning for generating a crypting address

type CryptoWithdrawalOptions

type CryptoWithdrawalOptions struct {
	Amount           float64  `bson:"amount" json:"amount" sql:"amount"`
	CryptoAddress    string   `bson:"crypto_address" json:"crypto_address" sql:"crypto_address"`
	Currency         string   `bson:"currency" json:"currency" sql:"currency"`
	DestinationTag   *string  `bson:"destination_tag" json:"destination_tag" sql:"destination_tag"`
	Fee              *float64 `bson:"fee" json:"fee" sql:"fee"`
	NoDestinationTag *bool    `bson:"no_destination_tag" json:"no_destination_tag" sql:"no_destination_tag"`
	Nonce            *int     `bson:"nonce" json:"nonce" sql:"nonce"`
	ProfileID        *string  `bson:"profile_id" json:"profile_id" sql:"profile_id"`
	TwoFactorCode    *string  `bson:"two_factor_code" json:"two_factor_code" sql:"two_factor_code"`
}

CryptoWithdrawalOptions are options for API requests.

func (*CryptoWithdrawalOptions) EncodeBody

func (opts *CryptoWithdrawalOptions) EncodeBody() (buf io.Reader, err error)

func (*CryptoWithdrawalOptions) EncodeQuery

func (opts *CryptoWithdrawalOptions) EncodeQuery(req *http.Request)

func (*CryptoWithdrawalOptions) SetAmount

func (opts *CryptoWithdrawalOptions) SetAmount(Amount float64) *CryptoWithdrawalOptions

SetAmount sets the Amount field on CryptoWithdrawalOptions.

func (*CryptoWithdrawalOptions) SetCryptoAddress

func (opts *CryptoWithdrawalOptions) SetCryptoAddress(CryptoAddress string) *CryptoWithdrawalOptions

SetCryptoAddress sets the CryptoAddress field on CryptoWithdrawalOptions.

func (*CryptoWithdrawalOptions) SetCurrency

func (opts *CryptoWithdrawalOptions) SetCurrency(Currency string) *CryptoWithdrawalOptions

SetCurrency sets the Currency field on CryptoWithdrawalOptions.

func (*CryptoWithdrawalOptions) SetDestinationTag

func (opts *CryptoWithdrawalOptions) SetDestinationTag(DestinationTag string) *CryptoWithdrawalOptions

SetDestinationTag sets the DestinationTag field on CryptoWithdrawalOptions.

func (*CryptoWithdrawalOptions) SetFee

SetFee sets the Fee field on CryptoWithdrawalOptions.

func (*CryptoWithdrawalOptions) SetNoDestinationTag

func (opts *CryptoWithdrawalOptions) SetNoDestinationTag(NoDestinationTag bool) *CryptoWithdrawalOptions

SetNoDestinationTag sets the NoDestinationTag field on CryptoWithdrawalOptions.

func (*CryptoWithdrawalOptions) SetNonce

func (opts *CryptoWithdrawalOptions) SetNonce(Nonce int) *CryptoWithdrawalOptions

SetNonce sets the Nonce field on CryptoWithdrawalOptions.

func (*CryptoWithdrawalOptions) SetProfileID

func (opts *CryptoWithdrawalOptions) SetProfileID(ProfileID string) *CryptoWithdrawalOptions

SetProfileID sets the ProfileID field on CryptoWithdrawalOptions.

func (*CryptoWithdrawalOptions) SetTwoFactorCode

func (opts *CryptoWithdrawalOptions) SetTwoFactorCode(TwoFactorCode string) *CryptoWithdrawalOptions

SetTwoFactorCode sets the TwoFactorCode field on CryptoWithdrawalOptions.

type Currency

type Currency struct {
	ConvertibleTo []string        `bson:"convertible_to" json:"convertible_to" sql:"convertible_to"`
	Details       CurrencyDetails `bson:"details" json:"details" sql:"details"`
	ID            string          `bson:"id" json:"id" sql:"id"`
	MaxPrecision  string          `bson:"max_precision" json:"max_precision" sql:"max_precision"`
	Message       string          `bson:"message" json:"message" sql:"message"`
	MinSize       string          `bson:"min_size" json:"min_size" sql:"min_size"`
	Name          string          `bson:"name" json:"name" sql:"name"`
	Status        string          `bson:"status" json:"status" sql:"status"`
}

Currency is a currency that coinbase knows about. Not al currencies may be currently in use for trading.

type CurrencyConversion

type CurrencyConversion struct {
	Amount        string `bson:"amount" json:"amount" sql:"amount"`
	From          string `bson:"from" json:"from" sql:"from"`
	FromAccountID string `bson:"from_account_id" json:"from_account_id" sql:"from_account_id"`
	ID            string `bson:"id" json:"id" sql:"id"`
	To            string `bson:"to" json:"to" sql:"to"`
	ToAccountID   string `bson:"to_account_id" json:"to_account_id" sql:"to_account_id"`
}

CurrencyConversion is the response that converts funds from from currency to to currency. Funds are converted on the from account in the profile_id profile.

type CurrencyConversionOptions

type CurrencyConversionOptions struct {
	ProfileID *string `bson:"profile_id" json:"profile_id" sql:"profile_id"`
}

CurrencyConversionOptions are options for API requests.

func (*CurrencyConversionOptions) EncodeBody

func (opts *CurrencyConversionOptions) EncodeBody() (buf io.Reader, err error)

func (*CurrencyConversionOptions) EncodeQuery

func (opts *CurrencyConversionOptions) EncodeQuery(req *http.Request)

func (*CurrencyConversionOptions) SetProfileID

func (opts *CurrencyConversionOptions) SetProfileID(ProfileID string) *CurrencyConversionOptions

SetProfileID sets the ProfileID field on CurrencyConversionOptions.

type CurrencyDetails

type CurrencyDetails struct {
	CryptoAddressLink     string   `bson:"crypto_address_link" json:"crypto_address_link" sql:"crypto_address_link"`
	CryptoTransactionLink string   `bson:"crypto_transaction_link" json:"crypto_transaction_link" sql:"crypto_transaction_link"`
	DisplayName           string   `bson:"display_name" json:"display_name" sql:"display_name"`
	GroupTypes            []string `bson:"group_types" json:"group_types" sql:"group_types"`
	MaxWithdrawalAmount   float64  `bson:"max_withdrawal_amount" json:"max_withdrawal_amount" sql:"max_withdrawal_amount"`
	MinWithdrawalAmount   float64  `bson:"min_withdrawal_amount" json:"min_withdrawal_amount" sql:"min_withdrawal_amount"`
	NetworkConfirmations  int      `bson:"network_confirmations" json:"network_confirmations" sql:"network_confirmations"`
	ProcessingTimeSeconds float64  `bson:"processing_time_seconds" json:"processing_time_seconds" sql:"processing_time_seconds"`
	PushPaymentMethods    []string `bson:"push_payment_methods" json:"push_payment_methods" sql:"push_payment_methods"`
	SortOrder             int      `bson:"sort_order" json:"sort_order" sql:"sort_order"`
	Symbol                string   `bson:"symbol" json:"symbol" sql:"symbol"`
	Type                  string   `bson:"type" json:"type" sql:"type"`
}

CurrencyDetails are the details for a currency that coinbase knows about

type CurrencyTransferLimit

type CurrencyTransferLimit struct {
	Max       float64 `bson:"max" json:"max" sql:"max"`
	Remaining float64 `bson:"remaining" json:"remaining" sql:"remaining"`
}

CurrencyTransferLimit encapsulates ACH data for a currency via Max/Remaining amounts.

type CurrencyTransferLimits

type CurrencyTransferLimits map[string]CurrencyTransferLimit

CurrencyTransferLimits encapsulates ACH data for many currencies.

type DeleteProfileOptions

type DeleteProfileOptions struct {
	ProfileID *string `bson:"profile_id" json:"profile_id" sql:"profile_id"`
	To        *string `bson:"to" json:"to" sql:"to"`
}

DeleteProfileOptions are options for API requests.

func (*DeleteProfileOptions) EncodeBody

func (opts *DeleteProfileOptions) EncodeBody() (buf io.Reader, err error)

func (*DeleteProfileOptions) EncodeQuery

func (opts *DeleteProfileOptions) EncodeQuery(req *http.Request)

func (*DeleteProfileOptions) SetProfileID

func (opts *DeleteProfileOptions) SetProfileID(ProfileID string) *DeleteProfileOptions

SetProfileID sets the ProfileID field on DeleteProfileOptions.

func (*DeleteProfileOptions) SetTo

SetTo sets the To field on DeleteProfileOptions.

type Deposit

type Deposit struct {
	Amount   string `bson:"amount" json:"amount" sql:"amount"`
	Currency string `bson:"currency" json:"currency" sql:"currency"`
	Fee      string `bson:"fee" json:"fee" sql:"fee"`
	ID       string `bson:"id" json:"id" sql:"id"`
	PayoutAt string `bson:"payout_at" json:"payout_at" sql:"payout_at"`
	Subtotal string `bson:"subtotal" json:"subtotal" sql:"subtotal"`
}

Deposit is the response for deposited funds from a www.coinbase.com wallet to the specified profile_id.

type EntryType

type EntryType string

EntryType indicates the reason for the account change.

const (
	// EntryTypeTransfer are funds moved to/from Coinbase to Coinbase Exchange.
	EntryTypeTransfer EntryType = "transfer"

	// EntryTypeMatch are funds moved as a result of a trade.
	EntryTypeMatch EntryType = "match"

	// EntryTypeFee is a fee as a result of a trade.
	EntryTypeFee EntryType = "fee"

	// EntryTypeRebate is a fee rebate as per our fee schedule.
	EntryTypeRebate EntryType = "rebate"

	// EntryTypeConversion are funds converted between fiat currency and a stablecoin.
	EntryTypeConversion EntryType = "conversion"
)

func (*EntryType) String

func (EntryType *EntryType) String() string

String will convert a EntryType into a string.

type ExchangeLimits

type ExchangeLimits struct {
	LimitCurrency  string         `bson:"limit_currency" json:"limit_currency" sql:"limit_currency"`
	TransferLimits TransferLimits `bson:"transfer_limits" json:"transfer_limits" sql:"transfer_limits"`
}

ExchangeLimits represents exchange limit information for a single user.

type FIATAccount

type FIATAccount struct {
	ID           string `bson:"id" json:"id" sql:"id"`
	Resource     string `bson:"resource" json:"resource" sql:"resource"`
	ResourcePath string `bson:"resource_path" json:"resource_path" sql:"resource_path"`
}

FIATAccount references a FIAT account thata CoinbasePaymentMethod belongs to

type Fees

type Fees struct {
	MakerFeeRate string `bson:"maker_fee_rate" json:"maker_fee_rate" sql:"maker_fee_rate"`
	TakerFeeRate string `bson:"taker_fee_rate" json:"taker_fee_rate" sql:"taker_fee_rate"`
	UsdVolume    string `bson:"usd_volume" json:"usd_volume" sql:"usd_volume"`
}

Fees are fees rates and 30 days trailing volume.

type FileFormat

type FileFormat string
const (
	FileFormatPdf FileFormat = "pdf"
	FileFormatCsv FileFormat = "csv"
)

func (*FileFormat) String

func (FileFormat *FileFormat) String() string

String will convert a FileFormat into a string.

type Fill

type Fill struct {
	Fee       string `bson:"fee" json:"fee" sql:"fee"`
	Liquidity string `bson:"liquidity" json:"liquidity" sql:"liquidity"`
	OrderID   string `bson:"order_id" json:"order_id" sql:"order_id"`
	Price     string `bson:"price" json:"price" sql:"price"`
	ProductID string `bson:"product_id" json:"product_id" sql:"product_id"`
	ProfileID string `bson:"profile_id" json:"profile_id" sql:"profile_id"`
	Settled   bool   `bson:"settled" json:"settled" sql:"settled"`
	Side      string `bson:"side" json:"side" sql:"side"`
	Size      string `bson:"size" json:"size" sql:"size"`
	TradeID   int    `bson:"trade_id" json:"trade_id" sql:"trade_id"`
	UsdVolume string `bson:"usd_volume" json:"usd_volume" sql:"usd_volume"`
	UserID    string `bson:"user_id" json:"user_id" sql:"user_id"`
}

TODO: Get fill description

type FillsOptions

type FillsOptions struct {
	After     *int    `bson:"after" json:"after" sql:"after"`
	Before    *int    `bson:"before" json:"before" sql:"before"`
	Limit     *int    `bson:"limit" json:"limit" sql:"limit"`
	OrderID   *string `bson:"order_id" json:"order_id" sql:"order_id"`
	ProductID *string `bson:"product_id" json:"product_id" sql:"product_id"`
	ProfileID *string `bson:"profile_id" json:"profile_id" sql:"profile_id"`
}

FillsOptions are options for API requests.

func (*FillsOptions) EncodeBody

func (opts *FillsOptions) EncodeBody() (buf io.Reader, err error)

func (*FillsOptions) EncodeQuery

func (opts *FillsOptions) EncodeQuery(req *http.Request)

func (*FillsOptions) SetAfter

func (opts *FillsOptions) SetAfter(After int) *FillsOptions

SetAfter sets the After field on FillsOptions.

func (*FillsOptions) SetBefore

func (opts *FillsOptions) SetBefore(Before int) *FillsOptions

SetBefore sets the Before field on FillsOptions.

func (*FillsOptions) SetLimit

func (opts *FillsOptions) SetLimit(Limit int) *FillsOptions

SetLimit sets the Limit field on FillsOptions.

func (*FillsOptions) SetOrderID

func (opts *FillsOptions) SetOrderID(OrderID string) *FillsOptions

SetOrderID sets the OrderID field on FillsOptions.

func (*FillsOptions) SetProductID

func (opts *FillsOptions) SetProductID(ProductID string) *FillsOptions

SetProductID sets the ProductID field on FillsOptions.

func (*FillsOptions) SetProfileID

func (opts *FillsOptions) SetProfileID(ProfileID string) *FillsOptions

SetProfileID sets the ProfileID field on FillsOptions.

type Flags

type Flags struct{}

TODO

type Granularity

type Granularity string

Granularity is the time in seconds between each candle tick.

const (
	Granularity60    Granularity = "60"
	Granularity300   Granularity = "300"
	Granularity900   Granularity = "900"
	Granularity3600  Granularity = "3600"
	Granularity21600 Granularity = "21600"
	Granularity86400 Granularity = "86400"
)

func (*Granularity) String

func (Granularity *Granularity) String() string

String will convert a Granularity into a string.

type Limits

type Limits struct {
	Name string `bson:"name" json:"name" sql:"name"`
	Type string `bson:"type" json:"type" sql:"type"`
}

Limits defines limits for a payment method

type Oracle

type Oracle struct {
	// Messages are an array contains abi-encoded values [kind, timestamp, key, value], where kind always equals to
	// 'prices', timestamp is the time when the price was obtained, key is asset ticker (e.g. 'eth') and value is asset
	// price
	Messages []string `bson:"messages" json:"messages" sql:"messages"`

	// Prices contains human-readable asset prices
	Prices OraclePrices `bson:"prices" json:"prices" sql:"prices"`

	// Signatures are an array of Ethereum-compatible ECDSA signatures for each message
	Signatures []string `bson:"signatures" json:"signatures" sql:"signatures"`

	// Timestamp indicates when the latest datapoint was obtained
	Timestamp time.Time `bson:"timestamp" json:"timestamp" sql:"timestamp"`
}

Oracle is cryptographically signed price-info ready to be posted on-chain using Compound's Open Oracle smart contract.

func (*Oracle) UnmarshalJSON

func (Oracle *Oracle) UnmarshalJSON(d []byte) error

UnmarshalJSON will deserialize bytes into a Oracle model

type OraclePrices

type OraclePrices struct {
	AdditionalProp string `bson:"additionalProp" json:"additionalProp" sql:"additionalProp"`
}

OraclePrices contain human-readable asset prices.

type Order

type Order struct {
	CreatedAt      time.Time   `bson:"created_at" json:"created_at" sql:"created_at"`
	DoneAt         time.Time   `bson:"done_at" json:"done_at" sql:"done_at"`
	DoneReason     string      `bson:"done_reason" json:"done_reason" sql:"done_reason"`
	ExecutedValue  string      `bson:"executed_value" json:"executed_value" sql:"executed_value"`
	ExpireTime     time.Time   `bson:"expire_time" json:"expire_time" sql:"expire_time"`
	FillFees       string      `bson:"fill_fees" json:"fill_fees" sql:"fill_fees"`
	FilledSize     string      `bson:"filled_size" json:"filled_size" sql:"filled_size"`
	FundingAmount  string      `bson:"funding_amount" json:"funding_amount" sql:"funding_amount"`
	Funds          string      `bson:"funds" json:"funds" sql:"funds"`
	ID             string      `bson:"id" json:"id" sql:"id"`
	PostOnly       bool        `bson:"post_only" json:"post_only" sql:"post_only"`
	Price          string      `bson:"price" json:"price" sql:"price"`
	ProductID      string      `bson:"product_id" json:"product_id" sql:"product_id"`
	RejectReason   string      `bson:"reject_reason" json:"reject_reason" sql:"reject_reason"`
	Settled        bool        `bson:"settled" json:"settled" sql:"settled"`
	Side           Side        `bson:"side" json:"side" sql:"side"`
	Size           string      `bson:"size" json:"size" sql:"size"`
	SpecifiedFunds string      `bson:"specified_funds" json:"specified_funds" sql:"specified_funds"`
	Status         string      `bson:"status" json:"status" sql:"status"`
	Stop           string      `bson:"stop" json:"stop" sql:"stop"`
	StopPrice      string      `bson:"stop_price" json:"stop_price" sql:"stop_price"`
	TimeInForce    TimeInForce `bson:"time_in_force" json:"time_in_force" sql:"time_in_force"`
	Type           OrderType   `bson:"type" json:"type" sql:"type"`
}

Order is an open order.

type OrderType

type OrderType string

OrderType represents the way in which an order should execute.

const (
	// OrderTypeMarket is an order to buy or sell the product immediately. This type of order guarantees that the order will
	// be executed, but does not guarantee the execution price. A market order generally will execute at or near the current
	// bid (for a sell order) or ask (for a buy order) price. However, it is important for investors to remember that the
	// last-traded price is not necessarily the price at which a market order will be executed.
	OrderTypeMarket OrderType = "market"

	// OrderTypeLimit is an order to buy or sell a product at a specific price or better. A buy limit order can only be
	// executed at the limit price or lower, and a sell limit order can only be executed at the limit price or higher.
	OrderTypeLimit OrderType = "limit"
)

func (*OrderType) String

func (OrderType *OrderType) String() string

String will convert a OrderType into a string.

type OrdersOptions

type OrdersOptions struct {
	After     *string  `bson:"after" json:"after" sql:"after"`
	Before    *string  `bson:"before" json:"before" sql:"before"`
	EndDate   *string  `bson:"end_date" json:"end_date" sql:"end_date"`
	Limit     int      `bson:"limit" json:"limit" sql:"limit"`
	ProductID *string  `bson:"product_id" json:"product_id" sql:"product_id"`
	ProfileID *string  `bson:"profile_id" json:"profile_id" sql:"profile_id"`
	SortedBy  *string  `bson:"sortedBy" json:"sortedBy" sql:"sortedBy"`
	Sorting   *string  `bson:"sorting" json:"sorting" sql:"sorting"`
	StartDate *string  `bson:"start_date" json:"start_date" sql:"start_date"`
	Status    []string `bson:"status" json:"status" sql:"status"`
}

OrdersOptions are options for API requests.

func (*OrdersOptions) EncodeBody

func (opts *OrdersOptions) EncodeBody() (buf io.Reader, err error)

func (*OrdersOptions) EncodeQuery

func (opts *OrdersOptions) EncodeQuery(req *http.Request)

func (*OrdersOptions) SetAfter

func (opts *OrdersOptions) SetAfter(After string) *OrdersOptions

SetAfter sets the After field on OrdersOptions.

func (*OrdersOptions) SetBefore

func (opts *OrdersOptions) SetBefore(Before string) *OrdersOptions

SetBefore sets the Before field on OrdersOptions.

func (*OrdersOptions) SetEndDate

func (opts *OrdersOptions) SetEndDate(EndDate string) *OrdersOptions

SetEndDate sets the EndDate field on OrdersOptions.

func (*OrdersOptions) SetLimit

func (opts *OrdersOptions) SetLimit(Limit int) *OrdersOptions

SetLimit sets the Limit field on OrdersOptions.

func (*OrdersOptions) SetProductID

func (opts *OrdersOptions) SetProductID(ProductID string) *OrdersOptions

SetProductID sets the ProductID field on OrdersOptions.

func (*OrdersOptions) SetProfileID

func (opts *OrdersOptions) SetProfileID(ProfileID string) *OrdersOptions

SetProfileID sets the ProfileID field on OrdersOptions.

func (*OrdersOptions) SetSortedBy

func (opts *OrdersOptions) SetSortedBy(SortedBy string) *OrdersOptions

SetSortedBy sets the SortedBy field on OrdersOptions.

func (*OrdersOptions) SetSorting

func (opts *OrdersOptions) SetSorting(Sorting string) *OrdersOptions

SetSorting sets the Sorting field on OrdersOptions.

func (*OrdersOptions) SetStartDate

func (opts *OrdersOptions) SetStartDate(StartDate string) *OrdersOptions

SetStartDate sets the StartDate field on OrdersOptions.

func (*OrdersOptions) SetStatus

func (opts *OrdersOptions) SetStatus(Status []string) *OrdersOptions

SetStatus sets the Status field on OrdersOptions.

type PaymentMethod

type PaymentMethod struct {
	AllowBuy           bool                `bson:"allow_buy" json:"allow_buy" sql:"allow_buy"`
	AllowDeposit       bool                `bson:"allow_deposit" json:"allow_deposit" sql:"allow_deposit"`
	AllowSell          bool                `bson:"allow_sell" json:"allow_sell" sql:"allow_sell"`
	AllowWithdraw      bool                `bson:"allow_withdraw" json:"allow_withdraw" sql:"allow_withdraw"`
	AvailableBalance   AvailableBalance    `bson:"available_balance" json:"available_balance" sql:"available_balance"`
	CdvStatus          string              `bson:"cdv_status" json:"cdv_status" sql:"cdv_status"`
	CreateAt           time.Time           `bson:"create_at" json:"create_at" sql:"create_at"`
	CryptoAccount      CryptoAccount       `bson:"crypto_account" json:"crypto_account" sql:"crypto_account"`
	Currency           string              `bson:"currency" json:"currency" sql:"currency"`
	FIATAccount        FIATAccount         `bson:"fiat_account" json:"fiat_account" sql:"fiat_account"`
	HoldBusinessDays   int                 `bson:"hold_business_days" json:"hold_business_days" sql:"hold_business_days"`
	HoldDays           int                 `bson:"hold_days" json:"hold_days" sql:"hold_days"`
	ID                 string              `bson:"id" json:"id" sql:"id"`
	InstantBuy         bool                `bson:"instant_buy" json:"instant_buy" sql:"instant_buy"`
	InstantSale        bool                `bson:"instant_sale" json:"instant_sale" sql:"instant_sale"`
	Limits             Limits              `bson:"limits" json:"limits" sql:"limits"`
	Name               string              `bson:"name" json:"name" sql:"name"`
	PickerData         PickerData          `bson:"picker_data" json:"picker_data" sql:"picker_data"`
	PrimaryBuy         bool                `bson:"primary_buy" json:"primary_buy" sql:"primary_buy"`
	PrimarySell        bool                `bson:"primary_sell" json:"primary_sell" sql:"primary_sell"`
	RecurringOptions   []*RecurringOptions `bson:"recurring_options" json:"recurring_options" sql:"recurring_options"`
	Resource           string              `bson:"resource" json:"resource" sql:"resource"`
	ResourcePath       string              `bson:"resource_path" json:"resource_path" sql:"resource_path"`
	Type               string              `bson:"type" json:"type" sql:"type"`
	UpdatedAt          time.Time           `bson:"updated_at" json:"updated_at" sql:"updated_at"`
	VerificationMethod string              `bson:"verification_method" json:"verification_method" sql:"verification_method"`
	Verified           bool                `bson:"verified" json:"verified" sql:"verified"`
}

PaymentMethod is a payment method used on coinbase

type PaymentMethodDepositOptions

type PaymentMethodDepositOptions struct {
	Amount          float64 `bson:"amount" json:"amount" sql:"amount"`
	Currency        string  `bson:"currency" json:"currency" sql:"currency"`
	PaymentMethodID string  `bson:"payment_method_id" json:"payment_method_id" sql:"payment_method_id"`
	ProfileID       *string `bson:"profile_id" json:"profile_id" sql:"profile_id"`
}

PaymentMethodDepositOptions are options for API requests.

func (*PaymentMethodDepositOptions) EncodeBody

func (opts *PaymentMethodDepositOptions) EncodeBody() (buf io.Reader, err error)

func (*PaymentMethodDepositOptions) EncodeQuery

func (opts *PaymentMethodDepositOptions) EncodeQuery(req *http.Request)

func (*PaymentMethodDepositOptions) SetAmount

SetAmount sets the Amount field on PaymentMethodDepositOptions.

func (*PaymentMethodDepositOptions) SetCurrency

func (opts *PaymentMethodDepositOptions) SetCurrency(Currency string) *PaymentMethodDepositOptions

SetCurrency sets the Currency field on PaymentMethodDepositOptions.

func (*PaymentMethodDepositOptions) SetPaymentMethodID

func (opts *PaymentMethodDepositOptions) SetPaymentMethodID(PaymentMethodID string) *PaymentMethodDepositOptions

SetPaymentMethodID sets the PaymentMethodID field on PaymentMethodDepositOptions.

func (*PaymentMethodDepositOptions) SetProfileID

func (opts *PaymentMethodDepositOptions) SetProfileID(ProfileID string) *PaymentMethodDepositOptions

SetProfileID sets the ProfileID field on PaymentMethodDepositOptions.

type PaymentMethodWithdrawalOptions

type PaymentMethodWithdrawalOptions struct {
	Amount          float64 `bson:"amount" json:"amount" sql:"amount"`
	Currency        string  `bson:"currency" json:"currency" sql:"currency"`
	PaymentMethodID string  `bson:"payment_method_id" json:"payment_method_id" sql:"payment_method_id"`
	ProfileID       *string `bson:"profile_id" json:"profile_id" sql:"profile_id"`
}

PaymentMethodWithdrawalOptions are options for API requests.

func (*PaymentMethodWithdrawalOptions) EncodeBody

func (opts *PaymentMethodWithdrawalOptions) EncodeBody() (buf io.Reader, err error)

func (*PaymentMethodWithdrawalOptions) EncodeQuery

func (opts *PaymentMethodWithdrawalOptions) EncodeQuery(req *http.Request)

func (*PaymentMethodWithdrawalOptions) SetAmount

SetAmount sets the Amount field on PaymentMethodWithdrawalOptions.

func (*PaymentMethodWithdrawalOptions) SetCurrency

SetCurrency sets the Currency field on PaymentMethodWithdrawalOptions.

func (*PaymentMethodWithdrawalOptions) SetPaymentMethodID

func (opts *PaymentMethodWithdrawalOptions) SetPaymentMethodID(PaymentMethodID string) *PaymentMethodWithdrawalOptions

SetPaymentMethodID sets the PaymentMethodID field on PaymentMethodWithdrawalOptions.

func (*PaymentMethodWithdrawalOptions) SetProfileID

SetProfileID sets the ProfileID field on PaymentMethodWithdrawalOptions.

type PickerData

type PickerData struct {
	AccountName           string  `bson:"account_name" json:"account_name" sql:"account_name"`
	AccountNumber         string  `bson:"account_number" json:"account_number" sql:"account_number"`
	AccountType           string  `bson:"account_type" json:"account_type" sql:"account_type"`
	Balance               Balance `bson:"balance" json:"balance" sql:"balance"`
	BankName              string  `bson:"bank_name" json:"bank_name" sql:"bank_name"`
	BranchName            string  `bson:"branch_name" json:"branch_name" sql:"branch_name"`
	CustomerName          string  `bson:"customer_name" json:"customer_name" sql:"customer_name"`
	Iban                  string  `bson:"iban" json:"iban" sql:"iban"`
	IconURL               string  `bson:"icon_url" json:"icon_url" sql:"icon_url"`
	InstitutionCode       string  `bson:"institution_code" json:"institution_code" sql:"institution_code"`
	InstitutionIdentifier string  `bson:"institution_identifier" json:"institution_identifier" sql:"institution_identifier"`
	InstitutionName       string  `bson:"institution_name" json:"institution_name" sql:"institution_name"`
	PaypalEmail           string  `bson:"paypal_email" json:"paypal_email" sql:"paypal_email"`
	PaypalOwner           string  `bson:"paypal_owner" json:"paypal_owner" sql:"paypal_owner"`
	RoutingNumber         string  `bson:"routing_number" json:"routing_number" sql:"routing_number"`
	SWIFT                 string  `bson:"swift" json:"swift" sql:"swift"`
	Symbol                string  `bson:"symbol" json:"symbol" sql:"symbol"`
}

PickerData ??

type Product

type Product struct {
	AuctionMode           bool   `bson:"auction_mode" json:"auction_mode" sql:"auction_mode"`
	BaseCurrency          string `bson:"base_currency" json:"base_currency" sql:"base_currency"`
	BaseIncrement         string `bson:"base_increment" json:"base_increment" sql:"base_increment"`
	BaseMaxSize           string `bson:"base_max_size" json:"base_max_size" sql:"base_max_size"`
	BaseMinSize           string `bson:"base_min_size" json:"base_min_size" sql:"base_min_size"`
	CancelOnly            bool   `bson:"cancel_only" json:"cancel_only" sql:"cancel_only"`
	DisplayName           string `bson:"display_name" json:"display_name" sql:"display_name"`
	FxStablecoin          bool   `bson:"fx_stablecoin" json:"fx_stablecoin" sql:"fx_stablecoin"`
	ID                    string `bson:"id" json:"id" sql:"id"`
	LimitOnly             bool   `bson:"limit_only" json:"limit_only" sql:"limit_only"`
	MarginEnabled         bool   `bson:"margin_enabled" json:"margin_enabled" sql:"margin_enabled"`
	MaxMarketFunds        string `bson:"max_market_funds" json:"max_market_funds" sql:"max_market_funds"`
	MaxSlippagePercentage string `bson:"max_slippage_percentage" json:"max_slippage_percentage" sql:"max_slippage_percentage"`
	MinMarketFunds        string `bson:"min_market_funds" json:"min_market_funds" sql:"min_market_funds"`
	PostOnly              bool   `bson:"post_only" json:"post_only" sql:"post_only"`
	QuoteCurrency         string `bson:"quote_currency" json:"quote_currency" sql:"quote_currency"`
	QuoteIncrement        string `bson:"quote_increment" json:"quote_increment" sql:"quote_increment"`
	Status                Status `bson:"status" json:"status" sql:"status"`
	StatusMessage         string `bson:"status_message" json:"status_message" sql:"status_message"`
	TradingDisabled       bool   `bson:"trading_disabled" json:"trading_disabled" sql:"trading_disabled"`
}

Product represents a currency pair available for trading.

type ProductStats

type ProductStats struct {
	High        string `bson:"high" json:"high" sql:"high"`
	Last        string `bson:"last" json:"last" sql:"last"`
	Low         string `bson:"low" json:"low" sql:"low"`
	Open        string `bson:"open" json:"open" sql:"open"`
	Volume      string `bson:"volume" json:"volume" sql:"volume"`
	Volume30day string `bson:"volume_30day" json:"volume_30day" sql:"volume_30day"`
}

ProductStats are 30day and 24hour stats for a product.

type ProductTicker

type ProductTicker struct {
	Ask     string    `bson:"ask" json:"ask" sql:"ask"`
	Bid     string    `bson:"bid" json:"bid" sql:"bid"`
	Price   string    `bson:"price" json:"price" sql:"price"`
	Size    string    `bson:"size" json:"size" sql:"size"`
	Time    time.Time `bson:"time" json:"time" sql:"time"`
	TradeID int       `bson:"trade_id" json:"trade_id" sql:"trade_id"`
	Volume  string    `bson:"volume" json:"volume" sql:"volume"`
}

ProductTicker is a snapshot information about the last trade (tick), best bid/ask and 24h volume.

type ProductWebsocket

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

func NewWebsocket

func NewWebsocket(ws websocket.Creator) *ProductWebsocket

NewWebsocket will create a connection to the coinbase websocket and return a singleton that can be used to open channels that stream product data via a websocket.

func (*ProductWebsocket) Ticker

func (productWebsocket *ProductWebsocket) Ticker(products ...string) *AsyncTicker

Ticker ticker uses the ProductWebsocket connection to query coinbase for ticket data, then it puts that data onto a channel for model.CoinbaseTicker

Example
package main

import (
	"fmt"
	"time"

	"github.com/alpine-hodler/web/pkg/coinbasepro"
	"github.com/alpine-hodler/web/pkg/websocket"
)

func main() {
	ws := coinbasepro.NewWebsocket(websocket.DefaultConnector)

	// initialize the ticker object to channel product messages
	ticker := ws.Ticker("ETH-USD")

	// start a go routine that passes product messages concerning ETH-USD currency pair to a channel on the ticker struct.
	ticker.Open()
	go func() {
		// Next we range over the product message channel and print the product messages.
		for productMsg := range ticker.Channel() {
			fmt.Printf("ETH-USD Price @ %v: %v\n", productMsg.Time, productMsg.Price)
		}
	}()

	// Let the product messages print for 5 seconds.
	time.Sleep(5 * time.Second)

	// Then close the ticker channel, this will unsubscribe from the websocket and close the underlying channel that the
	// messages read to.
	ticker.Close()
}
Output:

type ProductsOptions

type ProductsOptions struct {
	Type *string `bson:"type" json:"type" sql:"type"`
}

ProductsOptions are options for API requests.

func (*ProductsOptions) EncodeBody

func (opts *ProductsOptions) EncodeBody() (buf io.Reader, err error)

func (*ProductsOptions) EncodeQuery

func (opts *ProductsOptions) EncodeQuery(req *http.Request)

func (*ProductsOptions) SetType

func (opts *ProductsOptions) SetType(Type string) *ProductsOptions

SetType sets the Type field on ProductsOptions.

type Profile

type Profile struct {
	Active    bool      `bson:"active" json:"active" sql:"active"`
	CreatedAt time.Time `bson:"created_at" json:"created_at" sql:"created_at"`
	HasMargin bool      `bson:"has_margin" json:"has_margin" sql:"has_margin"`
	ID        string    `bson:"id" json:"id" sql:"id"`
	IsDefault bool      `bson:"is_default" json:"is_default" sql:"is_default"`
	Name      string    `bson:"name" json:"name" sql:"name"`
	UserID    string    `bson:"user_id" json:"user_id" sql:"user_id"`
}

Profile represents a profile to interact with the API.

type ProfileOptions

type ProfileOptions struct {
	Active *bool `bson:"active" json:"active" sql:"active"`
}

ProfileOptions are options for API requests.

func (*ProfileOptions) EncodeBody

func (opts *ProfileOptions) EncodeBody() (buf io.Reader, err error)

func (*ProfileOptions) EncodeQuery

func (opts *ProfileOptions) EncodeQuery(req *http.Request)

func (*ProfileOptions) SetActive

func (opts *ProfileOptions) SetActive(Active bool) *ProfileOptions

SetActive sets the Active field on ProfileOptions.

type ProfilesOptions

type ProfilesOptions struct {
	Active *bool `bson:"active" json:"active" sql:"active"`
}

ProfilesOptions are options for API requests.

func (*ProfilesOptions) EncodeBody

func (opts *ProfilesOptions) EncodeBody() (buf io.Reader, err error)

func (*ProfilesOptions) EncodeQuery

func (opts *ProfilesOptions) EncodeQuery(req *http.Request)

func (*ProfilesOptions) SetActive

func (opts *ProfilesOptions) SetActive(Active bool) *ProfilesOptions

SetActive sets the Active field on ProfilesOptions.

type RecurringOptions

type RecurringOptions struct {
	Label  string `bson:"label" json:"label" sql:"label"`
	Period string `bson:"period" json:"period" sql:"period"`
}

RecurringOptions ??

type RenameProfileOptions

type RenameProfileOptions struct {
	Name      *string `bson:"name" json:"name" sql:"name"`
	ProfileID *string `bson:"profile_id" json:"profile_id" sql:"profile_id"`
}

RenameProfileOptions are options for API requests.

func (*RenameProfileOptions) EncodeBody

func (opts *RenameProfileOptions) EncodeBody() (buf io.Reader, err error)

func (*RenameProfileOptions) EncodeQuery

func (opts *RenameProfileOptions) EncodeQuery(req *http.Request)

func (*RenameProfileOptions) SetName

func (opts *RenameProfileOptions) SetName(Name string) *RenameProfileOptions

SetName sets the Name field on RenameProfileOptions.

func (*RenameProfileOptions) SetProfileID

func (opts *RenameProfileOptions) SetProfileID(ProfileID string) *RenameProfileOptions

SetProfileID sets the ProfileID field on RenameProfileOptions.

type Report

type Report struct {
	CreatedAt time.Time     `bson:"created_at" json:"created_at" sql:"created_at"`
	ExpiresAt time.Time     `bson:"expires_at" json:"expires_at" sql:"expires_at"`
	FileCount string        `bson:"file_count" json:"file_count" sql:"file_count"`
	FileURL   string        `bson:"file_url" json:"file_url" sql:"file_url"`
	ID        string        `bson:"id" json:"id" sql:"id"`
	Params    ReportsParams `bson:"params" json:"params" sql:"params"`
	Status    Status        `bson:"status" json:"status" sql:"status"`
	Type      ReportType    `bson:"type" json:"type" sql:"type"`
	UpdatedAt time.Time     `bson:"updated_at" json:"updated_at" sql:"updated_at"`
	UserID    string        `bson:"user_id" json:"user_id" sql:"user_id"`
}

Report represents a list of past fills/account reports.

type ReportType

type ReportType string
const (
	ReportTypeFills                       ReportType = "fills"
	ReportTypeAccounts                    ReportType = "accounts"
	ReportTypeOtcFills                    ReportType = "otc_fills"
	ReportTypeType1099kTransactionHistory ReportType = "type_1099k_transaction_history"
	ReportTypeTaxInvoice                  ReportType = "tax_invoice"
)

func (*ReportType) String

func (ReportType *ReportType) String() string

String will convert a ReportType into a string.

type ReportsOptions

type ReportsOptions struct {
	// Filter results after a specific date
	After *string `bson:"after" json:"after" sql:"after"`

	// Filter results by a specific profile_id
	PortfolioID *string `bson:"portfolio_id" json:"portfolio_id" sql:"portfolio_id"`

	// Filter results by type of report (fills or account) - otc_fills: real string is otc-fills -
	// type_1099k_transaction_history: real string is 1099-transaction-history - tax_invoice: real string is tax-invoice
	Type *ReportType `bson:"type" json:"type" sql:"type"`

	// Ignore expired results
	IgnoredExpired *bool `bson:"ignored_expired" json:"ignored_expired" sql:"ignored_expired"`

	// Limit results to a specific number
	Limit *int `bson:"limit" json:"limit" sql:"limit"`
}

ReportsOptions are options for API requests.

func (*ReportsOptions) EncodeBody

func (opts *ReportsOptions) EncodeBody() (buf io.Reader, err error)

func (*ReportsOptions) EncodeQuery

func (opts *ReportsOptions) EncodeQuery(req *http.Request)

func (*ReportsOptions) SetAfter

func (opts *ReportsOptions) SetAfter(After string) *ReportsOptions

SetAfter sets the After field on ReportsOptions. Filter results after a specific date

func (*ReportsOptions) SetIgnoredExpired

func (opts *ReportsOptions) SetIgnoredExpired(IgnoredExpired bool) *ReportsOptions

SetIgnoredExpired sets the IgnoredExpired field on ReportsOptions. Ignore expired results

func (*ReportsOptions) SetLimit

func (opts *ReportsOptions) SetLimit(Limit int) *ReportsOptions

SetLimit sets the Limit field on ReportsOptions. Limit results to a specific number

func (*ReportsOptions) SetPortfolioID

func (opts *ReportsOptions) SetPortfolioID(PortfolioID string) *ReportsOptions

SetPortfolioID sets the PortfolioID field on ReportsOptions. Filter results by a specific profile_id

func (*ReportsOptions) SetType

func (opts *ReportsOptions) SetType(Type ReportType) *ReportsOptions

SetType sets the Type field on ReportsOptions. Filter results by type of report (fills or account) - otc_fills: real string is otc-fills - type_1099k_transaction_history: real string is 1099-transaction-history - tax_invoice: real string is tax-invoice

type ReportsParams

type ReportsParams struct {
	AccountID    string     `bson:"account_id" json:"account_id" sql:"account_id"`
	Email        string     `bson:"email" json:"email" sql:"email"`
	EndDate      time.Time  `bson:"end_date" json:"end_date" sql:"end_date"`
	Format       FileFormat `bson:"format" json:"format" sql:"format"`
	NewYorkState bool       `bson:"new_york_state" json:"new_york_state" sql:"new_york_state"`
	ProductID    string     `bson:"product_id" json:"product_id" sql:"product_id"`
	ProfileID    string     `bson:"profile_id" json:"profile_id" sql:"profile_id"`
	StartDate    time.Time  `bson:"start_date" json:"start_date" sql:"start_date"`
	User         User       `bson:"user" json:"user" sql:"user"`
}

TODO

type Role

type Role struct{}

TODO

type SEPADepositInformation

type SEPADepositInformation struct {
	AccountAddress string      `bson:"account_address" json:"account_address" sql:"account_address"`
	AccountName    string      `bson:"account_name" json:"account_name" sql:"account_name"`
	BankAddress    string      `bson:"bank_address" json:"bank_address" sql:"bank_address"`
	BankCountry    BankCountry `bson:"bank_country" json:"bank_country" sql:"bank_country"`
	BankName       string      `bson:"bank_name" json:"bank_name" sql:"bank_name"`
	Iban           string      `bson:"iban" json:"iban" sql:"iban"`
	Reference      string      `bson:"reference" json:"reference" sql:"reference"`
	SWIFT          string      `bson:"swift" json:"swift" sql:"swift"`
}

SEPADepositInformation information regarding a wallet's deposits. A SEPA credit transfer is a single transfer of Euros from one person or organisation to another. For example, this could be to pay the deposit for a holiday rental or to settle an invoice. A SEPA direct debit is a recurring payment, for example to pay monthly rent or for a service like a mobile phone contract.

type STP

type STP string

STP is the order's Self trade preservation flag.

const (
	// STPDc is decrease and cancel, default.
	STPDc STP = "dc"

	// STPCo is cancel oldest.
	STPCo STP = "co"

	// STPCn is cancel newest.
	STPCn STP = "cn"

	// STPCb is cancel both.
	STPCb STP = "cb"
)

func (*STP) String

func (STP *STP) String() string

String will convert a STP into a string.

type SWIFTDepositInformation

type SWIFTDepositInformation struct {
	AccountAddress string      `bson:"account_address" json:"account_address" sql:"account_address"`
	AccountName    string      `bson:"account_name" json:"account_name" sql:"account_name"`
	AccountNumber  string      `bson:"account_number" json:"account_number" sql:"account_number"`
	BankAddress    string      `bson:"bank_address" json:"bank_address" sql:"bank_address"`
	BankCountry    BankCountry `bson:"bank_country" json:"bank_country" sql:"bank_country"`
	BankName       string      `bson:"bank_name" json:"bank_name" sql:"bank_name"`
	Reference      string      `bson:"reference" json:"reference" sql:"reference"`
}

SWIFTDepositInformation information regarding a wallet's deposits. SWIFT stands for Society for Worldwide Interbank Financial Telecommunications. Basically, it's a computer network that connects over 900 banks around the world – and enables them to transfer money. ING is part of this network. There is no fee for accepting deposits into your account with ING.

type Side

type Side string

Side represents which side our order is on: the "sell" side or the "buy" side.

const (
	SideBuy  Side = "buy"
	SideSell Side = "sell"
)

func (*Side) String

func (Side *Side) String() string

String will convert a Side into a string.

type Status

type Status string
const (
	StatusOnline     Status = "online"
	StatusOffline    Status = "offline"
	StatusInternal   Status = "internal"
	StatusDelisted   Status = "delisted"
	StatusPending    Status = "pending"
	StatusCreating   Status = "creating"
	StatusReady      Status = "ready"
	StatusCreated    Status = "created"
	StatusInProgress Status = "in_progress"
	StatusFailed     Status = "failed"
	StatusComplete   Status = "complete"
)

func (*Status) String

func (Status *Status) String() string

String will convert a Status into a string.

type Stop

type Stop string

Stop is either loss or entry.

const (
	StopLoss  Stop = "loss"
	StopEntry Stop = "entry"
)

func (*Stop) String

func (Stop *Stop) String() string

String will convert a Stop into a string.

type Ticker

type Ticker struct {
	BestAsk   string    `bson:"best_ask" json:"best_ask" sql:"best_ask"`
	BestBid   string    `bson:"best_bid" json:"best_bid" sql:"best_bid"`
	LastSize  string    `bson:"last_size" json:"last_size" sql:"last_size"`
	Price     string    `bson:"price" json:"price" sql:"price"`
	ProductID string    `bson:"product_id" json:"product_id" sql:"product_id"`
	Sequence  int       `bson:"sequence" json:"sequence" sql:"sequence"`
	Side      string    `bson:"side" json:"side" sql:"side"`
	Time      time.Time `bson:"time" json:"time" sql:"time"`
	TradeID   int       `bson:"trade_id" json:"trade_id" sql:"trade_id"`
	Type      string    `bson:"type" json:"type" sql:"type"`
}

Ticker is real-time price updates every time a match happens. It batches updates in case of cascading matches, greatly reducing bandwidth requirements.

type TickerChannel

type TickerChannel chan Ticker

type TimeInForce

type TimeInForce string

TimeInForce policies provide guarantees about the lifetime of an order.

const (
	// TimeInForceGTC Good till canceled orders remain open on the book until canceled. This is the default behavior if no
	// policy is specified.
	TimeInForceGTC TimeInForce = "GTC"

	// TimeInForceIOC Immediate or cancel orders instantly cancel the remaining size of the limit order instead of opening
	// it on the book.
	TimeInForceIOC TimeInForce = "IOC"

	// TimeInForceFOK Fill or kill orders are rejected if the entire size cannot be matched.
	TimeInForceFOK TimeInForce = "FOK"

	// TimeInForceGTT Good till time orders remain open on the book until canceled or the allotted cancel_after is depleted
	// on the matching engine. GTT orders are guaranteed to cancel before any other order is processed after the
	// cancel_after timestamp which is returned by the API. A day is considered 24 hours.
	TimeInForceGTT TimeInForce = "GTT"
)

func (*TimeInForce) String

func (TimeInForce *TimeInForce) String() string

String will convert a TimeInForce into a string.

type Trade

type Trade struct {
	Price   string    `bson:"price" json:"price" sql:"price"`
	Side    Side      `bson:"side" json:"side" sql:"side"`
	Size    string    `bson:"size" json:"size" sql:"size"`
	Time    time.Time `bson:"time" json:"time" sql:"time"`
	TradeID int32     `bson:"trade_id" json:"trade_id" sql:"trade_id"`
}

Trade is the list the latest trades for a product.

type TradesOptions

type TradesOptions struct {
	After  *int32 `bson:"after" json:"after" sql:"after"`
	Before *int32 `bson:"before" json:"before" sql:"before"`
	Limit  *int32 `bson:"limit" json:"limit" sql:"limit"`
}

TradesOptions are options for API requests.

func (*TradesOptions) EncodeBody

func (opts *TradesOptions) EncodeBody() (buf io.Reader, err error)

func (*TradesOptions) EncodeQuery

func (opts *TradesOptions) EncodeQuery(req *http.Request)

func (*TradesOptions) SetAfter

func (opts *TradesOptions) SetAfter(After int32) *TradesOptions

SetAfter sets the After field on TradesOptions.

func (*TradesOptions) SetBefore

func (opts *TradesOptions) SetBefore(Before int32) *TradesOptions

SetBefore sets the Before field on TradesOptions.

func (*TradesOptions) SetLimit

func (opts *TradesOptions) SetLimit(Limit int32) *TradesOptions

SetLimit sets the Limit field on TradesOptions.

type Transfer

type Transfer struct {
	Amount      string                 `bson:"amount" json:"amount" sql:"amount"`
	CanceledAt  time.Time              `bson:"canceled_at" json:"canceled_at" sql:"canceled_at"`
	CompletedAt time.Time              `bson:"completed_at" json:"completed_at" sql:"completed_at"`
	CreatedAt   time.Time              `bson:"created_at" json:"created_at" sql:"created_at"`
	Details     AccountTransferDetails `bson:"details" json:"details" sql:"details"`
	ID          string                 `bson:"id" json:"id" sql:"id"`
	ProcessedAt time.Time              `bson:"processed_at" json:"processed_at" sql:"processed_at"`
	Type        string                 `bson:"type" json:"type" sql:"type"`
	UserNonce   string                 `bson:"user_nonce" json:"user_nonce" sql:"user_nonce"`
}

Transfer will lists past withdrawals and deposits for an account.

func (*Transfer) UnmarshalJSON

func (Transfer *Transfer) UnmarshalJSON(d []byte) error

UnmarshalJSON will deserialize bytes into a Transfer model

type TransferLimits

type TransferLimits struct {
	ACH                   CurrencyTransferLimits `bson:"ach" json:"ach" sql:"ach"`
	ACHNoBalance          CurrencyTransferLimits `bson:"ach_no_balance" json:"ach_no_balance" sql:"ach_no_balance"`
	Buy                   CurrencyTransferLimits `bson:"buy" json:"buy" sql:"buy"`
	CreditDebitCard       CurrencyTransferLimits `bson:"credit_debit_card" json:"credit_debit_card" sql:"credit_debit_card"`
	ExchangeWithdraw      CurrencyTransferLimits `bson:"exchange_withdraw" json:"exchange_withdraw" sql:"exchange_withdraw"`
	IdealDeposit          CurrencyTransferLimits `bson:"ideal_deposit" json:"ideal_deposit" sql:"ideal_deposit"`
	InstanceACHWithdrawal CurrencyTransferLimits `bson:"instance_ach_withdrawal" json:"instance_ach_withdrawal" sql:"instance_ach_withdrawal"`
	PaypalBuy             CurrencyTransferLimits `bson:"paypal_buy" json:"paypal_buy" sql:"paypal_buy"`
	PaypalWithdrawal      CurrencyTransferLimits `bson:"paypal_withdrawal" json:"paypal_withdrawal" sql:"paypal_withdrawal"`
	Secure3dBuy           CurrencyTransferLimits `bson:"secure3d_buy" json:"secure3d_buy" sql:"secure3d_buy"`
	Sell                  CurrencyTransferLimits `bson:"sell" json:"sell" sql:"sell"`
	SofortDeposit         CurrencyTransferLimits `bson:"sofort_deposit" json:"sofort_deposit" sql:"sofort_deposit"`
}

TODO

type TransferMethod

type TransferMethod string
const (
	TransferMethodDeposit  TransferMethod = "deposit"
	TransferMethodWithdraw TransferMethod = "withdraw"
)

func (*TransferMethod) String

func (TransferMethod *TransferMethod) String() string

String will convert a TransferMethod into a string.

type UKDepositInformation

type UKDepositInformation struct {
	AccountAddress string      `bson:"account_address" json:"account_address" sql:"account_address"`
	AccountName    string      `bson:"account_name" json:"account_name" sql:"account_name"`
	AccountNumber  string      `bson:"account_number" json:"account_number" sql:"account_number"`
	BankAddress    string      `bson:"bank_address" json:"bank_address" sql:"bank_address"`
	BankCountry    BankCountry `bson:"bank_country" json:"bank_country" sql:"bank_country"`
	BankName       string      `bson:"bank_name" json:"bank_name" sql:"bank_name"`
	Reference      string      `bson:"reference" json:"reference" sql:"reference"`
}

UKDepositInformation information regarding a wallet's deposits.

type User

type User struct {
	ActiveAt                  time.Time       `bson:"active_at" json:"active_at" sql:"active_at"`
	CbDataFromCache           bool            `bson:"cb_data_from_cache" json:"cb_data_from_cache" sql:"cb_data_from_cache"`
	CreatedAt                 time.Time       `bson:"created_at" json:"created_at" sql:"created_at"`
	Details                   UserDetails     `bson:"details" json:"details" sql:"details"`
	Flags                     Flags           `bson:"flags" json:"flags" sql:"flags"`
	FulfillsNewRequirements   bool            `bson:"fulfills_new_requirements" json:"fulfills_new_requirements" sql:"fulfills_new_requirements"`
	HasClawbackPaymentPending bool            `bson:"has_clawback_payment_pending" json:"has_clawback_payment_pending" sql:"has_clawback_payment_pending"`
	HasDefault                bool            `bson:"has_default" json:"has_default" sql:"has_default"`
	HasRestrictedAssets       bool            `bson:"has_restricted_assets" json:"has_restricted_assets" sql:"has_restricted_assets"`
	ID                        string          `bson:"id" json:"id" sql:"id"`
	IsBanned                  bool            `bson:"is_banned" json:"is_banned" sql:"is_banned"`
	LegalName                 string          `bson:"legal_name" json:"legal_name" sql:"legal_name"`
	Name                      string          `bson:"name" json:"name" sql:"name"`
	Preferences               UserPreferences `bson:"preferences" json:"preferences" sql:"preferences"`
	Roles                     []*Role         `bson:"roles" json:"roles" sql:"roles"`
	StateCode                 string          `bson:"state_code" json:"state_code" sql:"state_code"`
	TermsAccepted             time.Time       `bson:"terms_accepted" json:"terms_accepted" sql:"terms_accepted"`
	TwoFactorMethod           string          `bson:"two_factor_method" json:"two_factor_method" sql:"two_factor_method"`
	UserType                  string          `bson:"user_type" json:"user_type" sql:"user_type"`
}

TODO

type UserDetails

type UserDetails struct{}

TODO

type UserPreferences

type UserPreferences struct{}

TODO

type Wallet

type Wallet struct {
	Active                  bool                    `bson:"active" json:"active" sql:"active"`
	AvailableOnConsumer     bool                    `bson:"available_on_consumer" json:"available_on_consumer" sql:"available_on_consumer"`
	Balance                 string                  `bson:"balance" json:"balance" sql:"balance"`
	Currency                string                  `bson:"currency" json:"currency" sql:"currency"`
	DestinationTagName      string                  `bson:"destination_tag_name" json:"destination_tag_name" sql:"destination_tag_name"`
	DestinationTagRegex     string                  `bson:"destination_tag_regex" json:"destination_tag_regex" sql:"destination_tag_regex"`
	HoldBalance             string                  `bson:"hold_balance" json:"hold_balance" sql:"hold_balance"`
	HoldCurrency            string                  `bson:"hold_currency" json:"hold_currency" sql:"hold_currency"`
	ID                      string                  `bson:"id" json:"id" sql:"id"`
	Name                    string                  `bson:"name" json:"name" sql:"name"`
	Primary                 bool                    `bson:"primary" json:"primary" sql:"primary"`
	Ready                   bool                    `bson:"ready" json:"ready" sql:"ready"`
	SEPADepositInformation  SEPADepositInformation  `bson:"sepa_deposit_information" json:"sepa_deposit_information" sql:"sepa_deposit_information"`
	SWIFTDepositInformation SWIFTDepositInformation `bson:"swift_deposit_information" json:"swift_deposit_information" sql:"swift_deposit_information"`
	Type                    string                  `bson:"type" json:"type" sql:"type"`
	UKDepositInformation    UKDepositInformation    `bson:"uk_deposit_information" json:"uk_deposit_information" sql:"uk_deposit_information"`
	WireDepositInformation  WireDepositInformation  `bson:"wire_deposit_information" json:"wire_deposit_information" sql:"wire_deposit_information"`
}

Wallet represents a user's available Coinbase wallet (These are the wallets/accounts that are used for buying and selling on www.coinbase.com)

type WireDepositInformation

type WireDepositInformation struct {
	AccountAddress string      `bson:"account_address" json:"account_address" sql:"account_address"`
	AccountName    string      `bson:"account_name" json:"account_name" sql:"account_name"`
	AccountNumber  string      `bson:"account_number" json:"account_number" sql:"account_number"`
	BankAddress    string      `bson:"bank_address" json:"bank_address" sql:"bank_address"`
	BankCountry    BankCountry `bson:"bank_country" json:"bank_country" sql:"bank_country"`
	BankName       string      `bson:"bank_name" json:"bank_name" sql:"bank_name"`
	Reference      string      `bson:"reference" json:"reference" sql:"reference"`
	RoutingNumber  string      `bson:"routing_number" json:"routing_number" sql:"routing_number"`
}

WireDepositInformation information regarding a wallet's deposits

type Withdrawal

type Withdrawal struct {
	Amount   string `bson:"amount" json:"amount" sql:"amount"`
	Currency string `bson:"currency" json:"currency" sql:"currency"`
	Fee      string `bson:"fee" json:"fee" sql:"fee"`
	ID       string `bson:"id" json:"id" sql:"id"`
	PayoutAt string `bson:"payout_at" json:"payout_at" sql:"payout_at"`
	Subtotal string `bson:"subtotal" json:"subtotal" sql:"subtotal"`
}

Withdrawal is data concerning withdrawing funds from the specified profile_id to a www.coinbase.com wallet.

type WithdrawalFeeEstimate

type WithdrawalFeeEstimate struct {
	Fee float64 `bson:"fee" json:"fee" sql:"fee"`
}

WithdrawalFeeEstimate is a fee estimate for the crypto withdrawal to crypto address

type WithdrawalFeeEstimateOptions

type WithdrawalFeeEstimateOptions struct {
	CryptoAddress *string `bson:"crypto_address" json:"crypto_address" sql:"crypto_address"`
	Currency      *string `bson:"currency" json:"currency" sql:"currency"`
}

WithdrawalFeeEstimateOptions are options for API requests.

func (*WithdrawalFeeEstimateOptions) EncodeBody

func (opts *WithdrawalFeeEstimateOptions) EncodeBody() (buf io.Reader, err error)

func (*WithdrawalFeeEstimateOptions) EncodeQuery

func (opts *WithdrawalFeeEstimateOptions) EncodeQuery(req *http.Request)

func (*WithdrawalFeeEstimateOptions) SetCryptoAddress

func (opts *WithdrawalFeeEstimateOptions) SetCryptoAddress(CryptoAddress string) *WithdrawalFeeEstimateOptions

SetCryptoAddress sets the CryptoAddress field on WithdrawalFeeEstimateOptions.

func (*WithdrawalFeeEstimateOptions) SetCurrency

SetCurrency sets the Currency field on WithdrawalFeeEstimateOptions.

Jump to

Keyboard shortcuts

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