bitso

package module
v0.0.0-...-0d42fb1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2021 License: GPL-3.0 Imports: 10 Imported by: 0

README

Bitso API golang client Go GoDoc

The Bitso API in a gopher friendly way

This library uses dghubble/sling internally: A Go HTTP client library for creating and sending API requests.

Features
  • V3 partial coverage
  • Params and responses with custom structs.
  • HMAC authentication implemented.
  • Context for requests available.

Install

go get github.com/fernandez14/bitso

Documentation

Read GoDoc

Usage

Use bitso to set path, method, header, query, or body properties and create an http.Request.

// A example request to ticker endpoint... 
srv := bitso.New(http.DefaultClient, "account_api_secret")
res, err := srv.Ticker(context.Background(), "btc_mxn")
if err != nil {
    log.Error(err)
}
log.Printf("success=%+v", res.Success)
log.Printf("tick=%+v", res.Tick)
// tick={Book:btc_mxn High:381830.40 Vwap:375965.0682188447 Volume:174.82970689 Last:377297.63 Low:369472.00 Ask:377297.59 Bid:376409.35 Change24:4097.63}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BaseURL = "https://api.bitso.com"
)

Functions

This section is empty.

Types

type AvailableBook

type AvailableBook struct {
	Book          string `json:"book"`
	MinimumAmount string `json:"minimum_amount"`
	MaximumAmount string `json:"maximum_amount"`
	MinimumPrice  string `json:"minimum_price"`
	MaximumPrice  string `json:"maximum_price"`
	MinimumValue  string `json:"minimum_value"`
	MaximumValue  string `json:"maximum_value"`
}

type Balance

type Balance struct {
	Currency  string  `json:"currency"`
	Total     float64 `json:"total,string"`
	Locked    float64 `json:"locked,string"`
	Available float64 `json:"available,string"`
}

type BalanceRes

type BalanceRes struct {
	List []Balance `json:"balances"`
}

type BitsoErrRes

type BitsoErrRes struct {
	Wrap *BitsoError `json:"error"`
}

func (BitsoErrRes) Error

func (e BitsoErrRes) Error() string

type BitsoError

type BitsoError struct {
	Message string `json:"message"`
	Code    string `json:"code"`
}

type BookOrder

type BookOrder struct {
	Book   string `json:"book"`
	Price  string `json:"price"`
	Amount string `json:"amount"`
}

type CancelOrderParams

type CancelOrderParams struct {
	OrderIDs  string `url:"oids,omitempty"`
	OriginIDs string `url:"origin_ids,omitempty"`
	All       bool   `url:"-"`
}

type OpenOrder

type OpenOrder struct {
	OID            string `json:"oid"`
	Book           string `json:"book"`
	OriginalAmount string `json:"original_amount"`
	UnfilledAmount string `json:"unfilled_amount"`
	OriginalValue  string `json:"original_value"`
	CreatedAt      string `json:"created_at"`
	UpdatedAt      string `json:"updated_at"`
	Price          string `json:"price"`
	Side           string `json:"side"`
	Status         string `json:"status"`
	Type           string `json:"type"`
}

type OpenOrderParams

type OpenOrderParams struct {
	Book   string `url:"book,omitempty"`
	Marker string `url:"marker,omitempty"`
	Sort   string `url:"sort,omitempty"`
	Limit  int    `url:"limit,omitempty"`
}

type OrderBook

type OrderBook struct {
	Asks     []BookOrder `json:"asks"`
	Bids     []BookOrder `json:"bids"`
	Updated  time.Time   `json:"updated_at"`
	Sequence string      `json:"sequence"`
}

type OrderBookParams

type OrderBookParams struct {
	Book      string `url:"book"`
	Aggregate bool   `url:"aggregate,omitempty"`
}

type PlaceOrderParams

type PlaceOrderParams struct {
	Book        string `json:"book"`
	Side        string `json:"side"`
	Type        string `json:"type"`
	Major       string `json:"major,omitempty"`
	Minor       string `json:"minor,omitempty"`
	Price       string `json:"price,omitempty"`
	Stop        string `json:"stop,omitempty"`
	TimeInForce string `json:"time_in_force,omitempty"`
	OriginID    string `json:"origin_id,omitempty"`
}

type PlacedOrder

type PlacedOrder struct {
	OID string `json:"oid"`
}

type Service

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

Service is the API gateway struct.

func New

func New(httpClient *http.Client, apiKey, secret string) *Service

New setups a service struct to interact with bitso.com API.

func (*Service) Ask

func (srv *Service) Ask(ctx context.Context, amount, price, book string) (r placeOrderResponse, err error)

func (*Service) AvailableBooks

func (srv *Service) AvailableBooks(ctx context.Context) (r availableBooksResponse, err error)

AvailableBooks performs a request to bitso:v3/available_books

func (*Service) Balance

func (srv *Service) Balance(ctx context.Context) (r balanceResponse, err error)

Balance performs a request to bitso:v3/balance

func (*Service) Bid

func (srv *Service) Bid(ctx context.Context, amount, price, book string) (r placeOrderResponse, err error)

func (*Service) CancelOrder

func (srv *Service) CancelOrder(ctx context.Context, params CancelOrderParams) (r cancelOrderResponse, err error)

CancelOrder performs a request to bitso:v3/orders

func (*Service) OpenOrders

func (srv *Service) OpenOrders(ctx context.Context, params OpenOrderParams) (r openOrdersResponse, err error)

func (*Service) OrderBook

func (srv *Service) OrderBook(ctx context.Context, params OrderBookParams) (r orderBookResponse, err error)

OrderBook performs a request to bitso:v3/order_book

func (*Service) PlaceOrder

func (srv *Service) PlaceOrder(ctx context.Context, params PlaceOrderParams) (r placeOrderResponse, err error)

PlaceOrder performs a request to bitso:v3/orders

func (*Service) Ticker

func (srv *Service) Ticker(ctx context.Context, book string) (r tickResponse, err error)

Ticker performs a request to bitso:v3/ticker

type Tick

type Tick struct {
	Book     string `json:"book"`
	High     string `json:"high"`
	Vwap     string `json:"vwap"`
	Volume   string `json:"volume"`
	Last     string `json:"last"`
	Low      string `json:"low"`
	Ask      string `json:"ask"`
	Bid      string `json:"bid"`
	Change24 string `json:"change_24"`
}

type TickerParams

type TickerParams struct {
	Book string `url:"book"`
}

Jump to

Keyboard shortcuts

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