ticketbuyer

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2017 License: ISC Imports: 16 Imported by: 0

README

ticketbuyer

Package ticketbuyer provides automatic purchase of tickets from a Decred wallet.

Documentation

[GoDoc] (http://godoc.org/github.com/decred/dcrwallet/ticketbuyer)

Full go doc style documentation for the project can be viewed online without installing this package by using the GoDoc site here: http://godoc.org/github.com/decred/dcrwallet/ticketbuyer

You can also view the documentation locally once the package is installed with the godoc tool by running godoc -http=":6060" and pointing your browser to http://localhost:6060/pkg/github.com/decred/dcrwallet/ticketbuyer

Installation

$ go get github.com/decred/dcrwallet/ticketbuyer

Package ticketbuyer is licensed under the copyfree ISC License.

Documentation

Overview

Package ticketbuyer provides an implementation of automatic ticket purchasing for a decred wallet.

Index

Constants

View Source
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"
)
View Source
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.

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.

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.

Jump to

Keyboard shortcuts

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