broker

package
v0.0.0-...-c46be8d Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package broker manages calls to binance api V3. Documentation about all endpoints and how should they be formed can be found at https://github.com/binance/binance-spot-api-docs

Index

Constants

View Source
const (
	OrderTypeMarket = "MARKET"
	OrderSideSell   = "SELL"
	OrderSideBuy    = "BUY"

	MaxIdleConnections = 10
	IdleConnTimeout    = 30 * time.Second
	TestNet            = "https://testnet.binance.vision/api/v3"
	APIV3              = "https://api.binance.com/api/v3"
)

Variables

View Source
var (
	ErrBrokerNotFound        = errors.New("not found")
	ErrBrokerDuplicatedEntry = errors.New("duplicated entry")
)

Functions

func ToTime

func ToTime(ut float64) time.Time

ToTime takes a Binance time format (milliseconds) and return a time.Time object

Types

type Binance

type Binance struct {
	APIKey string        // APIKey is required for calls that need authentication
	Signer encode.Signer // Signer is used to encode calls to binance that include sensitive data, like APIKey
}

Binance manages calls to binance api v3

func (Binance) Request

func (as Binance) Request(ctx context.Context, method, endpoint string, keysAndValues ...string) (rd io.Reader, err error)

Request convert a bunch of key-value pairs into an url query, it takes the api endpoint and builds the binance api request. It returns the body of the response

func (Binance) Time

func (as Binance) Time(ctx context.Context) (int64, error)

Time fetches the api time

type Broker

type Broker interface {
	Request(ctx context.Context, method, endpoint string, keysAndValues ...string) (rd io.Reader, err error)
	Time(ctx context.Context) (int64, error)
}

type TestBinance

type TestBinance struct {
	APIKey string        // APIKey is required for calls that need authentication
	Signer encode.Signer // Signer is used to encode calls to binance that include sensitive data, like APIKey
}

TestBinance manages calls to binance test api v3 if the endpoint has an test api. Currently, only order endpoint has a test api

func (TestBinance) Request

func (as TestBinance) Request(ctx context.Context, method, endpoint string, keysAndValues ...string) (rd io.Reader, err error)

Request convert a bunch of key-value pairs into an url query, it takes the api endpoint and builds the binance api request. It returns the body of the response

func (TestBinance) Time

func (as TestBinance) Time(ctx context.Context) (int64, error)

Time fetches the api time

Directories

Path Synopsis
Package encode signs HMAC SHA25 for binance request
Package encode signs HMAC SHA25 for binance request

Jump to

Keyboard shortcuts

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