-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.rb
More file actions
23 lines (15 loc) · 791 Bytes
/
test.rb
File metadata and controls
23 lines (15 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require_relative 'swop_client'
require 'date'
swop_client = SwopClient.new("<your-swop-api-key>")
# fetch single rates
puts "single rate for EUR/USD for today"
puts swop_client.single_rate("EUR", "USD")
puts "single rate for EUR/USD for 21th July of 2020"
puts swop_client.single_rate("EUR", "USD", date: Date.new(2020, 07, 21))
# timeseries
puts "timeseries one week"
puts swop_client.timeseries(Date.new(2020, 07, 14), Date.new(2020, 07, 21))
puts "timeseries one week - with base currency USD"
puts swop_client.timeseries(Date.new(2020, 07, 14), Date.new(2020, 07, 21), base: "USD")
puts "timeseries one week - with base currency USD and target currencies GBP, EUR"
puts swop_client.timeseries(Date.new(2020, 07, 14), Date.new(2020, 07, 21), base: "USD", targets: ["GBP", "EUR"])