Documentation
¶
Index ¶
- Constants
- type Client
- func (c *Client) DownloadRateSheet(ctx context.Context, path string, opts ...Option) error
- func (c *Client) GetExchangeRate(ctx context.Context, currency Currency, opts ...Option) (*ExchangeRate, error)
- func (c *Client) GetExchangeRates(ctx context.Context, opts ...Option) (map[Currency]*ExchangeRate, error)
- func (c *Client) GetUrl(opts ...Option) string
- type Currency
- type ExchangeRate
- type Option
Constants ¶
View Source
const ( BaseURL = "https://www.sbp.org.pk/ecodata/rates/m2m" HTTPStatusOK = 200 YearModulo = 100 // For getting last 2 digits of year )
View Source
const (
HoursInDay = 24 // Hours in a day for time truncation
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func New ¶
func New(options ...httpr.ClientOption) *Client
func (*Client) DownloadRateSheet ¶
DownloadRateSheet downloads the exchange rate PDF to the specified file path.
func (*Client) GetExchangeRate ¶
func (*Client) GetExchangeRates ¶
type Currency ¶
type Currency string
const ( USD Currency = "USD" EUR Currency = "EUR" GBP Currency = "GBP" JPY Currency = "JPY" CHF Currency = "CHF" AUD Currency = "AUD" CAD Currency = "CAD" SEK Currency = "SEK" NOK Currency = "NOK" DKK Currency = "DKK" SAR Currency = "SAR" AED Currency = "AED" KWD Currency = "KWD" BHD Currency = "BHD" QAR Currency = "QAR" OMR Currency = "OMR" CNY Currency = "CNY" HKD Currency = "HKD" SGD Currency = "SGD" THB Currency = "THB" MYR Currency = "MYR" INR Currency = "INR" KRW Currency = "KRW" NZD Currency = "NZD" ZAR Currency = "ZAR" BDT Currency = "BDT" BRL Currency = "BRL" ARS Currency = "ARS" LKR Currency = "LKR" TRY Currency = "TRY" IDR Currency = "IDR" MXN Currency = "MXN" RUB Currency = "RUB" GNH Currency = "GNH" )
type ExchangeRate ¶
type ExchangeRate struct {
Currency Currency `json:"currency"`
Date time.Time `json:"date"`
URL string `json:"url"` // Source PDF URL
Ready string `json:"ready,omitempty"` // Spot rate (immediate delivery)
OneWeek string `json:"one_week,omitempty"` // 1-week forward rate
TwoWeek string `json:"two_week,omitempty"` // 2-week forward rate
OneMonth string `json:"one_month,omitempty"` // 1-month forward rate
TwoMonth string `json:"two_month,omitempty"` // 2-month forward rate
ThreeMonth string `json:"three_month,omitempty"` // 3-month forward rate
FourMonth string `json:"four_month,omitempty"` // 4-month forward rate
FiveMonth string `json:"five_month,omitempty"` // 5-month forward rate
SixMonth string `json:"six_month,omitempty"` // 6-month forward rate
NineMonth string `json:"nine_month,omitempty"` // 9-month forward rate
OneYear string `json:"one_year,omitempty"` // 1-year forward rate
}
ExchangeRate represents exchange rates for different delivery periods These are forward rates used for currency hedging and speculation.
func (*ExchangeRate) GetSpotRate ¶
func (e *ExchangeRate) GetSpotRate() string
GetSpotRate returns the spot rate (Ready rate) as a string.
Click to show internal directories.
Click to hide internal directories.