api

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2019 License: Apache-2.0 Imports: 6 Imported by: 66

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account interface {
	GetAccountBalances(assetList []model.Asset) (map[model.Asset]model.Number, error)
}

Account allows you to access key account functions

type Alert added in v1.2.0

type Alert interface {
	Trigger(description string, details interface{}) error
}

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
}

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

type ExchangeAPIKey struct {
	Key    string
	Secret string
}

ExchangeAPIKey specifies API credentials for an exchange

type FeedPair

type FeedPair struct {
	FeedA PriceFeed
	FeedB PriceFeed
}

FeedPair is the struct representing a price feed for a trading pair

func (*FeedPair) GetCenterPrice

func (p *FeedPair) GetCenterPrice() (float64, error)

GetCenterPrice fetches the center price from this feed

type FillHandler added in v1.3.0

type FillHandler interface {
	HandleFill(trade model.Trade) error
}

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 Level

type Level struct {
	Price  model.Number
	Amount model.Number
}

Level represents a layer in the orderbook

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 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 PriceFeed

type PriceFeed interface {
	GetPrice() (float64, error)
}

PriceFeed allows you to fetch the price of a feed

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 Ticker

type Ticker struct {
	AskPrice *model.Number
	BidPrice *model.Number
}

Ticker encapsulates all the data for a given Trading Pair

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

	GetOrderBook(pair *model.TradingPair, maxCount int32) (*model.OrderBook, error)

	GetTrades(pair *model.TradingPair, maybeCursor interface{}) (*TradesResult, error)

	TradeFetcher

	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

type TradeHistoryResult struct {
	Cursor interface{}
	Trades []model.Trade
}

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

type TradesResult struct {
	Cursor interface{}
	Trades []model.Trade
}

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

Jump to

Keyboard shortcuts

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