Documentation ¶
Index ¶
- Constants
- func NewRequest(method, path string, data interface{}) (req *http.Request, bodyString string, err error)
- type AccountBalanceItem
- type AccountBalanceResponse
- type AccountTradingFeeResponse
- type AmountDecimal
- type AmountWhole
- type Client
- func (c *Client) AccountBalance() (*AccountBalanceResponse, error)
- func (c *Client) AccountTradingFee(instrument Instrument, currency Currency) (*AccountTradingFeeResponse, error)
- func (c *Client) Get(path string, v interface{}, rateLimit RateLimitValue) error
- func (c *Client) Limit10() error
- func (c *Client) MarketOrderbook(instrument Instrument, currency Currency) (*MarketOrderbookResponse, error)
- func (c *Client) MarketTick(instrument Instrument, currency Currency) (*MarketTickResponse, error)
- func (c *Client) MarketTrades(instrument Instrument, currency Currency, since OrderID) (*MarketTradesResponse, error)
- func (c *Client) OrderCancel(orderIDs ...OrderID) (*OrderCancelResponse, error)
- func (c *Client) OrderCreate(currency Currency, instrument Instrument, price AmountWhole, ...) (*OrderCreateResponse, error)
- func (c *Client) OrderDetail(orderIDs ...OrderID) (*OrderDetailResponse, error)
- func (c *Client) OrderHistory(currency Currency, instrument Instrument, limit int, since OrderID) (*OrderHistoryResponse, error)
- func (c *Client) OrderOpen(currency Currency, instrument Instrument, limit int, since OrderID) (*OrderOpenResponse, error)
- func (c *Client) Post(path string, data interface{}, v interface{}, rateLimit RateLimitValue) error
- func (c *Client) String() string
- func (c *Client) WithdrawCrypto(amount AmountWhole, currency Currency, address string) (*FundTransferWithdrawCryptoResponse, error)
- func (c *Client) WithdrawEFT(amount AmountWhole, currency Currency, ...) (*FundTransferWithdrawEFTResponse, error)
- type Currency
- type FundTransferWithdrawCryptoRequest
- type FundTransferWithdrawCryptoResponse
- type FundTransferWithdrawEFTRequest
- type FundTransferWithdrawEFTResponse
- type Instrument
- type MarketOrderbookResponse
- type MarketTickResponse
- type MarketTradeDataItem
- type MarketTradesResponse
- type OrderCancelData
- type OrderCancelResponse
- type OrderCreateRequest
- type OrderCreateResponse
- type OrderDataItem
- type OrderDetailResponse
- type OrderHistoryRequest
- type OrderHistoryResponse
- type OrderID
- type OrderOpenRequest
- type OrderOpenResponse
- type OrderSide
- type OrderStatus
- type OrderTradeDataItem
- type OrderType
- type OrdersSpecificRequest
- type RateLimitValue
- type TradeID
Constants ¶
const ( // OrderStatusNew is an order which is created but has not yet been placed OrderStatusNew = "New" // OrderStatusPlaced is a placed order which is unfilled OrderStatusPlaced = "Placed" // OrderStatusFailed is an order which has failed OrderStatusFailed = "Failed" // OrderStatusError is an order which has failed due to an error OrderStatusError = "Error" // OrderStatusCancelled is an order cancelled by the client OrderStatusCancelled = "Cancelled" // OrderStatusPartiallyCancelled is an order that has been partially // completed, but cancelled before fully matched / completed OrderStatusPartiallyCancelled = "Partially Cancelled" // OrderStatusFullyMatched is a completed successful order OrderStatusFullyMatched = "Fully Matched" // OrderStatusPartiallyMatched is a partially completed order for which some // of the instrument has been traded, but not enough to complete the order OrderStatusPartiallyMatched = "Partially Matched" )
const (
// BaseURL is the protocol, and domain of the API to connect to.
BaseURL = "https://api.btcmarkets.net"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AccountBalanceItem ¶ added in v0.2.0
type AccountBalanceItem struct { Currency Currency `json:"currency"` Balance AmountWhole `json:"balance"` Pending AmountWhole `json:"pendingFunds"` }
AccountBalanceItem is the data structure that represents currency account balance.
func (*AccountBalanceItem) String ¶ added in v0.2.0
func (ab *AccountBalanceItem) String() string
type AccountBalanceResponse ¶ added in v0.2.0
type AccountBalanceResponse []AccountBalanceItem
AccountBalanceResponse represents the JSON data structure sent to the GET /account/balance endpoint.
func (AccountBalanceResponse) GetBalance ¶ added in v0.2.0
func (a AccountBalanceResponse) GetBalance(currency Currency) AmountWhole
GetBalance returns the balance of the provided currency.
type AccountTradingFeeResponse ¶ added in v0.2.0
type AccountTradingFeeResponse struct { Success bool `json:"success"` ErrorCode int `json:"errorCode"` ErrorMessage string `json:"errorMessage"` TradingFee AmountWhole `json:"tradingFeeRate"` Volume30Days AmountWhole `json:"volume30Day"` }
AccountTradingFeeResponse represents the JSON data structure sent to the GET /account/:instrument/:currency/tradingfee endpoint.
type AmountDecimal ¶
type AmountDecimal float64
AmountDecimal is a float type which represents the API numbers returned which can have decimal places.
The AmountDecimal is 1/100000000 of an AmountWhole.
func (AmountDecimal) ToAmountWhole ¶
func (amount AmountDecimal) ToAmountWhole() AmountWhole
ToAmountWhole converts from AmountDecimal to AmountWhole by multiplication by 100000000 (used by API)
func (AmountDecimal) TrimCurrency ¶
func (amount AmountDecimal) TrimCurrency() AmountDecimal
type AmountWhole ¶
type AmountWhole int64
AmountWhole is an integer type which represents the API numbers returned which can have decimal places.
The AmountWhole is 100000000x an AmountDecimal.
func (AmountWhole) ToAmountDecimal ¶
func (amount AmountWhole) ToAmountDecimal() AmountDecimal
ToAmountDecimal converts from AmountWhole to AmountDecimal by division by 100000000 (used by API)
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the main struct type representing an interface with the API as a particular client user. It is stateless and obtains state/object information from API calls. The client is limited to 25 calls per 10 seconds on certain API endpoints, and 10 calls per 10 seconds on others. It is concurrency safe. (documented at https://github.com/BTCMarkets/API/wiki/faq)
func NewClient ¶
NewClient constructs a new Client for communicating with the BTC Markets API. Both your API key and secret are required. The secret should be provided as displayed in your BTC Markets account, as a base-64 encoded string.
func (*Client) AccountBalance ¶
func (c *Client) AccountBalance() (*AccountBalanceResponse, error)
AccountBalance implements the GET /account/balance endpoint.
func (*Client) AccountTradingFee ¶
func (c *Client) AccountTradingFee(instrument Instrument, currency Currency) (*AccountTradingFeeResponse, error)
AccountTradingFee implements the /account/:instrument/:currency/tradingfee endpoint.
func (*Client) Get ¶ added in v0.2.0
func (c *Client) Get(path string, v interface{}, rateLimit RateLimitValue) error
Get handles a GET request to any BTC Markest API endpoint.
func (*Client) MarketOrderbook ¶
func (c *Client) MarketOrderbook(instrument Instrument, currency Currency) (*MarketOrderbookResponse, error)
MarketOrderbook implements the GET /market/:instrument/:currency/orderbook endpoint.
func (*Client) MarketTick ¶
func (c *Client) MarketTick(instrument Instrument, currency Currency) (*MarketTickResponse, error)
MarketTick implements the GET /market/:instrument/:currency/tick endpoint.
func (*Client) MarketTrades ¶
func (c *Client) MarketTrades(instrument Instrument, currency Currency, since OrderID) (*MarketTradesResponse, error)
MarketTrades implements the GET /market/:instrument/:currency/trades endpoint.
"since" is an optional parameter which, when greater than 0 will only get MarketTrades which occurred since the supplied trade ID.
func (*Client) OrderCancel ¶
func (c *Client) OrderCancel(orderIDs ...OrderID) (*OrderCancelResponse, error)
OrderCancel implements the POST /order/cancel endpoint.
func (*Client) OrderCreate ¶
func (c *Client) OrderCreate( currency Currency, instrument Instrument, price AmountWhole, volume AmountWhole, side OrderSide, ordertype OrderType, requestID string, ) (*OrderCreateResponse, error)
OrderCreate implements the POST /order/create endpoint.
func (*Client) OrderDetail ¶
func (c *Client) OrderDetail(orderIDs ...OrderID) (*OrderDetailResponse, error)
OrderDetail implements the POST /order/detail API endpoint
func (*Client) OrderHistory ¶
func (c *Client) OrderHistory(currency Currency, instrument Instrument, limit int, since OrderID) (*OrderHistoryResponse, error)
OrderHistory implements the POST /order/history API endpoint
func (*Client) OrderOpen ¶
func (c *Client) OrderOpen(currency Currency, instrument Instrument, limit int, since OrderID) (*OrderOpenResponse, error)
OrderOpen implements the POST /order/open API endpoint
func (*Client) Post ¶ added in v0.2.0
func (c *Client) Post(path string, data interface{}, v interface{}, rateLimit RateLimitValue) error
Post handles a POST request to any BTC Markest API endpoint.
func (*Client) WithdrawCrypto ¶
func (c *Client) WithdrawCrypto(amount AmountWhole, currency Currency, address string) (*FundTransferWithdrawCryptoResponse, error)
WithdrawCrypto implements the POST /fundtransfer/withdrawCrypto API endpoint
func (*Client) WithdrawEFT ¶
func (c *Client) WithdrawEFT(amount AmountWhole, currency Currency, accountName, accountNumber, bankName, bsb string) (*FundTransferWithdrawEFTResponse, error)
WithdrawEFT implements the POST /fundtransfer/withdrawEFT API endpoint
type Currency ¶
type Currency string
Currency represents the name of a real-world or crypto currency
type FundTransferWithdrawCryptoRequest ¶ added in v0.2.0
type FundTransferWithdrawCryptoRequest struct { Amount AmountWhole `json:"amount"` Address string `json:"address"` Currency Currency `json:"currency"` }
FundTransferWithdrawCryptoRequest represents the required information for a crypto tranfer.
type FundTransferWithdrawCryptoResponse ¶ added in v0.2.0
type FundTransferWithdrawCryptoResponse struct { Success bool `json:"success"` ErrorCode string `json:"errorCode"` ErrorMessage string `json:"errorMessage"` Status string `json:"status"` FundTransferID int64 `json:"fundTransferId"` Description string `json:"description"` Created int64 `json:"creationTime"` Currency Currency `json:"currency"` Amount AmountWhole `json:"amount"` Fee AmountWhole `json:"fee"` }
FundTransferWithdrawCryptoResponse represents the JSON data structure returned from the POST /fundtransfer/withdrawCrypto endpoint.
type FundTransferWithdrawEFTRequest ¶ added in v0.2.0
type FundTransferWithdrawEFTRequest struct { AccountName string `json:"accountName"` AccountNumber string `json:"accountNumber"` BankName string `json:"bankName"` BSB string `json:"bsbNumber"` Amount AmountWhole `json:"amount"` Currency Currency `json:"currency"` }
FundTransferWithdrawEFTRequest represents the required information for an external EFT tranfer
type FundTransferWithdrawEFTResponse ¶ added in v0.2.0
type FundTransferWithdrawEFTResponse struct {
FundTransferWithdrawCryptoResponse
}
FundTransferWithdrawEFTResponse represents the JSON data structure returned from the POST /fundtransfer/withdrawEFT endpoint. it sharres the same data structure as FundTransferWithdrawCryptoResponse.
type Instrument ¶
type Instrument string
Instrument represents the name of a crypto currency
const ( InstrumentBcash Instrument = "BCH" InstrumentBitcoin Instrument = "BTC" InstrumentEthereum Instrument = "ETH" InstrumentEthClassic Instrument = "ETC" InstrumentLitecoin Instrument = "LTC" InstrumentRipple Instrument = "XRP" )
Enumerated instruments.
type MarketOrderbookResponse ¶ added in v0.2.0
type MarketOrderbookResponse struct { Bids [][]float64 `json:"bids"` Asks [][]float64 `json:"asks"` Currency Currency `json:"currency"` Instrument Instrument `json:"instrument"` Timestamp int64 `json:"timestamp"` }
MarketOrderbookResponse represents the JSON data structure returned from the GET /market/:instrument/:currency/orderbook endpoint.
type MarketTickResponse ¶ added in v0.2.0
type MarketTickResponse struct { Bid AmountDecimal `json:"bestBid"` Ask AmountDecimal `json:"bestAsk"` Last AmountDecimal `json:"lastPrice"` Currency Currency `json:"currency"` Instrument Instrument `json:"instrument"` Timestamp int64 `json:"timestamp"` Volume float64 `json:"volume24h"` }
MarketTickResponse represents the JSON data structure returned from the GET /market/:instrument/:currency/tick endpoint.
type MarketTradeDataItem ¶ added in v0.2.0
type MarketTradeDataItem struct { TradeID TradeID `json:"tid"` Amount AmountDecimal `json:"amount"` Price AmountDecimal `json:"price"` Timestamp int64 `json:"date"` }
MarketTradeDataItem is the data structure that represents a single trade
func (*MarketTradeDataItem) String ¶ added in v0.2.0
func (mtdi *MarketTradeDataItem) String() string
String is a helper method for displaying a trade in human-readable format.
type MarketTradesResponse ¶ added in v0.2.0
type MarketTradesResponse []MarketTradeDataItem
MarketTradesResponse represents the JSON data structure returned from the GET /market/:instrument/:currency/trades endpoint.
func (*MarketTradesResponse) Describe ¶ added in v0.2.0
func (mtr *MarketTradesResponse) Describe() string
Describe is a helper method for displaying trades in human-readable format.
type OrderCancelData ¶ added in v0.2.0
type OrderCancelData struct { Success bool `json:"success"` ErrorCode int `json:"errorCode"` ErrorMessage string `json:"errorMessage"` ID OrderID `json:"id"` }
OrderCancelData represents the JSON data structure of a cancel order.
type OrderCancelResponse ¶ added in v0.2.0
type OrderCancelResponse struct { Success bool `json:"success"` ErrorCode int `json:"errorCode"` ErrorMessage string `json:"errorMessage"` Responses []OrderCancelData `json:"responses"` }
OrderCancelResponse represents the JSON data structure returned from the POST /order/cancel endpoint.
type OrderCreateRequest ¶ added in v0.2.0
type OrderCreateRequest struct { Currency Currency `json:"currency"` Instrument Instrument `json:"instrument"` Price AmountWhole `json:"price"` Volume AmountWhole `json:"volume"` OrderSide OrderSide `json:"orderSide"` OrderType OrderType `json:"ordertype"` ClientRequestID string `json:"clientRequestId"` }
OrderCreateRequest represents the JSON data structure sent to the POST /order/create endpoint.
type OrderCreateResponse ¶ added in v0.2.0
type OrderCreateResponse struct { Success bool `json:"success"` ErrorCode int `json:"errorCode"` ErrorMessage string `json:"errorMessage"` ID OrderID `json:"id"` ClientRequestID string `json:"clientRequestId"` }
OrderCreateResponse represents the JSON data structure returned from the POST /order/create endpoint.
type OrderDataItem ¶ added in v0.2.0
type OrderDataItem struct { OrderID OrderID `json:"id"` Currency Currency `json:"currency"` Instrument Instrument `json:"instrument"` OrderSide OrderSide `json:"orderSide"` OrderType OrderType `json:"ordertype"` Created int64 `json:"creationTime"` Status OrderStatus `json:"status"` ErrorMessage string `json:"errorMessage"` Price AmountWhole `json:"price"` Volume AmountWhole `json:"volume"` VolumeOpen AmountWhole `json:"openVolume"` Trades []OrderTradeDataItem `json:"trades"` }
OrderDataItem is the data structure that represents a single order
type OrderDetailResponse ¶ added in v0.2.0
type OrderDetailResponse struct { Success bool `json:"success"` ErrorCode string `json:"errorCode"` ErrorMessage string `json:"errorMessage"` Orders []OrderDataItem `josn:"orders"` }
OrderDetailResponse represents the JSON data structure returned from the POST /order/detail endpoint.
type OrderHistoryRequest ¶ added in v0.2.0
type OrderHistoryRequest struct { Currency Currency `json:"currency"` Instrument Instrument `json:"instrument"` Limit int `json:"limit"` Since OrderID `json:"since"` }
OrderHistoryRequest represents the JSON data structure sent to the POST /order/history endpoint.
type OrderHistoryResponse ¶ added in v0.2.0
type OrderHistoryResponse struct {
OrderDetailResponse
}
OrderHistoryResponse represents the JSON data structure returned from the POST /order/history endpoint. It shares the same data structure as OrderDetailResponse
type OrderID ¶
type OrderID int64
OrderID is an integer representing the returned ID of a created order
type OrderOpenRequest ¶ added in v0.2.0
type OrderOpenRequest struct {
OrderHistoryRequest
}
OrderOpenRequest represents the JSON data structure sent to the POST /order/open endpoint. It shares the same data structure as OrderHistoryRequest
type OrderOpenResponse ¶ added in v0.2.0
type OrderOpenResponse struct {
OrderDetailResponse
}
OrderOpenResponse represents the JSON data structure returned from the POST /order/open endpoint. It shares the same data structure as OrderDetailResponse
type OrderSide ¶
type OrderSide string
OrderSide is used when creating an order to state whether the order is an ask (sell), or a bid (buy).
type OrderStatus ¶
type OrderStatus string
OrderStatus is a string which describes the status of the order after being made.
type OrderTradeDataItem ¶ added in v0.2.0
type OrderTradeDataItem struct { TradeID TradeID `json:"id"` Created int64 `json:"creationTime"` Description string `json:"description"` Price AmountWhole `json:"price"` Volume AmountWhole `json:"volume"` Fee AmountWhole `json:"fee"` }
OrderTradeDataItem is the data structure that represents a single trade
type OrderType ¶
type OrderType string
OrderType is used when creating an order to state whether the order is limited by the provided parameters, or whether to place the order at the market value.
type OrdersSpecificRequest ¶ added in v0.2.0
type OrdersSpecificRequest struct {
Orders []OrderID `json:"orderIds"`
}
OrdersSpecificRequest is the data structure for sending multiple orders ids for endpoints that support that feature.
type RateLimitValue ¶ added in v0.2.0
type RateLimitValue int
RateLimitValue represent a rate limiting value in the form of an int