Documentation ¶
Index ¶
- Constants
- Variables
- type AggregateMethod
- type AnalysisMethod
- type Config
- type Day
- type Days
- type DaysRequest
- type DaysResponse
- type ExchangeCurrencies
- type ExchangeCurrenciesRequest
- type ExchangeCurrenciesResponse
- type ExchangeCurrency
- type ExchangeRate
- type ExchangeRates
- type ExchangeRatesRequest
- type ExchangeRatesResponse
- type Group
- type Groups
- type GroupsRequest
- type GroupsResponse
- type Rate
- type RateGroup
- type RateSeries
- type Rates
- type RatesRequest
- type RatesResponse
- type Riksbank
- func (rb *Riksbank) Days(ctx context.Context, req *DaysRequest) (*DaysResponse, error)
- func (rb *Riksbank) ExchangeCurrencies(ctx context.Context, req *ExchangeCurrenciesRequest) (*ExchangeCurrenciesResponse, error)
- func (rb *Riksbank) ExchangeRates(ctx context.Context, req *ExchangeRatesRequest) (*ExchangeRatesResponse, error)
- func (rb *Riksbank) Groups(ctx context.Context, req *GroupsRequest) (*GroupsResponse, error)
- func (rb *Riksbank) Rates(ctx context.Context, req *RatesRequest) (*RatesResponse, error)
- func (rb *Riksbank) Series(ctx context.Context, req *SeriesRequest) (*SeriesResponse, error)
- type Series
- type SeriesGroup
- type SeriesGroups
- type SeriesRequest
- type SeriesResponse
- type UnknownAggregateMethodError
- type UnknownAnalysisError
- type UnknownAnalysisForAggregateError
Constants ¶
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 ¶
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, } )
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 DaysRequest ¶
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 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 RateSeries ¶
RateSeries represents a series for a 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 ¶
Riksbank represents the API client
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 ¶
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 ¶
func (e UnknownAggregateMethodError) Error() string
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 ¶
func (e UnknownAnalysisForAggregateError) Error() string