Documentation
¶
Index ¶
- Constants
- func GetPrice(prices []*USDPrice, request *PriceRequest) (decimal.Decimal, error)
- func GetPrices(ctx context.Context, requests []*PriceRequest, granularity Granularity) (map[string]decimal.Decimal, error)
- func UseLogger(logger btclog.Logger)
- type Granularity
- type PriceRequest
- type USDPrice
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.
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.
Click to show internal directories.
Click to hide internal directories.