riksbank

package module
v0.0.0-...-983a08b Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

README

GoDoc Go Report Card Build Status

riksbank

Go library and command line tool for interacting with the swedish central bank API.

Command line tool

The command line tool can be used to perform most API calls and get the results printed out to the console.

Install

To install the command line tool, simply use go get.

$ go get -u github.com/zeeraw/riksbank/cmd/riksbank

Resources

Documentation

Index

Constants

View Source
const (
	// Daily aggregation method (default)
	Daily = AggregateMethod("D")

	// Weekly aggregation method
	Weekly = AggregateMethod("W")

	// Monthly aggregation method
	Monthly = AggregateMethod("M")

	// Quarterly aggregation method
	Quarterly = AggregateMethod("Q")

	// Yearly aggregation method
	Yearly = AggregateMethod("Y")
)

Variables

View Source
var (
	// AggregateNames are the real names of all known aggregate methods
	AggregateNames = map[AggregateMethod]string{
		Daily:     "daily",
		Weekly:    "weekly",
		Monthly:   "monthly",
		Quarterly: "quarterly",
		Yearly:    "yearly",
	}

	// AggregateMethods are all known aggregate methods
	AggregateMethods = map[string]AggregateMethod{
		"daily":     Daily,
		"weekly":    Weekly,
		"monthly":   Monthly,
		"quarterly": Quarterly,
		"yearly":    Yearly,
	}
)
View Source
var (
	// AnalysisMethods are all known analysis methods
	AnalysisMethods = map[string]AnalysisMethod{
		"real":   Real,
		"mean":   Mean,
		"min":    Min,
		"max":    Max,
		"ultimo": Ultimo,
	}

	// AnalysisMethodNames are all known analysis method names
	AnalysisMethodNames = map[AnalysisMethod]string{
		Real:   "real",
		Mean:   "mean",
		Min:    "min",
		Max:    "max",
		Ultimo: "ultimo",
	}

	// DailyAnalysis are the analysis methods allowed for daily aggregation
	DailyAnalysis = map[AnalysisMethod]struct{}{
		Real: struct{}{},
	}

	// WeeklyAnalysis are the analysis methods allowed for weekly aggregation
	WeeklyAnalysis = map[AnalysisMethod]struct{}{
		Mean: struct{}{},
		Min:  struct{}{},
		Max:  struct{}{},
	}

	// MonthlyAnalysis are the analysis methods allowed for monthly aggregation
	MonthlyAnalysis = map[AnalysisMethod]struct{}{
		Mean: struct{}{},
		Min:  struct{}{},
		Max:  struct{}{},
	}

	// QuarterlyAnalysis are the analysis methods allowed for quarterly aggregation
	QuarterlyAnalysis = map[AnalysisMethod]struct{}{
		Mean: struct{}{},
		Min:  struct{}{},
		Max:  struct{}{},
	}

	// YearlyAnalysis are the analysis methods allowed for yearly aggregation
	YearlyAnalysis = map[AnalysisMethod]struct{}{
		Mean:   struct{}{},
		Min:    struct{}{},
		Max:    struct{}{},
		Ultimo: struct{}{},
	}
)

Functions

This section is empty.

Types

type AggregateMethod

type AggregateMethod string

AggregateMethod represents an enumeration of available aggregate methods when calculating values

func ParseAggregate

func ParseAggregate(s string) (AggregateMethod, error)

ParseAggregate will turn a string into an aggregate method

func (AggregateMethod) Name

func (am AggregateMethod) Name() string

Name returns the human readable name of the aggregate method

func (AggregateMethod) String

func (am AggregateMethod) String() string

type AnalysisMethod

type AnalysisMethod int

AnalysisMethod represents the analysis method for comparing values in a period

const (
	// Real is the actual value for the period
	Real AnalysisMethod = iota + 1
	// Mean is the average value of all values in a period
	Mean
	// Min is the smallest value of all values in a period
	Min
	// Max is the largest value of all values in a period
	Max
	// Ultimo is the value of the last banking day in the period
	Ultimo
)

func ParseAggregateAnalysis

func ParseAggregateAnalysis(aggregate AggregateMethod, s string) (AnalysisMethod, error)

ParseAggregateAnalysis will attempt to parse a string with an aggregate

func (AnalysisMethod) String

func (am AnalysisMethod) String() string

type Config

type Config struct {
	Client swea.Client
}

Config represents riksbank API configuration

type Day

type Day struct {
	Date      time.Time
	Year      int
	Week      int
	IsBankDay bool
}

Day represents information about a specific day in banking context

type Days

type Days []Day

Days represents multiple instances of Day

type DaysRequest

type DaysRequest struct {
	From time.Time
	To   time.Time
}

DaysRequest represents parameters for requesting information about days

type DaysResponse

type DaysResponse struct {
	Days Days
}

DaysResponse represents the data retrieved from requesting information about days

type ExchangeCurrencies

type ExchangeCurrencies []ExchangeCurrency

ExchangeCurrencies represents multiple instances of ExchangeCurrency

type ExchangeCurrenciesRequest

type ExchangeCurrenciesRequest struct{}

ExchangeCurrenciesRequest represents parameters for requesting a list of all exchange currencies

type ExchangeCurrenciesResponse

type ExchangeCurrenciesResponse struct {
	Currencies ExchangeCurrencies
}

ExchangeCurrenciesResponse represents the data retrieved from requesting a list of all exchange currencies

type ExchangeCurrency

type ExchangeCurrency struct {
	SeriesID    string
	Code        string
	Currency    currency.Currency
	Description string
}

ExchangeCurrency represents the exchange information for a currency

type ExchangeRate

type ExchangeRate struct {
	Date    time.Time
	Period  period.Period
	Base    currency.Currency
	Counter currency.Currency
	Value   *float64
}

ExchangeRate represents an exchange rate between two currencies

type ExchangeRates

type ExchangeRates []ExchangeRate

ExchangeRates represents multiple instance of ExchangeRate

type ExchangeRatesRequest

type ExchangeRatesRequest struct {
	CurrencyPairs   []currency.Pair
	AggregateMethod AggregateMethod
	From            time.Time
	To              time.Time
}

ExchangeRatesRequest represents parameters for requesting exchange rates

type ExchangeRatesResponse

type ExchangeRatesResponse struct {
	ExchangeRates []ExchangeRate
}

ExchangeRatesResponse represents the data retrieved from requesting exchange rates

type Group

type Group struct {
	ID          string
	ParentID    string
	Name        string
	Description string
}

Group represents information about an interest and exchange rate grouping

type Groups

type Groups []Group

Groups represents multiple instances of Group

type GroupsRequest

type GroupsRequest struct{}

GroupsRequest represents parameters for requesting a list of groups

type GroupsResponse

type GroupsResponse struct {
	Groups Groups
}

GroupsResponse represents the data retrieved from requesting a list of groups

type Rate

type Rate struct {
	Group  RateGroup
	Series RateSeries
	Date   time.Time
	Period period.Period
	Value  *float64
}

Rate represents a interest or exchange series rate for a period

type RateGroup

type RateGroup struct {
	ID   string
	Name string
}

RateGroup represents a group for a rate

type RateSeries

type RateSeries struct {
	ID   string
	Name string
}

RateSeries represents a series for a rate

type Rates

type Rates []Rate

Rates represents multiple instances of Rate

type RatesRequest

type RatesRequest struct {
	Series          []string
	From            time.Time
	To              time.Time
	AggregateMethod AggregateMethod
	AnalysisMethod  AnalysisMethod
}

RatesRequest represents parameters for requesting interest and exchange rates

type RatesResponse

type RatesResponse struct {
	Rates Rates
}

RatesResponse represents the data retrieved from requesting interest and exchange rates

type Riksbank

type Riksbank struct {
	Client swea.Client
}

Riksbank represents the API client

func New

func New(config Config) *Riksbank

New starts a new instance of riksbank

func (*Riksbank) Days

func (rb *Riksbank) Days(ctx context.Context, req *DaysRequest) (*DaysResponse, error)

Days retrieves exchange rates for currency pairs

func (*Riksbank) ExchangeCurrencies

func (rb *Riksbank) ExchangeCurrencies(ctx context.Context, req *ExchangeCurrenciesRequest) (*ExchangeCurrenciesResponse, error)

ExchangeCurrencies retrieves exchange rates for currency pairs

func (*Riksbank) ExchangeRates

func (rb *Riksbank) ExchangeRates(ctx context.Context, req *ExchangeRatesRequest) (*ExchangeRatesResponse, error)

ExchangeRates retrieves exchange rates for currency pairs

func (*Riksbank) Groups

func (rb *Riksbank) Groups(ctx context.Context, req *GroupsRequest) (*GroupsResponse, error)

Groups returns a list of all interest and exchange rate series groups

func (*Riksbank) Rates

func (rb *Riksbank) Rates(ctx context.Context, req *RatesRequest) (*RatesResponse, error)

Rates return interest or change rates for one or more series between different dates

func (*Riksbank) Series

func (rb *Riksbank) Series(ctx context.Context, req *SeriesRequest) (*SeriesResponse, error)

Series returns a list of series grouped by their group

type Series

type Series struct {
	ID              string
	GroupID         string
	Name            string
	Description     string
	LongDescription string
	Source          string
	From            time.Time
	To              time.Time
}

Series represents information about a series

type SeriesGroup

type SeriesGroup struct {
	Group  Group
	Series []Series
}

SeriesGroup represents a group of series and information about the group

type SeriesGroups

type SeriesGroups []SeriesGroup

SeriesGroups represent multiple instances of SeriesGroup

type SeriesRequest

type SeriesRequest struct {
	Groups []string
}

SeriesRequest represents parameters for requesting grouped series

type SeriesResponse

type SeriesResponse struct {
	Groups SeriesGroups
}

SeriesResponse represents the data retrieved from requesting grouped series

type UnknownAggregateMethodError

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

UnknownAggregateMethodError happens when a string is not a known method

func (UnknownAggregateMethodError) Error

type UnknownAnalysisError

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

UnknownAnalysisError happens when the analysis method does not exist at all

func (UnknownAnalysisError) Error

func (e UnknownAnalysisError) Error() string

type UnknownAnalysisForAggregateError

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

UnknownAnalysisForAggregateError happens when the analysis method cannot be used for the aggregate method

func (UnknownAnalysisForAggregateError) Error

Directories

Path Synopsis
cli
cmd

Jump to

Keyboard shortcuts

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