@@ -165,31 +165,31 @@ https://www.ons.gov.uk/timeseriestool
165
165
- fred() which accesses the St. Louis Federal Reserve financial and economic data sets.
166
166
- yahoo() which is a wrapper from downloading financial time series for stocks from Yahoo Finance.
167
167
"""
168
- function ons (timeseries:: AbstractString = " L522" ,dataset:: AbstractString = " MM23" )
168
+ function ons (timeseries:: AbstractString = " L522" , dataset:: AbstractString = " MM23" )
169
169
url = " https://api.ons.gov.uk/dataset/$dataset /timeseries/$timeseries /data"
170
170
res = HTTP. get (url)
171
171
@assert res. status == 200
172
- json = JSON3. read (String (res. body ))
172
+ json = JSON3. read (HTTP . payload (res))
173
173
ta = nothing
174
174
if " months" in keys (json)
175
175
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 )
179
179
end
180
180
if " quarters" in keys (json)
181
181
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]
183
183
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 )
186
186
end
187
187
if " years" in keys (json)
188
188
data = json[" years" ]
189
189
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 )
193
193
end
194
- TimeArray (ta,meta= json[" description" ])
195
- end
194
+ TimeArray (ta, meta = json[" description" ])
195
+ end
0 commit comments