trader

package
v0.0.0-...-04e8804 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrParsingFailed        = errors.New("unable to parse exchange rate")
	ErrExchangeRateNotFound = errors.New("requested exchange rate not found")
)

Functions

func CheckSimilarity

func CheckSimilarity(a Offer, b Offer, percentage int64) bool

func FormatUSD

func FormatUSD(usd *big.Rat) string

Types

type ExchangeRate

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

func NewExchangeRate

func NewExchangeRate() *ExchangeRate

func (*ExchangeRate) Fetch

func (r *ExchangeRate) Fetch(id string) (*big.Rat, error)

type FixedPremiumTrader

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

func NewFixedPremiumTrader

func NewFixedPremiumTrader(premiumUSD *big.Rat, antiSpamFee big.Int,
	ethChain ethereum.Blockchain, siaChain sia.Blockchain) FixedPremiumTrader

func (*FixedPremiumTrader) PauseOrderPreparation

func (t *FixedPremiumTrader) PauseOrderPreparation(now time.Time)

func (*FixedPremiumTrader) PrepareBindingOffer

func (t *FixedPremiumTrader) PrepareBindingOffer(siacoin types.Currency, minerFee types.Currency,
	now time.Time) (*Offer, *time.Time, error)

func (*FixedPremiumTrader) PrepareNonBindingOffer

func (t *FixedPremiumTrader) PrepareNonBindingOffer(siacoin types.Currency, minerFee types.Currency,
	now time.Time) (*Offer, error)

func (*FixedPremiumTrader) ResumeOrderPreparation

func (t *FixedPremiumTrader) ResumeOrderPreparation()

type Offer

type Offer struct {
	Msg         string
	Available   bool
	Ether       big.Int
	AntiSpamFee big.Int
}

type Rate

type Rate struct {
	ID  string
	USD string `json:"price_usd"`
}

type Trader

type Trader interface {
	PrepareNonBindingOffer(siacoin types.Currency, minerFee types.Currency,
		now time.Time) (offer *Offer, err error)
	PrepareBindingOffer(siacoin types.Currency, minerFee types.Currency,
		now time.Time) (offer *Offer, deadline *time.Time, err error)
	PauseOrderPreparation(now time.Time)
	ResumeOrderPreparation()
}

Jump to

Keyboard shortcuts

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