rates

package
v0.0.0-...-da9e6da Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package rates retrieves and stores daily exchange rates.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type History

type History struct {
	Database    *SQLiteDB
	GetBuyRates func(lastUpdateDate string) (map[string]float64, error)
}

func (*History) Options

func (h *History) Options(date string, value float64) ([]Option, error)

Get tries the given date and four previous days.

func (*History) RunDaemon

func (h *History) RunDaemon() error

RunDaemon starts a loop which fetches the rates every hour and inserts them into the database. The function blocks.

func (*History) Synced

func (h *History) Synced() bool

Synced returns whether rates have been updated since four days ago.

type Option

type Option struct {
	Currency string // from GetBuyRates result
	Price    float64
}

func (Option) Tr

func (opt Option) Tr(l lang.Lang) string

ISO 4217

type SQLiteDB

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

func OpenDB

func OpenDB(fpath string) (*SQLiteDB, error)

func (*SQLiteDB) Get

func (db *SQLiteDB) Get(date string) (map[string]float64, error)

Get returns ErrNoRows if no data is found.

func (*SQLiteDB) Insert

func (db *SQLiteDB) Insert(date string, m map[string]float64) error

func (*SQLiteDB) LatestDate

func (db *SQLiteDB) LatestDate() (string, error)

Jump to

Keyboard shortcuts

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