exchange

package
v0.0.0-...-6214e1c Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const EXCHANGE_COMISSION = 0.0025
View Source
const EXCHANGE_PROVIDER_BITTREX = "bittrex"
View Source
const EXCHANGE_PROVIDER_FAKE = "fake"
View Source
const HISTORY_SIZE = 1000

Variables

This section is empty.

Functions

This section is empty.

Types

type Balance

type Balance struct {
	Currency      string          `json:"Currency"`
	Balance       decimal.Decimal `json:"Balance"`
	Available     decimal.Decimal `json:"Available"`
	Pending       decimal.Decimal `json:"Pending"`
	CryptoAddress string          `json:"CryptoAddress"`
	Requested     bool            `json:"Requested"`
	Uuid          string          `json:"Uuid"`
}

type CandleStick

type CandleStick struct {
	High       decimal.Decimal `json:"H,required"`
	Open       decimal.Decimal `json:"O,required"`
	Close      decimal.Decimal `json:"C,required"`
	Low        decimal.Decimal `json:"L,required"`
	Volume     decimal.Decimal `json:"V,required"`
	BaseVolume decimal.Decimal `json:"BV,required"`
	Timestamp  CandleTime      `json:"T,required"`
}

CandleStick represents a single candlestick in a chart.

func CopyCandles

func CopyCandles(candles []CandleStick) []CandleStick

type CandleTime

type CandleTime time.Time

func (*CandleTime) MarshalJSON

func (t *CandleTime) MarshalJSON() ([]byte, error)

func (*CandleTime) UnmarshalJSON

func (t *CandleTime) UnmarshalJSON(b []byte) error

type ExchangeProvider

type ExchangeProvider interface {
	Balances() ([]Balance, error)

	Balance(ticker string) (Balance, error)

	Buy(market string, amount decimal.Decimal, rate decimal.Decimal) (string, error)

	Sell(market string, amount decimal.Decimal, rate decimal.Decimal) (string, error)

	Name() string

	AllCandleSticks(market string, interval string) ([]CandleStick, error)

	LastCandleStick(market string, interval string) (CandleStick, error)

	MarketSummary(market string) (MarketSummary, error)
}

func ExchangeClient

func ExchangeClient(name string, config map[string]string) ExchangeProvider

func NewExchangeProviderBittrex

func NewExchangeProviderBittrex(pbk string, pvk string, config map[string]string) ExchangeProvider

type ExchangeProviderBittrex

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

func (ExchangeProviderBittrex) AllCandleSticks

func (p ExchangeProviderBittrex) AllCandleSticks(market string, interval string) ([]CandleStick, error)

func (ExchangeProviderBittrex) Balance

func (p ExchangeProviderBittrex) Balance(ticker string) (Balance, error)

func (ExchangeProviderBittrex) Balances

func (p ExchangeProviderBittrex) Balances() ([]Balance, error)

func (ExchangeProviderBittrex) Buy

func (p ExchangeProviderBittrex) Buy(market string, amount decimal.Decimal, rate decimal.Decimal) (string, error)

func (ExchangeProviderBittrex) LastCandleStick

func (p ExchangeProviderBittrex) LastCandleStick(market string, interval string) (CandleStick, error)

func (ExchangeProviderBittrex) MarketSummary

func (p ExchangeProviderBittrex) MarketSummary(market string) (MarketSummary, error)

func (ExchangeProviderBittrex) Name

func (ExchangeProviderBittrex) Sell

func (p ExchangeProviderBittrex) Sell(market string, amount decimal.Decimal, rate decimal.Decimal) (string, error)

type ExchangeProviderFake

type ExchangeProviderFake struct {
	Actions []TestMarketAction
	// contains filtered or unexported fields
}

func NewExchangeProviderFake

func NewExchangeProviderFake(testbed []CandleStick, config map[string]string, balances map[string]decimal.Decimal) ExchangeProviderFake

func (*ExchangeProviderFake) AllCandleSticks

func (p *ExchangeProviderFake) AllCandleSticks(market string, interval string) ([]CandleStick, error)

func (*ExchangeProviderFake) Balance

func (p *ExchangeProviderFake) Balance(ticker string) (Balance, error)

func (*ExchangeProviderFake) Balances

func (p *ExchangeProviderFake) Balances() ([]Balance, error)

func (*ExchangeProviderFake) Buy

func (p *ExchangeProviderFake) Buy(market string, amount decimal.Decimal, rate decimal.Decimal) (string, error)

func (*ExchangeProviderFake) LastCandleStick

func (p *ExchangeProviderFake) LastCandleStick(market string, interval string) (CandleStick, error)

func (*ExchangeProviderFake) MarketSummary

func (p *ExchangeProviderFake) MarketSummary(market string) (MarketSummary, error)

func (*ExchangeProviderFake) Name

func (p *ExchangeProviderFake) Name() string

func (*ExchangeProviderFake) OnEnd

func (p *ExchangeProviderFake) OnEnd(cb func())

func (*ExchangeProviderFake) Sell

func (p *ExchangeProviderFake) Sell(market string, amount decimal.Decimal, rate decimal.Decimal) (string, error)

type MarketSummary

type MarketSummary struct {
	MarketName string          `json:"MarketName,required"` //The name of the market (e.g. BTC-ETH).
	High       decimal.Decimal `json:"High,required"`       // The 24h high for the market.
	Low        decimal.Decimal `json:"Low,required"`        // The 24h low for the market.
	Last       decimal.Decimal `json:"Last,required"`       // The value of the last trade for the market (in base currency).
	Bid        decimal.Decimal `json:"Bid,required"`        // The current highest bid value for the market.
	Ask        decimal.Decimal `json:"Ask,required"`        // The current lowest ask value for the market.
	Volume     decimal.Decimal `json:"Volume,required"`     // The 24h volume of the market, in market currency.
	BaseVolume decimal.Decimal `json:"BaseVolume,required"` // The 24h volume for the market, in base currency.
}

type TestMarketAction

type TestMarketAction struct {
	Action int
	Value  decimal.Decimal
	Date   string
}

Jump to

Keyboard shortcuts

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