Documentation
¶
Index ¶
- Variables
- type Balance
- type Book
- type Client
- func (c *Client) APIPrefix() string
- func (c *Client) AvailableBooks() ([]ExchangeOrderBook, error)
- func (c *Client) Balances(params url.Values) ([]Balance, error)
- func (c *Client) BurstRate() time.Duration
- func (c *Client) CancelOrder(oid string) ([]string, error)
- func (c *Client) CancelOrders(oids []string) ([]string, error)
- func (c *Client) Fees(params url.Values) (*CustomerFees, error)
- func (c *Client) Fundings(params url.Values) ([]Funding, error)
- func (c *Client) Ledger(params url.Values) ([]Transaction, error)
- func (c *Client) LedgerByOperation(op Operation, params url.Values) ([]Transaction, error)
- func (c *Client) LookupOrder(oid string) (*UserOrder, error)
- func (c *Client) LookupOrders(oids []string) ([]UserOrder, error)
- func (c *Client) MyOpenOrders(params url.Values) ([]UserOrder, error)
- func (c *Client) MyTrades(params url.Values) ([]UserTrade, error)
- func (c *Client) OrderBook(params url.Values) (*OrderBook, error)
- func (c *Client) OrderTrades(oid string, params url.Values) ([]UserOrderTrade, error)
- func (c *Client) PlaceOrder(order *OrderPlacement) (string, error)
- func (c *Client) SetAPIKey(key string)
- func (c *Client) SetAPIPrefix(prefix string)
- func (c *Client) SetAPISecret(secret string)
- func (c *Client) SetBurstRate(burstRate time.Duration)
- func (c *Client) Ticker(book *Book) (*Ticker, error)
- func (c *Client) Tickers() ([]Ticker, error)
- func (c *Client) Trades(params url.Values) ([]Trade, error)
- type Currency
- type CustomerFees
- type Envelope
- type Error
- type ExchangeOrderBook
- type Fee
- type Funding
- type Monetary
- type Operation
- type Order
- type OrderBook
- type OrderPlacement
- type OrderSide
- type OrderStatus
- type OrderType
- type TID
- type Ticker
- type Time
- type Trade
- type Transaction
- type UserOrder
- type UserOrderTrade
- type UserTrade
- type Websocket
- type WebsocketDiffOrder
- type WebsocketMessage
- type WebsocketOrder
- type WebsocketReply
- type WebsocketTrade
Constants ¶
This section is empty.
Variables ¶
var DefaultClient = NewClient(http.DefaultClient)
DefaultClient is the default Bitso API client to use.
Functions ¶
This section is empty.
Types ¶
type Balance ¶
type Balance struct { Currency Currency `json:"currency"` Total Monetary `json:"total"` Locked Monetary `json:"locked"` Available Monetary `json:"available"` }
Balance represents the balance of a given currency.
type Book ¶
type Book struct {
// contains filtered or unexported fields
}
Book represents an exchange book.
func (Book) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Book) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A Client is a Bitso API consumer
func (*Client) AvailableBooks ¶
func (c *Client) AvailableBooks() ([]ExchangeOrderBook, error)
AvailableBooks returns a list of existing exchange order books and their respective order placement limits.
func (*Client) Balances ¶
Balances returns information concerning the user’s balances for all supported currencies.
func (*Client) CancelOrder ¶
CancelOrder cancels an open order
func (*Client) CancelOrders ¶
CancelOrders cancels open order(s)
func (*Client) Fees ¶
func (c *Client) Fees(params url.Values) (*CustomerFees, error)
Fees returns information on customer fees for all available order books, and withdrawal fees for applicable currencies.
func (*Client) Ledger ¶
func (c *Client) Ledger(params url.Values) ([]Transaction, error)
Ledger returns a list of all the user's registered operations.
func (*Client) LedgerByOperation ¶
LedgerByOperation returns a list of all the user's registered operations.
func (*Client) LookupOrder ¶
LookupOrder returns details of an order given its order ID.
func (*Client) LookupOrders ¶
LookupOrders returns a list of details for 1 or more orders
func (*Client) MyOpenOrders ¶
MyOpenOrders a list of the user's open orders.
func (*Client) OrderTrades ¶
OrderTrades returns a list of the user's order trades on a given order.
func (*Client) PlaceOrder ¶
func (c *Client) PlaceOrder(order *OrderPlacement) (string, error)
PlaceOrder places a buy or sell order (both limit and market orders are available)
func (*Client) SetAPIPrefix ¶
SetAPIPrefix sets the API prefix
func (*Client) SetAPISecret ¶
SetAPISecret sets the user secret to use for private API calls.
func (*Client) SetBurstRate ¶
SetBurstRate sets the amount of time the client should wait in between requests.
type Currency ¶
type Currency uint8
Currency represents currencies
Currencies
func (Currency) MarshalJSON ¶
MarshalJSON implements json.Marshaler
func (*Currency) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler
type CustomerFees ¶
type CustomerFees struct { Fees []Fee `json:"fees"` WithdrawalFees map[string]Monetary `json:"withdrawal_fees"` }
CustomerFees represents a list of fees that Bitso charges the user.
type Envelope ¶
type Envelope struct { Success bool `json:"success"` Error struct { Code interface{} `json:"code"` Message string `json:"message"` } `json:"error,omitempty"` }
Envelope represents a common response envelope from Bitso API.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error represents an API error
type ExchangeOrderBook ¶
type ExchangeOrderBook struct { // Order book symbol Book Book `json:"book"` // Minimum amount of major when placing orders MinimumAmount Monetary `json:"minimum_amount"` // Maximum amount of major when placing orders MaximumAmount Monetary `json:"maximum_amount"` // Minimum price when placing orders MinimumPrice Monetary `json:"minimum_price"` // Maximum price when placing orders MaximumPrice Monetary `json:"maximum_price"` // Minimum value amount (amount*price) when placing orders MinimumValue Monetary `json:"minimun_value"` // Maximum value amount (amount*price) when placing orders MaximumValue Monetary `json:"maximum_value"` }
ExchangeOrderBook represents order placement limits on books.
type Fee ¶
type Fee struct { Book Book `json:"book"` FeeDecimal Monetary `json:"fee_decimal"` FeePercent Monetary `json:"fee_percent"` }
Fee represents a Bitso fee.
type Funding ¶
type Funding struct { FID string `json:"fid"` Currency Monetary `json:"currency"` Method string `json:"method"` Amount Monetary `json:"amount"` Status string `json:"status"` CreatedAt Time `json:"created_at"` Details map[string]interface{} `json:"details"` }
Funding represents the fundings of the user
type Monetary ¶
type Monetary string
Monetary represents a monetary value
func ToMonetary ¶
ToMonetary converts a float64 value into Monetary
type Operation ¶
type Operation uint8
Operation represents the type of a transaction operation.
const ( OperationNone Operation = iota OperationFunding OperationWithdrawal OperationTrade OperationFee )
List of operation types.
func (Operation) MarshalJSON ¶
MarshalJSON implements json.Marshaler
func (*Operation) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler
type Order ¶
type Order struct { // Order book symbol Book Book `json:"book"` // Price per unit of major Price Monetary `json:"price"` // Major amount in order Amount Monetary `json:"amount"` // Order ID (only for unaggregated order) OID string `json:"oid"` }
Order represents a public order.
type OrderBook ¶
type OrderBook struct { Asks []Order `json:"asks"` Bids []Order `json:"bids"` UpdatedAt Time `json:"updated_at"` Sequence string `json:"sequence"` }
OrderBook represents a response from /v3/order_book
type OrderPlacement ¶
type OrderPlacement struct { Book Book `json:"book"` Side OrderSide `json:"side"` Type OrderType `json:"type"` Major Monetary `json:"major,omitempty"` Minor Monetary `json:"minor,omitempty"` Price Monetary `json:"price,omitempty"` }
OrderPlacement represents an order that can be set by the user.
type OrderSide ¶
type OrderSide uint8
OrderSide tells whether an order is a buy or a sell.
func (OrderSide) MarshalJSON ¶
MarshalJSON implements json.Marshaler
func (*OrderSide) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler
type OrderStatus ¶
type OrderStatus uint8
OrderStatus represents the status of open orders.
const ( OrderStatusNone OrderStatus = iota OrderStatusOpen OrderStatusPartialFill )
List of order statuses.
func (OrderStatus) MarshalJSON ¶
func (s OrderStatus) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler
func (*OrderStatus) String ¶
func (s *OrderStatus) String() string
func (*OrderStatus) UnmarshalJSON ¶
func (s *OrderStatus) UnmarshalJSON(in []byte) error
UnmarshalJSON implements json.Unmarshaler
type OrderType ¶
type OrderType uint8
OrderType tells whether the order is a market or limit order.
func (OrderType) MarshalJSON ¶
MarshalJSON implements json.Marshaler
func (*OrderType) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler
type TID ¶
type TID uint64
TID respresents a transaction ID
func (*TID) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler
type Ticker ¶
type Ticker struct { // Order book symbol Book Book `json:"book"` // Last 24 hours volume Volume Monetary `json:"volume"` // Last 24 hours price high High Monetary `json:"high"` // Last traded price Last Monetary `json:"last"` // Last 24 hours price low Low Monetary `json:"low"` // Last 24 hours volume weighted average price Vwap Monetary `json:"vwap"` // Lowest sell order Ask Monetary `json:"ask"` // Highest buy order Bid Monetary `json:"bid"` // When this ticker was generated CreatedAt Time `json:"created_at"` }
Ticker holds trading information from an specific book.
type Time ¶
Time represents a ISO8601 encoded time value.
func (*Time) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshal
type Trade ¶
type Trade struct { Book Book `json:"book"` CreatedAt Time `json:"created_at"` Amount Monetary `json:"amount"` MakerSide OrderSide `json:"maker_side"` Price Monetary `json:"price"` TID TID `json:"tid"` }
Trade represents a recent trade from the specified book
type Transaction ¶
type Transaction struct { EID string `json:"eid"` Operation Operation `json:"operation"` CreatedAt Time `json:"created_at"` BalanceUpdates []struct { Currency Currency `json:"currency"` Amount Monetary `json:"amount"` } `json:"balance_updates"` Details map[string]interface{} `json:"details"` }
Transaction represents a transaction on the ledger.
type UserOrder ¶
type UserOrder struct { Book Book `json:"book"` OriginalAmount Monetary `json:"original_amount"` UnfilledAmount Monetary `json:"unfilled_amount"` OriginalValue Monetary `json:"original_value"` CreatedAt Time `json:"created_at"` UpdatedAt Time `json:"updated_at"` Price Monetary `json:"price"` OID string `json:"oid"` Side OrderSide `json:"side"` Status OrderStatus `json:"status"` Type string `json:"type"` }
UserOrder represents an order from the current user.
type UserOrderTrade ¶
type UserOrderTrade struct { Book Book `json:"book"` Major Monetary `json:"major"` CreatedAt Time `json:"created_at"` Minor Monetary `json:"minor"` FeesAmount Monetary `json:"fees_amount"` FeesCurrency Currency `json:"currency"` Price Monetary `json:"price"` TID TID `json:"tid"` OID string `json:"oid"` Side OrderSide `json:"side"` }
UserOrderTrade represents a trade made by the user
type UserTrade ¶
type UserTrade struct { Book Book `json:"book"` Major Monetary `json:"major"` CreatedAt Time `json:"created_at"` Minor Monetary `json:"minor"` FeesAmount Monetary `json:"fees_amount"` FeesCurrency Currency `json:"fees_currency"` Price Monetary `json:"price"` TID TID `json:"tid"` OID string `json:"oid"` Side OrderSide `json:"side"` }
UserTrade represents a trade made by the user
type Websocket ¶
type Websocket struct {
// contains filtered or unexported fields
}
A Websocket establishes a connection with Bitso's websocket service to send and receive messages over the ws protocol.
func NewWebsocket ¶
NewWebsocket creates a websocket handler and establishes a connection with Bitso's websocket servers.
type WebsocketDiffOrder ¶
type WebsocketDiffOrder struct { Book Book Payload []struct { Timestamp uint64 `json:"d"` Price Monetary `json:"r"` Position int `json:"t"` Amount Monetary `json:"a"` Value Monetary `json:"v"` OrderID string `json:"o"` } }
WebsocketDiffOrder represents a message from the "diff-orders" channel.
type WebsocketMessage ¶
type WebsocketMessage struct { Action string `json:"action"` Book *Book `json:"book"` Type string `json:"type"` }
WebsocketMessage represents a message that can be sent to channel.
type WebsocketOrder ¶
type WebsocketOrder struct { Book Book Payload struct { Bids []struct { Price float64 `json:"r"` Amount float64 `json:"a"` Position int `json:"t"` Value float64 `json:"v"` Timestamp uint64 `json:"d"` } `json:"bids"` Asks []struct { Price float64 `json:"r"` Amount float64 `json:"a"` Position int `json:"t"` Value float64 `json:"v"` Timestamp uint64 `json:"d"` } `json:"asks"` } `json:"payload"` }
WebsocketOrder represents a message from the "diff-orders" channel.
type WebsocketReply ¶
type WebsocketReply struct { Action string `json:"action"` Response string `json:"response"` Time uint64 `json:"time"` Type string `json:"type"` Payload interface{} `json:"payload,omitempty"` }
WebsocketReply represents a generic reply from a channel.
type WebsocketTrade ¶
type WebsocketTrade struct { Book Book Payload []struct { TID uint64 `json:"i"` Amount Monetary `json:"a"` Price Monetary `json:"r"` Value Monetary `json:"v"` MakerOrderID string `json:"mo"` TakerOrderID string `json:"to"` } }
WebsocketTrade represents a message from the "trades" channel.