plugins

package
v0.0.0-...-832224e Latest Latest
Warning

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

Go to latest
Published: Apr 17, 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

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

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

MakeFillDBWriter is a factory method

func MakeFillLogger

func MakeFillLogger() api.FillHandler

MakeFillLogger is a factory method

func MakeFillTracker

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

MakeFillTracker impl.

func MakeIntervalTimeController

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

MakeIntervalTimeController is a factory method

func MakeMarketID

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

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

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

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

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

MakeBatchedExchange factory

func (BatchedExchange) GetAccountBalances

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

GetAccountBalances impl.

func (BatchedExchange) GetBalanceHack

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

GetBalanceHack impl

func (BatchedExchange) GetLatestTradeCursor

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

GetLatestTradeCursor impl

func (BatchedExchange) GetOpenOrders

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

GetOpenOrders impl.

func (BatchedExchange) GetOrderBook

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

GetOrderBook impl

func (BatchedExchange) GetOrderConstraints

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

GetOrderConstraints impl

func (BatchedExchange) GetTradeHistory

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

GetTradeHistory impl

func (BatchedExchange) LoadOffersHack

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

LoadOffersHack impl

func (BatchedExchange) OpenOrders2Offers

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

OpenOrders2Offers converts...

func (BatchedExchange) Ops2Commands

func (b BatchedExchange) Ops2Commands(ops []txnbuild.Operation, baseAsset hProtocol.Asset, quoteAsset hProtocol.Asset) ([]Command, error)

Ops2Commands converts...

func (BatchedExchange) OverrideOrderConstraints

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

OverrideOrderConstraints impl, can partially override values for specific pairs

func (BatchedExchange) SubmitOps

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

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

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

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

func (c BuySellConfig) String() string

String impl.

type CliPropsStruct

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

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

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

Command struct allows us to follow the Command pattern

func MakeCommandAdd

func MakeCommandAdd(order *model.Order) Command

MakeCommandAdd impl

func MakeCommandCancel

func MakeCommandCancel(openOrder *model.OpenOrder) Command

MakeCommandCancel impl

func Ops2CommandsHack

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

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

GetAdd returns the add op

func (*Command) GetCancel

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

GetCancel returns the cancel op

func (*Command) GetOp

func (c *Command) GetOp() Operation

GetOp returns the Operation

type CommonPropsStruct

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

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

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

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

func (e ErrFiatAPI) Error() string

type ExchangeContainer

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

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

FillDBWriter is a FillHandler that writes fills to a SQL database

func (*FillDBWriter) HandleFill

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

HandleFill impl.

type FillLogger

type FillLogger struct{}

FillLogger is a FillHandler that logs fills

func (*FillLogger) HandleFill

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

HandleFill impl.

type FillTracker

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

FillTracker tracks fills

func (*FillTracker) FillTrackSingleIteration

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

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

GetPair impl

func (*FillTracker) IsRunningInBackground

func (f *FillTracker) IsRunningInBackground() bool

IsRunningInBackground impl

func (*FillTracker) NumHandlers

func (f *FillTracker) NumHandlers() uint8

NumHandlers impl

func (*FillTracker) RegisterHandler

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

RegisterHandler impl

func (*FillTracker) TrackFills

func (f *FillTracker) TrackFills() error

TrackFills impl

type FilterFactory

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

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

MakeFilter is the function that makes the required filters

type IEIF

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

func MakeIEIF(isTradingSdex bool) *IEIF

MakeIEIF factory method

func (*IEIF) AddLiabilities

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

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

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

GetAssetBalance is the exported version of assetBalance

func (*IEIF) LogAllLiabilities

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

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

func (ieif *IEIF) ResetCachedBalances()

ResetCachedBalances resets the cached balances map

func (*IEIF) ResetCachedLiabilities

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

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

SetExchangeShim is a hack, TODO remove this hack

type IntervalTimeController

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

IntervalTimeController provides a standard time interval

func (*IntervalTimeController) ShouldUpdate

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

ShouldUpdate impl

func (*IntervalTimeController) SleepTime

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

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

func (c *MaxPriceFilterConfig) String() string

String is the stringer method

func (*MaxPriceFilterConfig) Validate

func (c *MaxPriceFilterConfig) Validate() error

Validate ensures validity

type MetricsTracker

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

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

MakeMetricsTracker is a factory method

func (*MetricsTracker) GetUpdateEventSentTime

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

GetUpdateEventSentTime gets the last sent time of the update event.

func (*MetricsTracker) SendDeleteEvent

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

SendDeleteEvent sends the delete Amplitude event.

func (*MetricsTracker) SendEventForGuiUser

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

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

func (*MetricsTracker) SendStartupEvent

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

SendStartupEvent sends the startup Amplitude event.

func (*MetricsTracker) SendUpdateEvent

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

SendUpdateEvent sends the update Amplitude event.

type MinPriceFilterConfig

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

func (c *MinPriceFilterConfig) String() string

String is the stringer method

func (*MinPriceFilterConfig) Validate

func (c *MinPriceFilterConfig) Validate() error

Validate ensures validity

type OpFeeStroops

type OpFeeStroops func() (uint64, error)

OpFeeStroops computes fees per operation

func SdexFeeFnFromStats

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

func SdexFixedFeeFn(fixedFeeStroops uint64) OpFeeStroops

SdexFixedFeeFn returns a fixedFee in stroops

type Operation

type Operation int8

Operation represents a type of operation

const (
	OpAdd Operation = iota
	OpCancel
)

type of Operations

type OrderConstraintsOverridesHandler

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

OrderConstraintsOverridesHandler knows how to capture overrides and apply them onto OrderConstraints

func MakeEmptyOrderConstraintsOverridesHandler

func MakeEmptyOrderConstraintsOverridesHandler() *OrderConstraintsOverridesHandler

MakeEmptyOrderConstraintsOverridesHandler is a factory method

func MakeOrderConstraintsOverridesHandler

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

MakeOrderConstraintsOverridesHandler is a factory method

func (*OrderConstraintsOverridesHandler) Apply

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

func (*OrderConstraintsOverridesHandler) Get

Get impl, panics if the override does not exist

func (*OrderConstraintsOverridesHandler) IsCompletelyOverriden

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

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

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

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

GetAccountBalances impl

func (*SDEX) GetAssetConverter

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

GetAssetConverter impl

func (*SDEX) GetBalanceHack

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

GetBalanceHack impl

func (*SDEX) GetLatestTradeCursor

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

GetLatestTradeCursor impl.

func (*SDEX) GetOrderBook

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

GetOrderBook gets the SDEX orderbook

func (*SDEX) GetOrderConstraints

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

GetOrderConstraints impl

func (*SDEX) GetTradeHistory

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

func (sdex *SDEX) IEIF() *IEIF

IEIF exoses the ieif var

func (*SDEX) LoadOffersHack

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

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

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

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

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

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

MakeFilterMakerMode makes a submit filter based on the passed in submitMode

func MakeFilterMaxPrice

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

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

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

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

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

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

func (c *VolumeFilterConfig) String() string

String is the stringer method

func (*VolumeFilterConfig) Validate

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