bitfinex

package
v0.0.0-...-42627a0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2015 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
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

type Client struct {
	APIKey    string
	APISecret string
}

Client stores Bitfinex credentials

func New

func New(key, secret string) Client

New returns a new Client instance

func (Client) ActivePositions

func (client Client) ActivePositions() (Positions, error)

ActivePositions returns active positions from the exchange

func (Client) CancelAll

func (client Client) CancelAll() (bool, error)

CancelAll cancels all active orders

func (Client) CancelOrder

func (client Client) CancelOrder(id int) (Order, error)

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

func (client Client) OrderStatus(id int) (Order, error)

OrderStatus gets order status

func (Client) Orderbook

func (client Client) Orderbook(symbol string, limitBids, limitAsks int) (Book, error)

Orderbook gets orderbook data from the exchange

func (Client) ReplaceOrder

func (client Client) ReplaceOrder(id int, symbol string, amount, price float64, exchange, side, otype string) (Order, error)

ReplaceOrder replaces existing orders on the exchange

func (Client) Trades

func (client Client) Trades(symbol string, limitTrades int) (Trades, error)

Trades gets trade data from the exchange

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 Orders

type Orders struct {
	Orders  []Order `json:"order_ids"`
	Message string  `json:"message"`
}

Orders is used in processing multiple orders

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 Positions

type Positions []Position

Positions is a slice of Position

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

type Trades

type Trades []Trade

Trades is slice of trades

Jump to

Keyboard shortcuts

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