Documentation
¶
Index ¶
- type Account
- type Alert
- type Balance
- type Constrainable
- type DepositAPI
- type ErrDepositAmountAboveLimit
- type ErrTooManyDepositAddresses
- type ErrWithdrawAmountAboveLimit
- type ErrWithdrawAmountInvalid
- type Exchange
- type ExchangeAPIKey
- type ExchangeHeader
- type ExchangeParam
- type ExchangeShim
- type FeedPair
- type FillHandler
- type FillTrackable
- type FillTracker
- type Level
- type LevelProvider
- type OrderbookFetcher
- type PrepareDepositResult
- type PriceFeed
- type SideStrategy
- type Strategy
- type SubmitMode
- type Ticker
- type TickerAPI
- type TimeController
- type TradeAPI
- type TradeFetcher
- type TradeHistoryResult
- type TradesResult
- type WithdrawAPI
- type WithdrawFunds
- type WithdrawInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account interface {
GetAccountBalances(assetList []interface{}) (map[interface{}]model.Number, error)
}
Account allows you to access key account functions
type Alert ¶ added in v1.2.0
Alert interface is used for the various monitoring and alerting tools for Kelp.
type Constrainable ¶ added in v1.3.0
type Constrainable interface {
// return nil if the constraint does not exist for the exchange
GetOrderConstraints(pair *model.TradingPair) *model.OrderConstraints
OverrideOrderConstraints(pair *model.TradingPair, override *model.OrderConstraintsOverride)
}
Constrainable extracts out the method that SDEX can implement for now
type DepositAPI ¶
type DepositAPI interface {
/*
Input:
asset - asset you want to deposit
amount - amount you want to deposit
Output:
PrepareDepositResult - contains the deposit instructions
error - ErrDepositAmountAboveLimit, ErrTooManyDepositAddresses, or any other error
*/
PrepareDeposit(asset model.Asset, amount *model.Number) (*PrepareDepositResult, error)
}
DepositAPI is defined by anything where you can deposit funds.
type ErrDepositAmountAboveLimit ¶
type ErrDepositAmountAboveLimit error
ErrDepositAmountAboveLimit error type
func MakeErrDepositAmountAboveLimit ¶
func MakeErrDepositAmountAboveLimit(amount *model.Number, limit *model.Number) ErrDepositAmountAboveLimit
MakeErrDepositAmountAboveLimit is a factory method
type ErrTooManyDepositAddresses ¶
type ErrTooManyDepositAddresses error
ErrTooManyDepositAddresses error type
func MakeErrTooManyDepositAddresses ¶
func MakeErrTooManyDepositAddresses() ErrTooManyDepositAddresses
MakeErrTooManyDepositAddresses is a factory method
type ErrWithdrawAmountAboveLimit ¶
type ErrWithdrawAmountAboveLimit error
ErrWithdrawAmountAboveLimit error type
func MakeErrWithdrawAmountAboveLimit ¶
func MakeErrWithdrawAmountAboveLimit(amount *model.Number, limit *model.Number) ErrWithdrawAmountAboveLimit
MakeErrWithdrawAmountAboveLimit is a factory method
type ErrWithdrawAmountInvalid ¶
type ErrWithdrawAmountInvalid error
ErrWithdrawAmountInvalid error type
func MakeErrWithdrawAmountInvalid ¶
func MakeErrWithdrawAmountInvalid(amountToWithdraw *model.Number, fee *model.Number) ErrWithdrawAmountInvalid
MakeErrWithdrawAmountInvalid is a factory method
type Exchange ¶
type Exchange interface {
Account
TickerAPI
TradeAPI
DepositAPI
WithdrawAPI
}
Exchange is the interface we use as a generic API for all crypto exchanges
type ExchangeAPIKey ¶ added in v1.2.0
ExchangeAPIKey specifies API credentials for an exchange
type ExchangeHeader ¶ added in v1.6.1
ExchangeHeader specifies additional HTTP headers
type ExchangeParam ¶ added in v1.6.1
ExchangeParam specifies an additional parameter to be sent when initializing the exchange
type ExchangeShim ¶ added in v1.6.0
type ExchangeShim interface {
SubmitOps(ops []build.TransactionMutator, asyncCallback func(hash string, e error)) error
SubmitOpsSynch(ops []build.TransactionMutator, asyncCallback func(hash string, e error)) error // forced synchronous version of SubmitOps
GetBalanceHack(asset horizon.Asset) (*Balance, error)
LoadOffersHack() ([]horizon.Offer, error)
Constrainable
OrderbookFetcher
FillTrackable
}
ExchangeShim is the interface we use as a generic API for all crypto exchanges
type FeedPair ¶
FeedPair is the struct representing a price feed for a trading pair
func (*FeedPair) GetCenterPrice ¶
GetCenterPrice fetches the center price from this feed
type FillHandler ¶ added in v1.3.0
FillHandler is invoked by the FillTracker (once registered) anytime an order is filled
type FillTrackable ¶ added in v1.3.0
type FillTrackable interface {
TradeFetcher
GetLatestTradeCursor() (interface{}, error)
}
FillTrackable enables any implementing exchange to support fill tracking
type FillTracker ¶ added in v1.3.0
type FillTracker interface {
GetPair() (pair *model.TradingPair)
// TrackFills should be executed in a new thread
TrackFills() error
RegisterHandler(handler FillHandler)
NumHandlers() uint8
}
FillTracker knows how to track fills against open orders
type LevelProvider ¶
type LevelProvider interface {
GetLevels(maxAssetBase float64, maxAssetQuote float64) ([]Level, error)
GetFillHandlers() ([]FillHandler, error)
}
LevelProvider returns the levels for the given center price, which controls the spread and number of levels
type OrderbookFetcher ¶ added in v1.6.0
type OrderbookFetcher interface {
GetOrderBook(pair *model.TradingPair, maxCount int32) (*model.OrderBook, error)
}
OrderbookFetcher extracts out the method that should go into ExchangeShim for now
type PrepareDepositResult ¶
type PrepareDepositResult struct {
Fee *model.Number // fee that will be deducted from your deposit, i.e. amount available is depositAmount - fee
Address string // address you should send the funds to
ExpireTs int64 // expire time as a unix timestamp, 0 if it does not expire
}
PrepareDepositResult is the result of a PrepareDeposit call
type SideStrategy ¶
type SideStrategy interface {
PruneExistingOffers(offers []horizon.Offer) ([]build.TransactionMutator, []horizon.Offer)
PreUpdate(maxAssetA float64, maxAssetB float64, trustA float64, trustB float64) error
UpdateWithOps(offers []horizon.Offer) (ops []build.TransactionMutator, newTopOffer *model.Number, e error)
PostUpdate() error
GetFillHandlers() ([]FillHandler, error)
}
SideStrategy represents a strategy on a single side of the orderbook
type Strategy ¶
type Strategy interface {
PruneExistingOffers(buyingAOffers []horizon.Offer, sellingAOffers []horizon.Offer) ([]build.TransactionMutator, []horizon.Offer, []horizon.Offer)
PreUpdate(maxAssetA float64, maxAssetB float64, trustA float64, trustB float64) error
UpdateWithOps(buyingAOffers []horizon.Offer, sellingAOffers []horizon.Offer) ([]build.TransactionMutator, error)
PostUpdate() error
GetFillHandlers() ([]FillHandler, error)
}
Strategy represents some logic for a bot to follow while doing market making
type SubmitMode ¶ added in v1.4.0
type SubmitMode uint8
SubmitMode is the type of mode to be used when submitting orders to the trader bot
const ( SubmitModeMakerOnly SubmitMode = iota SubmitModeBoth )
constants for the SubmitMode
func ParseSubmitMode ¶ added in v1.4.0
func ParseSubmitMode(submitMode string) (SubmitMode, error)
ParseSubmitMode converts a string to the SubmitMode constant
func (*SubmitMode) String ¶ added in v1.4.0
func (s *SubmitMode) String() string
type TickerAPI ¶ added in v1.1.0
type TickerAPI interface {
GetTickerPrice(pairs []model.TradingPair) (map[model.TradingPair]Ticker, error)
}
TickerAPI is the interface we use as a generic API for getting ticker data from any crypto exchange
type TimeController ¶ added in v1.2.0
type TimeController interface {
// ShouldUpdate defines when to enter the bot's update cycle
// lastUpdateTime will never start off as the zero value
ShouldUpdate(lastUpdateTime time.Time, currentUpdateTime time.Time) bool
// SleepTime computes how long we want to sleep before the next call to ShouldUpdate
SleepTime(lastUpdateTime time.Time, currentUpdateTime time.Time) time.Duration
}
TimeController controls the update loop for the bot
type TradeAPI ¶
type TradeAPI interface {
GetAssetConverter() *model.AssetConverter
Constrainable
OrderbookFetcher
GetTrades(pair *model.TradingPair, maybeCursor interface{}) (*TradesResult, error)
FillTrackable
GetOpenOrders(pairs []*model.TradingPair) (map[model.TradingPair][]model.OpenOrder, error)
AddOrder(order *model.Order) (*model.TransactionID, error)
CancelOrder(txID *model.TransactionID, pair model.TradingPair) (model.CancelOrderResult, error)
}
TradeAPI is the interface we use as a generic API for trading on any crypto exchange
type TradeFetcher ¶ added in v1.3.0
type TradeFetcher interface {
GetTradeHistory(pair model.TradingPair, maybeCursorStart interface{}, maybeCursorEnd interface{}) (*TradeHistoryResult, error)
}
TradeFetcher is the common method between FillTrackable and exchange temporarily extracted out from TradeAPI so SDEX has the flexibility to only implement this rather than exchange and FillTrackable
type TradeHistoryResult ¶
TradeHistoryResult is the result of a GetTradeHistory call this should be the same object as TradesResult but it's a separate object for backwards compatibility
type TradesResult ¶
TradesResult is the result of a GetTrades call
type WithdrawAPI ¶
type WithdrawAPI interface {
/*
Input:
asset - asset you want to withdraw
amountToWithdraw - amount you want deducted from your account
address - address you want to withdraw to
Output:
WithdrawInfo - details on how to perform the withdrawal
error - ErrWithdrawAmountAboveLimit, ErrWithdrawAmountInvalid, or any other error
*/
GetWithdrawInfo(asset model.Asset, amountToWithdraw *model.Number, address string) (*WithdrawInfo, error)
/*
Input:
asset - asset you want to withdraw
amountToWithdraw - amount you want deducted from your account (fees will be deducted from here, use GetWithdrawInfo for fee estimate)
address - address you want to withdraw to
Output:
WithdrawFunds - result of the withdrawal
error - any error
*/
WithdrawFunds(
asset model.Asset,
amountToWithdraw *model.Number,
address string,
) (*WithdrawFunds, error)
}
WithdrawAPI is defined by anything where you can withdraw funds.
type WithdrawFunds ¶
type WithdrawFunds struct {
WithdrawalID string
}
WithdrawFunds is the result of a WithdrawFunds call
type WithdrawInfo ¶
type WithdrawInfo struct {
AmountToReceive *model.Number // amount that you will receive after any fees is taken (excludes fees charged on the deposit side)
}
WithdrawInfo is the result of a GetWithdrawInfo call