fiat

package
v0.2.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2020 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

View Source
const Subsystem = "FIAT"

Subsystem defines the logging code for this subsystem.

Variables

This section is empty.

Functions

func GetPrice

func GetPrice(prices []*USDPrice, request *PriceRequest) (decimal.Decimal,
	error)

GetPrice gets the price for a timestamped request from a set of price data. This function expects the price data to be sorted with ascending timestamps. If request lies between two price points, we simply aggregate the two prices.

func GetPrices

func GetPrices(ctx context.Context, requests []*PriceRequest,
	granularity Granularity) (map[string]decimal.Decimal, error)

GetPrices gets a set of prices for a set of timestamped requests.

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 Granularity

type Granularity string

Granularity indicates the level of aggregation price information will be provided at.

const (
	// GranularityMinute aggregates the bitcoin price over 1 minute.
	GranularityMinute Granularity = "m1"

	// GranularityMinute aggregates the bitcoin price over 1 minute.
	Granularity5Minute Granularity = "m5"

	// GranularityMinute aggregates the bitcoin price over 15 minutes.
	Granularity15Minute Granularity = "m15"

	// GranularityMinute aggregates the bitcoin price over 30 minutes.
	Granularity30Minute Granularity = "m30"

	// GranularityHour aggregates the bitcoin price over 1 hour.
	GranularityHour Granularity = "h1"

	// Granularity6Hour aggregates the bitcoin price over 6 hours.
	Granularity6Hour Granularity = "h6"

	// Granularity12Hour aggregates the bitcoin price over 12h hours.
	Granularity12Hour Granularity = "h12"

	// GranularityDay aggregates the bitcoin price over one day.
	GranularityDay Granularity = "d1"
)

type PriceRequest

type PriceRequest struct {
	// Identifier uniquely identifies the request.
	Identifier string

	// Value is the amount of BTC in msat.
	Value lnwire.MilliSatoshi

	// Timestamp is the time at which the price should be obtained.
	Timestamp time.Time
}

PriceRequest describes a request for price information.

type USDPrice

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

USDPrice represents the Bitcoin price in USD at a certain time.

func CoinCapPriceData

func CoinCapPriceData(ctx context.Context, start, end time.Time,
	granularity Granularity) ([]*USDPrice, error)

CoinCapPriceData obtains price data over a given range for coincap.

Jump to

Keyboard shortcuts

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