Documentation ¶
Index ¶
- Variables
- func IsBotKey(key string) bool
- func SplitDataKey(key string) (string, string)
- func TradingPairs2Strings(c *AssetConverter, delim string, pairs []TradingPair) (map[TradingPair]string, error)
- func TradingPairs2Strings2(c *AssetConverter, delim string, pairs []*TradingPair) (map[TradingPair]string, error)
- type Asset
- type AssetConverter
- type BotKey
- type CancelOrderResult
- type Number
- func (n Number) Abs() *Number
- func (n Number) Add(n2 Number) *Number
- func (n Number) AsFloat() float64
- func (n Number) AsRatio() (int32, int32, error)
- func (n Number) AsString() string
- func (n Number) Divide(n2 Number) *Number
- func (n Number) EqualsPrecisionNormalized(n2 Number, epsilon float64) bool
- func (n Number) Multiply(n2 Number) *Number
- func (n Number) Negate() *Number
- func (n Number) Precision() int8
- func (n Number) Scale(scaleFactor float64) *Number
- func (n Number) String() string
- func (n Number) Subtract(n2 Number) *Number
- type OpenOrder
- type Order
- type OrderAction
- type OrderBook
- type OrderConstraints
- func MakeOrderConstraints(pricePrecision int8, volumePrecision int8, minBaseVolume float64) *OrderConstraints
- func MakeOrderConstraintsFromOverride(override *OrderConstraintsOverride) *OrderConstraints
- func MakeOrderConstraintsWithCost(pricePrecision int8, volumePrecision int8, minBaseVolume float64, ...) *OrderConstraints
- func MakeOrderConstraintsWithOverride(oc OrderConstraints, override *OrderConstraintsOverride) *OrderConstraints
- type OrderConstraintsOverride
- type OrderType
- type Timestamp
- type Trade
- type TradesByTsID
- type TradingPair
- type TransactionID
Constants ¶
This section is empty.
Variables ¶
var CcxtAssetConverter = Display
CcxtAssetConverter is the asset converter for the CCXT exchange interface
var Display = makeAssetConverter(map[Asset]string{ XLM: string(XLM), BTC: string(BTC), USD: string(USD), ETH: string(ETH), LTC: string(LTC), REP: string(REP), ADA: string(ADA), BCH: string(BCH), DASH: string(DASH), EOS: string(EOS), GNO: string(GNO), FEE: string(FEE), QTUM: string(QTUM), USDT: string(USDT), USDC: string(USDC), DAO: string(DAO), ETC: string(ETC), ICN: string(ICN), MLN: string(MLN), NMC: string(NMC), XDG: string(XDG), XMR: string(XMR), XRP: string(XRP), XVN: string(XVN), ZEC: string(ZEC), CAD: string(CAD), EUR: string(EUR), GBP: string(GBP), JPY: string(JPY), KRW: string(KRW), OMG: string(OMG), })
Display is a basic converter for display purposes
var KrakenAssetConverter = makeAssetConverter(map[Asset]string{ XLM: "XXLM", BTC: "XXBT", USD: "ZUSD", ETH: "XETH", LTC: "XLTC", REP: "XREP", ADA: "ADA", BCH: "BCH", DASH: "DASH", EOS: "EOS", GNO: "GNO", FEE: "KFEE", QTUM: "QTUM", USDT: "USDT", DAO: "XDAO", ETC: "XETC", ICN: "XICN", MLN: "XMLN", NMC: "XNMC", XDG: "XXDG", XMR: "XXMR", XRP: "XXRP", XVN: "XXVN", ZEC: "XZEC", CAD: "ZCAD", EUR: "ZEUR", GBP: "ZGBP", JPY: "ZJPY", KRW: "ZKRW", })
KrakenAssetConverter is the asset converter for the Kraken exchange
var KrakenAssetConverterOpenOrders = makeAssetConverter(map[Asset]string{ XLM: "XLM", BTC: "XBT", USD: "USD", })
KrakenAssetConverterOpenOrders is the asset converter for the Kraken exchange's GetOpenOrders API
var NumberConstants = struct { Zero *Number One *Number }{ Zero: NumberFromFloat(0.0, 16), One: NumberFromFloat(1.0, 16), }
NumberConstants holds some useful constants
Functions ¶
func SplitDataKey ¶
SplitDataKey splits the data key on the account into the hash and part
func TradingPairs2Strings ¶
func TradingPairs2Strings(c *AssetConverter, delim string, pairs []TradingPair) (map[TradingPair]string, error)
TradingPairs2Strings converts the trading pairs to an array of strings
func TradingPairs2Strings2 ¶ added in v1.3.0
func TradingPairs2Strings2(c *AssetConverter, delim string, pairs []*TradingPair) (map[TradingPair]string, error)
TradingPairs2Strings2 converts the trading pairs to an array of strings
Types ¶
type Asset ¶
type Asset string
Asset is typed and enlists the allowed assets that are understood by the bot
const ( XLM Asset = "XLM" BTC Asset = "BTC" USD Asset = "USD" ETH Asset = "ETH" LTC Asset = "LTC" REP Asset = "REP" ADA Asset = "ADA" BCH Asset = "BCH" DASH Asset = "DASH" EOS Asset = "EOS" GNO Asset = "GNO" FEE Asset = "FEE" QTUM Asset = "QTUM" USDT Asset = "USDT" USDC Asset = "USDC" DAO Asset = "DAO" ETC Asset = "ETC" ICN Asset = "ICN" MLN Asset = "MLN" NMC Asset = "NMC" XDG Asset = "XDG" XMR Asset = "XMR" XRP Asset = "XRP" XVN Asset = "XVN" ZEC Asset = "ZEC" CAD Asset = "CAD" EUR Asset = "EUR" GBP Asset = "GBP" JPY Asset = "JPY" KRW Asset = "KRW" OMG Asset = "OMG" )
this is the list of assets understood by the bot. This string can be converted by the specific exchange adapter as is needed by the exchange's API
func FromHorizonAsset ¶ added in v1.6.0
FromHorizonAsset is a factory method
type AssetConverter ¶
type AssetConverter struct {
// contains filtered or unexported fields
}
AssetConverter converts to and from the asset type, it is specific to an exchange
func (AssetConverter) FromString ¶
func (c AssetConverter) FromString(s string) (Asset, error)
FromString converts from a string to an asset
func (AssetConverter) MustFromString ¶
func (c AssetConverter) MustFromString(s string) Asset
MustFromString converts from a string to an asset, failing on errors
type BotKey ¶
type BotKey struct { AssetBaseCode string AssetBaseIssuer string AssetQuoteCode string AssetQuoteIssuer string // contains filtered or unexported fields }
BotKey is a unique key to identify a bot
func MakeSortedBotKey ¶
MakeSortedBotKey makes a BotKey by sorting the passed in assets
func (*BotKey) HashWithPrefix ¶
HashWithPrefix returns the hash prefixed with "b/"
type CancelOrderResult ¶
type CancelOrderResult int8
CancelOrderResult is the result of a CancelOrder call
const ( CancelResultCancelSuccessful CancelOrderResult = 0 CancelResultPending CancelOrderResult = 1 CancelResultFailed CancelOrderResult = 2 )
These are the available types
func (CancelOrderResult) String ¶
func (r CancelOrderResult) String() string
String is the stringer function
type Number ¶
type Number struct {
// contains filtered or unexported fields
}
Number abstraction
func InvertNumber ¶
InvertNumber inverts a number, returns nil if the original number is nil, preserves precision
func MustNumberFromString ¶
MustNumberFromString panics when there's an error
func NumberByCappingPrecision ¶
NumberByCappingPrecision returns a number with a precision that is at max the passed in precision
func NumberFromFloat ¶
NumberFromFloat makes a Number from a float
func NumberFromString ¶
NumberFromString makes a Number from a string, by calling NumberFromFloat
func (Number) Divide ¶ added in v1.3.0
Divide returns a new Number after dividing by the passed in Number
func (Number) EqualsPrecisionNormalized ¶ added in v1.3.0
EqualsPrecisionNormalized returns true if the two numbers are the same after comparing them at the same (lowest) precision level
func (Number) Multiply ¶ added in v1.3.0
Multiply returns a new Number after multiplying with the passed in Number
type OpenOrder ¶
type OpenOrder struct { Order ID string StartTime *Timestamp ExpireTime *Timestamp VolumeExecuted *Number }
OpenOrder represents an open order for a trading account
type Order ¶
type Order struct { Pair *TradingPair OrderAction OrderAction OrderType OrderType Price *Number Volume *Number Timestamp *Timestamp }
Order represents an order in the orderbook
type OrderAction ¶
type OrderAction bool
OrderAction is the action of buy / sell
const ( OrderActionBuy OrderAction = false OrderActionSell OrderAction = true )
OrderActionBuy and OrderActionSell are the two actions
func OrderActionFromString ¶
func OrderActionFromString(s string) OrderAction
OrderActionFromString is a convenience to convert from common strings to the corresponding OrderAction
func (OrderAction) Reverse ¶ added in v1.3.0
func (a OrderAction) Reverse() OrderAction
Reverse returns the opposite action
type OrderBook ¶
type OrderBook struct {
// contains filtered or unexported fields
}
OrderBook encapsulates the concept of an orderbook on a market
func MakeOrderBook ¶
func MakeOrderBook(pair *TradingPair, asks []Order, bids []Order) *OrderBook
MakeOrderBook creates a new OrderBook from the asks and the bids
func (OrderBook) Pair ¶ added in v1.1.0
func (o OrderBook) Pair() *TradingPair
Pair returns trading pair
type OrderConstraints ¶ added in v1.3.0
type OrderConstraints struct { PricePrecision int8 VolumePrecision int8 MinBaseVolume Number MinQuoteVolume *Number }
OrderConstraints describes constraints when placing orders on an excahnge
func MakeOrderConstraints ¶ added in v1.3.0
func MakeOrderConstraints(pricePrecision int8, volumePrecision int8, minBaseVolume float64) *OrderConstraints
MakeOrderConstraints is a factory method for OrderConstraints
func MakeOrderConstraintsFromOverride ¶ added in v1.6.1
func MakeOrderConstraintsFromOverride(override *OrderConstraintsOverride) *OrderConstraints
MakeOrderConstraintsFromOverride is a factory method to convert an OrderConstraintsOverride to an OrderConstraints
func MakeOrderConstraintsWithCost ¶ added in v1.6.0
func MakeOrderConstraintsWithCost(pricePrecision int8, volumePrecision int8, minBaseVolume float64, minQuoteVolume float64) *OrderConstraints
MakeOrderConstraintsWithCost is a factory method for OrderConstraints
func MakeOrderConstraintsWithOverride ¶ added in v1.6.1
func MakeOrderConstraintsWithOverride(oc OrderConstraints, override *OrderConstraintsOverride) *OrderConstraints
MakeOrderConstraintsWithOverride is a factory method for OrderConstraints, oc is not a pointer because we want a copy since we modify it
func (*OrderConstraints) String ¶ added in v1.6.0
func (o *OrderConstraints) String() string
OrderConstraints describes constraints when placing orders on an excahnge
type OrderConstraintsOverride ¶ added in v1.6.1
type OrderConstraintsOverride struct { PricePrecision *int8 VolumePrecision *int8 MinBaseVolume *Number MinQuoteVolume **Number }
OrderConstraintsOverride describes an override for an OrderConstraint
func MakeOrderConstraintsOverride ¶ added in v1.6.1
func MakeOrderConstraintsOverride( pricePrecision *int8, volumePrecision *int8, minBaseVolume *Number, minQuoteVolume **Number, ) *OrderConstraintsOverride
MakeOrderConstraintsOverride is a factory method
func MakeOrderConstraintsOverrideFromConstraints ¶ added in v1.6.1
func MakeOrderConstraintsOverrideFromConstraints(oc *OrderConstraints) *OrderConstraintsOverride
MakeOrderConstraintsOverrideFromConstraints is a factory method for OrderConstraintsOverride
func (*OrderConstraintsOverride) Augment ¶ added in v1.6.1
func (override *OrderConstraintsOverride) Augment(updates *OrderConstraintsOverride)
Augment only updates values if updates are non-nil
func (*OrderConstraintsOverride) IsComplete ¶ added in v1.6.1
func (override *OrderConstraintsOverride) IsComplete() bool
IsComplete returns true if the override contains all values
type OrderType ¶
type OrderType int8
OrderType represents a type of an order, example market, limit, etc.
These are the available order types
func OrderTypeFromString ¶
OrderTypeFromString is a convenience to convert from common strings to the corresponding OrderType
type Timestamp ¶
type Timestamp int64
Timestamp is millis since epoch
func MakeTimestampFromTime ¶ added in v1.3.0
MakeTimestampFromTime creates a new Timestamp
type Trade ¶
type Trade struct { Order TransactionID *TransactionID Cost *Number Fee *Number }
Trade represents a trade on an exchange
type TradesByTsID ¶ added in v1.6.0
type TradesByTsID []Trade
TradesByTsID implements sort.Interface for []Trade based on Timestamp and TransactionID
func (TradesByTsID) Len ¶ added in v1.6.0
func (t TradesByTsID) Len() int
func (TradesByTsID) Swap ¶ added in v1.6.0
func (t TradesByTsID) Swap(i int, j int)
type TradingPair ¶
type TradingPair struct { // Base represents the asset that has a unit of 1 (implicit) Base Asset // Quote (or Counter) represents the asset that has its unit specified relative to the base asset Quote Asset }
TradingPair lists an ordered pair that is understood by the bot and our exchange API. EUR/USD = 1.25; EUR is base, USD is Quote. EUR is more valuable in this example USD/EUR = 0.80; USD is base, EUR is Quote. EUR is more valuable in this example
func MakeTradingPair ¶ added in v1.3.0
func MakeTradingPair(base Asset, quote Asset) *TradingPair
MakeTradingPair is a factory method
func TradingPairFromString ¶
func TradingPairFromString(codeSize int8, c *AssetConverter, p string) (*TradingPair, error)
TradingPairFromString makes a TradingPair out of a string
func TradingPairFromString2 ¶ added in v1.6.1
func TradingPairFromString2(codeSize int8, converters []*AssetConverter, p string) (*TradingPair, error)
TradingPairFromString2 makes a TradingPair out of a string
func (TradingPair) ToString ¶
func (p TradingPair) ToString(c *AssetConverter, delim string) (string, error)
ToString converts the trading pair to a string using the passed in assetConverter
type TransactionID ¶
type TransactionID string
TransactionID is typed for the concept of a transaction ID of an order
func MakeTransactionID ¶
func MakeTransactionID(s string) *TransactionID
MakeTransactionID is a factory method for convenience
func (*TransactionID) String ¶
func (t *TransactionID) String() string
String is the stringer function