Documentation ¶
Index ¶
- Constants
- type APIError
- type Balance
- type BalanceMap
- type BaseOrder
- type Client
- func (client *Client) CreateOrder(requestOrder BaseOrder) (order OrderSummary, err error)
- func (client *Client) DeleteAllOrders(options *DeleteAllOrdersOpts) (err error)
- func (client *Client) DeleteOrderById(orderId int64) error
- func (client *Client) GetAllTicker() (tickers Tickers, err error)
- func (client *Client) GetBalances() (balances BalanceMap, err error)
- func (client *Client) GetFees() (fees Fees, err error)
- func (client *Client) GetFills(options *GetFillsOpts) (fills []OrderSummary, err error)
- func (client *Client) GetL2Orderbook(market string) (orderbook OrderBook, err error)
- func (client *Client) GetL3Orderbook(market string) (orderbook OrderBook, err error)
- func (client *Client) GetOrderById(orderId int64) (order OrderSummary, err error)
- func (client *Client) GetOrders(options *GetOrdersOpts) (orders []OrderSummary, err error)
- func (client *Client) GetSymbol(market string) (symbol Symbol, err error)
- func (client *Client) GetSymbols() (symbols []Symbol, err error)
- func (client *Client) GetTicker(market string) (ticker Ticker, err error)
- func (client *Client) GetTrades(options *GetTradesOpts) (trades []Trade, err error)
- type DeleteAllOrdersOpts
- type Fees
- type GetFillsOpts
- type GetOrdersOpts
- type GetTradesOpts
- type OrdType
- type OrderBook
- type OrderBookEntry
- type OrderStatus
- type OrderSummary
- type Side
- type Symbol
- type Ticker
- type Tickers
- type TimeInForce
- type Trade
Constants ¶
const (
API_BASE = "https://api.blockchain.com/v3/exchange" // BCEX API endpoint
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BalanceMap ¶
type BalanceMap struct {
Primary []Balance `json:"primary"`
}
type BaseOrder ¶
type BaseOrder struct { // Reference field provided by client. Cannot exceed 20 characters, only alphanumeric characters are allowed. ClOrdId string `json:"clOrdId"` OrdType OrdType `json:"ordType"` // Blockchain symbol identifier Symbol string `json:"symbol"` Side Side `json:"side"` // The order size in the terms of the base currency OrderQty float64 `json:"orderQty"` TimeInForce TimeInForce `json:"timeInForce,omitempty"` // The limit price for the order Price float64 `json:"price,omitempty"` // expiry date in the format YYYYMMDD ExpireDate int32 `json:"expireDate,omitempty"` // The minimum quantity required for an IOC fill MinQty float64 `json:"minQty,omitempty"` // The limit price for the order StopPx float64 `json:"stopPx,omitempty"` }
BaseOrder struct for BaseOrder
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClientWithCustomHttpConfig ¶
NewClientWithCustomHttpConfig returns a new HTTP client using the predefined http client
func NewClientWithCustomTimeout ¶
NewClient returns a new HTTP client with custom timeout
func (*Client) CreateOrder ¶
func (client *Client) CreateOrder(requestOrder BaseOrder) (order OrderSummary, err error)
CreateOrder Add an order
- @param baseOrder Trade
@return OrderSummary
func (*Client) DeleteAllOrders ¶
func (client *Client) DeleteAllOrders(options *DeleteAllOrdersOpts) (err error)
DeleteAllOrders Delete all open orders (of a symbol, if specified)
- @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
- @param optional nil or *DeleteAllOrdersOpts - Optional Parameters:
- @param "Symbol" (optional.String) -
func (*Client) DeleteOrderById ¶
DeleteOrderById cancel a specific order
- @param orderId Order ID
@return OrderSummary
func (*Client) GetAllTicker ¶
GetAllTicker is used to get the current ticker values for all markets.
func (*Client) GetBalances ¶
func (client *Client) GetBalances() (balances BalanceMap, err error)
GetBalances is used to retrieve all balances from your account
func (*Client) GetFills ¶
func (client *Client) GetFills(options *GetFillsOpts) (fills []OrderSummary, err error)
GetFills Get a list of filled orders Returns filled orders, including partial fills. Returns at most 100 results, use timestamp to paginate for further results
- @param nil or *GetFillsOpts - Parameters:
- @param "Symbol" (string) - Only return results for this symbol
- @param "From" (int64) - Epoch timestamp in ms
- @param "To" (optional.Int64) - Epoch timestamp in ms
- @param "Limit" (optional.Int32) - Maximum amount of results to return in a single call. If omitted, 100 results are returned by default.
@return []OrderSummary
func (*Client) GetL2Orderbook ¶
GetL2Orderbook is used to get the current level 2 order book for a market.
func (*Client) GetL3Orderbook ¶
GetL3Orderbook is used to get the current level 2 order book for a market.
func (*Client) GetOrderById ¶
func (client *Client) GetOrderById(orderId int64) (order OrderSummary, err error)
GetOrderById Get a specific order
- @param orderId Order ID
@return OrderSummary
func (*Client) GetOrders ¶
func (client *Client) GetOrders(options *GetOrdersOpts) (orders []OrderSummary, err error)
GetOrders Get a list orders Returns live and historic orders, defaulting to live orders. Returns at most 100 results, use timestamp to paginate for further results
- @param nil or *GetOrdersOpts - Optional Parameters:
- @param "Symbol" (string) - Only return results for this symbol
- @param "From" (int64) - Epoch timestamp in ms
- @param "To" (int64) - Epoch timestamp in ms
- @param "Status" (interface of OrderStatus) - Order Status
- @param "Limit" (int32) - Maximum amount of results to return in a single call. If omitted, 100 results are returned by default.
@return []OrderSummary
func (*Client) GetSymbols ¶
GetSymbols is used to get the open and available trading markets along with other meta data.
func (*Client) GetTrades ¶
func (client *Client) GetTrades(options *GetTradesOpts) (trades []Trade, err error)
GetTrades used to retrieve your trade history. * @param nil or *GetTradesOpts - Optional Parameters: * @param "Symbol" (string) - Only return results for this symbol * @param "From" (int64) - Epoch timestamp in ms * @param "To" (int64) - Epoch timestamp in ms * @param "Limit" (int32) - Maximum amount of results to return in a single call. If omitted, 100 results are returned by default.
type DeleteAllOrdersOpts ¶
type DeleteAllOrdersOpts struct {
Symbol string
}
DeleteAllOrdersOpts Optional parameters for the method 'DeleteAllOrders'
type GetFillsOpts ¶
GetFillsOpts Optional parameters for the method 'GetFills'
type GetOrdersOpts ¶
GetOrdersOpts Optional parameters for the method 'GetOrders'
type GetTradesOpts ¶
GetTradesOpts Optional parameters for the method 'GetTrades'
type OrderBook ¶
type OrderBook struct { // Blockchain symbol identifier Symbol string `json:"symbol,omitempty"` Bids []OrderBookEntry `json:"bids,omitempty"` Asks []OrderBookEntry `json:"asks,omitempty"` }
type OrderBookEntry ¶
type OrderStatus ¶
type OrderStatus string
OrderStatus the model 'OrderStatus'
const ( OPEN OrderStatus = "OPEN" REJECTED OrderStatus = "REJECTED" CANCELED OrderStatus = "CANCELED" FILLED OrderStatus = "FILLED" PART_FILLED OrderStatus = "PART_FILLED" EXPIRED OrderStatus = "EXPIRED" )
List of OrderStatus
type OrderSummary ¶
type OrderSummary struct { // The unique order id assigned by the exchange ExOrdId int64 `json:"exOrdId,omitempty"` // Reference field provided by client. Cannot exceed 20 characters, only alphanumeric characters are allowed. ClOrdId string `json:"clOrdId"` OrdType OrdType `json:"ordType"` OrdStatus OrderStatus `json:"ordStatus"` Side Side `json:"side"` // The limit price for the order Price float64 `json:"price,omitempty"` // The reason for rejecting the order, if applicable Text string `json:"text,omitempty"` // Blockchain symbol identifier Symbol string `json:"symbol"` LastShares float64 `json:"lastShares,omitempty"` // The executed price for the last fill LastPx float64 `json:"lastPx,omitempty"` // For Open and Partially Filled orders this is the remaining quantity open for execution. For Canceled and Expired orders this is the quantity than was still open before cancellation/expiration. For Rejected order this is equal to orderQty. For other states this is always zero. LeavesQty float64 `json:"leavesQty,omitempty"` // The quantity of the order which has been filled CumQty float64 `json:"cumQty,omitempty"` // Calculated the Volume Weighted Average Price of all fills for this order AvgPx float64 `json:"avgPx,omitempty"` // Time in ms since 01/01/1970 (epoch) Timestamp int64 `json:"timestamp,omitempty"` }
OrderSummary struct for OrderSummary
type Symbol ¶
type Symbol struct { // Blockchain symbol identifier BaseCurrency string `json:"base_currency,omitempty"` // The number of decimals the currency can be split in BaseCurrencyScale int32 `json:"base_currency_scale,omitempty"` // Blockchain symbol identifier CounterCurrency string `json:"counter_currency,omitempty"` // The number of decimals the currency can be split in CounterCurrencyScale int32 `json:"counter_currency_scale,omitempty"` // The price of the instrument must be a multiple of min_price_increment * (10^-min_price_increment_scale) MinPriceIncrement int64 `json:"min_price_increment,omitempty"` MinPriceIncrementScale int32 `json:"min_price_increment_scale,omitempty"` // The minimum quantity for an order for this instrument must be min_order_size*(10^-min_order_size_scale) MinOrderSize int64 `json:"min_order_size,omitempty"` MinOrderSizeScale int32 `json:"min_order_size_scale,omitempty"` // The maximum quantity for an order for this instrument is max_order_size*(10^-max_order_size_scale). If this equal to zero, there is no limit MaxOrderSize int64 `json:"max_order_size,omitempty"` MaxOrderSizeScale int32 `json:"max_order_size_scale,omitempty"` LotSize int64 `json:"lot_size,omitempty"` LotSizeScale int32 `json:"lot_size_scale,omitempty"` // Symbol status; open, close, suspend, halt, halt-freeze. Status string `json:"status,omitempty"` Id int64 `json:"id,omitempty"` // If the symbol is halted and will open on an auction, this will be the opening price. AuctionPrice float64 `json:"auction_price,omitempty"` // Opening size AuctionSize float64 `json:"auction_size,omitempty"` // Opening time in HHMM format AuctionTime string `json:"auction_time,omitempty"` // Auction imbalance. If > 0 then there will be buy orders left over at the auction price. If < 0 then there will be sell orders left over at the auction price. Imbalance float64 `json:"imbalance,omitempty"` }
Symbol represents data of a Currency Pair on a market.
type Ticker ¶
type Ticker struct { Symbol string `json:"symbol,omitempty"` Price24h float64 `json:"price_24h,omitempty"` Volume24h float64 `json:"volume_24h,omitempty"` LastTradePrice float64 `json:"last_trade_price,omitempty"` }
Ticker represents a Ticker from hitbtc API.
type TimeInForce ¶
type TimeInForce string
TimeInForce \"GTC\" for Good Till Cancel, \"IOC\" for Immediate or Cancel, \"FOK\" for Fill or Kill, \"GTD\" Good Till Date
const ( GTC TimeInForce = "GTC" IOC TimeInForce = "IOC" FOK TimeInForce = "FOK" GTD TimeInForce = "GTD" )
List of TimeInForce
type Trade ¶
type Trade struct { Id uint64 `json:"id"` OrderId uint64 `json:"orderId"` ClientOrderId string `json:"clientOrderId"` Symbol string `json:"symbol"` Type string `json:"side"` Price float64 `json:"price,string"` Quantity float64 `json:"quantity,string"` Fee float64 `json:"fee,string"` Timestamp time.Time `json:"timestamp"` }
Trade represents a single trade made by a user.