Skip to content

Commit 2fe84e6

Browse files
author
Andrey Oskin
committed
Bump
1 parent a62ef55 commit 2fe84e6

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ HTTP = "0.8, 0.9"
1818
Reexport = "0.2, 1.0"
1919
TimeSeries = "0.17, 0.18, 0.19, 0.20, 0.21, 0.22, 0.23"
2020
julia = "1"
21-
JSON3 = "1.9.1"
21+
JSON3 = "1"
2222

2323
[extras]
2424
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

src/downloads.jl

+13-13
Original file line numberDiff line numberDiff line change
@@ -165,31 +165,31 @@ https://www.ons.gov.uk/timeseriestool
165165
- fred() which accesses the St. Louis Federal Reserve financial and economic data sets.
166166
- yahoo() which is a wrapper from downloading financial time series for stocks from Yahoo Finance.
167167
"""
168-
function ons(timeseries::AbstractString="L522",dataset::AbstractString="MM23")
168+
function ons(timeseries::AbstractString = "L522", dataset::AbstractString = "MM23")
169169
url = "https://api.ons.gov.uk/dataset/$dataset/timeseries/$timeseries/data"
170170
res = HTTP.get(url)
171171
@assert res.status == 200
172-
json = JSON3.read(String(res.body))
172+
json = JSON3.read(HTTP.payload(res))
173173
ta = nothing
174174
if "months" in keys(json)
175175
data = json["months"]
176-
dates = [Date(x["year"]*" "*x["month"],dateformat"Y U") for x in data]
177-
values = [parse(Float64,x["value"]) for x in data]
178-
ta = TimeArray((timestamp=dates,monthly=values),timestamp=:timestamp)
176+
dates = [Date(x["year"]*" "*x["month"], dateformat"Y U") for x in data]
177+
values = [parse(Float64, x["value"]) for x in data]
178+
ta = TimeArray((timestamp = dates, monthly = values),timestamp=:timestamp)
179179
end
180180
if "quarters" in keys(json)
181181
data = json["quarters"]
182-
dates = [Date(x["year"]*" "*string(parse(Int,x["quarter"][2])*3-2),dateformat"Y m") for x in data]
182+
dates = [Date(x["year"]*" "*string(parse(Int, x["quarter"][2])*3-2),dateformat"Y m") for x in data]
183183
values = [parse(Float64,x["value"]) for x in data]
184-
tb = TimeArray((timestamp=dates,quarterly=values),timestamp=:timestamp)
185-
ta === nothing ? ta = tb : ta = merge(ta,tb;method=:outer)
184+
tb = TimeArray((timestamp = dates, quarterly = values), timestamp = :timestamp)
185+
ta === nothing ? ta = tb : ta = merge(ta, tb; method = :outer)
186186
end
187187
if "years" in keys(json)
188188
data = json["years"]
189189
dates = [Date(x["year"]) for x in data]
190-
values = [parse(Float64,x["value"]) for x in data]
191-
tb = TimeArray((timestamp=dates,yearly=values),timestamp=:timestamp)
192-
ta === nothing ? ta = tb : ta = merge(ta,tb;method=:outer)
190+
values = [parse(Float64, x["value"]) for x in data]
191+
tb = TimeArray((timestamp = dates, yearly = values), timestamp = :timestamp)
192+
ta === nothing ? ta = tb : ta = merge(ta, tb; method = :outer)
193193
end
194-
TimeArray(ta,meta=json["description"])
195-
end
194+
TimeArray(ta, meta = json["description"])
195+
end

test/downloads.jl

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ using Test
77
@test ta |> timestamp |> length > 100
88
ta = fred("DGS10")
99
@test ta |> timestamp |> length > 100
10-
@test !(ta isa TimeArray{T} where T<:AbstractString)
1110
end
1211

1312
@testset "Yahoo" begin

0 commit comments

Comments
 (0)