Documentation ¶
Overview ¶
Package ticketbuyer provides an implementation of automatic ticket purchasing for a decred wallet.
Index ¶
Constants ¶
const ( // TicketFeeMean is the string indicating that the mean ticket fee // should be used when determining ticket fee. TicketFeeMean = "mean" // TicketFeeMedian is the string indicating that the median ticket fee // should be used when determining ticket fee. TicketFeeMedian = "median" // PriceTargetVWAP is the string indicating that the volume // weighted average price should be used as the price target. PriceTargetVWAP = "vwap" // PriceTargetPool is the string indicating that the ticket pool // price should be used as the price target. PriceTargetPool = "pool" // PriceTargetDual is the string indicating that a combination of the // ticket pool price and the ticket VWAP should be used as the // price target. PriceTargetDual = "dual" )
const ( // AvgPriceVWAPMode indicates to use only the VWAP. AvgPriceVWAPMode = iota // AvgPricePoolMode indicates to use only the average // price in the ticket pool. AvgPricePoolMode // AvgPriceDualMode indicates to use bothe the VWAP and // the average pool price. AvgPriceDualMode )
Variables ¶
This section is empty.
Functions ¶
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.
Types ¶
type Config ¶
type Config struct { AccountName string AvgPriceMode string AvgPriceVWAPDelta int BalanceToMaintainAbsolute float64 BalanceToMaintainRelative float64 BlocksToAvg int DontWaitForTickets bool ExpiryDelta int FeeSource string FeeTargetScaling float64 HighPricePenalty float64 MinFee float64 MaxFee float64 MaxPerBlock int MaxPriceAbsolute float64 MaxPriceRelative float64 MaxPriceScale float64 MaxInMempool int PoolAddress string PoolFees float64 PriceTarget float64 SpreadTicketPurchases bool TicketAddress string TxFee float64 TicketFeeInfo bool PrevToBuyDiffPeriod int PrevToBuyHeight int }
Config stores the configuration options for ticket buyer.
type PurchaseManager ¶
type PurchaseManager struct {
// contains filtered or unexported fields
}
PurchaseManager is the main handler of websocket notifications to pass to the purchaser and internal quit notifications.
func NewPurchaseManager ¶
func NewPurchaseManager(w *wallet.Wallet, purchaser *TicketPurchaser, ntfnChan <-chan *wallet.MainTipChangedNotification) *PurchaseManager
NewPurchaseManager creates a new PurchaseManager.
func (*PurchaseManager) NotificationHandler ¶
func (p *PurchaseManager) NotificationHandler()
NotificationHandler handles notifications, which trigger ticket purchases.
func (*PurchaseManager) Start ¶ added in v0.8.0
func (p *PurchaseManager) Start()
Start starts the purchase manager goroutines.
func (*PurchaseManager) Stop ¶ added in v0.8.0
func (p *PurchaseManager) Stop()
Stop signals all purchase manager goroutines to shutdown.
func (*PurchaseManager) WaitForShutdown ¶ added in v0.8.0
func (p *PurchaseManager) WaitForShutdown()
WaitForShutdown blocks until all purchase manager goroutines have finished executing.
type PurchaseStats ¶
type PurchaseStats struct { Height int64 PriceMaxScale float64 PriceAverage float64 PriceNext float64 PriceCurrent float64 MempoolAll int MempoolOwn int Purchased int LeftWindow int FeeMin float64 FeeMax float64 FeeMedian float64 FeeMean float64 FeeOwn float64 Balance int64 TicketPrice int64 }
PurchaseStats stats is a collection of statistics related to the ticket purchase.
type TicketPurchaser ¶
type TicketPurchaser struct { ProportionLive float64 // contains filtered or unexported fields }
TicketPurchaser is the main handler for purchasing tickets. It decides whether or not to do so based on information obtained from daemon and wallet chain servers.
func NewTicketPurchaser ¶
func NewTicketPurchaser(cfg *Config, dcrdChainSvr *dcrrpcclient.Client, w *wallet.Wallet, activeNet *chaincfg.Params) (*TicketPurchaser, error)
NewTicketPurchaser creates a new TicketPurchaser.
func (*TicketPurchaser) Purchase ¶
func (t *TicketPurchaser) Purchase(height int64) (*PurchaseStats, error)
Purchase is the main handler for purchasing tickets for the user. TODO Not make this an inlined pile of crap.