bitstamp

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2021 License: MIT Imports: 18 Imported by: 0

README

Go Report Card

bitstamp-go

Client implementations for Bitstamp's REST and Websocket APIs in Go. Copied heavily from github.com/ajph/bitstamp-go. Websocket client uses API v2 instead of Pusher (which is not available anymore).

Requirements

  • Go 1.15+
  • Dependencies in go.mod

Usage examples

Require the repo in your go.mod file. See examples folder for more. For instance, you can try running:

$ go run examples/http_api/http_api.go

TODO

  • Upgrade Go.
  • Configure Github Actions.
  • Update pairs.
  • Finish implementing all the endpoints.
  • Remove/deprecate REST v1.
  • Godoc / documentation.
  • More tests.
  • E2E tests against Bitstamp's API.
  • Docker builds.
  • Authors file / information?
  • Shadow order book creation. (Is this an example? A separate project even?)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiClient

type ApiClient struct {
	// contains filtered or unexported fields
}

func NewApiClient

func NewApiClient(options ...ApiOption) *ApiClient

func (*ApiClient) V1HourlyTicker

func (c *ApiClient) V1HourlyTicker() (response TickerResponse, err error)

GET https://www.bitstamp.net/api/ticker_hour/

func (*ApiClient) V1OrderBook

func (c *ApiClient) V1OrderBook(group int) (response V1OrderBookResponse, err error)

GET https://www.bitstamp.net/api/order_book?group=1

func (*ApiClient) V1Ticker

func (c *ApiClient) V1Ticker() (response TickerResponse, err error)

GET https://www.bitstamp.net/api/ticker/

func (*ApiClient) V2BuyInstantOrder

func (c *ApiClient) V2BuyInstantOrder(currencyPair string, amount decimal.Decimal, clOrdId string) (response V2InstantOrderResponse, err error)

func (*ApiClient) V2BuyLimitOrder

func (c *ApiClient) V2BuyLimitOrder(currencyPair string, price, amount, limitPrice decimal.Decimal, dailyOrder, iocOrder bool, clOrdId string) (response V2LimitOrderResponse, err error)

func (*ApiClient) V2BuyMarketOrder

func (c *ApiClient) V2BuyMarketOrder(currencyPair string, amount decimal.Decimal, clOrdId string) (response V2MarketOrderResponse, err error)

func (*ApiClient) V2CancelOrder

func (c *ApiClient) V2CancelOrder(orderId int64) (response V2CancelOrderResponse, err error)

func (*ApiClient) V2HourlyTicker

func (c *ApiClient) V2HourlyTicker(currencyPair string) (response TickerResponse, err error)

GET https://www.bitstamp.net/api/v2/ticker_hour/{currency_pair}/

func (*ApiClient) V2OrderBook

func (c *ApiClient) V2OrderBook(currencyPair string, group int) (response V2OrderBookResponse, err error)

GET https://www.bitstamp.net/api/v2/order_book/{currency_pair}?group=1 Possible values are for group parameter - 0 (orders are not grouped at same price) - 1 (orders are grouped at same price - default) - 2 (orders with their order ids are not grouped at same price) GET https://www.bitstamp.net/api/order_book?group=1

func (*ApiClient) V2OrderStatus

func (c *ApiClient) V2OrderStatus(orderId int64, clOrdId string, omitTx bool) (response V2OrderStatusResponse, err error)

POST https://www.bitstamp.net/api/v2/order_status/

func (*ApiClient) V2SellInstantOrder

func (c *ApiClient) V2SellInstantOrder(currencyPair string, amount decimal.Decimal, clOrdId string) (response V2InstantOrderResponse, err error)

func (*ApiClient) V2SellLimitOrder

func (c *ApiClient) V2SellLimitOrder(currencyPair string, price, amount, limitPrice decimal.Decimal, dailyOrder, iocOrder bool, clOrdId string) (response V2LimitOrderResponse, err error)

func (*ApiClient) V2SellMarketOrder

func (c *ApiClient) V2SellMarketOrder(currencyPair string, amount decimal.Decimal, clOrdId string) (response V2MarketOrderResponse, err error)

func (*ApiClient) V2Ticker

func (c *ApiClient) V2Ticker(currencyPair string) (response TickerResponse, err error)

GET https://www.bitstamp.net/api/v2/ticker/{currency_pair}/

func (*ApiClient) V2UserTransactions

func (c *ApiClient) V2UserTransactions(currencyPairOrAll string) (response []V2UserTransactionsResponse, err error)

TODO: add arguments!

type ApiOption

type ApiOption func(*apiClientConfig)

func AutoRoundingEnabled

func AutoRoundingEnabled() ApiOption

func Credentials

func Credentials(customerId string, apiKey string, apiSecret string) ApiOption

func NonceGenerator

func NonceGenerator(nonceGen func() string) ApiOption

func UrlDomain

func UrlDomain(rawDomain string) ApiOption

type OrderBookEntry

type OrderBookEntry struct {
	Price  decimal.Decimal
	Amount decimal.Decimal
	Id     uint64
}

func (*OrderBookEntry) UnmarshalJSON

func (obe *OrderBookEntry) UnmarshalJSON(bytes []byte) error

helper method that lets us unmarshal order book entries directly from API JSON responses

type TickerResponse

type TickerResponse struct {
	High      decimal.Decimal `json:"high"`
	Last      decimal.Decimal `json:"last"`
	Timestamp decimal.Decimal `json:"timestamp"`
	Bid       decimal.Decimal `json:"bid"`
	Vwap      decimal.Decimal `json:"vwap"`
	Volume    decimal.Decimal `json:"volume"`
	Low       decimal.Decimal `json:"low"`
	Ask       decimal.Decimal `json:"ask"`
	Open      decimal.Decimal `json:"open"`
}

type V1OrderBookResponse

type V1OrderBookResponse struct {
	Timestamp string           `json:"timestamp"` // UNIX epoch in UTC in seconds
	Bids      []OrderBookEntry `json:"bids"`
	Asks      []OrderBookEntry `json:"asks"`
}

type V2BalanceResponse

type V2BalanceResponse struct {
	// currencies
	AaveAvailable      decimal.Decimal `json:"aave_available"`
	AaveBalance        decimal.Decimal `json:"aave_balance"`
	AaveReserved       decimal.Decimal `json:"aave_reserved"`
	AaveWithdrawalFee  decimal.Decimal `json:"aave_withdrawal_fee"`
	AlgoAvailable      decimal.Decimal `json:"algo_available"`
	AlgoBalance        decimal.Decimal `json:"algo_balance"`
	AlgoReserved       decimal.Decimal `json:"algo_reserved"`
	AlgoWithdrawalFee  decimal.Decimal `json:"algo_withdrawal_fee"`
	AudioAvailable     decimal.Decimal `json:"audio_available"`
	AudioBalance       decimal.Decimal `json:"audio_balance"`
	AudioReserved      decimal.Decimal `json:"audio_reserved"`
	AudioWithdrawalFee decimal.Decimal `json:"audio_withdrawal_fee"`
	BatAvailable       decimal.Decimal `json:"bat_available"`
	BatBalance         decimal.Decimal `json:"bat_balance"`
	BatReserved        decimal.Decimal `json:"bat_reserved"`
	BatWithdrawalFee   decimal.Decimal `json:"bat_withdrawal_fee"`
	BchAvailable       decimal.Decimal `json:"bch_available"`
	BchBalance         decimal.Decimal `json:"bch_balance"`
	BchReserved        decimal.Decimal `json:"bch_reserved"`
	BchWithdrawalFee   decimal.Decimal `json:"bch_withdrawal_fee"`
	BtcAvailable       decimal.Decimal `json:"btc_available"`
	BtcBalance         decimal.Decimal `json:"btc_balance"`
	BtcReserved        decimal.Decimal `json:"btc_reserved"`
	BtcWithdrawalFee   decimal.Decimal `json:"btc_withdrawal_fee"`
	CompAvailable      decimal.Decimal `json:"comp_available"`
	CompBalance        decimal.Decimal `json:"comp_balance"`
	CompReserved       decimal.Decimal `json:"comp_reserved"`
	CompWithdrawalFee  decimal.Decimal `json:"comp_withdrawal_fee"`
	CrvAvailable       decimal.Decimal `json:"crv_available"`
	CrvBalance         decimal.Decimal `json:"crv_balance"`
	CrvReserved        decimal.Decimal `json:"crv_reserved"`
	CrvWithdrawalFee   decimal.Decimal `json:"crv_withdrawal_fee"`
	DaiAvailable       decimal.Decimal `json:"dai_available"`
	DaiBalance         decimal.Decimal `json:"dai_balance"`
	DaiReserved        decimal.Decimal `json:"dai_reserved"`
	DaiWithdrawalFee   decimal.Decimal `json:"dai_withdrawal_fee"`
	Eth2Available      decimal.Decimal `json:"eth2_available"`
	Eth2Balance        decimal.Decimal `json:"eth2_balance"`
	Eth2Reserved       decimal.Decimal `json:"eth2_reserved"`
	Eth2rAvailable     decimal.Decimal `json:"eth2r_available"`
	Eth2rBalance       decimal.Decimal `json:"eth2r_balance"`
	Eth2rReserved      decimal.Decimal `json:"eth2r_reserved"`
	EthAvailable       decimal.Decimal `json:"eth_available"`
	EthBalance         decimal.Decimal `json:"eth_balance"`
	EthReserved        decimal.Decimal `json:"eth_reserved"`
	EthWithdrawalFee   decimal.Decimal `json:"eth_withdrawal_fee"`
	EurAvailable       decimal.Decimal `json:"eur_available"`
	EurBalance         decimal.Decimal `json:"eur_balance"`
	EurReserved        decimal.Decimal `json:"eur_reserved"`
	EurWithdrawalFee   decimal.Decimal `json:"eur_withdrawal_fee"`
	GbpAvailable       decimal.Decimal `json:"gbp_available"`
	GbpBalance         decimal.Decimal `json:"gbp_balance"`
	GbpReserved        decimal.Decimal `json:"gbp_reserved"`
	GbpWithdrawalFee   decimal.Decimal `json:"gbp_withdrawal_fee"`
	GrtAvailable       decimal.Decimal `json:"grt_available"`
	GrtBalance         decimal.Decimal `json:"grt_balance"`
	GrtReserved        decimal.Decimal `json:"grt_reserved"`
	GrtWithdrawalFee   decimal.Decimal `json:"grt_withdrawal_fee"`
	GusdAvailable      decimal.Decimal `json:"gusd_available"`
	GusdBalance        decimal.Decimal `json:"gusd_balance"`
	GusdReserved       decimal.Decimal `json:"gusd_reserved"`
	GusdWithdrawalFee  decimal.Decimal `json:"gusd_withdrawal_fee"`
	KncAvailable       decimal.Decimal `json:"knc_available"`
	KncBalance         decimal.Decimal `json:"knc_balance"`
	KncReserved        decimal.Decimal `json:"knc_reserved"`
	KncWithdrawalFee   decimal.Decimal `json:"knc_withdrawal_fee"`
	LinkAvailable      decimal.Decimal `json:"link_available"`
	LinkBalance        decimal.Decimal `json:"link_balance"`
	LinkReserved       decimal.Decimal `json:"link_reserved"`
	LinkWithdrawalFee  decimal.Decimal `json:"link_withdrawal_fee"`
	LtcAvailable       decimal.Decimal `json:"ltc_available"`
	LtcBalance         decimal.Decimal `json:"ltc_balance"`
	LtcReserved        decimal.Decimal `json:"ltc_reserved"`
	LtcWithdrawalFee   decimal.Decimal `json:"ltc_withdrawal_fee"`
	MkrAvailable       decimal.Decimal `json:"mkr_available"`
	MkrBalance         decimal.Decimal `json:"mkr_balance"`
	MkrReserved        decimal.Decimal `json:"mkr_reserved"`
	MkrWithdrawalFee   decimal.Decimal `json:"mkr_withdrawal_fee"`
	OmgAvailable       decimal.Decimal `json:"omg_available"`
	OmgBalance         decimal.Decimal `json:"omg_balance"`
	OmgReserved        decimal.Decimal `json:"omg_reserved"`
	OmgWithdrawalFee   decimal.Decimal `json:"omg_withdrawal_fee"`
	PaxAvailable       decimal.Decimal `json:"pax_available"`
	PaxBalance         decimal.Decimal `json:"pax_balance"`
	PaxReserved        decimal.Decimal `json:"pax_reserved"`
	PaxWithdrawalFee   decimal.Decimal `json:"pax_withdrawal_fee"`
	SnxAvailable       decimal.Decimal `json:"snx_available"`
	SnxBalance         decimal.Decimal `json:"snx_balance"`
	SnxReserved        decimal.Decimal `json:"snx_reserved"`
	SnxWithdrawalFee   decimal.Decimal `json:"snx_withdrawal_fee"`
	UmaAvailable       decimal.Decimal `json:"uma_available"`
	UmaBalance         decimal.Decimal `json:"uma_balance"`
	UmaReserved        decimal.Decimal `json:"uma_reserved"`
	UmaWithdrawalFee   decimal.Decimal `json:"uma_withdrawal_fee"`
	UniAvailable       decimal.Decimal `json:"uni_available"`
	UniBalance         decimal.Decimal `json:"uni_balance"`
	UniReserved        decimal.Decimal `json:"uni_reserved"`
	UniWithdrawalFee   decimal.Decimal `json:"uni_withdrawal_fee"`
	UsdAvailable       decimal.Decimal `json:"usd_available"`
	UsdBalance         decimal.Decimal `json:"usd_balance"`
	UsdReserved        decimal.Decimal `json:"usd_reserved"`
	UsdWithdrawalFee   decimal.Decimal `json:"usd_withdrawal_fee"`
	UsdcAvailable      decimal.Decimal `json:"usdc_available"`
	UsdcBalance        decimal.Decimal `json:"usdc_balance"`
	UsdcReserved       decimal.Decimal `json:"usdc_reserved"`
	UsdcWithdrawalFee  decimal.Decimal `json:"usdc_withdrawal_fee"`
	UsdtAvailable      decimal.Decimal `json:"usdt_available"`
	UsdtBalance        decimal.Decimal `json:"usdt_balance"`
	UsdtReserved       decimal.Decimal `json:"usdt_reserved"`
	UsdtWithdrawalFee  decimal.Decimal `json:"usdt_withdrawal_fee"`
	XlmAvailable       decimal.Decimal `json:"xlm_available"`
	XlmBalance         decimal.Decimal `json:"xlm_balance"`
	XlmReserved        decimal.Decimal `json:"xlm_reserved"`
	XlmWithdrawalFee   decimal.Decimal `json:"xlm_withdrawal_fee"`
	XrpAvailable       decimal.Decimal `json:"xrp_available"`
	XrpBalance         decimal.Decimal `json:"xrp_balance"`
	XrpReserved        decimal.Decimal `json:"xrp_reserved"`
	XrpWithdrawalFee   decimal.Decimal `json:"xrp_withdrawal_fee"`
	YfiAvailable       decimal.Decimal `json:"yfi_available"`
	YfiBalance         decimal.Decimal `json:"yfi_balance"`
	YfiReserved        decimal.Decimal `json:"yfi_reserved"`
	YfiWithdrawalFee   decimal.Decimal `json:"yfi_withdrawal_fee"`
	ZrxAvailable       decimal.Decimal `json:"zrx_available"`
	ZrxBalance         decimal.Decimal `json:"zrx_balance"`
	ZrxReserved        decimal.Decimal `json:"zrx_reserved"`
	ZrxWithdrawalFee   decimal.Decimal `json:"zrx_withdrawal_fee"`

	// pairs
	AavebtcFee  decimal.Decimal `json:"aavebtc_fee"`
	AaveeurFee  decimal.Decimal `json:"aaveeur_fee"`
	AaveusdFee  decimal.Decimal `json:"aaveusd_fee"`
	AlgobtcFee  decimal.Decimal `json:"algobtc_fee"`
	AlgoeurFee  decimal.Decimal `json:"algoeur_fee"`
	AlgousdFee  decimal.Decimal `json:"algousd_fee"`
	AudiobtcFee decimal.Decimal `json:"audiobtc_fee"`
	AudioeurFee decimal.Decimal `json:"audioeur_fee"`
	AudiousdFee decimal.Decimal `json:"audiousd_fee"`
	BatbtcFee   decimal.Decimal `json:"batbtc_fee"`
	BateurFee   decimal.Decimal `json:"bateur_fee"`
	BatusdFee   decimal.Decimal `json:"batusd_fee"`
	BchbtcFee   decimal.Decimal `json:"bchbtc_fee"`
	BcheurFee   decimal.Decimal `json:"bcheur_fee"`
	BchgbpFee   decimal.Decimal `json:"bchgbp_fee"`
	BchusdFee   decimal.Decimal `json:"bchusd_fee"`
	BtceurFee   decimal.Decimal `json:"btceur_fee"`
	BtcgbpFee   decimal.Decimal `json:"btcgbp_fee"`
	BtcpaxFee   decimal.Decimal `json:"btcpax_fee"`
	BtcusdFee   decimal.Decimal `json:"btcusd_fee"`
	BtcusdcFee  decimal.Decimal `json:"btcusdc_fee"`
	BtcusdtFee  decimal.Decimal `json:"btcusdt_fee"`
	CompbtcFee  decimal.Decimal `json:"compbtc_fee"`
	CompeurFee  decimal.Decimal `json:"compeur_fee"`
	CompusdFee  decimal.Decimal `json:"compusd_fee"`
	CrvbtcFee   decimal.Decimal `json:"crvbtc_fee"`
	CrveurFee   decimal.Decimal `json:"crveur_fee"`
	CrvusdFee   decimal.Decimal `json:"crvusd_fee"`
	DaiusdFee   decimal.Decimal `json:"daiusd_fee"`
	Eth2ethFee  decimal.Decimal `json:"eth2eth_fee"`
	EthbtcFee   decimal.Decimal `json:"ethbtc_fee"`
	EtheurFee   decimal.Decimal `json:"etheur_fee"`
	EthgbpFee   decimal.Decimal `json:"ethgbp_fee"`
	EthpaxFee   decimal.Decimal `json:"ethpax_fee"`
	EthusdFee   decimal.Decimal `json:"ethusd_fee"`
	EthusdcFee  decimal.Decimal `json:"ethusdc_fee"`
	EthusdtFee  decimal.Decimal `json:"ethusdt_fee"`
	EurusdFee   decimal.Decimal `json:"eurusd_fee"`
	GbpeurFee   decimal.Decimal `json:"gbpeur_fee"`
	GbpusdFee   decimal.Decimal `json:"gbpusd_fee"`
	GusdusdFee  decimal.Decimal `json:"gusdusd_fee"`
	KncbtcFee   decimal.Decimal `json:"kncbtc_fee"`
	KnceurFee   decimal.Decimal `json:"knceur_fee"`
	KncusdFee   decimal.Decimal `json:"kncusd_fee"`
	LinkbtcFee  decimal.Decimal `json:"linkbtc_fee"`
	LinkethFee  decimal.Decimal `json:"linketh_fee"`
	LinkeurFee  decimal.Decimal `json:"linkeur_fee"`
	LinkgbpFee  decimal.Decimal `json:"linkgbp_fee"`
	LinkusdFee  decimal.Decimal `json:"linkusd_fee"`
	LtcbtcFee   decimal.Decimal `json:"ltcbtc_fee"`
	LtceurFee   decimal.Decimal `json:"ltceur_fee"`
	LtcgbpFee   decimal.Decimal `json:"ltcgbp_fee"`
	LtcusdFee   decimal.Decimal `json:"ltcusd_fee"`
	MkrbtcFee   decimal.Decimal `json:"mkrbtc_fee"`
	MkreurFee   decimal.Decimal `json:"mkreur_fee"`
	MkrusdFee   decimal.Decimal `json:"mkrusd_fee"`
	OmgbtcFee   decimal.Decimal `json:"omgbtc_fee"`
	OmgeurFee   decimal.Decimal `json:"omgeur_fee"`
	OmggbpFee   decimal.Decimal `json:"omggbp_fee"`
	OmgusdFee   decimal.Decimal `json:"omgusd_fee"`
	PaxeurFee   decimal.Decimal `json:"paxeur_fee"`
	PaxgbpFee   decimal.Decimal `json:"paxgbp_fee"`
	PaxusdFee   decimal.Decimal `json:"paxusd_fee"`
	SnxbtcFee   decimal.Decimal `json:"snxbtc_fee"`
	SnxeurFee   decimal.Decimal `json:"snxeur_fee"`
	SnxusdFee   decimal.Decimal `json:"snxusd_fee"`
	UmabtcFee   decimal.Decimal `json:"umabtc_fee"`
	UmaeurFee   decimal.Decimal `json:"umaeur_fee"`
	UmausdFee   decimal.Decimal `json:"umausd_fee"`
	UnibtcFee   decimal.Decimal `json:"unibtc_fee"`
	UnieurFee   decimal.Decimal `json:"unieur_fee"`
	UniusdFee   decimal.Decimal `json:"uniusd_fee"`
	UsdceurFee  decimal.Decimal `json:"usdceur_fee"`
	UsdcusdFee  decimal.Decimal `json:"usdcusd_fee"`
	UsdcusdtFee decimal.Decimal `json:"usdcusdt_fee"`
	UsdteurFee  decimal.Decimal `json:"usdteur_fee"`
	UsdtusdFee  decimal.Decimal `json:"usdtusd_fee"`
	XlmbtcFee   decimal.Decimal `json:"xlmbtc_fee"`
	XlmeurFee   decimal.Decimal `json:"xlmeur_fee"`
	XlmgbpFee   decimal.Decimal `json:"xlmgbp_fee"`
	XlmusdFee   decimal.Decimal `json:"xlmusd_fee"`
	XrpbtcFee   decimal.Decimal `json:"xrpbtc_fee"`
	XrpeurFee   decimal.Decimal `json:"xrpeur_fee"`
	XrpgbpFee   decimal.Decimal `json:"xrpgbp_fee"`
	XrppaxFee   decimal.Decimal `json:"xrppax_fee"`
	XrpusdFee   decimal.Decimal `json:"xrpusd_fee"`
	XrpusdtFee  decimal.Decimal `json:"xrpusdt_fee"`
	YfibtcFee   decimal.Decimal `json:"yfibtc_fee"`
	YfieurFee   decimal.Decimal `json:"yfieur_fee"`
	YfiusdFee   decimal.Decimal `json:"yfiusd_fee"`
	ZrxbtcFee   decimal.Decimal `json:"zrxbtc_fee"`
	ZrxeurFee   decimal.Decimal `json:"zrxeur_fee"`
	ZrxusdFee   decimal.Decimal `json:"zrxusd_fee"`

	// fee
	Fee decimal.Decimal `json:"fee"`
}

Account balance

type V2CancelOrderResponse

type V2CancelOrderResponse struct {
	Id     uint64          `json:"id"`
	Amount decimal.Decimal `json:"amount"`
	Price  decimal.Decimal `json:"price"`
	Type   uint8           `json:"type"`
	Error  string          `json:"error"`
}

Cancel order

type V2InstantOrderResponse

type V2InstantOrderResponse struct {
	Id       string          `json:"id"`
	Datetime string          `json:"datetime"`
	Type     string          `json:"type"`
	Price    decimal.Decimal `json:"price"`
	Amount   decimal.Decimal `json:"amount"`
	Error    string          `json:"error"`
	Status   string          `json:"status"`
	Reason   interface{}     `json:"reason"`
}

type V2LimitOrderResponse

type V2LimitOrderResponse struct {
	Id       string          `json:"id"`
	Datetime string          `json:"datetime"`
	Type     string          `json:"type"`
	Price    decimal.Decimal `json:"price"`
	Amount   decimal.Decimal `json:"amount"`
	Status   string          `json:"status"`
	Reason   interface{}     `json:"reason"`
}

{"status": "error", "reason": {"__all__": ["Price is more than 20% below market price."]}} {"status": "error", "reason": {"__all__": ["You need 158338.86 USD to open that order. You have only 99991.52 USD available. Check your account balance for details."]}}

type V2MarketOrderResponse

type V2MarketOrderResponse struct {
	Id       string          `json:"id"`
	Datetime string          `json:"datetime"`
	Type     string          `json:"type"`
	Price    decimal.Decimal `json:"price"`
	Amount   decimal.Decimal `json:"amount"`
	Error    string          `json:"error"`
	Status   string          `json:"status"`
	Reason   interface{}     `json:"reason"`
}

type V2OpenOrdersResponse

type V2OpenOrdersResponse struct {
	Id           string          `json:"id"`
	Datetime     string          `json:"datetime"`
	Type         string          `json:"type"`
	Price        decimal.Decimal `json:"price"`
	Amount       decimal.Decimal `json:"amount"`
	CurrencyPair string          `json:"currency_pair"`
	Status       string          `json:"status"`
	Reason       interface{}     `json:"reason"`
}

Open orders

type V2OrderBookResponse

type V2OrderBookResponse struct {
	V1OrderBookResponse
	Microtimestamp string `json:"microtimestamp"`
}

type V2OrderStatusResponse

type V2OrderStatusResponse struct {
	Id              int64                      `json:"id"`
	Status          string                     `json:"status"`
	Transactions    []V2OrderStatusTransaction `json:"transactions"`
	AmountRemaining decimal.Decimal            `json:"amount_remaining"`
	ClientOrderId   string                     `json:"client_order_id"`

	Reason interface{} `json:"reason"`
}

type V2OrderStatusTransaction

type V2OrderStatusTransaction struct {
	Btc      decimal.Decimal `json:"btc"`
	Datetime string          `json:"datetime"`
	Fee      decimal.Decimal `json:"fee"`
	Price    decimal.Decimal `json:"price"`
	Tid      int64           `json:"tid"`
	Type     int             `json:"type"`
	Usd      decimal.Decimal `json:"usd"`
}

Order status

type V2UserTransactionsResponse

type V2UserTransactionsResponse struct {
	Datetime string          `json:"datetime"`
	Fee      decimal.Decimal `json:"fee"`
	Id       int64           `json:"id"`
	OrderId  int64           `json:"order_id"`
	Type     string          `json:"type"`

	Status string      `json:"status"`
	Reason interface{} `json:"reason"`

	// amounts
	Aave   decimal.Decimal `json:"aave"`
	Algo   decimal.Decimal `json:"algo"`
	Audio  decimal.Decimal `json:"audio"`
	Bat    decimal.Decimal `json:"bat"`
	Bch    decimal.Decimal `json:"bch"`
	Btc    decimal.Decimal `json:"btc"`
	Comp   decimal.Decimal `json:"comp"`
	Crv    decimal.Decimal `json:"crv"`
	Dai    decimal.Decimal `json:"dai"`
	Eth    decimal.Decimal `json:"eth"`
	Eth2   decimal.Decimal `json:"eth2"`
	Eth2r  decimal.Decimal `json:"eth2r"`
	Eur    decimal.Decimal `json:"eur"`
	Gbp    decimal.Decimal `json:"gbp"`
	Grt    decimal.Decimal `json:"grt"`
	Gusd   decimal.Decimal `json:"gusd"`
	Knc    decimal.Decimal `json:"knc"`
	Link   decimal.Decimal `json:"link"`
	Ltc    decimal.Decimal `json:"ltc"`
	Mkr    decimal.Decimal `json:"mkr"`
	Omg    decimal.Decimal `json:"omg"`
	Pax    decimal.Decimal `json:"pax"`
	Snx    decimal.Decimal `json:"snx"`
	Uma    decimal.Decimal `json:"uma"`
	Uni    decimal.Decimal `json:"uni"`
	Usd    decimal.Decimal `json:"usd"`
	Usdc   decimal.Decimal `json:"usdc"`
	Usdt   decimal.Decimal `json:"usdt"`
	Xlm    decimal.Decimal `json:"xlm"`
	Xrp    decimal.Decimal `json:"xrp"`
	Yfi    decimal.Decimal `json:"yfi"`
	Zrx    decimal.Decimal `json:"zrx"`
	BtcUsd decimal.Decimal `json:"btc_usd"`
}

User transactions

type WsClient

type WsClient struct {
	Stream chan *WsEvent
	Errors chan error
	// contains filtered or unexported fields
}

func NewWsClient

func NewWsClient(options ...WsOption) (*WsClient, error)

func (*WsClient) Close

func (c *WsClient) Close()

func (*WsClient) IsReconnectRequest

func (c *WsClient) IsReconnectRequest(event *WsEvent) bool

Determines whether server is requesting reconnect. If such a request is made by the server, we should immediately reconnect. Note: Bitstamp ensures, that once such a request is received by the client, any new websocket client is connected to a healthy server.

func (*WsClient) Subscribe

func (c *WsClient) Subscribe(channels ...string)

func (*WsClient) Unsubscribe

func (c *WsClient) Unsubscribe(channels ...string)

type WsEvent

type WsEvent struct {
	Event   string      `json:"event"`
	Channel string      `json:"channel"`
	Data    interface{} `json:"data"`
}

type WsOption

type WsOption func(*wsClientConfig)

func Timeout

func Timeout(timeout time.Duration) WsOption

func WsUrl

func WsUrl(domain string) WsOption

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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