You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+61-34Lines changed: 61 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,31 +24,31 @@ There are three types of accounts supported by OER API, Unlimited, Enterprise an
24
24
25
25
### 2.2 Installation
26
26
27
-
The latest version of Scala Forex is 0.6.0, which is cross-built against 2.11.x and 2.12.x.
27
+
The latest version of Scala Forex is 0.7.0, which is built against 2.12.x.
28
28
29
29
If you're using SBT, add the following lines to your build file:
30
30
31
31
```scala
32
32
libraryDependencies ++=Seq(
33
-
"com.snowplowanalytics"%%"scala-forex"%"0.6.0"
33
+
"com.snowplowanalytics"%%"scala-forex"%"0.7.0"
34
34
)
35
35
```
36
36
37
37
Note the double percent (`%%`) between the group and artifactId. That'll ensure you get the right package for your Scala version.
38
38
39
39
## 3. Usage
40
40
41
-
The Scala Forex supports two types of usage:
41
+
The Scala Forex library supports two types of usage:
42
42
43
43
1. Exchange rate lookups
44
44
2. Currency conversions
45
45
46
46
Both usage types support live, near-live or historical (end-of-day) exchange rates.
47
47
48
48
For all code samples below we are assuming the following imports:
49
+
49
50
```scala
50
51
importorg.joda.money.CurrencyUnit
51
-
importcats.effect.IO
52
52
importcom.snowplowanalytics.forex._
53
53
```
54
54
@@ -75,13 +75,13 @@ To go through each in turn:
75
75
76
76
2.`accountLevel` is the type of OER account you have. Possible values are `UnlimitedAccount`, `EnterpriseAccount`, and `DeveloperAccount`.
77
77
78
-
1.`nowishCacheSize` is the size configuration for near-live(nowish) lookup cache, it can be disabled by setting its value to 0. The key to nowish cache is a currency pair so the size of the cache equals to the number of pairs of currencies available.
78
+
1.`nowishCacheSize` is the size configuration for near-live(nowish) lookup cache, it can be disabled by setting its value to 0. The key to nowish cache is a currency pair so the size of the cache equals to the number of pairs of currencies available.
79
79
80
-
2.`nowishSecs` is the time configuration for near-live lookup. Nowish call will use the exchange rates stored in nowish cache if its time stamp is less than or equal to `nowishSecs` old.
80
+
2.`nowishSecs` is the time configuration for near-live lookup. A call to this cache will use the exchange rates stored in nowish cache if its time stamp is less than or equal to `nowishSecs` old.
81
81
82
-
3.`eodCacheSize` is the size configuration for end-of-day(eod) lookup cache, it can be disabled by setting its value to 0. The key to eod cache is a tuple of currency pair and time stamp, so the size of eod cache equals to the number of currency pairs times the days which the cache will remember the data for.
82
+
3.`eodCacheSize` is the size configuration for end-of-day(eod) lookup cache, it can be disabled by setting its value to 0. The key to eod cache is a tuple of currency pair and time stamp, so the size of eod cache equals to the number of currency pairs times the days which the cache will remember the data for.
83
83
84
-
4.`getNearestDay` is the rounding configuration for latest eod(at) lookup. The lookup will be performed on the next day if the rounding mode is set to EodRoundUp, and on the previous day if EodRoundDown.
84
+
4.`getNearestDay` is the rounding configuration for latest eod(at) lookup. The lookup will be performed on the next day if the rounding mode is set to EodRoundUp, and on the previous day if EodRoundDown.
85
85
86
86
5.`baseCurrency` can be configured to different currencies by the users.
87
87
@@ -90,70 +90,91 @@ For an explanation for the default values please see section **5.4 Explanation o
90
90
### 3.2 Rate lookup
91
91
92
92
Unless specified otherwise, assume `forex` value is initialized as:
fx <-Forex.getForex[IO](ForexConfig("Your API key / app id", DeveloperAccount, getNearestDay =EodRoundUp))
276
+
fx <-CreateForex[IO].create(ForexConfig("Your API key / app id", DeveloperAccount, getNearestDay =EodRoundUp))
256
277
result <- fx.convert(10000, CurrencyUnit.GBP).to(CurrencyUnit.JPY).at(tradeDate)
257
278
} yield result
258
279
```
@@ -289,7 +310,7 @@ val tradeInYen = for {
289
310
#### 3.4.1 LRU cache
290
311
291
312
The `eodCacheSize` and `nowishCacheSize` values determine the maximum number of values to keep in the LRU cache,
292
-
which the Client will check prior to making an API lookup. To disable eithe LRU cache, set its size to zero,
313
+
which the Client will check prior to making an API lookup. To disable either LRU cache, set its size to zero,
293
314
i.e. `eodCacheSize = 0`.
294
315
295
316
#### 3.4.2 From currency selection
@@ -301,7 +322,7 @@ If not specified, `baseCurrency` is set to USD by default.
301
322
302
323
### 4.1 Running tests
303
324
304
-
You **must** export your `OER_KEY` or else the test suite will fail. To run the test suite locally:
325
+
You **must** export your `OER_KEY` or else the tests will be skipped. To run the test suite locally:
305
326
306
327
```
307
328
$ export OER_KEY=<<key>>
@@ -360,9 +381,13 @@ We selected USD for the base currency because this is the OER default as well.
360
381
361
382
With Open Exchange Rates' Unlimited and Enterprise accounts, Scala Forex can specify the base currency to use when looking up exchange rates; Developer-level accounts will always retrieve rates against USD, so a rate lookup from e.g. GBY to EUR will require two conversions (GBY -> USD -> EUR). For this reason, we recommend Unlimited and Enterprise-level accounts for slightly more accurate non-USD-related lookups.
362
383
363
-
## 6. Copyright and license
384
+
## 6. Documentation
385
+
386
+
The Scaladoc pages for this library can be found [here][scaladoc-pages].
364
387
365
-
Scala Forex is copyright 2013-2018 Snowplow Analytics Ltd.
388
+
## 7. Copyright and license
389
+
390
+
Scala Forex is copyright 2013-2019 Snowplow Analytics Ltd.
366
391
367
392
Licensed under the [Apache License, Version 2.0][license] (the "License");
368
393
you may not use this software except in compliance with the License.
@@ -388,3 +413,5 @@ limitations under the License.
0 commit comments