coinbasepro

package
v0.0.0-...-ae86ed1 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2022 License: MIT Imports: 33 Imported by: 0

README

GoCryptoTrader package Coinbasepro

Build Status Software License GoDoc Coverage Status Go Report Card

This coinbasepro package is part of the GoCryptoTrader codebase.

This is still in active development

You can track ideas, planned features and what's in progress on this Trello board: https://trello.com/b/ZAhMhpOy/gocryptotrader.

Join our slack to discuss all things related to GoCryptoTrader! GoCryptoTrader Slack

CoinbasePro Exchange

Current Features
  • REST Support
  • Websocket Support
How to enable
	// Exchanges will be abstracted out in further updates and examples will be
	// supplied then
How to do REST public/private calls
  • If enabled via "configuration".json file the exchange will be added to the IBotExchange array in the go var bot Bot and you will only be able to use the wrapper interface functions for accessing exchange data. View routines.go for an example of integration usage with GoCryptoTrader. Rudimentary example below:

main.go

var c exchange.IBotExchange

for i := range bot.Exchanges {
	if bot.Exchanges[i].GetName() == "CoinbasePro" {
		c = bot.Exchanges[i]
	}
}

// Public calls - wrapper functions

// Fetches current ticker information
tick, err := c.FetchTicker()
if err != nil {
	// Handle error
}

// Fetches current orderbook information
ob, err := c.FetchOrderbook()
if err != nil {
	// Handle error
}

// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
// set and AuthenticatedAPISupport is set to true

// Fetches current account information
accountInfo, err := c.GetAccountInfo()
if err != nil {
	// Handle error
}
  • If enabled via individually importing package, rudimentary example below:
// Public calls

// Fetches current ticker information
ticker, err := c.GetTicker()
if err != nil {
	// Handle error
}

// Fetches current orderbook information
ob, err := c.GetOrderBook()
if err != nil {
	// Handle error
}

// Private calls - make sure your APIKEY and APISECRET are set and
// AuthenticatedAPISupport is set to true

// GetUserInfo returns account info
accountInfo, err := c.GetUserInfo(...)
if err != nil {
	// Handle error
}

// Submits an order and the exchange and returns its tradeID
tradeID, err := c.Trade(...)
if err != nil {
	// Handle error
}
How to do Websocket public/private calls
	// Exchanges will be abstracted out in further updates and examples will be
	// supplied then
Please click GoDocs chevron above to view current GoDoc information for this package

Contribution

Please feel free to submit any pull requests or suggest any desired features to be added.

When submitting a PR, please abide by our coding guidelines:

  • Code must adhere to the official Go formatting guidelines (i.e. uses gofmt).
  • Code must be documented adhering to the official Go commentary guidelines.
  • Code must adhere to our coding style.
  • Pull requests need to be based on and opened against the master branch.

Donations

If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:

bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID            string  `json:"id"`
	Balance       float64 `json:"balance,string"`
	Hold          float64 `json:"hold,string"`
	FundedAmount  float64 `json:"funded_amount,string"`
	DefaultAmount float64 `json:"default_amount,string"`
}

Account is a sub-type for account overview

type AccountHolds

type AccountHolds struct {
	ID        string    `json:"id"`
	AccountID string    `json:"account_id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt string    `json:"updated_at"`
	Amount    float64   `json:"amount,string"`
	Type      string    `json:"type"`
	Reference string    `json:"ref"`
}

AccountHolds contains the hold information about an account

type AccountLedgerResponse

type AccountLedgerResponse struct {
	ID        string      `json:"id"`
	CreatedAt time.Time   `json:"created_at"`
	Amount    float64     `json:"amount,string"`
	Balance   float64     `json:"balance,string"`
	Type      string      `json:"type"`
	Details   interface{} `json:"details"`
}

AccountLedgerResponse holds account history information

type AccountOverview

type AccountOverview struct {
	Status  string `json:"status"`
	Funding struct {
		MaxFundingValue   float64 `json:"max_funding_value,string"`
		FundingValue      float64 `json:"funding_value,string"`
		OldestOutstanding struct {
			ID        string    `json:"id"`
			OrderID   string    `json:"order_id"`
			CreatedAt time.Time `json:"created_at"`
			Currency  string    `json:"currency"`
			AccountID string    `json:"account_id"`
			Amount    float64   `json:"amount,string"`
		} `json:"oldest_outstanding"`
	} `json:"funding"`
	Accounts struct {
		LTC Account `json:"LTC"`
		ETH Account `json:"ETH"`
		USD Account `json:"USD"`
		BTC Account `json:"BTC"`
	} `json:"accounts"`
	MarginCall struct {
		Active bool    `json:"active"`
		Price  float64 `json:"price,string"`
		Side   string  `json:"side"`
		Size   float64 `json:"size,string"`
		Funds  float64 `json:"funds,string"`
	} `json:"margin_call"`
	UserID    string `json:"user_id"`
	ProfileID string `json:"profile_id"`
	Position  struct {
		Type       string  `json:"type"`
		Size       float64 `json:"size,string"`
		Complement float64 `json:"complement,string"`
		MaxSize    float64 `json:"max_size,string"`
	} `json:"position"`
	ProductID string `json:"product_id"`
}

AccountOverview holds account information returned from position

type AccountResponse

type AccountResponse struct {
	ID            string  `json:"id"`
	Currency      string  `json:"currency"`
	Balance       float64 `json:"balance,string"`
	Available     float64 `json:"available,string"`
	Hold          float64 `json:"hold,string"`
	ProfileID     string  `json:"profile_id"`
	MarginEnabled bool    `json:"margin_enabled"`
	FundedAmount  float64 `json:"funded_amount,string"`
	DefaultAmount float64 `json:"default_amount,string"`
}

AccountResponse holds the details for the trading accounts

type CoinbaseAccounts

type CoinbaseAccounts struct {
	ID                     string  `json:"id"`
	Name                   string  `json:"name"`
	Balance                float64 `json:"balance,string"`
	Currency               string  `json:"currency"`
	Type                   string  `json:"type"`
	Primary                bool    `json:"primary"`
	Active                 bool    `json:"active"`
	WireDepositInformation struct {
		AccountNumber string `json:"account_number"`
		RoutingNumber string `json:"routing_number"`
		BankName      string `json:"bank_name"`
		BankAddress   string `json:"bank_address"`
		BankCountry   struct {
			Code string `json:"code"`
			Name string `json:"name"`
		} `json:"bank_country"`
		AccountName    string `json:"account_name"`
		AccountAddress string `json:"account_address"`
		Reference      string `json:"reference"`
	} `json:"wire_deposit_information"`
	SepaDepositInformation struct {
		Iban            string `json:"iban"`
		Swift           string `json:"swift"`
		BankName        string `json:"bank_name"`
		BankAddress     string `json:"bank_address"`
		BankCountryName string `json:"bank_country_name"`
		AccountName     string `json:"account_name"`
		AccountAddress  string `json:"account_address"`
		Reference       string `json:"reference"`
	} `json:"sep_deposit_information"`
}

CoinbaseAccounts holds coinbase account information

type CoinbasePro

type CoinbasePro struct {
	exchange.Base
}

CoinbasePro is the overarching type across the coinbasepro package

func (*CoinbasePro) CancelAllExistingOrders

func (c *CoinbasePro) CancelAllExistingOrders(currencyPair string) ([]string, error)

CancelAllExistingOrders cancels all open orders on the exchange and returns and array of order IDs currencyPair - [optional] all orders for a currencyPair string will be canceled

func (*CoinbasePro) CancelAllOrders

func (c *CoinbasePro) CancelAllOrders(_ *order.Cancel) (order.CancelAllResponse, error)

CancelAllOrders cancels all orders associated with a currency pair

func (*CoinbasePro) CancelBatchOrders

func (c *CoinbasePro) CancelBatchOrders(o []order.Cancel) (order.CancelBatchResponse, error)

CancelBatchOrders cancels an orders by their corresponding ID numbers

func (*CoinbasePro) CancelExistingOrder

func (c *CoinbasePro) CancelExistingOrder(orderID string) error

CancelExistingOrder cancels order by orderID

func (*CoinbasePro) CancelOrder

func (c *CoinbasePro) CancelOrder(o *order.Cancel) error

CancelOrder cancels an order by its corresponding ID number

func (*CoinbasePro) ClosePosition

func (c *CoinbasePro) ClosePosition(repayOnly bool) (AccountOverview, error)

ClosePosition closes a position and allowing you to repay position as well repayOnly - allows the position to be repaid

func (*CoinbasePro) DepositViaCoinbase

func (c *CoinbasePro) DepositViaCoinbase(amount float64, currency, accountID string) (DepositWithdrawalInfo, error)

DepositViaCoinbase deposits funds from a coinbase account. Move funds between a Coinbase account and coinbasepro trading account within daily limits. Moving funds between Coinbase and coinbasepro is instant and free. See the Coinbase Accounts section for retrieving your Coinbase accounts.

amount - The amount to deposit currency - The type of currency accountID - ID of the coinbase account

func (*CoinbasePro) DepositViaPaymentMethod

func (c *CoinbasePro) DepositViaPaymentMethod(amount float64, currency, paymentID string) (DepositWithdrawalInfo, error)

DepositViaPaymentMethod deposits funds from a payment method. See the Payment Methods section for retrieving your payment methods.

amount - The amount to deposit currency - The type of currency paymentID - ID of the payment method

func (*CoinbasePro) FetchAccountInfo

func (c *CoinbasePro) FetchAccountInfo(assetType asset.Item) (account.Holdings, error)

FetchAccountInfo retrieves balances for all enabled currencies

func (*CoinbasePro) FetchOrderbook

func (c *CoinbasePro) FetchOrderbook(p currency.Pair, assetType asset.Item) (*orderbook.Base, error)

FetchOrderbook returns orderbook base on the currency pair

func (*CoinbasePro) FetchTicker

func (c *CoinbasePro) FetchTicker(p currency.Pair, assetType asset.Item) (*ticker.Price, error)

FetchTicker returns the ticker for a currency pair

func (*CoinbasePro) FetchTradablePairs

func (c *CoinbasePro) FetchTradablePairs(asset asset.Item) ([]string, error)

FetchTradablePairs returns a list of the exchanges tradable pairs

func (*CoinbasePro) GenerateDefaultSubscriptions

func (c *CoinbasePro) GenerateDefaultSubscriptions() ([]stream.ChannelSubscription, error)

GenerateDefaultSubscriptions Adds default subscriptions to websocket to be handled by ManageSubscriptions()

func (*CoinbasePro) GetAccount

func (c *CoinbasePro) GetAccount(accountID string) (AccountResponse, error)

GetAccount returns information for a single account. Use this endpoint when account_id is known

func (*CoinbasePro) GetAccountHistory

func (c *CoinbasePro) GetAccountHistory(accountID string) ([]AccountLedgerResponse, error)

GetAccountHistory returns a list of account activity. Account activity either increases or decreases your account balance. Items are paginated and sorted latest first.

func (*CoinbasePro) GetAccounts

func (c *CoinbasePro) GetAccounts() ([]AccountResponse, error)

GetAccounts returns a list of trading accounts associated with the APIKEYS

func (*CoinbasePro) GetActiveOrders

func (c *CoinbasePro) GetActiveOrders(req *order.GetOrdersRequest) ([]order.Detail, error)

GetActiveOrders retrieves any orders that are active/open

func (*CoinbasePro) GetCoinbaseAccounts

func (c *CoinbasePro) GetCoinbaseAccounts() ([]CoinbaseAccounts, error)

GetCoinbaseAccounts returns a list of coinbase accounts

func (*CoinbasePro) GetCurrencies

func (c *CoinbasePro) GetCurrencies() ([]Currency, error)

GetCurrencies returns a list of supported currency on the exchange Warning: Not all currencies may be currently in use for tradinc.

func (*CoinbasePro) GetDefaultConfig

func (c *CoinbasePro) GetDefaultConfig() (*config.ExchangeConfig, error)

GetDefaultConfig returns a default exchange config

func (*CoinbasePro) GetDepositAddress

func (c *CoinbasePro) GetDepositAddress(cryptocurrency currency.Code, accountID string) (string, error)

GetDepositAddress returns a deposit address for a specified currency

func (*CoinbasePro) GetFee

func (c *CoinbasePro) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error)

GetFee returns an estimate of fee based on type of transaction

func (*CoinbasePro) GetFeeByType

func (c *CoinbasePro) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error)

GetFeeByType returns an estimate of fee based on type of transaction

func (*CoinbasePro) GetFills

func (c *CoinbasePro) GetFills(orderID, currencyPair string) ([]FillResponse, error)

GetFills returns a list of recent fills

func (*CoinbasePro) GetFundingHistory

func (c *CoinbasePro) GetFundingHistory() ([]exchange.FundHistory, error)

GetFundingHistory returns funding history, deposits and withdrawals

func (*CoinbasePro) GetHistoricCandles

func (c *CoinbasePro) GetHistoricCandles(p currency.Pair, a asset.Item, start, end time.Time, interval kline.Interval) (kline.Item, error)

GetHistoricCandles returns a set of candle between two time periods for a designated time period

func (*CoinbasePro) GetHistoricCandlesExtended

func (c *CoinbasePro) GetHistoricCandlesExtended(p currency.Pair, a asset.Item, start, end time.Time, interval kline.Interval) (kline.Item, error)

GetHistoricCandlesExtended returns candles between a time period for a set time interval

func (*CoinbasePro) GetHistoricRates

func (c *CoinbasePro) GetHistoricRates(currencyPair, start, end string, granularity int64) ([]History, error)

GetHistoricRates returns historic rates for a product. Rates are returned in grouped buckets based on requested granularity.

func (*CoinbasePro) GetHistoricTrades

func (c *CoinbasePro) GetHistoricTrades(_ currency.Pair, _ asset.Item, _, _ time.Time) ([]trade.Data, error)

GetHistoricTrades returns historic trade data within the timeframe provided

func (*CoinbasePro) GetHolds

func (c *CoinbasePro) GetHolds(accountID string) ([]AccountHolds, error)

GetHolds returns the holds that 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 a withdraw, once it is completed, the hold is removed.

func (*CoinbasePro) GetOrder

func (c *CoinbasePro) GetOrder(orderID string) (GeneralizedOrderResponse, error)

GetOrder returns a single order by order id.

func (*CoinbasePro) GetOrderHistory

func (c *CoinbasePro) GetOrderHistory(req *order.GetOrdersRequest) ([]order.Detail, error)

GetOrderHistory retrieves account order information Can Limit response to specific order status

func (*CoinbasePro) GetOrderInfo

func (c *CoinbasePro) GetOrderInfo(orderID string, pair currency.Pair, assetType asset.Item) (order.Detail, error)

GetOrderInfo returns order information based on order ID

func (*CoinbasePro) GetOrderbook

func (c *CoinbasePro) GetOrderbook(symbol string, level int) (interface{}, error)

GetOrderbook returns orderbook by currency pair and level

func (*CoinbasePro) GetOrders

func (c *CoinbasePro) GetOrders(status []string, currencyPair string) ([]GeneralizedOrderResponse, error)

GetOrders lists current open orders. Only open or un-settled orders are returned. As soon as an order is no longer open and settled, it will no longer appear in the default request. status - can be a range of "open", "pending", "done" or "active" currencyPair - [optional] for example "BTC-USD"

func (*CoinbasePro) GetPayMethods

func (c *CoinbasePro) GetPayMethods() ([]PaymentMethod, error)

GetPayMethods returns a full list of payment methods

func (*CoinbasePro) GetPosition

func (c *CoinbasePro) GetPosition() (AccountOverview, error)

GetPosition returns an overview of account profile.

func (*CoinbasePro) GetProducts

func (c *CoinbasePro) GetProducts() ([]Product, error)

GetProducts returns supported currency pairs on the exchange with specific information about the pair

func (*CoinbasePro) GetRecentTrades

func (c *CoinbasePro) GetRecentTrades(p currency.Pair, assetType asset.Item) ([]trade.Data, error)

GetRecentTrades returns the most recent trades for a currency and asset

func (*CoinbasePro) GetReport

func (c *CoinbasePro) GetReport(reportType, startDate, endDate, currencyPair, accountID, format, email string) (Report, error)

GetReport returns batches of historic information about your account in various human and machine readable forms.

reportType - "fills" or "account" startDate - Starting date for the report (inclusive) endDate - Ending date for the report (inclusive) currencyPair - ID of the product to generate a fills report for. E.c. BTC-USD. *Required* if type is fills accountID - ID of the account to generate an account report for. *Required* if type is account format - pdf or csv (default is pdf) email - [optional] Email address to send the report to

func (*CoinbasePro) GetReportStatus

func (c *CoinbasePro) GetReportStatus(reportID string) (Report, error)

GetReportStatus once a report request has been accepted for processing, the status is available by polling the report resource endpoint.

func (*CoinbasePro) GetServerTime

func (c *CoinbasePro) GetServerTime() (ServerTime, error)

GetServerTime returns the API server time

func (*CoinbasePro) GetStats

func (c *CoinbasePro) GetStats(currencyPair string) (Stats, error)

GetStats returns a 24 hr stat for the product. Volume is in base currency units. open, high, low are in quote currency units.

func (*CoinbasePro) GetTicker

func (c *CoinbasePro) GetTicker(currencyPair string) (Ticker, error)

GetTicker returns ticker by currency pair currencyPair - example "BTC-USD"

func (*CoinbasePro) GetTrades

func (c *CoinbasePro) GetTrades(currencyPair string) ([]Trade, error)

GetTrades listd the latest trades for a product currencyPair - example "BTC-USD"

func (*CoinbasePro) GetTrailingVolume

func (c *CoinbasePro) GetTrailingVolume() ([]Volume, error)

GetTrailingVolume this request will return your 30-day trailing volume for all products.

func (*CoinbasePro) GetWithdrawalsHistory

func (c *CoinbasePro) GetWithdrawalsHistory(cur currency.Code) (resp []exchange.WithdrawalHistory, err error)

GetWithdrawalsHistory returns previous withdrawals data

func (*CoinbasePro) MarginTransfer

func (c *CoinbasePro) MarginTransfer(amount float64, transferType, profileID, currency string) (MarginTransfer, error)

MarginTransfer sends funds between a standard/default profile and a margin profile. A deposit will transfer funds from the default profile into the margin profile. A withdraw will transfer funds from the margin profile to the default profile. Withdraws will fail if they would set your margin ratio below the initial margin ratio requirement.

amount - the amount to transfer between the default and margin profile transferType - either "deposit" or "withdraw" profileID - The id of the margin profile to deposit or withdraw from currency - currency to transfer, currently on "BTC" or "USD"

func (*CoinbasePro) ModifyOrder

func (c *CoinbasePro) ModifyOrder(action *order.Modify) (string, error)

ModifyOrder will allow of changing orderbook placement and limit to market conversion

func (*CoinbasePro) PlaceLimitOrder

func (c *CoinbasePro) PlaceLimitOrder(clientRef string, price, amount float64, side, timeInforce, cancelAfter, productID, stp string, postOnly bool) (string, error)

PlaceLimitOrder places a new limit order. Orders can only be placed if the account has sufficient funds. Once an order is placed, 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.

GENERAL PARAMS clientRef - [optional] Order ID selected by you to identify your order side - buy or sell productID - A valid product id stp - [optional] Self-trade prevention flag

LIMIT ORDER PARAMS price - Price per bitcoin amount - Amount of BTC to buy or sell timeInforce - [optional] GTC, GTT, IOC, or FOK (default is GTC) cancelAfter - [optional] min, hour, day * Requires time_in_force to be GTT postOnly - [optional] Post only flag Invalid when time_in_force is IOC or FOK

func (*CoinbasePro) PlaceMarginOrder

func (c *CoinbasePro) PlaceMarginOrder(clientRef string, size, funds float64, side, productID, stp string) (string, error)

PlaceMarginOrder places a new market order. Orders can only be placed if the account has sufficient funds. Once an order is placed, 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.

GENERAL PARAMS clientRef - [optional] Order ID selected by you to identify your order side - buy or sell productID - A valid product id stp - [optional] Self-trade prevention flag

MARGIN ORDER PARAMS size - [optional]* Desired amount in BTC funds - [optional]* Desired amount of quote currency to use

func (*CoinbasePro) PlaceMarketOrder

func (c *CoinbasePro) PlaceMarketOrder(clientRef string, size, funds float64, side, productID, stp string) (string, error)

PlaceMarketOrder places a new market order. Orders can only be placed if the account has sufficient funds. Once an order is placed, 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.

GENERAL PARAMS clientRef - [optional] Order ID selected by you to identify your order side - buy or sell productID - A valid product id stp - [optional] Self-trade prevention flag

MARKET ORDER PARAMS size - [optional]* Desired amount in BTC funds [optional]* Desired amount of quote currency to use * One of size or funds is required.

func (*CoinbasePro) ProcessSnapshot

func (c *CoinbasePro) ProcessSnapshot(snapshot *WebsocketOrderbookSnapshot) error

ProcessSnapshot processes the initial orderbook snap shot

func (*CoinbasePro) ProcessUpdate

func (c *CoinbasePro) ProcessUpdate(update WebsocketL2Update) error

ProcessUpdate updates the orderbook local cache

func (*CoinbasePro) Run

func (c *CoinbasePro) Run()

Run implements the coinbasepro wrapper

func (*CoinbasePro) SendAuthenticatedHTTPRequest

func (c *CoinbasePro) SendAuthenticatedHTTPRequest(ep exchange.URL, method, path string, params map[string]interface{}, result interface{}) (err error)

SendAuthenticatedHTTPRequest sends an authenticated HTTP request

func (*CoinbasePro) SendHTTPRequest

func (c *CoinbasePro) SendHTTPRequest(ep exchange.URL, path string, result interface{}) error

SendHTTPRequest sends an unauthenticated HTTP request

func (*CoinbasePro) SetDefaults

func (c *CoinbasePro) SetDefaults()

SetDefaults sets default values for the exchange

func (*CoinbasePro) Setup

func (c *CoinbasePro) Setup(exch *config.ExchangeConfig) error

Setup initialises the exchange parameters with the current configuration

func (*CoinbasePro) Start

func (c *CoinbasePro) Start(wg *sync.WaitGroup)

Start starts the coinbasepro go routine

func (*CoinbasePro) SubmitOrder

func (c *CoinbasePro) SubmitOrder(s *order.Submit) (order.SubmitResponse, error)

SubmitOrder submits a new order

func (*CoinbasePro) Subscribe

func (c *CoinbasePro) Subscribe(channelsToSubscribe []stream.ChannelSubscription) error

Subscribe sends a websocket message to receive data from the channel

func (*CoinbasePro) Unsubscribe

func (c *CoinbasePro) Unsubscribe(channelsToUnsubscribe []stream.ChannelSubscription) error

Unsubscribe sends a websocket message to stop receiving data from the channel

func (*CoinbasePro) UpdateAccountInfo

func (c *CoinbasePro) UpdateAccountInfo(assetType asset.Item) (account.Holdings, error)

UpdateAccountInfo retrieves balances for all enabled currencies for the coinbasepro exchange

func (*CoinbasePro) UpdateOrderbook

func (c *CoinbasePro) UpdateOrderbook(p currency.Pair, assetType asset.Item) (*orderbook.Base, error)

UpdateOrderbook updates and returns the orderbook for a currency pair

func (*CoinbasePro) UpdateTicker

func (c *CoinbasePro) UpdateTicker(p currency.Pair, assetType asset.Item) (*ticker.Price, error)

UpdateTicker updates and returns the ticker for a currency pair

func (*CoinbasePro) UpdateTradablePairs

func (c *CoinbasePro) UpdateTradablePairs(forceUpdate bool) error

UpdateTradablePairs updates the exchanges available pairs and stores them in the exchanges config

func (*CoinbasePro) ValidateCredentials

func (c *CoinbasePro) ValidateCredentials(assetType asset.Item) error

ValidateCredentials validates current credentials used for wrapper functionality

func (*CoinbasePro) WithdrawCrypto

func (c *CoinbasePro) WithdrawCrypto(amount float64, currency, cryptoAddress string) (DepositWithdrawalInfo, error)

WithdrawCrypto withdraws funds to a crypto address

amount - The amount to withdraw currency - The type of currency cryptoAddress - A crypto address of the recipient

func (*CoinbasePro) WithdrawCryptocurrencyFunds

func (c *CoinbasePro) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is submitted

func (*CoinbasePro) WithdrawFiatFunds

func (c *CoinbasePro) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawFiatFunds returns a withdrawal ID when a withdrawal is submitted

func (*CoinbasePro) WithdrawFiatFundsToInternationalBank

func (c *CoinbasePro) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is submitted

func (*CoinbasePro) WithdrawViaPaymentMethod

func (c *CoinbasePro) WithdrawViaPaymentMethod(amount float64, currency, paymentID string) (DepositWithdrawalInfo, error)

WithdrawViaPaymentMethod withdraws funds to a payment method

amount - The amount to withdraw currency - The type of currency paymentID - ID of the payment method

func (*CoinbasePro) WsConnect

func (c *CoinbasePro) WsConnect() error

WsConnect initiates a websocket connection

type Currency

type Currency struct {
	ID      string
	Name    string
	MinSize float64 `json:"min_size,string"`
}

Currency holds singular currency product information

type DepositWithdrawalInfo

type DepositWithdrawalInfo struct {
	ID       string    `json:"id"`
	Amount   float64   `json:"amount,string"`
	Currency string    `json:"currency"`
	PayoutAt time.Time `json:"payout_at"`
}

DepositWithdrawalInfo holds returned deposit information

type FillResponse

type FillResponse struct {
	TradeID   int64     `json:"trade_id"`
	ProductID string    `json:"product_id"`
	Price     float64   `json:"price,string"`
	Size      float64   `json:"size,string"`
	OrderID   string    `json:"order_id"`
	CreatedAt time.Time `json:"created_at"`
	Liquidity string    `json:"liquidity"`
	Fee       float64   `json:"fee,string"`
	Settled   bool      `json:"settled"`
	Side      string    `json:"side"`
}

FillResponse contains fill information from the exchange

type Funding

type Funding struct {
	ID            string    `json:"id"`
	OrderID       string    `json:"order_id"`
	ProfileID     string    `json:"profile_id"`
	Amount        float64   `json:"amount,string"`
	Status        string    `json:"status"`
	CreatedAt     time.Time `json:"created_at"`
	Currency      string    `json:"currency"`
	RepaidAmount  float64   `json:"repaid_amount"`
	DefaultAmount float64   `json:"default_amount,string"`
	RepaidDefault bool      `json:"repaid_default"`
}

Funding holds funding data

type GeneralizedOrderResponse

type GeneralizedOrderResponse struct {
	ID             string    `json:"id"`
	Price          float64   `json:"price,string"`
	Size           float64   `json:"size,string"`
	ProductID      string    `json:"product_id"`
	Side           string    `json:"side"`
	Stp            string    `json:"stp"`
	Type           string    `json:"type"`
	TimeInForce    string    `json:"time_in_force"`
	PostOnly       bool      `json:"post_only"`
	CreatedAt      time.Time `json:"created_at"`
	FillFees       float64   `json:"fill_fees,string"`
	FilledSize     float64   `json:"filled_size,string"`
	ExecutedValue  float64   `json:"executed_value,string"`
	Status         string    `json:"status"`
	Settled        bool      `json:"settled"`
	Funds          float64   `json:"funds,string"`
	SpecifiedFunds float64   `json:"specified_funds,string"`
	DoneReason     string    `json:"done_reason"`
	DoneAt         string    `json:"done_at"`
}

GeneralizedOrderResponse is the generalized return type across order placement and information collation

type History

type History struct {
	Time   int64   `json:"time"`
	Low    float64 `json:"low"`
	High   float64 `json:"high"`
	Open   float64 `json:"open"`
	Close  float64 `json:"close"`
	Volume float64 `json:"volume"`
}

History holds historic rate information

type LimitInfo

type LimitInfo struct {
	PeriodInDays int `json:"period_in_days"`
	Total        struct {
		Amount   float64 `json:"amount,string"`
		Currency string  `json:"currency"`
	} `json:"total"`
}

LimitInfo is a sub-type for payment method

type MarginTransfer

type MarginTransfer struct {
	CreatedAt       time.Time `json:"created_at"`
	ID              string    `json:"id"`
	UserID          string    `json:"user_id"`
	ProfileID       string    `json:"profile_id"`
	MarginProfileID string    `json:"margin_profile_id"`
	Type            string    `json:"type"`
	Amount          float64   `json:"amount,string"`
	Currency        string    `json:"currency"`
	AccountID       string    `json:"account_id"`
	MarginAccountID string    `json:"margin_account_id"`
	MarginProductID string    `json:"margin_product_id"`
	Status          string    `json:"status"`
	Nonce           int       `json:"nonce"`
}

MarginTransfer holds margin transfer details

type OrderL1L2

type OrderL1L2 struct {
	Price     float64
	Amount    float64
	NumOrders float64
}

OrderL1L2 is a type used in layer conversion

type OrderL3

type OrderL3 struct {
	Price   float64
	Amount  float64
	OrderID string
}

OrderL3 is a type used in layer conversion

type OrderbookL1L2

type OrderbookL1L2 struct {
	Sequence int64       `json:"sequence"`
	Bids     []OrderL1L2 `json:"bids"`
	Asks     []OrderL1L2 `json:"asks"`
}

OrderbookL1L2 holds level 1 and 2 order book information

type OrderbookL3

type OrderbookL3 struct {
	Sequence int64     `json:"sequence"`
	Bids     []OrderL3 `json:"bids"`
	Asks     []OrderL3 `json:"asks"`
}

OrderbookL3 holds level 3 order book information

type OrderbookResponse

type OrderbookResponse struct {
	Sequence int64           `json:"sequence"`
	Bids     [][]interface{} `json:"bids"`
	Asks     [][]interface{} `json:"asks"`
}

OrderbookResponse is a generalized response for order books

type PaymentMethod

type PaymentMethod struct {
	ID            string `json:"id"`
	Type          string `json:"type"`
	Name          string `json:"name"`
	Currency      string `json:"currency"`
	PrimaryBuy    bool   `json:"primary_buy"`
	PrimarySell   bool   `json:"primary_sell"`
	AllowBuy      bool   `json:"allow_buy"`
	AllowSell     bool   `json:"allow_sell"`
	AllowDeposits bool   `json:"allow_deposits"`
	AllowWithdraw bool   `json:"allow_withdraw"`
	Limits        struct {
		Buy        []LimitInfo `json:"buy"`
		InstantBuy []LimitInfo `json:"instant_buy"`
		Sell       []LimitInfo `json:"sell"`
		Deposit    []LimitInfo `json:"deposit"`
	} `json:"limits"`
}

PaymentMethod holds payment method information

type Product

type Product struct {
	ID             string      `json:"id"`
	BaseCurrency   string      `json:"base_currency"`
	QuoteCurrency  string      `json:"quote_currency"`
	BaseMinSize    float64     `json:"base_min_size,string"`
	BaseMaxSize    interface{} `json:"base_max_size"`
	QuoteIncrement float64     `json:"quote_increment,string"`
	DisplayName    string      `json:"string"`
}

Product holds product information

type RateLimit

type RateLimit struct {
	Auth   *rate.Limiter
	UnAuth *rate.Limiter
}

RateLimit implements the request.Limiter interface

func SetRateLimit

func SetRateLimit() *RateLimit

SetRateLimit returns the rate limit for the exchange

func (*RateLimit) Limit

func (r *RateLimit) Limit(f request.EndpointLimit) error

Limit limits outbound calls

type Report

type Report struct {
	ID          string    `json:"id"`
	Type        string    `json:"type"`
	Status      string    `json:"status"`
	CreatedAt   time.Time `json:"created_at"`
	CompletedAt time.Time `json:"completed_at"`
	ExpiresAt   time.Time `json:"expires_at"`
	FileURL     string    `json:"file_url"`
	Params      struct {
		StartDate time.Time `json:"start_date"`
		EndDate   time.Time `json:"end_date"`
	} `json:"params"`
}

Report holds historical information

type ServerTime

type ServerTime struct {
	ISO   time.Time `json:"iso"`
	Epoch float64   `json:"epoch"`
}

ServerTime holds current requested server time information

type Stats

type Stats struct {
	Open        float64 `json:"open,string"`
	High        float64 `json:"high,string"`
	Low         float64 `json:"low,string"`
	Volume      float64 `json:"volume,string"`
	Last        float64 `json:"last,string"`
	Volume30Day float64 `json:"volume_30day,string"`
}

Stats holds last 24 hr data for coinbasepro

type Ticker

type Ticker struct {
	TradeID int64     `json:"trade_id"`
	Ask     float64   `json:"ask,string"`
	Bid     float64   `json:"bid,string"`
	Price   float64   `json:"price,string"`
	Size    float64   `json:"size,string"`
	Volume  float64   `json:"volume,string"`
	Time    time.Time `json:"time"`
}

Ticker holds basic ticker information

type Trade

type Trade struct {
	TradeID int64     `json:"trade_id"`
	Price   float64   `json:"price,string"`
	Size    float64   `json:"size,string"`
	Time    time.Time `json:"time"`
	Side    string    `json:"side"`
}

Trade holds executed trade information

type Volume

type Volume struct {
	ProductID      string  `json:"product_id"`
	ExchangeVolume float64 `json:"exchange_volume,string"`
	Volume         float64 `json:"volume,string"`
	RecordedAt     string  `json:"recorded_at"`
}

Volume type contains trailing volume information

type WebsocketHeartBeat

type WebsocketHeartBeat struct {
	Type        string `json:"type"`
	Sequence    int64  `json:"sequence"`
	LastTradeID int64  `json:"last_trade_id"`
	ProductID   string `json:"product_id"`
	Time        string `json:"time"`
}

WebsocketHeartBeat defines JSON response for a heart beat message

type WebsocketL2Update

type WebsocketL2Update struct {
	Type      string          `json:"type"`
	ProductID string          `json:"product_id"`
	Time      string          `json:"time"`
	Changes   [][]interface{} `json:"changes"`
}

WebsocketL2Update defines an update on the L2 orderbooks

type WebsocketOrderbookSnapshot

type WebsocketOrderbookSnapshot struct {
	ProductID string          `json:"product_id"`
	Type      string          `json:"type"`
	Bids      [][]interface{} `json:"bids"`
	Asks      [][]interface{} `json:"asks"`
}

WebsocketOrderbookSnapshot defines a snapshot response

type WebsocketSubscribe

type WebsocketSubscribe struct {
	Type       string       `json:"type"`
	ProductIDs []string     `json:"product_ids,omitempty"`
	Channels   []WsChannels `json:"channels,omitempty"`
	Signature  string       `json:"signature,omitempty"`
	Key        string       `json:"key,omitempty"`
	Passphrase string       `json:"passphrase,omitempty"`
	Timestamp  string       `json:"timestamp,omitempty"`
}

WebsocketSubscribe takes in subscription information

type WebsocketTicker

type WebsocketTicker struct {
	Type      string        `json:"type"`
	Sequence  int64         `json:"sequence"`
	ProductID currency.Pair `json:"product_id"`
	Price     float64       `json:"price,string"`
	Open24H   float64       `json:"open_24h,string"`
	Volume24H float64       `json:"volume_24h,string"`
	Low24H    float64       `json:"low_24h,string"`
	High24H   float64       `json:"high_24h,string"`
	Volume30D float64       `json:"volume_30d,string"`
	BestBid   float64       `json:"best_bid,string"`
	BestAsk   float64       `json:"best_ask,string"`
	Side      string        `json:"side"`
	Time      time.Time     `json:"time"`
	TradeID   int64         `json:"trade_id"`
	LastSize  float64       `json:"last_size,string"`
}

WebsocketTicker defines ticker websocket response

type WsChannels

type WsChannels struct {
	Name       string   `json:"name"`
	ProductIDs []string `json:"product_ids,omitempty"`
}

WsChannels defines outgoing channels for subscription purposes

Jump to

Keyboard shortcuts

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