price

package
v0.4.31 Latest Latest
Warning

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

Go to latest
Published: May 15, 2020 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchURLWithRetry

func FetchURLWithRetry(url string) ([]byte, error)

Types

type CoinMarketCapConfig added in v0.4.11

type CoinMarketCapConfig struct {
	WhatToMineID int           `yaml:"what_to_mine_id" required:"true"`
	URL          string        `yaml:"url" required:"true"`
	Interval     time.Duration `yaml:"update_interval" default:"10m"`
}

type CoinMarketCapFactory added in v0.4.11

type CoinMarketCapFactory struct {
	CoinMarketCapConfig
}

func (*CoinMarketCapFactory) Config added in v0.4.11

func (m *CoinMarketCapFactory) Config() interface{}

func (*CoinMarketCapFactory) Init added in v0.4.11

func (m *CoinMarketCapFactory) Init(margin float64) Provider

func (*CoinMarketCapFactory) ValidateConfig added in v0.4.11

func (m *CoinMarketCapFactory) ValidateConfig() error

type Factory added in v0.4.11

type Factory interface {
	Config() interface{}
	ValidateConfig() error
	Init(margin float64) Provider
}

func NewFactory added in v0.4.11

func NewFactory(t string) Factory

type Provider

type Provider interface {
	// GetPrice returns last known value of token's price.
	// Note that value is ether-graded (1e18).
	GetPrice() *big.Int
}

Provider loads and calculates mining profit for specified token. The value is is USD per Second per hash.

func NewCMCProvider added in v0.4.11

func NewCMCProvider(cfg *CoinMarketCapConfig, margin float64) Provider

func NewStaticProvider added in v0.4.11

func NewStaticProvider(cfg *StaticProviderConfig) Provider

type SourceConfig added in v0.4.11

type SourceConfig struct {
	Factory
}

SourceConfig configure different sources which van be used to obtain price for orders/deals.

func (*SourceConfig) MarshalYAML added in v0.4.11

func (m *SourceConfig) MarshalYAML() (interface{}, error)

func (*SourceConfig) UnmarshalYAML added in v0.4.11

func (m *SourceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

type StaticFactory added in v0.4.11

type StaticFactory struct {
	StaticProviderConfig
}

func (*StaticFactory) Config added in v0.4.11

func (m *StaticFactory) Config() interface{}

func (*StaticFactory) Init added in v0.4.11

func (m *StaticFactory) Init(Margin float64) Provider

func (*StaticFactory) ValidateConfig added in v0.4.11

func (m *StaticFactory) ValidateConfig() error

type StaticProviderConfig added in v0.4.11

type StaticProviderConfig struct {
	Price int64 `yaml:"price" required:"true"`
}

type Updateable added in v0.4.11

type Updateable interface {
	Update(ctx context.Context) error
	Interval() time.Duration
}

Updateable provider should refresh their state with given interval.

Jump to

Keyboard shortcuts

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