Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/filiptubic/eurex


https://github.com/filiptubic/eurex

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

        

# eurex

Eurex is a simple money conversion library which converts value from one currency to another.
Rates which are applied are configurable and currently only supported rate source is from ECB ([European Central Bank](https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml)).

## Quickstart
### Install
Open terminal and invoke:
```
go get -u github.com/filiptubic/eurex
```
### Example
Convert 10 USD to CHF on 25. March 2022:
```
package main

import (
"time"

"github.com/filiptubic/eurex"
"github.com/filiptubic/eurex/currency"
"github.com/sirupsen/logrus"
)

func main() {
logger := eurex.DefaultLogger
logger.SetLevel(logrus.DebugLevel)
converter := eurex.DefaultConverter
date := time.Date(2022, time.March, 25, 0, 0, 0, 0, time.Local)

value, err := converter.Convert(date, 10, currency.USD, currency.CHF)
if err != nil {
logger.Errorf("got error: %v", err)
}
logger.Info(value)
}
```
Outputs:
```
DEBU[0000] [GET] https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml: code=200
INFO[0000] 9.277404108343935
```

## Tests
Clone repo and invoke in project root:
```
go test -coverprofile=coverage.out ./... -v
```

## Docs
Docs are available [here](https://pkg.go.dev/github.com/filiptubic/eurex).

Docs are locally available by invoking `godoc` in project root and opening http://localhost:6060/pkg/github.com/filiptubic/eurex/ in browser.