plugins

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2019 License: Apache-2.0 Imports: 24 Imported by: 0

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,
) 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,
	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, simMode bool) (api.Exchange, error)

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

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 ExchangeContainer added in v1.3.0

type ExchangeContainer struct {
	SortOrder    uint8
	Description  string
	TradeEnabled 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 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 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,
	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,
) *SDEX

MakeSDEX is a factory method for SDEX

func (*SDEX) AddLiabilities

func (sdex *SDEX) 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 (*SDEX) AvailableCapacity

func (sdex *SDEX) AvailableCapacity(asset horizon.Asset, incrementalNativeAmountRaw float64) (*Liabilities, error)

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

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) GetLatestTradeCursor added in v1.3.0

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

GetLatestTradeCursor impl.

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) LogAllLiabilities

func (sdex *SDEX) LogAllLiabilities(assetBase horizon.Asset, assetQuote horizon.Asset)

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

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) ParseOfferAmount

func (sdex *SDEX) ParseOfferAmount(amt string) (float64, error)

ParseOfferAmount is a convenience method to parse an offer amount

func (*SDEX) RecomputeAndLogCachedLiabilities

func (sdex *SDEX) RecomputeAndLogCachedLiabilities(assetBase horizon.Asset, assetQuote horizon.Asset)

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

func (*SDEX) ResetCachedBalances

func (sdex *SDEX) ResetCachedBalances()

ResetCachedBalances resets the cached balances map

func (*SDEX) ResetCachedLiabilities

func (sdex *SDEX) ResetCachedLiabilities(assetBase horizon.Asset, assetQuote horizon.Asset) error

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

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

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

Jump to

Keyboard shortcuts

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