Documentation
¶
Index ¶
- Constants
- type Book
- type BookItems
- type Cancellation
- type Client
- func (client Client) ActivePositions() (Positions, error)
- func (client Client) CancelAll() (bool, error)
- func (client Client) CancelOrder(id int) (Order, error)
- func (client Client) MultipleNewOrders(params []OrderParams) (Orders, error)
- func (client Client) NewOrder(symbol string, amount, price float64, exchange, side, otype string) (Order, error)
- func (client Client) OrderStatus(id int) (Order, error)
- func (client Client) Orderbook(symbol string, limitBids, limitAsks int) (Book, error)
- func (client Client) ReplaceOrder(id int, symbol string, amount, price float64, exchange, side, otype string) (Order, error)
- func (client Client) Trades(symbol string, limitTrades int) (Trades, error)
- type ErrorMessage
- type Order
- type OrderParams
- type Orders
- type Position
- type Positions
- type Trade
- type Trades
Constants ¶
const (
APIURL = "https://api.bitfinex.com"
)
Bitfinex API URL
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Book ¶
type Book struct {
Bids []BookItems // Slice of bid data items
Asks []BookItems // Slice of ask data items
}
Book contains orderbook data from the exchange
type BookItems ¶
type BookItems struct {
Price float64 `json:"price,string"` // Order price
Amount float64 `json:"amount,string"` // Order volume
Timestamp float64 `json:"timestamp,string"` // Exchange timestamp
}
BookItems contains inner orderbook data from the exchange
type Cancellation ¶
type Cancellation struct {
Result string `json:"result"`
}
Cancellation contains a response from CancelAll
type Client ¶
Client stores Bitfinex credentials
func (Client) ActivePositions ¶
ActivePositions returns active positions from the exchange
func (Client) CancelOrder ¶
CancelOrder cancels existing orders on the exchange
func (Client) MultipleNewOrders ¶
func (client Client) MultipleNewOrders(params []OrderParams) (Orders, error)
MultipleNewOrders posts multiple new orders to the exchange
func (Client) NewOrder ¶
func (client Client) NewOrder(symbol string, amount, price float64, exchange, side, otype string) (Order, error)
NewOrder posts new order to the exchange
func (Client) OrderStatus ¶
OrderStatus gets order status
type ErrorMessage ¶
type ErrorMessage struct {
Message string `json:"message"`
}
ErrorMessage contains an error message from exchange
type Order ¶
type Order struct {
ID int `json:"id"` // Order ID
Symbol string `json:"symbol"` // The symbol name the order belongs to
Exchange string `json:"exchange"` // Exchange name "bitfinex"
Price float64 `json:"price,string"` // The price the order was issued at (can be null for market orders)
ExecutionPrice float64 `json:"avg_execution_price,string"` // The average price at which this order as been executed so far. 0 if the order has not been executed at all
Side string `json:"side"` // Either "buy" or "sell"
Type string `json:"type"` // Either "market" / "limit" / "stop" / "trailing-stop"
Timestamp float64 `json:"timestamp,string"` // The time the order was submitted
IsLive bool `json:"is_live,bool"` // Could the order still be filled?
IsCancelled bool `json:"is_cancelled,bool"` // Has the order been cancelled?
WasForced bool `json:"was_forced,bool"` // For margin onlytrue if it was forced by the system
OriginalAmount float64 `json:"original_amount,string"` // What was the order originally submitted for?
ExecutedAmount float64 `json:"executed_amount,string"` // How much of the order has been executed so far in its history?
RemainingAmount float64 `json:"remaining_amount,string"` // How much is still remaining to be submitted?
Message string `json:"message"` // Message returned by some functions
// Used in multi order responses because the API sucks
Pair string `json:"pair"` // Order symbol
Amount float64 `json:"amount,string"` // Remaing order amount
Status string `json:"status"` // Order status
CreatedAt string `json:"created_at"` // Creation time
UpdatedAt string `json:"updated_at"` // Update time
AvgPrice float64 `json:"avg_price,string"` // Average execution price
}
Order contains order data to/from the exchange
type OrderParams ¶
type OrderParams struct {
Symbol string `json:"symbol"`
Amount float64 `json:"amount,string"`
Price float64 `json:"price,string"`
Exchange string `json:"exchange"`
Side string `json:"side"`
Type string `json:"type"`
}
OrderParams contains inputs for submitting an order
type Position ¶
type Position struct {
ID int `json:"id"` // Position ID
Symbol string `json:"symbol"` // The symbol for the contract
Status string `json:"status"` // Status of position
Base float64 `json:"base,string"` // The initiation price
Amount float64 `json:"amount,string"` // Position size
Timestamp float64 `json:"timestamp,string"` // The time the position was initiated?
Swap float64 `json:"swap,string"` // ?
PL float64 `json:"pl,string"` // Current PL
}
Position contains position data from the exchange
type Trade ¶
type Trade struct {
Timestamp int `json:"timestamp"` // Exchange timestamp
TID int `json:"tid"` // Trade ID
Price float64 `json:"price,string"` // Trade price
Amount float64 `json:"amount,string"` // Trade size
Exchange string `json:"exchange"` // Exchange name "bitfinex"
Type string `json:"type"` // Type, if it can be determined
}
Trade contains executed trade data from the exchange