bitstamp

package
v0.0.193 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Endpoint   = "https://www.bitstamp.net/api/v2"
	TimeFormat = "2006-01-02 15:04:05"
)
View Source
const (
	BUY  = "buy"
	SELL = "sell"
)

Variables

View Source
var (
	RequestsPerSecond float64                         = 10
	BeforeRequest     func(method, path string) error = nil
	AfterRequest      func()                          = nil
)

Functions

func GetMinOrderSize

func GetMinOrderSize(client *Client, market string, ticker float64, prec int) (float64, error)

func GetMinimumOrder

func GetMinimumOrder(client *Client, market string) (float64, error)

Types

type BookEntry

type BookEntry []string

func (*BookEntry) Price

func (be *BookEntry) Price() float64

func (*BookEntry) Size

func (be *BookEntry) Size() float64

type Client

type Client struct {
	URL    string
	Key    string
	Secret string
	// contains filtered or unexported fields
}

func New

func New(apiKey, apiSecret string) *Client

func (*Client) BuyLimitOrder

func (client *Client) BuyLimitOrder(pair string, amount, price float64) (*Order, error)

func (*Client) BuyMarketOrder

func (client *Client) BuyMarketOrder(pair string, amount float64) (*Order, error)

func (*Client) CancelOrder

func (client *Client) CancelOrder(id string) error

func (*Client) GetOpenOrders

func (client *Client) GetOpenOrders() ([]Order, error)

func (*Client) GetOpenOrdersEx

func (client *Client) GetOpenOrdersEx(pair string) ([]Order, error)

func (*Client) GetUserTransactions

func (client *Client) GetUserTransactions(pair string) (Transactions, error)

func (*Client) OrderBook

func (client *Client) OrderBook(pair string) (*OrderBook, error)

func (*Client) SellLimitOrder

func (client *Client) SellLimitOrder(pair string, amount, price float64) (*Order, error)

func (*Client) SellMarketOrder

func (client *Client) SellMarketOrder(pair string, amount float64) (*Order, error)

func (*Client) Ticker

func (client *Client) Ticker(pair string) (*Ticker, error)

func (*Client) TradingPairsInfo

func (client *Client) TradingPairsInfo() ([]Pair, error)

type Market

type Market struct {
	Name      string `json:"name"`
	Enabled   bool   `json:"enabled"`
	SizePrec  int    `json:"sizePrec"`
	PricePrec int    `json:"pricePrec"`
	Base      string // 1st listed currency of this market pair
	Quote     string // 2nd listed currency of this market pair
}

func GetMarkets

func GetMarkets(client *Client, cached bool) ([]Market, error)

type Order

type Order struct {
	Id           string  `json:"id"`
	DateTime     string  `json:"datetime"`
	Type         int     `json:"type,string"`
	Price        float64 `json:"price,string"`
	Amount       float64 `json:"amount,string"`
	CurrencyPair string  `json:"currency_pair,omitempty"` // warning: NOT equal to market name
}

func (*Order) GetDateTime

func (order *Order) GetDateTime() (*time.Time, error)

func (*Order) GetDateTimeEx

func (order *Order) GetDateTimeEx() time.Time

func (*Order) Market

func (order *Order) Market() (string, error)

func (*Order) MarketEx

func (order *Order) MarketEx() string

func (*Order) Side

func (order *Order) Side() string

type OrderBook

type OrderBook struct {
	Bids []BookEntry `json:"bids"`
	Asks []BookEntry `json:"asks"`
}

type Orders

type Orders []Order

func (Orders) IndexById

func (orders Orders) IndexById(id string) int

func (Orders) OrderById

func (orders Orders) OrderById(id string) *Order

type Pair

type Pair struct {
	BaseDecimals    int    `json:"base_decimals"`
	MinimumOrder    string `json:"minimum_order"`
	Name            string `json:"name"`
	CounterDecimals int    `json:"counter_decimals"`
	Trading         string `json:"trading"`
	UrlSymbol       string `json:"url_symbol"`
	Description     string `json:"description"`
}

type Ticker

type Ticker struct {
	Last      float64 `json:"last,string"`
	High      float64 `json:"high,string"`
	Low       float64 `json:"low,string"`
	Vwap      float64 `json:"vwap,string"`
	Volume    float64 `json:"volume,string"`
	Bid       float64 `json:"bid,string"`
	Ask       float64 `json:"ask,string"`
	Timestamp string  `json:"timestamp"`
	Open      float64 `json:"open,string"`
}

type Transaction

type Transaction map[string]interface{}

func (*Transaction) Amount

func (transaction *Transaction) Amount(client *Client) float64

func (*Transaction) DateTime

func (transaction *Transaction) DateTime() time.Time

func (*Transaction) Market

func (transaction *Transaction) Market(client *Client) string

func (*Transaction) OrderId

func (transaction *Transaction) OrderId() string

func (*Transaction) Price

func (transaction *Transaction) Price(client *Client) float64

func (*Transaction) Side

func (transaction *Transaction) Side(client *Client) (string, error)

type Transactions

type Transactions []Transaction

func (Transactions) GetOrders

func (transactions Transactions) GetOrders() Transactions

func (Transactions) GetOrdersEx

func (transactions Transactions) GetOrdersEx(client *Client, market string) Transactions

func (Transactions) IndexByOrderId

func (transactions Transactions) IndexByOrderId(id string) int

Jump to

Keyboard shortcuts

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