trader

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: 17 Imported by: 0

Documentation

Index

Constants

View Source
const XLM = "XLM"

XLM is a constant for XLM

Variables

This section is empty.

Functions

This section is empty.

Types

type BotConfig

type BotConfig struct {
	SourceSecretSeed  string `valid:"-" toml:"SOURCE_SECRET_SEED" json:"source_secret_seed"`
	TradingSecretSeed string `valid:"-" toml:"TRADING_SECRET_SEED" json:"trading_secret_seed"`
	AssetCodeA        string `valid:"-" toml:"ASSET_CODE_A" json:"asset_code_a"`
	IssuerA           string `valid:"-" toml:"ISSUER_A" json:"issuer_a"`
	AssetCodeB        string `valid:"-" toml:"ASSET_CODE_B" json:"asset_code_b"`
	IssuerB           string `valid:"-" toml:"ISSUER_B" json:"issuer_b"`
	// Deprecated: use TICK_INTERVAL_MILLIS instead
	TickIntervalSecondsDeprecated      int32      `valid:"-" toml:"TICK_INTERVAL_SECONDS" json:"tick_interval_seconds" deprecated:"true"`
	TickIntervalMillis                 int32      `valid:"-" toml:"TICK_INTERVAL_MILLIS" json:"tick_interval_millis"`
	MaxTickDelayMillis                 int64      `valid:"-" toml:"MAX_TICK_DELAY_MILLIS" json:"max_tick_delay_millis"`
	SleepMode                          string     `valid:"-" toml:"SLEEP_MODE" json:"sleep_mode"`
	DeleteCyclesThreshold              int64      `valid:"-" toml:"DELETE_CYCLES_THRESHOLD" json:"delete_cycles_threshold"`
	SubmitMode                         string     `valid:"-" toml:"SUBMIT_MODE" json:"submit_mode"`
	FillTrackerSleepMillis             uint32     `valid:"-" toml:"FILL_TRACKER_SLEEP_MILLIS" json:"fill_tracker_sleep_millis"`
	FillTrackerDeleteCyclesThreshold   int64      `valid:"-" toml:"FILL_TRACKER_DELETE_CYCLES_THRESHOLD" json:"fill_tracker_delete_cycles_threshold"`
	SynchronizeStateLoadEnable         bool       `valid:"-" toml:"SYNCHRONIZE_STATE_LOAD_ENABLE"`
	SynchronizeStateLoadMaxRetries     int        `valid:"-" toml:"SYNCHRONIZE_STATE_LOAD_MAX_RETRIES"`
	FillTrackerLastTradeCursorOverride string     `valid:"-" toml:"FILL_TRACKER_LAST_TRADE_CURSOR_OVERRIDE"`
	HorizonURL                         string     `valid:"-" toml:"HORIZON_URL" json:"horizon_url"`
	CcxtRestURL                        *string    `valid:"-" toml:"CCXT_REST_URL" json:"ccxt_rest_url"`
	DollarValueFeedBaseAsset           string     `valid:"-" toml:"DOLLAR_VALUE_FEED_BASE_ASSET" json:"dollar_value_feed_base_asset"`
	DollarValueFeedQuoteAsset          string     `valid:"-" toml:"DOLLAR_VALUE_FEED_QUOTE_ASSET" json:"dollar_value_feed_quote_asset"`
	Fee                                *FeeConfig `valid:"-" toml:"FEE" json:"fee"`
	CentralizedPricePrecisionOverride  *int8      `valid:"-" toml:"CENTRALIZED_PRICE_PRECISION_OVERRIDE" json:"centralized_price_precision_override"`
	CentralizedVolumePrecisionOverride *int8      `valid:"-" toml:"CENTRALIZED_VOLUME_PRECISION_OVERRIDE" json:"centralized_volume_precision_override"`
	// Deprecated: use CENTRALIZED_MIN_BASE_VOLUME_OVERRIDE instead
	MinCentralizedBaseVolumeDeprecated *float64                 `valid:"-" toml:"MIN_CENTRALIZED_BASE_VOLUME" deprecated:"true" json:"min_centralized_base_volume"`
	CentralizedMinBaseVolumeOverride   *float64                 `valid:"-" toml:"CENTRALIZED_MIN_BASE_VOLUME_OVERRIDE" json:"centralized_min_base_volume_override"`
	CentralizedMinQuoteVolumeOverride  *float64                 `valid:"-" toml:"CENTRALIZED_MIN_QUOTE_VOLUME_OVERRIDE" json:"centralized_min_quote_volume_override"`
	PostgresDbConfig                   *postgresdb.Config       `valid:"-" toml:"POSTGRES_DB" json:"postgres_db"`
	DbOverrideAccountID                string                   `valid:"-" toml:"DB_OVERRIDE__ACCOUNT_ID" json:"db_override__account_id"`
	Filters                            []string                 `valid:"-" toml:"FILTERS" json:"filters"`
	AlertType                          string                   `valid:"-" toml:"ALERT_TYPE" json:"alert_type"`
	AlertAPIKey                        string                   `valid:"-" toml:"ALERT_API_KEY" json:"alert_api_key"`
	MonitoringPort                     uint16                   `valid:"-" toml:"MONITORING_PORT" json:"monitoring_port"`
	MonitoringTLSCert                  string                   `valid:"-" toml:"MONITORING_TLS_CERT" json:"monitoring_tls_cert"`
	MonitoringTLSKey                   string                   `valid:"-" toml:"MONITORING_TLS_KEY" json:"monitoring_tls_key"`
	GoogleClientID                     string                   `valid:"-" toml:"GOOGLE_CLIENT_ID" json:"google_client_id"`
	GoogleClientSecret                 string                   `valid:"-" toml:"GOOGLE_CLIENT_SECRET" json:"google_client_secret"`
	AcceptableEmails                   string                   `valid:"-" toml:"ACCEPTABLE_GOOGLE_EMAILS" json:"acceptable_google_emails"`
	TradingExchange                    string                   `valid:"-" toml:"TRADING_EXCHANGE" json:"trading_exchange"`
	ExchangeAPIKeys                    toml.ExchangeAPIKeysToml `valid:"-" toml:"EXCHANGE_API_KEYS" json:"exchange_api_keys"`
	ExchangeParams                     toml.ExchangeParamsToml  `valid:"-" toml:"EXCHANGE_PARAMS" json:"exchange_params"`
	ExchangeHeaders                    toml.ExchangeHeadersToml `valid:"-" toml:"EXCHANGE_HEADERS" json:"exchange_headers"`
	// contains filtered or unexported fields
}

BotConfig represents the configuration params for the bot

func MakeBotConfig

func MakeBotConfig(
	sourceSecretSeed string,
	tradingSecretSeed string,
	assetCodeA string,
	issuerA string,
	assetCodeB string,
	issuerB string,
	tickIntervalMillis int32,
	maxTickDelayMillis int64,
	deleteCyclesThreshold int64,
	submitMode string,
	fillTrackerSleepMillis uint32,
	fillTrackerDeleteCyclesThreshold int64,
	horizonURL string,
	ccxtRestURL *string,
	dollarValueFeedBaseAsset string,
	dollarValueFeedQuoteAsset string,
	fee *FeeConfig,
	centralizedPricePrecisionOverride *int8,
	centralizedVolumePrecisionOverride *int8,
	centralizedMinBaseVolumeOverride *float64,
	centralizedMinQuoteVolumeOverride *float64,
) *BotConfig

MakeBotConfig factory method for BotConfig

func (*BotConfig) AssetBase

func (b *BotConfig) AssetBase() hProtocol.Asset

AssetBase returns the config's assetBase

func (*BotConfig) AssetQuote

func (b *BotConfig) AssetQuote() hProtocol.Asset

AssetQuote returns the config's assetQuote

func (*BotConfig) Init

func (b *BotConfig) Init() error

Init initializes this config

func (*BotConfig) IsTradingSdex

func (b *BotConfig) IsTradingSdex() bool

IsTradingSdex returns whether the config is set to trade on SDEX

func (*BotConfig) SourceAccount

func (b *BotConfig) SourceAccount() string

SourceAccount returns the config's source account

func (BotConfig) String

func (b BotConfig) String() string

String impl.

func (*BotConfig) TradingAccount

func (b *BotConfig) TradingAccount() string

TradingAccount returns the config's trading account

func (*BotConfig) TradingExchangeName

func (b *BotConfig) TradingExchangeName() string

TradingExchangeName returns the defaulted trading exchange name

func (*BotConfig) TradingPair

func (b *BotConfig) TradingPair() string

TradingPair returns the config's trading pair name.

type FeeConfig

type FeeConfig struct {
	CapacityTrigger float64 `valid:"-" toml:"CAPACITY_TRIGGER" json:"capacity_trigger"`     // trigger when "ledger_capacity_usage" in /fee_stats is >= this value
	Percentile      uint8   `valid:"-" toml:"PERCENTILE" json:"percentile"`                 // percentile computation to use from /fee_stats (10, 20, ..., 90, 95, 99)
	MaxOpFeeStroops uint64  `valid:"-" toml:"MAX_OP_FEE_STROOPS" json:"max_op_fee_stroops"` // max fee in stroops per operation to use
}

FeeConfig represents input data for how to deal with network fees

type SleepMode

type SleepMode string

SleepMode defines when the bot sleeps, before (begin) or after (end) of update cycle

const (
	SleepModeBegin SleepMode = "begin"
	SleepModeEnd   SleepMode = "end"
)

The following are the two types of sleep modes

func ParseSleepMode

func ParseSleepMode(sleepMode string) SleepMode

ParseSleepMode factory, defaults to SleepModeEnd so it does not return any error

func (SleepMode) String

func (s SleepMode) String() string

String is the Stringer impl.

type Trader

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

Trader represents a market making bot, which is composed of various parts include the strategy and various APIs.

func MakeTrader

func MakeTrader(
	api *horizonclient.Client,
	ieif *plugins.IEIF,
	assetBase hProtocol.Asset,
	assetQuote hProtocol.Asset,
	valueBaseFeed api.PriceFeed,
	valueQuoteFeed api.PriceFeed,
	tradingAccount string,
	sdex *plugins.SDEX,
	exchangeShim api.ExchangeShim,
	strategy api.Strategy,
	timeController api.TimeController,
	sleepMode SleepMode,
	synchronizeStateLoadEnable bool,
	synchronizeStateLoadMaxRetries int,
	fillTracker api.FillTracker,
	deleteCyclesThreshold int64,
	submitMode api.SubmitMode,
	submitFilters []plugins.SubmitFilter,
	threadTracker *multithreading.ThreadTracker,
	fixedIterations *uint64,
	dataKey *model.BotKey,
	alert api.Alert,
	metricsTracker *plugins.MetricsTracker,
	startTime time.Time,
) *Trader

MakeTrader is the factory method for the Trader struct

func (*Trader) Start

func (t *Trader) Start()

Start starts the bot with the injected strategy

Jump to

Keyboard shortcuts

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