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)
- type Asset
- type AssetConverter
- type BotKey
- type CancelOrderResult
- type Number
- type OpenOrder
- type Order
- type OrderAction
- type OrderBook
- type OrderType
- type Timestamp
- type Trade
- type TradingPair
- type TransactionID
Constants ¶
This section is empty.
Variables ¶
var Display = makeAssetConverter(map[Asset]string{ XLM: string(XLM), BTC: string(BTC), USD: string(USD), ETH: string(ETH), LTC: string(LTC), REP: string(REP), })
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", })
KrakenAssetConverter is the asset converter for the Kraken exchange
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
Types ¶
type Asset ¶
type Asset string
Asset is typed and enlists the allowed assets that are understood by the bot
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 NumberFromFloat ¶
NumberFromFloat makes a Number from a float
func NumberFromString ¶
NumberFromString makes a Number from a string, by calling NumberFromFloat
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
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
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 Trade ¶
type Trade struct { Order TransactionID *TransactionID Cost *Number Fee *Number }
Trade represents a trade on an exchange
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 TradingPairFromString ¶
func TradingPairFromString(codeSize int8, c *AssetConverter, p string) (*TradingPair, error)
TradingPairFromString 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