plugins

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2019 License: Apache-2.0 Imports: 28 Imported by: 36

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exchanges

func Exchanges() map[string]ExchangeContainer

Exchanges returns the list of exchanges

func MakeExchange

func MakeExchange(exchangeType string, simMode bool) (api.Exchange, error)

MakeExchange is a factory method to make an exchange based on a given type

func MakeFeedPair

func MakeFeedPair(dataTypeA, dataFeedAUrl, dataTypeB, dataFeedBUrl string) (*api.FeedPair, error)

MakeFeedPair is the factory method that we expose

func MakeFillLogger added in v1.3.0

func MakeFillLogger() api.FillHandler

MakeFillLogger is a factory method

func MakeFillTracker added in v1.3.0

func MakeFillTracker(
	pair *model.TradingPair,
	threadTracker *multithreading.ThreadTracker,
	fillTrackable api.FillTrackable,
	fillTrackerSleepMillis uint32,
	fillTrackerDeleteCyclesThreshold int64,
) api.FillTracker

MakeFillTracker impl.

func MakeIntervalTimeController added in v1.2.0

func MakeIntervalTimeController(tickInterval time.Duration, maxTickDelayMillis int64) api.TimeController

MakeIntervalTimeController is a factory method

func MakePriceFeed

func MakePriceFeed(feedType string, url string) (api.PriceFeed, error)

MakePriceFeed makes a PriceFeed

func MakeStrategy

func MakeStrategy(
	sdex *SDEX,
	ieif *IEIF,
	tradingPair *model.TradingPair,
	assetBase *horizon.Asset,
	assetQuote *horizon.Asset,
	strategy string,
	stratConfigPath string,
	simMode bool,
) (api.Strategy, error)

MakeStrategy makes a strategy

func MakeTradingExchange added in v1.3.0

func MakeTradingExchange(exchangeType string, apiKeys []api.ExchangeAPIKey, exchangeParams []api.ExchangeParam, headers []api.ExchangeHeader, simMode bool) (api.Exchange, error)

MakeTradingExchange is a factory method to make an exchange based on a given type

func SetPrivateSdexHack added in v1.4.0

func SetPrivateSdexHack(api *horizon.Client, ieif *IEIF, network build.Network) error

SetPrivateSdexHack sets the privateSdexHack variable which is temporary until the pending SDEX price feed refactor

func Strategies

func Strategies() map[string]StrategyContainer

Strategies returns the list of strategies along with metadata

Types

type Balance

type Balance struct {
	Balance float64
	Trust   float64
	Reserve float64
}

Balance repesents an asset's balance response from the assetBalance method below

type BatchedExchange added in v1.6.0

type BatchedExchange struct {
	// contains filtered or unexported fields
}

BatchedExchange accumulates instructions that can be read out and processed in a batch-style later

func MakeBatchedExchange added in v1.6.0

func MakeBatchedExchange(
	inner api.Exchange,
	simMode bool,
	baseAsset horizon.Asset,
	quoteAsset horizon.Asset,
	tradingAccount string,
) *BatchedExchange

MakeBatchedExchange factory

func (BatchedExchange) GetAccountBalances added in v1.6.0

func (b BatchedExchange) GetAccountBalances(assetList []interface{}) (map[interface{}]model.Number, error)

GetAccountBalances impl.

func (BatchedExchange) GetBalanceHack added in v1.6.0

func (b BatchedExchange) GetBalanceHack(asset horizon.Asset) (*api.Balance, error)

GetBalanceHack impl

func (BatchedExchange) GetLatestTradeCursor added in v1.6.0

func (b BatchedExchange) GetLatestTradeCursor() (interface{}, error)

GetLatestTradeCursor impl

func (BatchedExchange) GetOpenOrders added in v1.6.0

func (b BatchedExchange) GetOpenOrders(pairs []*model.TradingPair) (map[model.TradingPair][]model.OpenOrder, error)

GetOpenOrders impl.

func (BatchedExchange) GetOrderBook added in v1.6.0

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

GetOrderBook impl

func (BatchedExchange) GetOrderConstraints added in v1.6.0

func (b BatchedExchange) GetOrderConstraints(pair *model.TradingPair) *model.OrderConstraints

GetOrderConstraints impl

func (BatchedExchange) GetTradeHistory added in v1.6.0

func (b BatchedExchange) GetTradeHistory(pair model.TradingPair, maybeCursorStart interface{}, maybeCursorEnd interface{}) (*api.TradeHistoryResult, error)

GetTradeHistory impl

func (BatchedExchange) LoadOffersHack added in v1.6.0

func (b BatchedExchange) LoadOffersHack() ([]horizon.Offer, error)

LoadOffersHack impl

func (BatchedExchange) OpenOrders2Offers added in v1.6.0

func (b BatchedExchange) OpenOrders2Offers(orders []model.OpenOrder, baseAsset horizon.Asset, quoteAsset horizon.Asset, tradingAccount string) ([]hProtocol.Offer, error)

OpenOrders2Offers converts...

func (BatchedExchange) Ops2Commands added in v1.6.0

func (b BatchedExchange) Ops2Commands(ops []build.TransactionMutator, baseAsset horizon.Asset, quoteAsset horizon.Asset) ([]Command, error)

Ops2Commands converts...

func (BatchedExchange) OverrideOrderConstraints added in v1.6.1

func (b BatchedExchange) OverrideOrderConstraints(pair *model.TradingPair, override *model.OrderConstraintsOverride)

OverrideOrderConstraints impl, can partially override values for specific pairs

func (BatchedExchange) SubmitOps added in v1.6.0

func (b BatchedExchange) SubmitOps(ops []build.TransactionMutator, asyncCallback func(hash string, e error)) error

SubmitOps performs any finalization or submission step needed by the exchange

func (BatchedExchange) SubmitOpsSynch added in v1.6.0

func (b BatchedExchange) SubmitOpsSynch(ops []build.TransactionMutator, asyncCallback func(hash string, e error)) error

SubmitOpsSynch is the forced synchronous version of SubmitOps below (same for batchedExchange)

type Command added in v1.6.0

type Command struct {
	// contains filtered or unexported fields
}

Command struct allows us to follow the Command pattern

func MakeCommandAdd added in v1.6.0

func MakeCommandAdd(order *model.Order) Command

MakeCommandAdd impl

func MakeCommandCancel added in v1.6.0

func MakeCommandCancel(openOrder *model.OpenOrder) Command

MakeCommandCancel impl

func Ops2CommandsHack added in v1.6.0

func Ops2CommandsHack(
	ops []build.TransactionMutator,
	baseAsset horizon.Asset,
	quoteAsset horizon.Asset,
	offerID2OrderID map[int64]string,
	orderConstraints *model.OrderConstraints,
) ([]Command, error)

Ops2CommandsHack converts...

func (*Command) GetAdd added in v1.6.0

func (c *Command) GetAdd() (*model.Order, error)

GetAdd returns the add op

func (*Command) GetCancel added in v1.6.0

func (c *Command) GetCancel() (*model.OpenOrder, error)

GetCancel returns the cancel op

func (*Command) GetOp added in v1.6.0

func (c *Command) GetOp() Operation

GetOp returns the Operation

type ExchangeContainer added in v1.3.0

type ExchangeContainer struct {
	SortOrder    uint16
	Description  string
	TradeEnabled bool
	Tested       bool
	// contains filtered or unexported fields
}

ExchangeContainer contains the exchange factory method along with some metadata

type FillLogger added in v1.3.0

type FillLogger struct{}

FillLogger is a FillHandler that logs fills

func (*FillLogger) HandleFill added in v1.3.0

func (f *FillLogger) HandleFill(trade model.Trade) error

HandleFill impl.

type FillTracker added in v1.3.0

type FillTracker struct {
	// contains filtered or unexported fields
}

FillTracker tracks fills

func (*FillTracker) GetPair added in v1.3.0

func (f *FillTracker) GetPair() (pair *model.TradingPair)

GetPair impl

func (*FillTracker) NumHandlers added in v1.3.0

func (f *FillTracker) NumHandlers() uint8

NumHandlers impl

func (*FillTracker) RegisterHandler added in v1.3.0

func (f *FillTracker) RegisterHandler(handler api.FillHandler)

RegisterHandler impl

func (*FillTracker) TrackFills added in v1.3.0

func (f *FillTracker) TrackFills() error

TrackFills impl

type IEIF added in v1.6.0

type IEIF struct {
	// contains filtered or unexported fields
}

IEIF is the module that allows us to ensure that orders are always "Immediately Executable In Full"

func MakeIEIF added in v1.6.0

func MakeIEIF(isTradingSdex bool) *IEIF

MakeIEIF factory method

func (*IEIF) AddLiabilities added in v1.6.0

func (ieif *IEIF) AddLiabilities(selling horizon.Asset, buying horizon.Asset, incrementalSell float64, incrementalBuy float64, incrementalNativeAmountRaw float64)

AddLiabilities updates the cached liabilities, units are in their respective assets

func (*IEIF) AvailableCapacity added in v1.6.0

func (ieif *IEIF) AvailableCapacity(asset horizon.Asset, incrementalNativeAmountRaw float64) (*Liabilities, error)

AvailableCapacity returns the buying and selling amounts available for a given asset

func (*IEIF) GetAssetBalance added in v1.6.0

func (ieif *IEIF) GetAssetBalance(asset horizon.Asset) (*api.Balance, error)

GetAssetBalance is the exported version of assetBalance

func (*IEIF) LogAllLiabilities added in v1.6.0

func (ieif *IEIF) LogAllLiabilities(assetBase horizon.Asset, assetQuote horizon.Asset)

LogAllLiabilities logs the liabilities for the two assets along with the native asset

func (*IEIF) RecomputeAndLogCachedLiabilities added in v1.6.0

func (ieif *IEIF) RecomputeAndLogCachedLiabilities(assetBase horizon.Asset, assetQuote horizon.Asset)

RecomputeAndLogCachedLiabilities clears the cached liabilities and recomputes from the network before logging

func (*IEIF) ResetCachedBalances added in v1.6.0

func (ieif *IEIF) ResetCachedBalances()

ResetCachedBalances resets the cached balances map

func (*IEIF) ResetCachedLiabilities added in v1.6.0

func (ieif *IEIF) ResetCachedLiabilities(assetBase horizon.Asset, assetQuote horizon.Asset) error

ResetCachedLiabilities resets the cache to include only the two assets passed in

func (*IEIF) SetExchangeShim added in v1.6.0

func (ieif *IEIF) SetExchangeShim(exchangeShim api.ExchangeShim)

SetExchangeShim is a hack, TODO remove this hack

type IntervalTimeController added in v1.2.0

type IntervalTimeController struct {
	// contains filtered or unexported fields
}

IntervalTimeController provides a standard time interval

func (*IntervalTimeController) ShouldUpdate added in v1.2.0

func (t *IntervalTimeController) ShouldUpdate(lastUpdateTime time.Time, currentUpdateTime time.Time) bool

ShouldUpdate impl

func (*IntervalTimeController) SleepTime added in v1.2.0

func (t *IntervalTimeController) SleepTime(lastUpdateTime time.Time, currentUpdateTime time.Time) time.Duration

SleepTime impl

type Liabilities

type Liabilities struct {
	Buying  float64 // affects how much more can be bought
	Selling float64 // affects how much more can be sold
}

Liabilities represents the "committed" units of an asset on both the buy and sell sides

type OpFeeStroops added in v1.5.0

type OpFeeStroops func() (uint64, error)

OpFeeStroops computes fees per operation

func SdexFeeFnFromStats added in v1.5.0

func SdexFeeFnFromStats(
	capacityTrigger float64,
	percentile uint8,
	maxOpFeeStroops uint64,
	newClient *horizonclient.Client,
) (OpFeeStroops, error)

SdexFeeFnFromStats returns an OpFeeStroops that uses the /fee_stats endpoint

func SdexFixedFeeFn added in v1.5.0

func SdexFixedFeeFn(fixedFeeStroops uint64) OpFeeStroops

SdexFixedFeeFn returns a fixedFee in stroops

type Operation added in v1.6.0

type Operation int8

Operation represents a type of operation

const (
	OpAdd Operation = iota
	OpCancel
)

type of Operations

type OrderConstraintsOverridesHandler added in v1.6.1

type OrderConstraintsOverridesHandler struct {
	// contains filtered or unexported fields
}

OrderConstraintsOverridesHandler knows how to capture overrides and apply them onto OrderConstraints

func MakeEmptyOrderConstraintsOverridesHandler added in v1.6.1

func MakeEmptyOrderConstraintsOverridesHandler() *OrderConstraintsOverridesHandler

MakeEmptyOrderConstraintsOverridesHandler is a factory method

func MakeOrderConstraintsOverridesHandler added in v1.6.1

func MakeOrderConstraintsOverridesHandler(inputs map[model.TradingPair]model.OrderConstraints) *OrderConstraintsOverridesHandler

MakeOrderConstraintsOverridesHandler is a factory method

func (*OrderConstraintsOverridesHandler) Apply added in v1.6.1

Apply creates a new order constraints after checking for any existing overrides

func (*OrderConstraintsOverridesHandler) Get added in v1.6.1

Get impl, panics if the override does not exist

func (*OrderConstraintsOverridesHandler) IsCompletelyOverriden added in v1.6.1

func (ocHandler *OrderConstraintsOverridesHandler) IsCompletelyOverriden(pair *model.TradingPair) bool

IsCompletelyOverriden returns true if the override exists and is complete for the given trading pair

func (*OrderConstraintsOverridesHandler) Upsert added in v1.6.1

Upsert allows you to set overrides to partially override values for specific pairs

type SDEX

type SDEX struct {
	API            *horizon.Client
	SourceAccount  string
	TradingAccount string
	SourceSeed     string
	TradingSeed    string
	Network        build.Network
	// contains filtered or unexported fields
}

SDEX helps with building and submitting transactions to the Stellar network

func MakeSDEX

func MakeSDEX(
	api *horizon.Client,
	ieif *IEIF,
	exchangeShim api.ExchangeShim,
	sourceSeed string,
	tradingSeed string,
	sourceAccount string,
	tradingAccount string,
	network build.Network,
	threadTracker *multithreading.ThreadTracker,
	operationalBuffer float64,
	operationalBufferNonNativePct float64,
	simMode bool,
	pair *model.TradingPair,
	assetMap map[model.Asset]horizon.Asset,
	opFeeStroopsFn OpFeeStroops,
) *SDEX

MakeSDEX is a factory method for SDEX

func (*SDEX) Assets added in v1.4.0

func (sdex *SDEX) Assets() (baseAsset horizon.Asset, quoteAsset horizon.Asset, e error)

Assets returns the base and quote asset used by sdex

func (*SDEX) ComputeIncrementalNativeAmountRaw

func (sdex *SDEX) ComputeIncrementalNativeAmountRaw(isNewOffer bool) float64

ComputeIncrementalNativeAmountRaw returns the native amount that will be added to liabilities because of fee and min-reserve additions

func (*SDEX) CreateBuyOffer

func (sdex *SDEX) CreateBuyOffer(base horizon.Asset, counter horizon.Asset, price float64, amount float64, incrementalNativeAmountRaw float64) (*build.ManageOfferBuilder, error)

CreateBuyOffer creates a buy offer

func (*SDEX) CreateSellOffer

func (sdex *SDEX) CreateSellOffer(base horizon.Asset, counter horizon.Asset, price float64, amount float64, incrementalNativeAmountRaw float64) (*build.ManageOfferBuilder, error)

CreateSellOffer creates a sell offer

func (*SDEX) DeleteAllOffers

func (sdex *SDEX) DeleteAllOffers(offers []horizon.Offer) []build.TransactionMutator

DeleteAllOffers is a helper that accumulates delete operations for the passed in offers

func (*SDEX) DeleteOffer

func (sdex *SDEX) DeleteOffer(offer horizon.Offer) build.ManageOfferBuilder

DeleteOffer returns the op that needs to be submitted to the network in order to delete the passed in offer

func (*SDEX) GetAccountBalances added in v1.6.0

func (sdex *SDEX) GetAccountBalances(assetList []interface{}) (map[interface{}]model.Number, error)

GetAccountBalances impl

func (*SDEX) GetAssetConverter added in v1.6.0

func (sdex *SDEX) GetAssetConverter() *model.AssetConverter

GetAssetConverter impl

func (*SDEX) GetBalanceHack added in v1.6.0

func (sdex *SDEX) GetBalanceHack(asset horizon.Asset) (*api.Balance, error)

GetBalanceHack impl

func (*SDEX) GetLatestTradeCursor added in v1.3.0

func (sdex *SDEX) GetLatestTradeCursor() (interface{}, error)

GetLatestTradeCursor impl.

func (*SDEX) GetOrderBook added in v1.4.0

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

GetOrderBook gets the SDEX orderbook

func (*SDEX) GetOrderConstraints added in v1.3.0

func (sdex *SDEX) GetOrderConstraints(pair *model.TradingPair) *model.OrderConstraints

GetOrderConstraints impl

func (*SDEX) GetTradeHistory added in v1.3.0

func (sdex *SDEX) GetTradeHistory(pair model.TradingPair, maybeCursorStart interface{}, maybeCursorEnd interface{}) (*api.TradeHistoryResult, error)

GetTradeHistory fetches trades for the trading account bound to this instance of SDEX

func (*SDEX) IEIF added in v1.6.0

func (sdex *SDEX) IEIF() *IEIF

IEIF exoses the ieif var

func (*SDEX) LoadOffersHack added in v1.6.0

func (sdex *SDEX) LoadOffersHack() ([]horizon.Offer, error)

LoadOffersHack impl

func (*SDEX) ModifyBuyOffer

func (sdex *SDEX) ModifyBuyOffer(offer horizon.Offer, price float64, amount float64, incrementalNativeAmountRaw float64) (*build.ManageOfferBuilder, error)

ModifyBuyOffer modifies a buy offer

func (*SDEX) ModifySellOffer

func (sdex *SDEX) ModifySellOffer(offer horizon.Offer, price float64, amount float64, incrementalNativeAmountRaw float64) (*build.ManageOfferBuilder, error)

ModifySellOffer modifies a sell offer

func (*SDEX) OverrideOrderConstraints added in v1.6.1

func (sdex *SDEX) OverrideOrderConstraints(pair *model.TradingPair, override *model.OrderConstraintsOverride)

OverrideOrderConstraints impl, can partially override values for specific pairs

func (*SDEX) SubmitOps

func (sdex *SDEX) SubmitOps(ops []build.TransactionMutator, asyncCallback func(hash string, e error)) error

SubmitOps submits the passed in operations to the network asynchronously in a single transaction

func (*SDEX) SubmitOpsSynch added in v1.6.0

func (sdex *SDEX) SubmitOpsSynch(ops []build.TransactionMutator, asyncCallback func(hash string, e error)) error

SubmitOpsSynch is the forced synchronous version of SubmitOps below

type StrategyContainer

type StrategyContainer struct {
	SortOrder   uint8
	Description string
	NeedsConfig bool
	Complexity  string
	// contains filtered or unexported fields
}

StrategyContainer contains the strategy factory method along with some metadata

type SubmitFilter added in v1.4.0

type SubmitFilter interface {
	Apply(
		ops []build.TransactionMutator,
		sellingOffers []horizon.Offer,
		buyingOffers []horizon.Offer,
	) ([]build.TransactionMutator, error)
}

SubmitFilter allows you to filter out operations before submitting to the network

func MakeFilterMakerMode added in v1.6.0

func MakeFilterMakerMode(submitMode api.SubmitMode, exchangeShim api.ExchangeShim, sdex *SDEX, tradingPair *model.TradingPair) SubmitFilter

MakeFilterMakerMode makes a submit filter based on the passed in submitMode

func MakeFilterOrderConstraints added in v1.6.0

func MakeFilterOrderConstraints(
	oc *model.OrderConstraints,
	baseAsset horizon.Asset,
	quoteAsset horizon.Asset,
) SubmitFilter

MakeFilterOrderConstraints makes a submit filter based on the passed in orderConstraints

Jump to

Keyboard shortcuts

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