Documentation ¶
Index ¶
- Constants
- func Exchanges() map[string]ExchangeContainer
- func FetchOrRegisterMarketID(db *sql.DB, exchangeName string, baseAsset string, quoteAsset string) (string, error)
- func MakeExchange(exchangeType string, simMode bool) (api.Exchange, error)
- func MakeFeedPair(dataTypeA, dataFeedAUrl, dataTypeB, dataFeedBUrl string) (*api.FeedPair, error)
- func MakeFillDBWriter(db *sql.DB, assetDisplayFn model.AssetDisplayFn, exchangeName string, ...) api.FillHandler
- func MakeFillLogger() api.FillHandler
- func MakeFillTracker(pair *model.TradingPair, threadTracker *multithreading.ThreadTracker, ...) api.FillTracker
- func MakeIntervalTimeController(tickInterval time.Duration, maxTickDelayMillis int64) api.TimeController
- func MakeMarketID(exchangeName string, baseAsset string, quoteAsset string) string
- func MakePriceFeed(feedType string, url string) (api.PriceFeed, error)
- func MakeStrategy(sdex *SDEX, exchangeShim api.ExchangeShim, tradeFetcher api.TradeFetcher, ...) (api.Strategy, error)
- func MakeTradingExchange(exchangeType string, apiKeys []api.ExchangeAPIKey, ...) (api.Exchange, error)
- func SetPrivateSdexHack(api *horizonclient.Client, ieif *IEIF, network string) error
- func Strategies() map[string]StrategyContainer
- type Balance
- type BatchedExchange
- func (b BatchedExchange) GetAccountBalances(assetList []interface{}) (map[interface{}]model.Number, error)
- func (b BatchedExchange) GetBalanceHack(asset hProtocol.Asset) (*api.Balance, error)
- func (b BatchedExchange) GetLatestTradeCursor() (interface{}, error)
- func (b BatchedExchange) GetOpenOrders(pairs []*model.TradingPair) (map[model.TradingPair][]model.OpenOrder, error)
- func (b BatchedExchange) GetOrderBook(pair *model.TradingPair, maxCount int32) (*model.OrderBook, error)
- func (b BatchedExchange) GetOrderConstraints(pair *model.TradingPair) *model.OrderConstraints
- func (b BatchedExchange) GetTradeHistory(pair model.TradingPair, maybeCursorStart interface{}, ...) (*api.TradeHistoryResult, error)
- func (b BatchedExchange) LoadOffersHack() ([]hProtocol.Offer, error)
- func (b BatchedExchange) OpenOrders2Offers(orders []model.OpenOrder, baseAsset hProtocol.Asset, ...) ([]hProtocol.Offer, error)
- func (b BatchedExchange) Ops2Commands(ops []txnbuild.Operation, baseAsset hProtocol.Asset, ...) ([]Command, error)
- func (b BatchedExchange) OverrideOrderConstraints(pair *model.TradingPair, override *model.OrderConstraintsOverride)
- func (b BatchedExchange) SubmitOps(opsOld []build.TransactionMutator, submitMode api.SubmitMode, ...) error
- func (b BatchedExchange) SubmitOpsSynch(ops []build.TransactionMutator, submitMode api.SubmitMode, ...) error
- type BuySellConfig
- type CliPropsStruct
- type Command
- type CommonPropsStruct
- type DayOfWeekFilterConfig
- type ErrFiatAPI
- type ExchangeContainer
- type FillDBWriter
- type FillLogger
- type FillTracker
- func (f *FillTracker) FillTrackSingleIteration() ([]model.Trade, error)
- func (f *FillTracker) GetPair() (pair *model.TradingPair)
- func (f *FillTracker) IsRunningInBackground() bool
- func (f *FillTracker) NumHandlers() uint8
- func (f *FillTracker) RegisterHandler(handler api.FillHandler)
- func (f *FillTracker) TrackFills() error
- type FilterFactory
- type IEIF
- func (ieif *IEIF) AddLiabilities(selling hProtocol.Asset, buying hProtocol.Asset, incrementalSell float64, ...)
- func (ieif *IEIF) AvailableCapacity(asset hProtocol.Asset, incrementalNativeAmountRaw float64) (*Liabilities, error)
- func (ieif *IEIF) GetAssetBalance(asset hProtocol.Asset) (*api.Balance, error)
- func (ieif *IEIF) LogAllLiabilities(assetBase hProtocol.Asset, assetQuote hProtocol.Asset)
- func (ieif *IEIF) RecomputeAndLogCachedLiabilities(assetBase hProtocol.Asset, assetQuote hProtocol.Asset)
- func (ieif *IEIF) ResetCachedBalances()
- func (ieif *IEIF) ResetCachedLiabilities(assetBase hProtocol.Asset, assetQuote hProtocol.Asset) error
- func (ieif *IEIF) SetExchangeShim(exchangeShim api.ExchangeShim)
- type IntervalTimeController
- type Liabilities
- type MaxPriceFilterConfig
- type MetricsTracker
- func (mt *MetricsTracker) GetUpdateEventSentTime() *time.Time
- func (mt *MetricsTracker) SendDeleteEvent(exit bool) error
- func (mt *MetricsTracker) SendEventForGuiUser(guiUserID string, eventType string, eventPropsInterface interface{}, ...) error
- func (mt *MetricsTracker) SendStartupEvent(now time.Time) error
- func (mt *MetricsTracker) SendUpdateEvent(now time.Time, updateResult UpdateLoopResult, millisForUpdate int64) error
- type MinPriceFilterConfig
- type OpFeeStroops
- type Operation
- type OrderConstraintsOverridesHandler
- func (ocHandler *OrderConstraintsOverridesHandler) Apply(pair *model.TradingPair, oc *model.OrderConstraints) *model.OrderConstraints
- func (ocHandler *OrderConstraintsOverridesHandler) Get(pair *model.TradingPair) *model.OrderConstraintsOverride
- func (ocHandler *OrderConstraintsOverridesHandler) IsCompletelyOverriden(pair *model.TradingPair) bool
- func (ocHandler *OrderConstraintsOverridesHandler) Upsert(pair *model.TradingPair, override *model.OrderConstraintsOverride)
- type SDEX
- func (sdex *SDEX) Assets() (baseAsset hProtocol.Asset, quoteAsset hProtocol.Asset, e error)
- func (sdex *SDEX) ComputeIncrementalNativeAmountRaw(isNewOffer bool) float64
- func (sdex *SDEX) CreateBuyOffer(base hProtocol.Asset, counter hProtocol.Asset, price float64, amount float64, ...) (*txnbuild.ManageSellOffer, error)
- func (sdex *SDEX) CreateSellOffer(base hProtocol.Asset, counter hProtocol.Asset, price float64, amount float64, ...) (*txnbuild.ManageSellOffer, error)
- func (sdex *SDEX) DeleteAllOffers(offers []hProtocol.Offer) []txnbuild.Operation
- func (sdex *SDEX) DeleteOffer(offer hProtocol.Offer) txnbuild.ManageSellOffer
- func (sdex *SDEX) GetAccountBalances(assetList []interface{}) (map[interface{}]model.Number, error)
- func (sdex *SDEX) GetAssetConverter() model.AssetConverterInterface
- func (sdex *SDEX) GetBalanceHack(asset hProtocol.Asset) (*api.Balance, error)
- func (sdex *SDEX) GetLatestTradeCursor() (interface{}, error)
- func (sdex *SDEX) GetOrderBook(pair *model.TradingPair, maxCount int32) (*model.OrderBook, error)
- func (sdex *SDEX) GetOrderConstraints(pair *model.TradingPair) *model.OrderConstraints
- func (sdex *SDEX) GetTradeHistory(pair model.TradingPair, maybeCursorStart interface{}, ...) (*api.TradeHistoryResult, error)
- func (sdex *SDEX) IEIF() *IEIF
- func (sdex *SDEX) LoadOffersHack() ([]hProtocol.Offer, error)
- func (sdex *SDEX) ModifyBuyOffer(offer hProtocol.Offer, price float64, amount float64, ...) (*txnbuild.ManageSellOffer, error)
- func (sdex *SDEX) ModifySellOffer(offer hProtocol.Offer, price float64, amount float64, ...) (*txnbuild.ManageSellOffer, error)
- func (sdex *SDEX) OverrideOrderConstraints(pair *model.TradingPair, override *model.OrderConstraintsOverride)
- func (sdex *SDEX) SubmitOps(ops []build.TransactionMutator, submitMode api.SubmitMode, ...) error
- func (sdex *SDEX) SubmitOpsSynch(ops []build.TransactionMutator, submitMode api.SubmitMode, ...) error
- type StaticLevel
- type StrategyContainer
- type SubmitFilter
- func MakeFilterMakerMode(exchangeShim api.ExchangeShim, sdex *SDEX, tradingPair *model.TradingPair) SubmitFilter
- func MakeFilterMaxPrice(baseAsset hProtocol.Asset, quoteAsset hProtocol.Asset, ...) (SubmitFilter, error)
- func MakeFilterMinPrice(baseAsset hProtocol.Asset, quoteAsset hProtocol.Asset, ...) (SubmitFilter, error)
- func MakeFilterOrderConstraints(oc *model.OrderConstraints, baseAsset hProtocol.Asset, ...) SubmitFilter
- func MakeFilterPriceFeed(baseAsset hProtocol.Asset, quoteAsset hProtocol.Asset, ...) (SubmitFilter, error)
- type UpdateLoopResult
- type VolumeFilterConfig
Constants ¶
const FiatErrorCodeAccountInactive = 102
const FiatErrorCodeExhaustedAPIKey = 104
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 ¶
MakeExchange is a factory method to make an exchange based on a given type
func MakeFeedPair ¶
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 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 ¶
MakeMarketID generates a universal marketID
func MakePriceFeed ¶
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 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 ¶
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
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 MakeCommandCancel ¶
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...
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`.
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 ¶
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) RegisterHandler ¶
func (f *FillTracker) RegisterHandler(handler api.FillHandler)
RegisterHandler 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 (*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 ¶
GetAssetBalance is the exported version of assetBalance
func (*IEIF) LogAllLiabilities ¶
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
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 ¶
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 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 ¶
func (ocHandler *OrderConstraintsOverridesHandler) Apply(pair *model.TradingPair, oc *model.OrderConstraints) *model.OrderConstraints
Apply creates a new order constraints after checking for any existing overrides
func (*OrderConstraintsOverridesHandler) Get ¶
func (ocHandler *OrderConstraintsOverridesHandler) Get(pair *model.TradingPair) *model.OrderConstraintsOverride
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 ¶
func (ocHandler *OrderConstraintsOverridesHandler) Upsert(pair *model.TradingPair, override *model.OrderConstraintsOverride)
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) ComputeIncrementalNativeAmountRaw ¶
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 ¶
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 ¶
GetAccountBalances impl
func (*SDEX) GetAssetConverter ¶
func (sdex *SDEX) GetAssetConverter() model.AssetConverterInterface
GetAssetConverter impl
func (*SDEX) GetBalanceHack ¶
GetBalanceHack impl
func (*SDEX) GetLatestTradeCursor ¶
GetLatestTradeCursor impl.
func (*SDEX) GetOrderBook ¶
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) LoadOffersHack ¶
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
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
Source Files ¶
- balancedLevelProvider.go
- balancedStrategy.go
- batchedExchange.go
- buyTwapStrategy.go
- buysellStrategy.go
- ccxtExchange.go
- ccxtExchangeSpecificParamFactory.go
- cmcFeed.go
- composeStrategy.go
- deleteSideStrategy.go
- deleteStrategy.go
- exchangeFeed.go
- factory.go
- fiatFeed.go
- fillDBWriter.go
- fillLogger.go
- fillTracker.go
- filterFactory.go
- fixedFeed.go
- functionFeed.go
- ieif.go
- intervalTimeController.go
- krakenExchange.go
- makerModeFilter.go
- maxPriceFilter.go
- metricsTracker.go
- minPriceFilter.go
- mirrorStrategy.go
- orderConstraintsFilter.go
- orderConstraintsOverridesHandler.go
- pendulumLevelProvider.go
- pendulumStrategy.go
- priceFeed.go
- priceFeedFilter.go
- priceFeedFunctions.go
- sdex.go
- sdexExtensions.go
- sdexFeed.go
- sellSideStrategy.go
- sellStrategy.go
- sellTwapLevelProvider.go
- sellTwapStrategy.go
- staticSpreadLevelProvider.go
- submitFilter.go
- volumeFilter.go