exchanges

package
Version: v0.0.2-alpha.0...-0fc358b Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2019 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Overview

Package exchanges contains all wrappers for common exchanges.

Index

Constants

View Source
const (
	// TakerTrade represents the "buy" order type.
	TakerTrade = "taker"
	// MakerTrade represents the "sell" order type.
	MakerTrade = "maker"
)

Variables

View Source
var ErrWebsocketNotSupported = errors.New("Cannot use websocket: exchange does not support it")

ErrWebsocketNotSupported is the error representing when an exchange does not support websocket.

Functions

func MarketNameFor

func MarketNameFor(m *environment.Market, wrapper ExchangeWrapper) string

MarketNameFor gets the market name as seen by the exchange.

Types

type BinanceWrapper

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

BinanceWrapper represents the wrapper for the Binance exchange.

func (*BinanceWrapper) BuyLimit

func (wrapper *BinanceWrapper) BuyLimit(market *environment.Market, amount float64, limit float64) (string, error)

BuyLimit performs a limit buy action.

func (*BinanceWrapper) BuyMarket

func (wrapper *BinanceWrapper) BuyMarket(market *environment.Market, amount float64) (string, error)

BuyMarket performs a market buy action.

func (*BinanceWrapper) CalculateTradingFees

func (wrapper *BinanceWrapper) CalculateTradingFees(market *environment.Market, amount float64, limit float64, orderType TradeType) float64

CalculateTradingFees calculates the trading fees for an order on a specified market.

NOTE: In Binance fees are currently hardcoded.

func (*BinanceWrapper) CalculateWithdrawFees

func (wrapper *BinanceWrapper) CalculateWithdrawFees(market *environment.Market, amount float64) float64

CalculateWithdrawFees calculates the withdrawal fees on a specified market.

func (*BinanceWrapper) FeedConnect

func (wrapper *BinanceWrapper) FeedConnect(markets []*environment.Market) error

FeedConnect connects to the feed of the exchange.

func (*BinanceWrapper) GetBalance

func (wrapper *BinanceWrapper) GetBalance(symbol string) (*decimal.Decimal, error)

GetBalance gets the balance of the user of the specified currency.

func (*BinanceWrapper) GetCandles

func (wrapper *BinanceWrapper) GetCandles(market *environment.Market) ([]environment.CandleStick, error)

GetCandles gets the candle data from the exchange.

func (*BinanceWrapper) GetDepositAddress

func (wrapper *BinanceWrapper) GetDepositAddress(coinTicker string) (string, bool)

GetDepositAddress gets the deposit address for the specified coin on the exchange.

func (*BinanceWrapper) GetMarketSummary

func (wrapper *BinanceWrapper) GetMarketSummary(market *environment.Market) (*environment.MarketSummary, error)

GetMarketSummary gets the current market summary.

func (*BinanceWrapper) GetMarkets

func (wrapper *BinanceWrapper) GetMarkets() ([]*environment.Market, error)

GetMarkets Gets all the markets info.

func (*BinanceWrapper) GetOrderBook

func (wrapper *BinanceWrapper) GetOrderBook(market *environment.Market) (*environment.OrderBook, error)

GetOrderBook gets the order(ASK + BID) book of a market.

func (*BinanceWrapper) GetTicker

func (wrapper *BinanceWrapper) GetTicker(market *environment.Market) (*environment.Ticker, error)

GetTicker gets the updated ticker for a market.

func (*BinanceWrapper) Name

func (wrapper *BinanceWrapper) Name() string

Name returns the name of the wrapped exchange.

func (*BinanceWrapper) SellLimit

func (wrapper *BinanceWrapper) SellLimit(market *environment.Market, amount float64, limit float64) (string, error)

SellLimit performs a limit sell action.

func (*BinanceWrapper) SellMarket

func (wrapper *BinanceWrapper) SellMarket(market *environment.Market, amount float64) (string, error)

SellMarket performs a market sell action.

func (*BinanceWrapper) String

func (wrapper *BinanceWrapper) String() string

func (*BinanceWrapper) Withdraw

func (wrapper *BinanceWrapper) Withdraw(destinationAddress string, coinTicker string, amount float64) error

Withdraw performs a withdraw operation from the exchange to a destination address.

type BitfinexWrapper

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

BitfinexWrapper provides a Generic wrapper of the Bitfinex API.

func (*BitfinexWrapper) BuyLimit

func (wrapper *BitfinexWrapper) BuyLimit(market *environment.Market, amount float64, limit float64) (string, error)

BuyLimit performs a limit buy action.

NOTE: In bitfinex buy and sell orders behave the same (the go bitfinex api automatically puts it on correct side)

func (*BitfinexWrapper) BuyMarket

func (wrapper *BitfinexWrapper) BuyMarket(market *environment.Market, amount float64) (string, error)

BuyMarket performs a limit buy action.

NOTE: In bitfinex buy and sell orders behave the same (the go bitfinex api automatically puts it on correct side)

func (*BitfinexWrapper) CalculateTradingFees

func (wrapper *BitfinexWrapper) CalculateTradingFees(market *environment.Market, amount float64, limit float64, orderType TradeType) float64

CalculateTradingFees calculates the trading fees for an order on a specified market.

NOTE: In Bitfinex fees are currently hardcoded.

func (*BitfinexWrapper) CalculateWithdrawFees

func (wrapper *BitfinexWrapper) CalculateWithdrawFees(market *environment.Market, amount float64) float64

CalculateWithdrawFees calculates the withdrawal fees on a specified market.

func (*BitfinexWrapper) FeedConnect

func (wrapper *BitfinexWrapper) FeedConnect(markets []*environment.Market) error

FeedConnect connects to the feed of the exchange.

func (*BitfinexWrapper) GetBalance

func (wrapper *BitfinexWrapper) GetBalance(symbol string) (*decimal.Decimal, error)

GetBalance gets the balance of the user of the specified currency.

func (*BitfinexWrapper) GetCandles

func (wrapper *BitfinexWrapper) GetCandles(market *environment.Market) ([]environment.CandleStick, error)

GetCandles gets the candle data from the exchange.

func (*BitfinexWrapper) GetDepositAddress

func (wrapper *BitfinexWrapper) GetDepositAddress(coinTicker string) (string, bool)

GetDepositAddress gets the deposit address for the specified coin on the exchange.

func (*BitfinexWrapper) GetMarketSummary

func (wrapper *BitfinexWrapper) GetMarketSummary(market *environment.Market) (*environment.MarketSummary, error)

GetMarketSummary gets the current market summary.

func (*BitfinexWrapper) GetMarkets

func (wrapper *BitfinexWrapper) GetMarkets() ([]*environment.Market, error)

GetMarkets gets all the markets info.

func (*BitfinexWrapper) GetOrderBook

func (wrapper *BitfinexWrapper) GetOrderBook(market *environment.Market) (*environment.OrderBook, error)

GetOrderBook gets the order(ASK + BID) book of a market.

func (*BitfinexWrapper) GetTicker

func (wrapper *BitfinexWrapper) GetTicker(market *environment.Market) (*environment.Ticker, error)

GetTicker gets the updated ticker for a market.

func (*BitfinexWrapper) Name

func (wrapper *BitfinexWrapper) Name() string

Name returns the name of the wrapped exchange.

func (*BitfinexWrapper) SellLimit

func (wrapper *BitfinexWrapper) SellLimit(market *environment.Market, amount float64, limit float64) (string, error)

SellLimit performs a limit sell action.

NOTE: In bitfinex buy and sell orders behave the same (the go bitfinex api automatically puts it on correct side)

func (*BitfinexWrapper) SellMarket

func (wrapper *BitfinexWrapper) SellMarket(market *environment.Market, amount float64) (string, error)

SellMarket performs a limit sell action.

NOTE: In bitfinex buy and sell orders behave the same (the go bitfinex api automatically puts it on correct side)

func (*BitfinexWrapper) String

func (wrapper *BitfinexWrapper) String() string

func (*BitfinexWrapper) Withdraw

func (wrapper *BitfinexWrapper) Withdraw(destinationAddress string, coinTicker string, amount float64) error

Withdraw performs a withdraw operation from the exchange to a destination address.

type BittrexWrapper

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

BittrexWrapper provides a Generic wrapper of the Bittrex API.

func (*BittrexWrapper) BuyLimit

func (wrapper *BittrexWrapper) BuyLimit(market *environment.Market, amount float64, limit float64) (string, error)

BuyLimit performs a limit buy action.

func (*BittrexWrapper) BuyMarket

func (wrapper *BittrexWrapper) BuyMarket(market *environment.Market, amount float64) (string, error)

BuyMarket performs a market buy action.

func (*BittrexWrapper) CalculateTradingFees

func (wrapper *BittrexWrapper) CalculateTradingFees(market *environment.Market, amount float64, limit float64, orderType TradeType) float64

CalculateTradingFees calculates the trading fees for an order on a specified market.

NOTE: In Bittrex fees are hardcoded due to the inability to obtain them via API before placing an order.

func (*BittrexWrapper) CalculateWithdrawFees

func (wrapper *BittrexWrapper) CalculateWithdrawFees(market *environment.Market, amount float64) float64

CalculateWithdrawFees calculates the withdrawal fees on a specified market.

func (*BittrexWrapper) FeedConnect

func (wrapper *BittrexWrapper) FeedConnect(markets []*environment.Market) error

FeedConnect connects to the feed of the exchange.

func (*BittrexWrapper) GetBalance

func (wrapper *BittrexWrapper) GetBalance(symbol string) (*decimal.Decimal, error)

GetBalance gets the balance of the user of the specified currency.

func (*BittrexWrapper) GetCandles

func (wrapper *BittrexWrapper) GetCandles(market *environment.Market) ([]environment.CandleStick, error)

GetCandles gets the candle data from the exchange.

func (*BittrexWrapper) GetDepositAddress

func (wrapper *BittrexWrapper) GetDepositAddress(coinTicker string) (string, bool)

GetDepositAddress gets the deposit address for the specified coin on the exchange.

func (*BittrexWrapper) GetMarketSummary

func (wrapper *BittrexWrapper) GetMarketSummary(market *environment.Market) (*environment.MarketSummary, error)

GetMarketSummary gets the current market summary.

func (*BittrexWrapper) GetMarkets

func (wrapper *BittrexWrapper) GetMarkets() ([]*environment.Market, error)

GetMarkets gets all the markets info.

func (*BittrexWrapper) GetOrderBook

func (wrapper *BittrexWrapper) GetOrderBook(market *environment.Market) (*environment.OrderBook, error)

GetOrderBook gets the order(ASK + BID) book of a market.

func (*BittrexWrapper) GetTicker

func (wrapper *BittrexWrapper) GetTicker(market *environment.Market) (*environment.Ticker, error)

GetTicker gets the updated ticker for a market.

func (*BittrexWrapper) Name

func (wrapper *BittrexWrapper) Name() string

Name returns the name of the wrapped exchange.

func (*BittrexWrapper) SellLimit

func (wrapper *BittrexWrapper) SellLimit(market *environment.Market, amount float64, limit float64) (string, error)

SellLimit performs a limit sell action.

func (*BittrexWrapper) SellMarket

func (wrapper *BittrexWrapper) SellMarket(market *environment.Market, amount float64) (string, error)

SellMarket performs a market sell action.

func (*BittrexWrapper) String

func (wrapper *BittrexWrapper) String() string

func (*BittrexWrapper) Withdraw

func (wrapper *BittrexWrapper) Withdraw(destinationAddress string, coinTicker string, amount float64) error

Withdraw performs a withdraw operation from the exchange to a destination address.

type BittrexWrapperV2

type BittrexWrapperV2 struct {
	PublicKey string
	SecretKey string
	// contains filtered or unexported fields
}

BittrexWrapperV2 wraps Bittrex API v2.0

func (*BittrexWrapperV2) BuyLimit

func (wrapper *BittrexWrapperV2) BuyLimit(market *environment.Market, amount float64, limit float64) (string, error)

BuyLimit performs a limit buy action.

func (*BittrexWrapperV2) BuyMarket

func (wrapper *BittrexWrapperV2) BuyMarket(market *environment.Market, amount float64) (string, error)

BuyMarket performs a market buy action.

func (*BittrexWrapperV2) CalculateTradingFees

func (wrapper *BittrexWrapperV2) CalculateTradingFees(market *environment.Market, amount float64, limit float64, orderType TradeType) float64

CalculateTradingFees calculates the trading fees for an order on a specified market.

NOTE: In Bittrex fees are hardcoded due to the inability to obtain them via API before placing an order.

func (*BittrexWrapperV2) CalculateWithdrawFees

func (wrapper *BittrexWrapperV2) CalculateWithdrawFees(market *environment.Market, amount float64) float64

CalculateWithdrawFees calculates the withdrawal fees on a specified market.

func (*BittrexWrapperV2) FeedConnect

func (wrapper *BittrexWrapperV2) FeedConnect(markets []*environment.Market) error

FeedConnect connects to the feed of the exchange.

NOTE: Not supported on Bittrex v1 API, use *BittrexWrapperV2.

func (*BittrexWrapperV2) GetBalance

func (wrapper *BittrexWrapperV2) GetBalance(symbol string) (*decimal.Decimal, error)

GetBalance gets the balance of the user of the specified currency.

func (*BittrexWrapperV2) GetCandles

func (wrapper *BittrexWrapperV2) GetCandles(market *environment.Market) ([]environment.CandleStick, error)

GetCandles gets the candle data from the exchange.

func (*BittrexWrapperV2) GetDepositAddress

func (wrapper *BittrexWrapperV2) GetDepositAddress(coinTicker string) (string, bool)

GetDepositAddress gets the deposit address for the specified coin on the exchange.

func (*BittrexWrapperV2) GetMarketSummary

func (wrapper *BittrexWrapperV2) GetMarketSummary(market *environment.Market) (*environment.MarketSummary, error)

GetMarketSummary gets the current market summary.

func (*BittrexWrapperV2) GetMarkets

func (wrapper *BittrexWrapperV2) GetMarkets() ([]*environment.Market, error)

GetMarkets gets all the markets info.

func (*BittrexWrapperV2) GetOrderBook

func (wrapper *BittrexWrapperV2) GetOrderBook(market *environment.Market) (*environment.OrderBook, error)

GetOrderBook gets the order(ASK + BID) book of a market.

func (*BittrexWrapperV2) Name

func (wrapper *BittrexWrapperV2) Name() string

Name returns the name of the wrapped exchange.

func (*BittrexWrapperV2) SellLimit

func (wrapper *BittrexWrapperV2) SellLimit(market *environment.Market, amount float64, limit float64) (string, error)

SellLimit performs a limit sell action.

func (*BittrexWrapperV2) SellMarket

func (wrapper *BittrexWrapperV2) SellMarket(market *environment.Market, amount float64) (string, error)

SellMarket performs a market sell action.

func (*BittrexWrapperV2) String

func (wrapper *BittrexWrapperV2) String() string

func (*BittrexWrapperV2) Withdraw

func (wrapper *BittrexWrapperV2) Withdraw(destinationAddress string, coinTicker string, amount float64) error

Withdraw performs a withdraw operation from the exchange to a destination address.

type CandlesCache

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

CandlesCache represents a local candles cache for every exchange. To allow dinamic polling from multiple sources (REST + Websocket)

func NewCandlesCache

func NewCandlesCache() *CandlesCache

NewCandlesCache creates a new CandlesCache Object

func (*CandlesCache) Get

Get gets the value for the specified key.

func (*CandlesCache) Set

Set sets a value for the specified key.

type ExchangeWrapper

type ExchangeWrapper interface {
	Name() string                                                                    // Gets the name of the exchange.
	GetCandles(market *environment.Market) ([]environment.CandleStick, error)        // Gets the candle data from the exchange.
	GetMarketSummary(market *environment.Market) (*environment.MarketSummary, error) // Gets the current market summary.
	GetOrderBook(market *environment.Market) (*environment.OrderBook, error)         // Gets the order(ASK + BID) book of a market.

	BuyLimit(market *environment.Market, amount float64, limit float64) (string, error)  // Performs a limit buy action.
	SellLimit(market *environment.Market, amount float64, limit float64) (string, error) // Performs a limit sell action.
	BuyMarket(market *environment.Market, amount float64) (string, error)                // Performs a market buy action.
	SellMarket(market *environment.Market, amount float64) (string, error)               // Performs a market sell action.

	CalculateTradingFees(market *environment.Market, amount float64, limit float64, orderType TradeType) float64 // Calculates the trading fees for an order on a specified market.
	CalculateWithdrawFees(market *environment.Market, amount float64) float64                                    // Calculates the withdrawal fees on a specified market.

	GetBalance(symbol string) (*decimal.Decimal, error) // Gets the balance of the user of the specified currency.
	GetDepositAddress(coinTicker string) (string, bool) // Gets the deposit address for the specified coin on the exchange, if exists.

	FeedConnect(markets []*environment.Market) error // Connects to the feed of the exchange.

	Withdraw(destinationAddress string, coinTicker string, amount float64) error // Performs a withdraw operation from the exchange to a destination address.

	String() string // Returns a string representation of the object.
}

ExchangeWrapper provides a generic wrapper for exchange services.

func NewBinanceWrapper

func NewBinanceWrapper(publicKey string, secretKey string, depositAddresses map[string]string) ExchangeWrapper

NewBinanceWrapper creates a generic wrapper of the binance API.

func NewBitfinexWrapper

func NewBitfinexWrapper(publicKey string, secretKey string, depositAddresses map[string]string) ExchangeWrapper

NewBitfinexWrapper creates a generic wrapper of the bittrex API.

func NewBittrexV2Wrapper

func NewBittrexV2Wrapper(publicKey string, secretKey string, depositAddresses map[string]string) ExchangeWrapper

NewBittrexV2Wrapper creates a generic wrapper of the bittrex API v2.0.

func NewBittrexWrapper

func NewBittrexWrapper(publicKey string, secretKey string, depositAddresses map[string]string) ExchangeWrapper

NewBittrexWrapper creates a generic wrapper of the bittrex API.

func NewHitBtcV2Wrapper

func NewHitBtcV2Wrapper(publicKey string, secretKey string, depositAddresses map[string]string) ExchangeWrapper

NewHitBtcV2Wrapper creates a generic wrapper of the HitBtc API v2.0.

func NewKrakenWrapper

func NewKrakenWrapper(publicKey string, secretKey string, depositAddresses map[string]string) ExchangeWrapper

NewKrakenWrapper creates a generic wrapper of the poloniex API.

func NewKucoinWrapper

func NewKucoinWrapper(publicKey string, secretKey string, depositAddresses map[string]string) ExchangeWrapper

NewKucoinWrapper creates a generic wrapper of theKucoin

func NewPoloniexWrapper

func NewPoloniexWrapper(publicKey string, secretKey string, depositAddresses map[string]string) ExchangeWrapper

NewPoloniexWrapper creates a generic wrapper of the poloniex API.

type ExchangeWrapperSimulator

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

ExchangeWrapperSimulator wraps another wrapper and returns simulated balances and orders.

func NewExchangeWrapperSimulator

func NewExchangeWrapperSimulator(mockedWrapper ExchangeWrapper, initialBalances map[string]decimal.Decimal) *ExchangeWrapperSimulator

NewExchangeWrapperSimulator creates a new simulated wrapper from another wrapper and an initial balance.

func (*ExchangeWrapperSimulator) BuyLimit

func (wrapper *ExchangeWrapperSimulator) BuyLimit(market *environment.Market, amount float64, limit float64) (string, error)

BuyLimit here is just to implement the ExchangeWrapper Interface, do not use, use BuyMarket instead.

func (*ExchangeWrapperSimulator) BuyMarket

func (wrapper *ExchangeWrapperSimulator) BuyMarket(market *environment.Market, amount float64) (string, error)

BuyMarket performs a FAKE market buy action.

func (*ExchangeWrapperSimulator) CalculateTradingFees

func (wrapper *ExchangeWrapperSimulator) CalculateTradingFees(market *environment.Market, amount float64, limit float64, orderType TradeType) float64

CalculateTradingFees calculates the trading fees for an order on a specified market.

func (*ExchangeWrapperSimulator) CalculateWithdrawFees

func (wrapper *ExchangeWrapperSimulator) CalculateWithdrawFees(market *environment.Market, amount float64) float64

CalculateWithdrawFees calculates the withdrawal fees on a specified market.

func (*ExchangeWrapperSimulator) FeedConnect

func (wrapper *ExchangeWrapperSimulator) FeedConnect(markets []*environment.Market) error

FeedConnect connects to the feed of the exchange.

func (*ExchangeWrapperSimulator) GetBalance

func (wrapper *ExchangeWrapperSimulator) GetBalance(symbol string) (*decimal.Decimal, error)

GetBalance gets the balance of the user of the specified currency.

func (*ExchangeWrapperSimulator) GetCandles

func (wrapper *ExchangeWrapperSimulator) GetCandles(market *environment.Market) ([]environment.CandleStick, error)

GetCandles gets the candle data from the exchange.

func (*ExchangeWrapperSimulator) GetDepositAddress

func (wrapper *ExchangeWrapperSimulator) GetDepositAddress(coinTicker string) (string, bool)

GetDepositAddress gets the deposit address for the specified coin on the exchange.

func (*ExchangeWrapperSimulator) GetMarketSummary

func (wrapper *ExchangeWrapperSimulator) GetMarketSummary(market *environment.Market) (*environment.MarketSummary, error)

GetMarketSummary gets the current market summary.

func (*ExchangeWrapperSimulator) GetOrderBook

func (wrapper *ExchangeWrapperSimulator) GetOrderBook(market *environment.Market) (*environment.OrderBook, error)

GetOrderBook gets the order(ASK + BID) book of a market.

func (*ExchangeWrapperSimulator) Name

func (wrapper *ExchangeWrapperSimulator) Name() string

Name gets the name of the exchange.

func (*ExchangeWrapperSimulator) SellLimit

func (wrapper *ExchangeWrapperSimulator) SellLimit(market *environment.Market, amount float64, limit float64) (string, error)

SellLimit here is just to implement the ExchangeWrapper Interface, do not use, use SellMarket instead.

func (*ExchangeWrapperSimulator) SellMarket

func (wrapper *ExchangeWrapperSimulator) SellMarket(market *environment.Market, amount float64) (string, error)

SellMarket performs a FAKE market buy action.

func (*ExchangeWrapperSimulator) String

func (wrapper *ExchangeWrapperSimulator) String() string

String returns a string representation of the exchange simulator.

func (*ExchangeWrapperSimulator) Withdraw

func (wrapper *ExchangeWrapperSimulator) Withdraw(destinationAddress string, coinTicker string, amount float64) error

Withdraw performs a FAKE withdraw operation from the exchange to a destination address.

type HitBtcWrapperV2

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

HitBtcWrapperV2 wraps HitBtc API v2.0

func (*HitBtcWrapperV2) BuyLimit

func (wrapper *HitBtcWrapperV2) BuyLimit(market *environment.Market, amount float64, limit float64) (string, error)

BuyLimit performs a limit buy action.

func (*HitBtcWrapperV2) BuyMarket

func (wrapper *HitBtcWrapperV2) BuyMarket(market *environment.Market, amount float64) (string, error)

BuyMarket performs a market buy action.

func (*HitBtcWrapperV2) CalculateTradingFees

func (wrapper *HitBtcWrapperV2) CalculateTradingFees(market *environment.Market, amount float64, limit float64, orderType TradeType) float64

CalculateTradingFees calculates the trading fees for an order on a specified market.

func (*HitBtcWrapperV2) CalculateWithdrawFees

func (wrapper *HitBtcWrapperV2) CalculateWithdrawFees(market *environment.Market, amount float64) float64

CalculateWithdrawFees calculates the withdrawal fees on a specified market.

func (*HitBtcWrapperV2) FeedConnect

func (wrapper *HitBtcWrapperV2) FeedConnect(markets []*environment.Market) error

FeedConnect connects to the feed of the exchange.

func (*HitBtcWrapperV2) GetBalance

func (wrapper *HitBtcWrapperV2) GetBalance(symbol string) (*decimal.Decimal, error)

GetBalance gets the balance of the user of the specified currency.

func (*HitBtcWrapperV2) GetCandles

func (wrapper *HitBtcWrapperV2) GetCandles(market *environment.Market) ([]environment.CandleStick, error)

GetCandles gets the candle data from the exchange.

func (*HitBtcWrapperV2) GetDepositAddress

func (wrapper *HitBtcWrapperV2) GetDepositAddress(coinTicker string) (string, bool)

GetDepositAddress gets the deposit address for the specified coin on the exchange.

func (*HitBtcWrapperV2) GetMarketSummary

func (wrapper *HitBtcWrapperV2) GetMarketSummary(market *environment.Market) (*environment.MarketSummary, error)

GetMarketSummary gets the current market summary.

func (*HitBtcWrapperV2) GetMarkets

func (wrapper *HitBtcWrapperV2) GetMarkets() ([]*environment.Market, error)

GetMarkets gets all the markets info.

func (*HitBtcWrapperV2) GetOrderBook

func (wrapper *HitBtcWrapperV2) GetOrderBook(market *environment.Market) (*environment.OrderBook, error)

GetOrderBook gets the order(ASK + BID) book of a market.

func (*HitBtcWrapperV2) GetTicker

func (wrapper *HitBtcWrapperV2) GetTicker(market *environment.Market) (*environment.Ticker, error)

GetTicker gets the updated ticker for a market.

func (*HitBtcWrapperV2) Name

func (wrapper *HitBtcWrapperV2) Name() string

Name returns the name of the wrapped exchange.

func (*HitBtcWrapperV2) SellLimit

func (wrapper *HitBtcWrapperV2) SellLimit(market *environment.Market, amount float64, limit float64) (string, error)

SellLimit performs a limit sell action.

func (*HitBtcWrapperV2) SellMarket

func (wrapper *HitBtcWrapperV2) SellMarket(market *environment.Market, amount float64) (string, error)

SellMarket performs a market sell action.

func (*HitBtcWrapperV2) String

func (wrapper *HitBtcWrapperV2) String() string

func (*HitBtcWrapperV2) Withdraw

func (wrapper *HitBtcWrapperV2) Withdraw(destinationAddress string, coinTicker string, amount float64) error

Withdraw performs a withdraw operation from the exchange to a destination address.

type KrakenWrapper

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

KrakenWrapper provides a Generic wrapper of the Kraken API.

func (*KrakenWrapper) BuyLimit

func (wrapper *KrakenWrapper) BuyLimit(market *environment.Market, amount float64, limit float64) (string, error)

BuyLimit performs a limit buy action.

func (*KrakenWrapper) BuyMarket

func (wrapper *KrakenWrapper) BuyMarket(market *environment.Market, amount float64) (string, error)

BuyMarket performs a market buy action.

func (*KrakenWrapper) CalculateTradingFees

func (wrapper *KrakenWrapper) CalculateTradingFees(market *environment.Market, amount float64, limit float64, orderType TradeType) float64

CalculateTradingFees calculates the trading fees for an order on a specified market.

NOTE: In Kraken fees are currently hardcoded.

func (*KrakenWrapper) CalculateWithdrawFees

func (wrapper *KrakenWrapper) CalculateWithdrawFees(market *environment.Market, amount float64) float64

CalculateWithdrawFees calculates the withdrawal fees on a specified market.

func (*KrakenWrapper) FeedConnect

func (wrapper *KrakenWrapper) FeedConnect(markets []*environment.Market) error

FeedConnect connects to the feed of the exchange.

func (*KrakenWrapper) GetBalance

func (wrapper *KrakenWrapper) GetBalance(symbol string) (*decimal.Decimal, error)

GetBalance gets the balance of the user of the specified currency.

func (*KrakenWrapper) GetCandles

func (wrapper *KrakenWrapper) GetCandles(market *environment.Market) ([]environment.CandleStick, error)

GetCandles gets the candle data from the exchange.

func (*KrakenWrapper) GetDepositAddress

func (wrapper *KrakenWrapper) GetDepositAddress(coinTicker string) (string, bool)

GetDepositAddress gets the deposit address for the specified coin on the exchange.

func (*KrakenWrapper) GetMarketSummary

func (wrapper *KrakenWrapper) GetMarketSummary(market *environment.Market) (*environment.MarketSummary, error)

GetMarketSummary gets the current market summary.

func (*KrakenWrapper) GetMarkets

func (wrapper *KrakenWrapper) GetMarkets() ([]*environment.Market, error)

GetMarkets gets all the markets info.

func (*KrakenWrapper) GetOrderBook

func (wrapper *KrakenWrapper) GetOrderBook(market *environment.Market) (*environment.OrderBook, error)

GetOrderBook gets the order(ASK + BID) book of a market.

func (*KrakenWrapper) GetTicker

func (wrapper *KrakenWrapper) GetTicker(market *environment.Market) (*environment.Ticker, error)

GetTicker gets the updated ticker for a market.

func (*KrakenWrapper) Name

func (wrapper *KrakenWrapper) Name() string

Name returns the name of the wrapped exchange.

func (*KrakenWrapper) SellLimit

func (wrapper *KrakenWrapper) SellLimit(market *environment.Market, amount float64, limit float64) (string, error)

SellLimit performs a limit sell action.

NOTE: In kraken buy and sell orders behave the same (the go kraken api automatically puts it on correct side)

func (*KrakenWrapper) SellMarket

func (wrapper *KrakenWrapper) SellMarket(market *environment.Market, amount float64) (string, error)

SellMarket performs a market sell action.

func (*KrakenWrapper) String

func (wrapper *KrakenWrapper) String() string

func (*KrakenWrapper) Withdraw

func (wrapper *KrakenWrapper) Withdraw(destinationAddress string, coinTicker string, amount float64) error

Withdraw performs a withdraw operation from the exchange to a destination address.

type KucoinWrapper

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

KucoinWrapper wrapsKucoin

func (*KucoinWrapper) BuyLimit

func (wrapper *KucoinWrapper) BuyLimit(market *environment.Market, amount, limit float64) (string, error)

BuyLimit performs a limit buy action.

func (*KucoinWrapper) BuyMarket

func (wrapper *KucoinWrapper) BuyMarket(market *environment.Market, amount float64) (string, error)

BuyMarket performs a market buy action.

func (*KucoinWrapper) CalculateTradingFees

func (wrapper *KucoinWrapper) CalculateTradingFees(market *environment.Market, amount float64, limit float64, orderType TradeType) float64

CalculateTradingFees calculates the trading fees for an order on a specified market.

func (*KucoinWrapper) CalculateWithdrawFees

func (wrapper *KucoinWrapper) CalculateWithdrawFees(market *environment.Market, amount float64) float64

CalculateWithdrawFees calculates the withdrawal fees on a specified market.

func (*KucoinWrapper) FeedConnect

func (wrapper *KucoinWrapper) FeedConnect(markets []*environment.Market) error

FeedConnect connects to the feed of the exchange.

func (*KucoinWrapper) GetBalance

func (wrapper *KucoinWrapper) GetBalance(symbol string) (*decimal.Decimal, error)

GetBalance gets the balance of the user of the specified currency.

func (*KucoinWrapper) GetCandles

func (wrapper *KucoinWrapper) GetCandles(market *environment.Market) ([]environment.CandleStick, error)

GetCandles gets the candle data from the exchange.

func (*KucoinWrapper) GetDepositAddress

func (wrapper *KucoinWrapper) GetDepositAddress(coinTicker string) (string, bool)

GetDepositAddress gets the deposit address for the specified coin on the exchange.

func (*KucoinWrapper) GetMarketSummary

func (wrapper *KucoinWrapper) GetMarketSummary(market *environment.Market) (*environment.MarketSummary, error)

GetMarketSummary gets the current market summary.

func (*KucoinWrapper) GetMarkets

func (wrapper *KucoinWrapper) GetMarkets() ([]*environment.Market, error)

GetMarkets gets all the markets info.

func (*KucoinWrapper) GetOrderBook

func (wrapper *KucoinWrapper) GetOrderBook(market *environment.Market) (*environment.OrderBook, error)

GetOrderBook gets the order(ASK + BID) book of a market.

func (*KucoinWrapper) GetTicker

func (wrapper *KucoinWrapper) GetTicker(market *environment.Market) (*environment.Ticker, error)

GetTicker gets the updated ticker for a market.

func (*KucoinWrapper) Name

func (wrapper *KucoinWrapper) Name() string

Name returns the name of the wrapped exchange.

func (*KucoinWrapper) SellLimit

func (wrapper *KucoinWrapper) SellLimit(market *environment.Market, amount, limit float64) (string, error)

SellLimit performs a limit sell action.

func (*KucoinWrapper) SellMarket

func (wrapper *KucoinWrapper) SellMarket(market *environment.Market, amount float64) (string, error)

SellMarket performs a market sell action.

func (*KucoinWrapper) String

func (wrapper *KucoinWrapper) String() string

func (*KucoinWrapper) Withdraw

func (wrapper *KucoinWrapper) Withdraw(destinationAddress string, coinTicker string, amount float64) error

Withdraw performs a withdraw operation from the exchange to a destination address.

type OrderbookCache

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

OrderbookCache represents a local orderbook cache for every exchange. To allow dinamic polling from multiple sources (REST + Websocket)

func NewOrderbookCache

func NewOrderbookCache() *OrderbookCache

NewOrderbookCache creates a new OrderbookCache Object

func (*OrderbookCache) Get

Get gets the value for the specified key.

func (*OrderbookCache) Set

Set sets a value for the specified key.

type PoloniexWrapper

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

PoloniexWrapper provides a Generic wrapper of the Poloniex API.

func (*PoloniexWrapper) BuyLimit

func (wrapper *PoloniexWrapper) BuyLimit(market *environment.Market, amount float64, limit float64) (string, error)

BuyLimit performs a limit buy action.

func (*PoloniexWrapper) BuyMarket

func (wrapper *PoloniexWrapper) BuyMarket(market *environment.Market, amount float64) (string, error)

BuyMarket performs a market buy action.

func (*PoloniexWrapper) CalculateTradingFees

func (wrapper *PoloniexWrapper) CalculateTradingFees(market *environment.Market, amount float64, limit float64, orderType TradeType) float64

CalculateTradingFees calculates the trading fees for an order on a specified market.

NOTE: In Binance fees are currently hardcoded.

func (*PoloniexWrapper) CalculateWithdrawFees

func (wrapper *PoloniexWrapper) CalculateWithdrawFees(market *environment.Market, amount float64) float64

CalculateWithdrawFees calculates the withdrawal fees on a specified market.

func (*PoloniexWrapper) FeedConnect

func (wrapper *PoloniexWrapper) FeedConnect(markets []*environment.Market) error

FeedConnect connects to the feed of the poloniex websocket.

func (*PoloniexWrapper) GetBalance

func (wrapper *PoloniexWrapper) GetBalance(symbol string) (*decimal.Decimal, error)

GetBalance gets the balance of the user of the specified currency.

func (*PoloniexWrapper) GetCandles

func (wrapper *PoloniexWrapper) GetCandles(market *environment.Market) ([]environment.CandleStick, error)

GetCandles gets the candle data from the exchange.

func (*PoloniexWrapper) GetDepositAddress

func (wrapper *PoloniexWrapper) GetDepositAddress(coinTicker string) (string, bool)

GetDepositAddress gets the deposit address for the specified coin on the exchange.

func (*PoloniexWrapper) GetMarketSummary

func (wrapper *PoloniexWrapper) GetMarketSummary(market *environment.Market) (*environment.MarketSummary, error)

GetMarketSummary gets the current market summary.

func (*PoloniexWrapper) GetMarkets

func (wrapper *PoloniexWrapper) GetMarkets() ([]*environment.Market, error)

GetMarkets gets all the markets info.

func (*PoloniexWrapper) GetOrderBook

func (wrapper *PoloniexWrapper) GetOrderBook(market *environment.Market) (*environment.OrderBook, error)

GetOrderBook gets the order(ASK + BID) book of a market.

func (*PoloniexWrapper) GetTicker

func (wrapper *PoloniexWrapper) GetTicker(market *environment.Market) (*environment.Ticker, error)

GetTicker gets the updated ticker for a market.

func (*PoloniexWrapper) Name

func (wrapper *PoloniexWrapper) Name() string

Name returns the name of the wrapped exchange.

func (*PoloniexWrapper) SellLimit

func (wrapper *PoloniexWrapper) SellLimit(market *environment.Market, amount float64, limit float64) (string, error)

SellLimit performs a limit sell action.

func (*PoloniexWrapper) SellMarket

func (wrapper *PoloniexWrapper) SellMarket(market *environment.Market, amount float64) (string, error)

SellMarket performs a market sell action.

func (*PoloniexWrapper) String

func (wrapper *PoloniexWrapper) String() string

func (*PoloniexWrapper) Withdraw

func (wrapper *PoloniexWrapper) Withdraw(destinationAddress string, coinTicker string, amount float64) error

Withdraw performs a withdraw operation from the exchange to a destination address.

type SummaryCache

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

SummaryCache represents a local summary cache for every exchange. To allow dinamic polling from multiple sources (REST + Websocket)

func NewSummaryCache

func NewSummaryCache() *SummaryCache

NewSummaryCache creates a new SummaryCache Object

func (*SummaryCache) Get

Get gets the value for the specified key.

func (*SummaryCache) Set

Set sets a value for the specified key.

type TradeType

type TradeType string

TradeType represents a type of order, from trading fees point of view.

Jump to

Keyboard shortcuts

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