plugins

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2021 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const FiatErrorCodeAccountInactive = 102
View Source
const FiatErrorCodeExhaustedAPIKey = 104
View Source
const FiatErrorCodeInvalidAPIKey = 101

Variables

This section is empty.

Functions

func Exchanges

func Exchanges() map[string]ExchangeContainer

Exchanges returns the list of exchanges

func FetchOrRegisterMarketID added in v1.10.0

func FetchOrRegisterMarketID(db *sql.DB, exchangeName string, baseAsset string, quoteAsset string) (string, error)

FetchOrRegisterMarketID is the public method, so we don't need to export tradingMarket unncessarily

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 MakeFillDBWriter added in v1.8.0

func MakeFillDBWriter(db *sql.DB, assetDisplayFn model.AssetDisplayFn, exchangeName string, accountID string) api.FillHandler

MakeFillDBWriter is a factory method

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,
	lastCursor interface{},
) 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 MakeMarketID added in v1.10.0

func MakeMarketID(exchangeName string, baseAsset string, quoteAsset string) string

MakeMarketID generates a universal marketID

func MakePriceFeed

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

MakePriceFeed makes a PriceFeed

func MakeStrategy

func MakeStrategy(
	sdex *SDEX,
	exchangeShim api.ExchangeShim,
	tradeFetcher api.TradeFetcher,
	ieif *IEIF,
	tradingPair *model.TradingPair,
	assetBase *hProtocol.Asset,
	assetQuote *hProtocol.Asset,
	marketID string,
	strategy string,
	stratConfigPath string,
	simMode bool,
	isTradingSdex bool,
	filterFactory *FilterFactory,
	db *sql.DB,
) (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 *horizonclient.Client, ieif *IEIF, network string) 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 hProtocol.Asset,
	quoteAsset hProtocol.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 hProtocol.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() ([]hProtocol.Offer, error)

LoadOffersHack impl

func (BatchedExchange) OpenOrders2Offers added in v1.6.0

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

OpenOrders2Offers converts...

func (BatchedExchange) Ops2Commands added in v1.6.0

func (b BatchedExchange) Ops2Commands(ops []txnbuild.Operation, baseAsset hProtocol.Asset, quoteAsset hProtocol.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(opsOld []build.TransactionMutator, submitMode api.SubmitMode, 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, submitMode api.SubmitMode, asyncCallback func(hash string, e error)) error

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

type BuySellConfig added in v1.8.0

type BuySellConfig struct {
	PriceTolerance         float64       `valid:"-" toml:"PRICE_TOLERANCE" json:"price_tolerance"`
	AmountTolerance        float64       `valid:"-" toml:"AMOUNT_TOLERANCE" json:"amount_tolerance"`
	RateOffsetPercent      float64       `valid:"-" toml:"RATE_OFFSET_PERCENT" json:"rate_offset_percent"`
	RateOffset             float64       `valid:"-" toml:"RATE_OFFSET" json:"rate_offset"`
	RateOffsetPercentFirst bool          `valid:"-" toml:"RATE_OFFSET_PERCENT_FIRST" json:"rate_offset_percent_first"`
	AmountOfABase          float64       `valid:"-" toml:"AMOUNT_OF_A_BASE" json:"amount_of_a_base"` // the size of order to keep on either side
	DataTypeA              string        `valid:"-" toml:"DATA_TYPE_A" json:"data_type_a"`
	DataFeedAURL           string        `valid:"-" toml:"DATA_FEED_A_URL" json:"data_feed_a_url"`
	DataTypeB              string        `valid:"-" toml:"DATA_TYPE_B" json:"data_type_b"`
	DataFeedBURL           string        `valid:"-" toml:"DATA_FEED_B_URL" json:"data_feed_b_url"`
	Levels                 []StaticLevel `valid:"-" toml:"LEVELS" json:"levels"`
}

BuySellConfig contains the configuration params for this strategy

func MakeBuysellConfig added in v1.8.0

func MakeBuysellConfig(
	priceTolerance float64,
	amountTolerance float64,
	rateOffsetPercent float64,
	rateOffset float64,
	rateOffsetPercentFirst bool,
	amountOfABase float64,
	dataTypeA string,
	dataFeedAURL string,
	dataTypeB string,
	dataFeedBURL string,
	levels []StaticLevel,
) *BuySellConfig

MakeBuysellConfig factory method

func (BuySellConfig) String added in v1.8.0

func (c BuySellConfig) String() string

String impl.

type CliPropsStruct added in v1.11.0

type CliPropsStruct struct {
	Strategy                         string  `json:"strategy"`
	UpdateTimeIntervalSeconds        float64 `json:"update_time_interval_seconds"`
	Exchange                         string  `json:"exchange"`
	TradingPair                      string  `json:"trading_pair"`
	MaxTickDelayMillis               int64   `json:"max_tick_delay_millis"`
	SubmitMode                       string  `json:"submit_mode"`
	DeleteCyclesThreshold            int64   `json:"delete_cycles_threshold"`
	FillTrackerSleepMillis           uint32  `json:"fill_tracker_sleep_millis"`
	FillTrackerDeleteCyclesThreshold int64   `json:"fill_tracker_delete_cycles_threshold"`
	SynchronizeStateLoadEnable       bool    `json:"synchronize_state_load_enable"`
	SynchronizeStateLoadMaxRetries   int     `json:"synchronize_state_load_max_retries"`
	EnabledFeatureDollarValue        bool    `json:"enabled_feature_dollar_value"`
	AlertType                        string  `json:"alert_type"`
	EnabledFeatureMonitoring         bool    `json:"enabled_feature_monitoring"`
	EnabledFeatureFilters            bool    `json:"enabled_feature_filters"`
	EnabledFeaturePostgres           bool    `json:"enabled_feature_postgres"`
	EnabledFeatureLogging            bool    `json:"enabled_feature_logging"`
	OperationalBuffer                float64 `json:"operational_buffer"`
	OperationalBufferNonNativePct    float64 `json:"operational_buffer_non_native_pct"`
	SimMode                          bool    `json:"sim_mode"`
	FixedIterations                  uint64  `json:"fixed_iterations"`
}

CliPropsStruct contains only those props that are needed for all CLI events

func MakeCliProps added in v1.11.0

func MakeCliProps(
	strategy string,
	updateTimeIntervalSeconds float64,
	exchange string,
	tradingPair string,
	maxTickDelayMillis int64,
	submitMode string,
	deleteCyclesThreshold int64,
	fillTrackerSleepMillis uint32,
	fillTrackerDeleteCyclesThreshold int64,
	synchronizeStateLoadEnable bool,
	synchronizeStateLoadMaxRetries int,
	enabledFeatureDollarValue bool,
	alertType string,
	enabledFeatureMonitoring bool,
	enabledFeatureFilters bool,
	enabledFeaturePostgres bool,
	enabledFeatureLogging bool,
	operationalBuffer float64,
	operationalBufferNonNativePct float64,
	simMode bool,
	fixedIterations uint64,
) *CliPropsStruct

MakeCliProps is a factory mmethod for CommonPropsStruct

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 []txnbuild.Operation,
	baseAsset hProtocol.Asset,
	quoteAsset hProtocol.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 CommonPropsStruct added in v1.11.0

type CommonPropsStruct struct {
	CliVersion        string  `json:"cli_version"`
	GitHash           string  `json:"git_hash"`
	Env               string  `json:"env"`
	Goos              string  `json:"goos"`
	Goarch            string  `json:"goarch"`
	Goarm             string  `json:"goarm"`
	GoVersion         string  `json:"go_version"`
	SecondsSinceStart float64 `json:"seconds_since_start"`
	IsTestnet         bool    `json:"is_testnet"`
	GuiVersion        string  `json:"gui_version"` // can be present for cli trackers if they are started from the GUI
}

CommonPropsStruct holds the properties that are common to all our Amplitude events. TODO DS Add geodata. TODO DS Add cloud server information. TODO DS Add time to run update function as `millisForUpdate`.

func MakeCommonProps added in v1.11.0

func MakeCommonProps(
	cliVersion string,
	gitHash string,
	env string,
	goos string,
	goarch string,
	goarm string,
	goVersion string,
	secondsSinceStart float64,
	isTestnet bool,
	guiVersion string,
) *CommonPropsStruct

MakeCommonProps is a factory mmethod for CommonPropsStruct

type DayOfWeekFilterConfig added in v1.10.0

type DayOfWeekFilterConfig struct {
	Mo string `valid:"-" toml:"Mo"`
	Tu string `valid:"-" toml:"Tu"`
	We string `valid:"-" toml:"We"`
	Th string `valid:"-" toml:"Th"`
	Fr string `valid:"-" toml:"Fr"`
	Sa string `valid:"-" toml:"Sa"`
	Su string `valid:"-" toml:"Su"`
}

DayOfWeekFilterConfig is converted to a SubmitFilter and applied based on the current DOW

type ErrFiatAPI added in v1.8.0

type ErrFiatAPI struct {
	Code int
	Type string
	Info string
}

ErrFiatAPI is a custom error currently used to identify when we have an invalid APIKey

func (ErrFiatAPI) Error added in v1.8.0

func (e ErrFiatAPI) Error() string

type ExchangeContainer added in v1.3.0

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

ExchangeContainer contains the exchange factory method along with some metadata

type FillDBWriter added in v1.8.0

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

FillDBWriter is a FillHandler that writes fills to a SQL database

func (*FillDBWriter) HandleFill added in v1.8.0

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

HandleFill impl.

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) FillTrackSingleIteration added in v1.10.0

func (f *FillTracker) FillTrackSingleIteration() ([]model.Trade, error)

FillTrackSingleIteration is a single run of a call to track fills and to handle the results

func (*FillTracker) GetPair added in v1.3.0

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

GetPair impl

func (*FillTracker) IsRunningInBackground added in v1.10.0

func (f *FillTracker) IsRunningInBackground() bool

IsRunningInBackground 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 FilterFactory added in v1.8.0

type FilterFactory struct {
	ExchangeName   string
	TradingPair    *model.TradingPair
	AssetDisplayFn model.AssetDisplayFn
	BaseAsset      hProtocol.Asset
	QuoteAsset     hProtocol.Asset
	DB             *sql.DB
}

FilterFactory is a struct that handles creating all the filters

func (*FilterFactory) MakeFilter added in v1.8.0

func (f *FilterFactory) MakeFilter(configInput string) (SubmitFilter, error)

MakeFilter is the function that makes the required filters

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 hProtocol.Asset, buying hProtocol.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 hProtocol.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 hProtocol.Asset) (*api.Balance, error)

GetAssetBalance is the exported version of assetBalance

func (*IEIF) LogAllLiabilities added in v1.6.0

func (ieif *IEIF) LogAllLiabilities(assetBase hProtocol.Asset, assetQuote hProtocol.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 hProtocol.Asset, assetQuote hProtocol.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 hProtocol.Asset, assetQuote hProtocol.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) 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 MaxPriceFilterConfig added in v1.8.0

type MaxPriceFilterConfig struct {
	MaxPrice *float64
}

MaxPriceFilterConfig ensures that any one constraint that is hit will result in deleting all offers and pausing until limits are no longer constrained

func (*MaxPriceFilterConfig) String added in v1.8.0

func (c *MaxPriceFilterConfig) String() string

String is the stringer method

func (*MaxPriceFilterConfig) Validate added in v1.8.0

func (c *MaxPriceFilterConfig) Validate() error

Validate ensures validity

type MetricsTracker added in v1.11.0

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

MetricsTracker wraps the properties for Amplitude events, and can be used to directly send events to the Amplitude HTTP API.

func MakeMetricsTracker added in v1.11.0

func MakeMetricsTracker(
	client *http.Client,
	apiKey string,
	userID string,
	deviceID string,
	botStartTime time.Time,
	isDisabled bool,
	commonProps *CommonPropsStruct,
	cliProps *CliPropsStruct,
) (*MetricsTracker, error)

MakeMetricsTracker is a factory method

func (*MetricsTracker) GetUpdateEventSentTime added in v1.11.0

func (mt *MetricsTracker) GetUpdateEventSentTime() *time.Time

GetUpdateEventSentTime gets the last sent time of the update event.

func (*MetricsTracker) SendDeleteEvent added in v1.11.0

func (mt *MetricsTracker) SendDeleteEvent(exit bool) error

SendDeleteEvent sends the delete Amplitude event.

func (*MetricsTracker) SendEvent added in v1.11.0

func (mt *MetricsTracker) SendEvent(eventType string, eventPropsInterface interface{}, now time.Time) error

SendEvent sends an event with its type and properties to Amplitude.

func (*MetricsTracker) SendStartupEvent added in v1.11.0

func (mt *MetricsTracker) SendStartupEvent(now time.Time) error

SendStartupEvent sends the startup Amplitude event.

func (*MetricsTracker) SendUpdateEvent added in v1.11.0

func (mt *MetricsTracker) SendUpdateEvent(now time.Time, updateResult UpdateLoopResult, millisForUpdate int64) error

SendUpdateEvent sends the update Amplitude event.

type MinPriceFilterConfig added in v1.8.0

type MinPriceFilterConfig struct {
	MinPrice *float64
}

MinPriceFilterConfig ensures that any one constraint that is hit will result in deleting all offers and pausing until limits are no longer constrained

func (*MinPriceFilterConfig) String added in v1.8.0

func (c *MinPriceFilterConfig) String() string

String is the stringer method

func (*MinPriceFilterConfig) Validate added in v1.8.0

func (c *MinPriceFilterConfig) Validate() error

Validate ensures validity

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            *horizonclient.Client
	SourceAccount  string
	TradingAccount string
	SourceSeed     string
	TradingSeed    string
	Network        string
	// contains filtered or unexported fields
}

SDEX helps with building and submitting transactions to the Stellar network

func MakeSDEX

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

MakeSDEX is a factory method for SDEX

func (*SDEX) Assets added in v1.4.0

func (sdex *SDEX) Assets() (baseAsset hProtocol.Asset, quoteAsset hProtocol.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 hProtocol.Asset, counter hProtocol.Asset, price float64, amount float64, incrementalNativeAmountRaw float64) (*txnbuild.ManageSellOffer, error)

CreateBuyOffer creates a buy offer

func (*SDEX) CreateSellOffer

func (sdex *SDEX) CreateSellOffer(base hProtocol.Asset, counter hProtocol.Asset, price float64, amount float64, incrementalNativeAmountRaw float64) (*txnbuild.ManageSellOffer, error)

CreateSellOffer creates a sell offer

func (*SDEX) DeleteAllOffers

func (sdex *SDEX) DeleteAllOffers(offers []hProtocol.Offer) []txnbuild.Operation

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

func (*SDEX) DeleteOffer

func (sdex *SDEX) DeleteOffer(offer hProtocol.Offer) txnbuild.ManageSellOffer

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.AssetConverterInterface

GetAssetConverter impl

func (*SDEX) GetBalanceHack added in v1.6.0

func (sdex *SDEX) GetBalanceHack(asset hProtocol.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() ([]hProtocol.Offer, error)

LoadOffersHack impl

func (*SDEX) ModifyBuyOffer

func (sdex *SDEX) ModifyBuyOffer(offer hProtocol.Offer, price float64, amount float64, incrementalNativeAmountRaw float64) (*txnbuild.ManageSellOffer, error)

ModifyBuyOffer modifies a buy offer

func (*SDEX) ModifySellOffer

func (sdex *SDEX) ModifySellOffer(offer hProtocol.Offer, price float64, amount float64, incrementalNativeAmountRaw float64) (*txnbuild.ManageSellOffer, 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, submitMode api.SubmitMode, 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, submitMode api.SubmitMode, asyncCallback func(hash string, e error)) error

SubmitOpsSynch is the forced synchronous version of SubmitOps below

type StaticLevel added in v1.8.0

type StaticLevel struct {
	SPREAD float64 `valid:"-" json:"spread"`
	AMOUNT float64 `valid:"-" json:"amount"`
}

StaticLevel represents a layer in the orderbook defined statically extracted here because it's shared by strategy and sideStrategy where strategy depeneds on sideStrategy

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 []txnbuild.Operation,
		sellingOffers []hProtocol.Offer,
		buyingOffers []hProtocol.Offer,
	) ([]txnbuild.Operation, error)
}

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

func MakeFilterMakerMode added in v1.6.0

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

MakeFilterMakerMode makes a submit filter based on the passed in submitMode

func MakeFilterMaxPrice added in v1.8.0

func MakeFilterMaxPrice(baseAsset hProtocol.Asset, quoteAsset hProtocol.Asset, config *MaxPriceFilterConfig) (SubmitFilter, error)

MakeFilterMaxPrice makes a submit filter that limits orders placed based on the price

func MakeFilterMinPrice added in v1.8.0

func MakeFilterMinPrice(baseAsset hProtocol.Asset, quoteAsset hProtocol.Asset, config *MinPriceFilterConfig) (SubmitFilter, error)

MakeFilterMinPrice makes a submit filter that limits orders placed based on the price

func MakeFilterOrderConstraints added in v1.6.0

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

MakeFilterOrderConstraints makes a submit filter based on the passed in orderConstraints

func MakeFilterPriceFeed added in v1.8.0

func MakeFilterPriceFeed(baseAsset hProtocol.Asset, quoteAsset hProtocol.Asset, comparisonModeString string, pf api.PriceFeed) (SubmitFilter, error)

MakeFilterPriceFeed makes a submit filter that limits orders placed based on the value of the price feed

type UpdateLoopResult added in v1.11.0

type UpdateLoopResult struct {
	Success            bool
	NumPruneOps        int
	NumUpdateOpsDelete int
	NumUpdateOpsUpdate int
	NumUpdateOpsCreate int
}

UpdateLoopResult contains the results of the orderbook update. Note that this is used in `trader/trader.go`, but it is defined here to avoid an import cycle.

type VolumeFilterConfig added in v1.8.0

type VolumeFilterConfig struct {
	BaseAssetCapInBaseUnits  *float64
	BaseAssetCapInQuoteUnits *float64
	// contains filtered or unexported fields
}

VolumeFilterConfig ensures that any one constraint that is hit will result in deleting all offers and pausing until limits are no longer constrained

func (*VolumeFilterConfig) String added in v1.8.0

func (c *VolumeFilterConfig) String() string

String is the stringer method

func (*VolumeFilterConfig) Validate added in v1.8.0

func (c *VolumeFilterConfig) Validate() error

Validate ensures validity

Jump to

Keyboard shortcuts

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