Documentation
¶
Index ¶
- Constants
- type Amount
- type ArbMarketMakerConfig
- type ArbMarketMakingPlacement
- type AutoRebalanceConfig
- type BalanceEffects
- type BalanceState
- type BasicMarketMakingConfig
- type BotBalance
- type BotBalanceAllocation
- type BotBalances
- type BotConfig
- type BotInventoryDiffs
- type BotProblems
- type BotStatus
- type CEXConfig
- type CEXOrderEvent
- type CEXProblems
- type CEXStatus
- type CfgUpdate
- type DEXOrderEvent
- type DepositEvent
- type EpochReport
- type FeeGapStats
- type GapStrategy
- type LotFeeRange
- type LotFees
- type MarketMaker
- func (m *MarketMaker) ArchivedRuns() ([]*MarketMakingRun, error)
- func (m *MarketMaker) AvailableBalances(mkt *MarketWithHost, alternateConfigPath *string) (dexBalances, cexBalances map[uint32]uint64, _ error)
- func (m *MarketMaker) CEXBalance(cexName string, assetID uint32) (*libxc.ExchangeBalance, error)
- func (m *MarketMaker) CEXBook(host string, baseID, quoteID uint32) (buys, sells []*core.MiniOrder, _ error)
- func (m *MarketMaker) Connect(ctx context.Context) (*sync.WaitGroup, error)
- func (m *MarketMaker) MarketReport(host string, baseID, quoteID uint32) (*MarketReport, error)
- func (m *MarketMaker) RemoveBotConfig(host string, baseID, quoteID uint32) error
- func (m *MarketMaker) RunLogs(startTime int64, mkt *MarketWithHost, n uint64, refID *uint64, ...) (events, updatedEvents []*MarketMakingEvent, overview *MarketMakingRunOverview, ...)
- func (m *MarketMaker) RunOverview(startTime int64, mkt *MarketWithHost) (*MarketMakingRunOverview, error)
- func (m *MarketMaker) RunningBotsStatus() *Status
- func (m *MarketMaker) StartBot(startCfg *StartConfig, alternateConfigPath *string, appPW []byte) (err error)
- func (m *MarketMaker) Status() *Status
- func (m *MarketMaker) StopBot(mkt *MarketWithHost) error
- func (m *MarketMaker) UpdateBotConfig(updatedCfg *BotConfig) error
- func (m *MarketMaker) UpdateCEXConfig(updatedCfg *CEXConfig) error
- func (m *MarketMaker) UpdateRunningBotCfg(cfg *BotConfig, balanceDiffs *BotInventoryDiffs, saveUpdate bool) error
- func (m *MarketMaker) UpdateRunningBotInventory(mkt *MarketWithHost, balanceDiffs *BotInventoryDiffs) error
- type MarketMakingConfig
- type MarketMakingEvent
- type MarketMakingRun
- type MarketMakingRunOverview
- type MarketReport
- type MarketWithHost
- type OracleReport
- type OrderFees
- type OrderPlacement
- type OrderReport
- type ProfitLoss
- type RunLogFilters
- type RunStats
- type SimpleArbConfig
- type Spreader
- type StampedError
- type StartConfig
- type Status
- type TradePlacement
- type WithdrawalEvent
Constants ¶
const ( NoteTypeRunStats = "runstats" NoteTypeRunEvent = "runevent" NoteTypeCEXNotification = "cexnote" NoteTypeEpochReport = "epochreport" NoteTypeCEXProblems = "cexproblems" )
const (
TopicBalanceUpdate = "BalanceUpdate"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Amount ¶
type Amount struct { Atoms int64 `json:"atoms"` Conventional float64 `json:"conventional"` Fmt string `json:"fmt"` USD float64 `json:"usd"` FmtUSD string `json:"fmtUSD"` FiatRate float64 `json:"fiatRate"` }
Amount contains the conversions and formatted strings associated with an amount of asset and a fiat exchange rate.
type ArbMarketMakerConfig ¶
type ArbMarketMakerConfig struct { BuyPlacements []*ArbMarketMakingPlacement `json:"buyPlacements"` SellPlacements []*ArbMarketMakingPlacement `json:"sellPlacements"` Profit float64 `json:"profit"` DriftTolerance float64 `json:"driftTolerance"` NumEpochsLeaveOpen uint64 `json:"orderPersistence"` }
ArbMarketMakerConfig is the configuration for a market maker that places orders on both sides of the DEX order book, at rates where there are profitable counter trades on a CEX order book. Whenever a DEX order is filled, the opposite trade will immediately be made on the CEX.
Each placement in BuyPlacements and SellPlacements represents an order that will be made on the DEX order book. The first placement will be placed at a rate closest to the CEX mid-gap, and each subsequent one will get farther.
The bot calculates the extrema rate on the CEX order book where it can buy or sell the quantity of lots specified in the placement multiplied by the multiplier amount. This will be the rate of the expected counter trade. The bot will then place an order on the DEX order book where if both trades are filled, the bot will earn the profit specified in the configuration.
The multiplier is important because it ensures that even if some of the trades closest to the mid-gap on the CEX order book are filled before the bot's orders on the DEX are matched, the bot will still be able to earn the expected profit.
Consider the following example:
Market: DCR/BTC, lot size = 10 DCR. Sell Placements: 1. { Lots: 1, Multiplier: 1.5 } 2. { Lots 1, Multiplier: 1.0 } Profit: 0.01 (1%) CEX Asks: 1. 10 DCR @ .005 BTC/DCR 2. 10 DCR @ .006 BTC/DCR 3. 10 DCR @ .007 BTC/DCR
For the first placement, the bot will find the rate at which it can buy 15 DCR (1 lot * 1.5 multiplier). This rate is .006 BTC/DCR. Therefore, it will place place a sell order at .00606 BTC/DCR (.006 BTC/DCR * 1.01).
For the second placement, the bot will go deeper into the CEX order book and find the rate at which it can buy 25 DCR. This is the previous 15 DCR used for the first placement plus the Quantity * Multiplier of the second placement. This rate is .007 BTC/DCR. Therefore it will place a sell order at .00707 BTC/DCR (.007 BTC/DCR * 1.01).
type ArbMarketMakingPlacement ¶
type ArbMarketMakingPlacement struct { Lots uint64 `json:"lots"` Multiplier float64 `json:"multiplier"` }
ArbMarketMakingPlacement is the configuration for an order placement on the DEX order book based on the existing orders on a CEX order book.
type AutoRebalanceConfig ¶
type AutoRebalanceConfig struct { MinBaseTransfer uint64 `json:"minBaseTransfer"` MinQuoteTransfer uint64 `json:"minQuoteTransfer"` }
AutoRebalanceConfig configures deposits and withdrawals by setting minimum transfer sizes. Minimum transfer sizes should be set to prevent excessive fees on high-fee blockchains. To calculate a minimum transfer size for an asset, choose a fee-loss tolerance <= your profit target. If you only wanted to lose a maximum of 1% to transfers, and the fees associated with a transfer are 350 Sats, then your minimum transfer size might be set to 350 * (1 / 0.01) = 35000 Sats. For low-fee assets, a transfer size of zero would be perfectly fine in most cases, but using a higher value prevents churn. For obvious reasons, minimum transfer sizes should never be more than the total amount allocated for trading. The way these are configured will probably be changed to better capture the reasoning above.
type BalanceEffects ¶
type BalanceEffects struct { Settled map[uint32]int64 `json:"settled"` Locked map[uint32]uint64 `json:"locked"` Pending map[uint32]uint64 `json:"pending"` Reserved map[uint32]uint64 `json:"reserved"` }
BalanceEffects represents the effects that a market making event has on the bot's balances.
type BalanceState ¶
type BalanceState struct { FiatRates map[uint32]float64 `json:"fiatRates"` Balances map[uint32]*BotBalance `json:"balances"` InventoryMods map[uint32]int64 `json:"invMods"` }
BalanceState contains the fiat rates and bot balances at the latest point of a run.
type BasicMarketMakingConfig ¶
type BasicMarketMakingConfig struct { // GapStrategy selects an algorithm for calculating the distance from // the basis price to place orders. GapStrategy GapStrategy `json:"gapStrategy"` // SellPlacements is a list of order placements for sell orders. // The orders are prioritized from the first in this list to the // last. SellPlacements []*OrderPlacement `json:"sellPlacements"` // BuyPlacements is a list of order placements for buy orders. // The orders are prioritized from the first in this list to the // last. BuyPlacements []*OrderPlacement `json:"buyPlacements"` // DriftTolerance is how far away from an ideal price orders can drift // before they are replaced (units: ratio of price). Default: 0.1%. // 0 <= x <= 0.01. DriftTolerance float64 `json:"driftTolerance"` }
BasicMarketMakingConfig is the configuration for a simple market maker that places orders on both sides of the order book.
func (*BasicMarketMakingConfig) Validate ¶
func (c *BasicMarketMakingConfig) Validate() error
type BotBalance ¶
type BotBalance struct { Available uint64 `json:"available"` Locked uint64 `json:"locked"` Pending uint64 `json:"pending"` Reserved uint64 `json:"reserved"` }
BotBalance keeps track of the amount of funds available for a bot's use, locked to fund orders, and pending.
type BotBalanceAllocation ¶
type BotBalanceAllocation struct { DEX map[uint32]uint64 `json:"dex"` CEX map[uint32]uint64 `json:"cex"` }
BotBalanceAllocation is the initial allocation of funds for a bot.
type BotBalances ¶
type BotBalances struct { DEX *BotBalance `json:"dex"` CEX *BotBalance `json:"cex"` }
type BotConfig ¶
type BotConfig struct { Host string `json:"host"` BaseID uint32 `json:"baseID"` QuoteID uint32 `json:"quoteID"` BaseWalletOptions map[string]string `json:"baseWalletOptions"` QuoteWalletOptions map[string]string `json:"quoteWalletOptions"` CEXName string `json:"cexName"` // UIConfig is settings defined and used by the front end to determine // allocations. UIConfig json.RawMessage `json:"uiConfig,omitempty"` // RPCConfig can be used for file-based initial allocations and // auto-rebalance settings. RPCConfig *struct { Alloc *BotBalanceAllocation `json:"alloc"` AutoRebalance *AutoRebalanceConfig `json:"autoRebalance"` } `json:"rpcConfig"` // Only one of the following configs should be set BasicMMConfig *BasicMarketMakingConfig `json:"basicMarketMakingConfig,omitempty"` SimpleArbConfig *SimpleArbConfig `json:"simpleArbConfig,omitempty"` ArbMarketMakerConfig *ArbMarketMakerConfig `json:"arbMarketMakingConfig,omitempty"` }
BotConfig is the configuration for a market making bot. The balance fields are the initial amounts that will be reserved to use for this bot. As the bot trades, the amounts reserved for it will be updated.
type BotInventoryDiffs ¶
type BotInventoryDiffs struct { DEX map[uint32]int64 `json:"dex"` CEX map[uint32]int64 `json:"cex"` }
BotInventoryDiffs is the amount of funds to add or remove from a bot's allocation.
type BotProblems ¶ added in v1.0.1
type BotProblems struct { // WalletNotSynced is true if orders were unable to be placed due to a // wallet not being synced. WalletNotSynced map[uint32]bool `json:"walletNotSynced"` // NoWalletPeers is true if orders were unable to be placed due to a wallet // not having any peers. NoWalletPeers map[uint32]bool `json:"noWalletPeers"` // AccountSuspended is true if orders were unable to be placed due to the // account being suspended. AccountSuspended bool `json:"accountSuspended"` // UserLimitTooLow is true if the user does not have the bonding amount // necessary to place all of their orders. UserLimitTooLow bool `json:"userLimitTooLow"` // NoPriceSource is true if there is no oracle or fiat rate available. NoPriceSource bool `json:"noPriceSource"` // OracleFiatMismatch is true if the mid-gap is outside the oracle's // safe range as defined by the config. OracleFiatMismatch bool `json:"oracleFiatMismatch"` // CEXOrderbookUnsynced is true if the CEX orderbook is unsynced. CEXOrderbookUnsynced bool `json:"cexOrderbookUnsynced"` // CausesSelfMatch is true if the order would cause a self match. CausesSelfMatch bool `json:"causesSelfMatch"` // UnknownError is set if an error occurred that was not one of the above. UnknownError error `json:"unknownError"` }
BotProblems contains problems that prevent orders from being placed.
type BotStatus ¶
type BotStatus struct { Config *BotConfig `json:"config"` Running bool `json:"running"` // RunStats being non-nil means the bot is running. RunStats *RunStats `json:"runStats"` LatestEpoch *EpochReport `json:"latestEpoch"` CEXProblems *CEXProblems `json:"cexProblems"` }
BotStatus is state information about a configured bot.
type CEXConfig ¶
type CEXConfig struct { // Name is the name of the cex. Name string `json:"name"` // APIKey is the API key for the CEX. APIKey string `json:"apiKey"` // APISecret is the API secret for the CEX. APISecret string `json:"apiSecret"` }
CEXConfig is a configuration for connecting to a CEX API.
type CEXOrderEvent ¶
type CEXOrderEvent struct { ID string `json:"id"` Rate uint64 `json:"rate"` Qty uint64 `json:"qty"` Sell bool `json:"sell"` BaseFilled uint64 `json:"baseFilled"` QuoteFilled uint64 `json:"quoteFilled"` }
CEXOrderEvent represents a a cex order that a bot placed.
type CEXProblems ¶ added in v1.0.1
type CEXProblems struct { // DepositErr is set if the last attempted deposit for an asset failed. DepositErr map[uint32]*StampedError `json:"depositErr"` // WithdrawErr is set if the last attempted withdrawal for an asset failed. WithdrawErr map[uint32]*StampedError `json:"withdrawErr"` // TradeErr is set if the last attempted CEX trade failed. TradeErr *StampedError `json:"tradeErr"` }
CEXProblems contains a record of the last attempted CEX operations by a bot.
type CEXStatus ¶
type CEXStatus struct { Config *CEXConfig `json:"config"` Connected bool `json:"connected"` ConnectionError string `json:"connectErr"` Markets map[string]*libxc.Market `json:"markets"` Balances map[uint32]*libxc.ExchangeBalance `json:"balances"` }
CEXStatus is state information about a cex.
type CfgUpdate ¶
CfgUpdate contains a BotConfig and the timestamp the bot started to use this configuration.
type DEXOrderEvent ¶
type DEXOrderEvent struct { ID string `json:"id"` Rate uint64 `json:"rate"` Qty uint64 `json:"qty"` Sell bool `json:"sell"` Transactions []*asset.WalletTransaction `json:"transactions"` }
DEXOrderEvent represents a a dex order that a bot placed.
type DepositEvent ¶
type DepositEvent struct { Transaction *asset.WalletTransaction `json:"transaction"` AssetID uint32 `json:"assetID"` CEXCredit uint64 `json:"cexCredit"` }
DepositEvent represents a deposit that a bot made.
type EpochReport ¶ added in v1.0.1
type EpochReport struct { // PreOrderProblems is set if there were problems with the bot's // configuration or state that prevents orders from being placed. PreOrderProblems *BotProblems `json:"preOrderProblems"` // BuysReport is the report for the buys. BuysReport *OrderReport `json:"buysReport"` // SellsReport is the report for the sells. SellsReport *OrderReport `json:"sellsReport"` // EpochNum is the number of the epoch. EpochNum uint64 `json:"epochNum"` }
EpochReport contains a report of a bot's activity during an epoch.
type FeeGapStats ¶
type FeeGapStats struct { BasisPrice uint64 `json:"basisPrice"` RemoteGap uint64 `json:"remoteGap"` FeeGap uint64 `json:"feeGap"` RoundTripFees uint64 `json:"roundTripFees"` // base units }
FeeGapStats is info about market and fee state. The intepretation of the various statistics may vary slightly with bot type.
type GapStrategy ¶
type GapStrategy string
GapStrategy is a specifier for an algorithm to choose the maker bot's target spread.
const ( // GapStrategyMultiplier calculates the spread by multiplying the // break-even gap by the specified multiplier, 1 <= r <= 100. GapStrategyMultiplier GapStrategy = "multiplier" // GapStrategyAbsolute sets the spread to the rate difference. GapStrategyAbsolute GapStrategy = "absolute" // GapStrategyAbsolutePlus sets the spread to the rate difference plus the // break-even gap. GapStrategyAbsolutePlus GapStrategy = "absolute-plus" // GapStrategyPercent sets the spread as a ratio of the mid-gap rate. // 0 <= r <= 0.1 GapStrategyPercent GapStrategy = "percent" // GapStrategyPercentPlus sets the spread as a ratio of the mid-gap rate // plus the break-even gap. GapStrategyPercentPlus GapStrategy = "percent-plus" )
type LotFeeRange ¶
LotFeeRange combine the estimated and maximum LotFees.
type LotFees ¶
type LotFees struct { Swap uint64 `json:"swap"` Redeem uint64 `json:"redeem"` Refund uint64 `json:"refund"` }
LotFees are the fees for trading one lot.
type MarketMaker ¶
type MarketMaker struct {
// contains filtered or unexported fields
}
MarketMaker handles the market making process. It supports running different strategies on different markets.
func NewMarketMaker ¶
func NewMarketMaker(c clientCore, eventLogDBPath, cfgPath string, log dex.Logger) (*MarketMaker, error)
NewMarketMaker creates a new MarketMaker.
func (*MarketMaker) ArchivedRuns ¶
func (m *MarketMaker) ArchivedRuns() ([]*MarketMakingRun, error)
ArchivedRuns returns all archived market making runs.
func (*MarketMaker) AvailableBalances ¶
func (m *MarketMaker) AvailableBalances(mkt *MarketWithHost, alternateConfigPath *string) (dexBalances, cexBalances map[uint32]uint64, _ error)
AvailableBalances returns the available balances of assets relevant to market making on the specified market on the DEX (including fee assets), and optionally a CEX depending on the configured strategy.
func (*MarketMaker) CEXBalance ¶
func (m *MarketMaker) CEXBalance(cexName string, assetID uint32) (*libxc.ExchangeBalance, error)
func (*MarketMaker) CEXBook ¶
func (m *MarketMaker) CEXBook(host string, baseID, quoteID uint32) (buys, sells []*core.MiniOrder, _ error)
CEXBook generates a snapshot of the specified CEX order book.
func (*MarketMaker) MarketReport ¶
func (m *MarketMaker) MarketReport(host string, baseID, quoteID uint32) (*MarketReport, error)
MarketReport returns information about the oracle rates on a market pair and the fiat rates of the base and quote assets.
func (*MarketMaker) RemoveBotConfig ¶
func (m *MarketMaker) RemoveBotConfig(host string, baseID, quoteID uint32) error
RemoveConfig removes a bot config from the market making config.
func (*MarketMaker) RunLogs ¶
func (m *MarketMaker) RunLogs(startTime int64, mkt *MarketWithHost, n uint64, refID *uint64, filters *RunLogFilters) (events, updatedEvents []*MarketMakingEvent, overview *MarketMakingRunOverview, err error)
RunLogs returns the event logs of a market making run. At most n events are returned, if n == 0 then all events are returned. If refID is not nil, then the events including and after refID are returned. Updated events are events that were updated from pending to confirmed during this call. For completed runs, on each call to RunLogs, all pending events are checked for updates, and anything that was updated is returned.
func (*MarketMaker) RunOverview ¶
func (m *MarketMaker) RunOverview(startTime int64, mkt *MarketWithHost) (*MarketMakingRunOverview, error)
RunOverview returns the overview of a market making run.
func (*MarketMaker) RunningBotsStatus ¶
func (m *MarketMaker) RunningBotsStatus() *Status
RunningBotsStatus returns the status of all currently running bots. This should be used by the CLI which may have passed in an alternate config file when starting bots.
func (*MarketMaker) StartBot ¶
func (m *MarketMaker) StartBot(startCfg *StartConfig, alternateConfigPath *string, appPW []byte) (err error)
StartBot starts a market making bot.
func (*MarketMaker) Status ¶
func (m *MarketMaker) Status() *Status
Status generates a Status for the MarketMaker. This returns the status of all bots specified in the default config file.
func (*MarketMaker) StopBot ¶
func (m *MarketMaker) StopBot(mkt *MarketWithHost) error
StopBot stops a running bot.
func (*MarketMaker) UpdateBotConfig ¶
func (m *MarketMaker) UpdateBotConfig(updatedCfg *BotConfig) error
UpdateBotConfig updates the configuration for one of the bots.
func (*MarketMaker) UpdateCEXConfig ¶
func (m *MarketMaker) UpdateCEXConfig(updatedCfg *CEXConfig) error
func (*MarketMaker) UpdateRunningBotCfg ¶
func (m *MarketMaker) UpdateRunningBotCfg(cfg *BotConfig, balanceDiffs *BotInventoryDiffs, saveUpdate bool) error
UpdateRunningBotCfg updates the configuration and balance allocation for a running bot. If saveUpdate is true, the update configuration will be saved to the default config file.
func (*MarketMaker) UpdateRunningBotInventory ¶
func (m *MarketMaker) UpdateRunningBotInventory(mkt *MarketWithHost, balanceDiffs *BotInventoryDiffs) error
UpdateRunningBotInventory updates the inventory of a running bot.
type MarketMakingConfig ¶
type MarketMakingConfig struct { BotConfigs []*BotConfig `json:"botConfigs"` CexConfigs []*CEXConfig `json:"cexConfigs"` }
MarketMakingConfig is the overall configuration of the market maker.
func (*MarketMakingConfig) Copy ¶
func (cfg *MarketMakingConfig) Copy() *MarketMakingConfig
type MarketMakingEvent ¶
type MarketMakingEvent struct { ID uint64 `json:"id"` TimeStamp int64 `json:"timestamp"` Pending bool `json:"pending"` BalanceEffects *BalanceEffects `json:"balanceEffects,omitempty"` // Only one of the following will be populated. DEXOrderEvent *DEXOrderEvent `json:"dexOrderEvent,omitempty"` CEXOrderEvent *CEXOrderEvent `json:"cexOrderEvent,omitempty"` DepositEvent *DepositEvent `json:"depositEvent,omitempty"` WithdrawalEvent *WithdrawalEvent `json:"withdrawalEvent,omitempty"` UpdateConfig *BotConfig `json:"updateConfig,omitempty"` UpdateInventory *map[uint32]int64 `json:"updateInventory,omitempty"` }
MarketMakingEvent represents an action that a market making bot takes.
type MarketMakingRun ¶
type MarketMakingRun struct { StartTime int64 `json:"startTime"` Market *MarketWithHost `json:"market"` }
MarketMakingRun identifies a market making run.
type MarketMakingRunOverview ¶
type MarketMakingRunOverview struct { EndTime *int64 `json:"endTime,omitempty"` Cfgs []*CfgUpdate `json:"cfgs"` InitialBalances map[uint32]uint64 `json:"initialBalances"` ProfitLoss *ProfitLoss `json:"profitLoss"` FinalState *BalanceState `json:"finalState"` }
MarketMakingRunOverview contains information about a market making run.
type MarketReport ¶
type MarketReport struct { Price float64 `json:"price"` Oracles []*OracleReport `json:"oracles"` BaseFiatRate float64 `json:"baseFiatRate"` QuoteFiatRate float64 `json:"quoteFiatRate"` BaseFees *LotFeeRange `json:"baseFees"` QuoteFees *LotFeeRange `json:"quoteFees"` }
MarketReport contains a market's rates on various exchanges and the fiat rates of the base/quote assets.
type MarketWithHost ¶
type MarketWithHost struct { Host string `json:"host"` BaseID uint32 `json:"baseID"` QuoteID uint32 `json:"quoteID"` }
MarketWithHost represents a market on a specific dex server.
func (MarketWithHost) ID ¶
func (m MarketWithHost) ID() string
func (MarketWithHost) String ¶
func (m MarketWithHost) String() string
type OracleReport ¶
type OracleReport struct { Host string `json:"host"` USDVol float64 `json:"usdVol"` BestBuy float64 `json:"bestBuy"` BestSell float64 `json:"bestSell"` }
OracleReport is a summary of a market on an exchange.
type OrderFees ¶ added in v1.0.1
type OrderFees struct { *LotFeeRange Funding uint64 `json:"funding"` // bookingFeesPerLot is the amount of fee asset that needs to be reserved // for fees, per ordered lot. For all assets, this will include // LotFeeRange.Max.Swap. For non-token EVM assets (eth, matic) Max.Refund // will be added. If the asset is the parent chain of a token counter-asset, // Max.Redeem is added. This is a commonly needed sum in various validation // and optimization functions. BookingFeesPerLot uint64 `json:"bookingFeesPerLot"` }
OrderFees represents the fees that will be required for a single lot of a dex order.
type OrderPlacement ¶
type OrderPlacement struct { // Lots is the max number of lots to place at this distance from the // mid-gap rate. If there is not enough balance to place this amount // of lots, the max that can be afforded will be placed. Lots uint64 `json:"lots"` // GapFactor controls the gap width in a way determined by the GapStrategy. GapFactor float64 `json:"gapFactor"` }
OrderPlacement represents the distance from the mid-gap and the amount of lots that should be placed at this distance.
type OrderReport ¶ added in v1.0.1
type OrderReport struct { Placements []*TradePlacement `json:"placements"` Fees *OrderFees `json:"buyFees"` AvailableDEXBals map[uint32]*BotBalance `json:"availableDexBals"` RequiredDEXBals map[uint32]uint64 `json:"requiredDexBals"` UsedDEXBals map[uint32]uint64 `json:"usedDexBals"` RemainingDEXBals map[uint32]uint64 `json:"remainingDexBals"` AvailableCEXBal *BotBalance `json:"availableCexBal"` RequiredCEXBal uint64 `json:"requiredCexBal"` UsedCEXBal uint64 `json:"usedCexBal"` RemainingCEXBal uint64 `json:"remainingCexBal"` Error *BotProblems `json:"error"` }
OrderReport summarizes the results of a MultiTrade operation.
type ProfitLoss ¶
type ProfitLoss struct { Initial map[uint32]*Amount `json:"initial"` InitialUSD float64 `json:"initialUSD"` Mods map[uint32]*Amount `json:"mods"` ModsUSD float64 `json:"modsUSD"` Final map[uint32]*Amount `json:"final"` FinalUSD float64 `json:"finalUSD"` Diffs map[uint32]*Amount `json:"diffs"` Profit float64 `json:"profit"` ProfitRatio float64 `json:"profitRatio"` }
ProfitLoss is a breakdown of the profit calculations.
type RunLogFilters ¶
type RunStats ¶
type RunStats struct { InitialBalances map[uint32]uint64 `json:"initialBalances"` DEXBalances map[uint32]*BotBalance `json:"dexBalances"` CEXBalances map[uint32]*BotBalance `json:"cexBalances"` ProfitLoss *ProfitLoss `json:"profitLoss"` StartTime int64 `json:"startTime"` PendingDeposits int `json:"pendingDeposits"` PendingWithdrawals int `json:"pendingWithdrawals"` CompletedMatches uint32 `json:"completedMatches"` TradedUSD float64 `json:"tradedUSD"` FeeGap *FeeGapStats `json:"feeGap"` }
RunStats is a snapshot of the bot's balances and performance at a point in time.
type SimpleArbConfig ¶
type SimpleArbConfig struct { // ProfitTrigger is the minimum profit before a cross-exchange trade // sequence is initiated. Range: 0 < ProfitTrigger << 1. For example, if // the ProfitTrigger is 0.01 and a trade sequence would produce a 1% profit // or better, a trade sequence will be initiated. ProfitTrigger float64 `json:"profitTrigger"` // MaxActiveArbs sets a limit on the number of active arbitrage sequences // that can be open simultaneously. MaxActiveArbs uint32 `json:"maxActiveArbs"` // NumEpochsLeaveOpen is the number of epochs an arbitrage sequence will // stay open if one or both of the orders were not filled. NumEpochsLeaveOpen uint32 `json:"numEpochsLeaveOpen"` }
SimpleArbConfig is the configuration for an arbitrage bot that only places orders when there is a profitable arbitrage opportunity.
func (*SimpleArbConfig) Validate ¶
func (c *SimpleArbConfig) Validate() error
type Spreader ¶
type Spreader func(ctx context.Context, baseSymbol, quoteSymbol string, log dex.Logger) (sell, buy float64, err error)
Spreader is a function that can generate market spread data for a known exchange.
type StampedError ¶ added in v1.0.1
StampedError is an error with a timestamp.
type StartConfig ¶
type StartConfig struct { MarketWithHost AutoRebalance *AutoRebalanceConfig `json:"autoRebalance"` Alloc *BotBalanceAllocation `json:"alloc"` }
StartConfig contains the data that must be submitted with a call to StartBot.
type TradePlacement ¶ added in v1.0.1
type TradePlacement struct { Rate uint64 `json:"rate"` Lots uint64 `json:"lots"` StandingLots uint64 `json:"standingLots"` OrderedLots uint64 `json:"orderedLots"` CounterTradeRate uint64 `json:"counterTradeRate"` RequiredDEX map[uint32]uint64 `json:"requiredDex"` RequiredCEX uint64 `json:"requiredCex"` UsedDEX map[uint32]uint64 `json:"usedDex"` UsedCEX uint64 `json:"usedCex"` Error *BotProblems `json:"error"` }
TradePlacement represents a placement to be made on a DEX order book using the MultiTrade function. A non-zero counterTradeRate indicates that the bot intends to make a counter-trade on a CEX when matches are made on the DEX, and this must be taken into consideration in combination with the bot's balance on the CEX when deciding how many lots to place. This information is also used when considering deposits and withdrawals.
type WithdrawalEvent ¶
type WithdrawalEvent struct { ID string `json:"id"` AssetID uint32 `json:"assetID"` Transaction *asset.WalletTransaction `json:"transaction"` CEXDebit uint64 `json:"cexDebit"` }
WithdrawalEvent represents a withdrawal that a bot made.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
This code is available on the terms of the project LICENSE.md file, also available online at https://blueoakcouncil.org/license/1.0.0.
|
This code is available on the terms of the project LICENSE.md file, also available online at https://blueoakcouncil.org/license/1.0.0. |