price

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Multiply

func Multiply(n1, n2 decimal.Decimal) decimal.Decimal

Types

type NormalizedPrices

type NormalizedPrices map[*commodity.Commodity]decimal.Decimal

NormalizedPrices is a map representing the price of commodities in some base commodity.

func (NormalizedPrices) Price

func (NormalizedPrices) Valuate

Valuate valuates the given amount.

type Price

type Price struct {
	Src       *syntax.Price
	Date      time.Time
	Commodity *commodity.Commodity
	Price     decimal.Decimal
	Target    *commodity.Commodity
}

Price represents a price command.

func Create

func Create(reg *registry.Registry, p *syntax.Price) (*Price, error)

type Prices

Prices stores the price for a commodity to a target commodity Outer map: target commodity Inner map: commodity value: price in (target commodity / commodity)

func (Prices) Insert

func (ps Prices) Insert(commodity *commodity.Commodity, price decimal.Decimal, target *commodity.Commodity)

Insert inserts a new price.

func (Prices) Normalize

func (ps Prices) Normalize(t *commodity.Commodity) NormalizedPrices

Normalize creates a normalized price map for the given commodity.

Jump to

Keyboard shortcuts

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