exchanges

package
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2018 License: GPL-3.0 Imports: 13 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

This section is empty.

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) 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) 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) String

func (wrapper BinanceWrapper) String() string

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) 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) 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) String

func (wrapper BitfinexWrapper) String() string

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) 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) 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) String

func (wrapper BittrexWrapper) String() string

type BittrexWrapperV2

type BittrexWrapperV2 struct {
	PublicKey string
	SecretKey string
}

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) 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) GetTicker

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

GetTicker gets the updated ticker for 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

type ExchangeWrapper

type ExchangeWrapper interface {
	Name() string                                                                                                // Gets the name of the exchange.
	GetTicker(market *environment.Market) (*environment.Ticker, error)                                           // Gets the updated ticker for a market.
	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.
	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.
}

ExchangeWrapper provides a generic wrapper for exchange services.

func NewBinanceWrapper

func NewBinanceWrapper(publicKey string, secretKey string) ExchangeWrapper

NewBinanceWrapper creates a generic wrapper of the binance API.

func NewBitfinexWrapper

func NewBitfinexWrapper(publicKey string, secretKey string) ExchangeWrapper

NewBitfinexWrapper creates a generic wrapper of the bittrex API.

func NewBittrexV2Wrapper

func NewBittrexV2Wrapper(publicKey string, secretKey string) ExchangeWrapper

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

func NewBittrexWrapper

func NewBittrexWrapper(publicKey string, secretKey string) ExchangeWrapper

NewBittrexWrapper creates a generic wrapper of the bittrex API.

func NewKrakenWrapper

func NewKrakenWrapper(publicKey string, secretKey string) ExchangeWrapper

NewKrakenWrapper creates a generic wrapper of the poloniex API.

func NewPoloniexWrapper

func NewPoloniexWrapper(publicKey string, secretKey string) ExchangeWrapper

NewPoloniexWrapper creates a generic wrapper of the poloniex API.

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) 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) 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) String

func (wrapper KrakenWrapper) String() string

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) 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) 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) String

func (wrapper PoloniexWrapper) String() string

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