@@ -91,12 +91,22 @@ julia> yahoo(:AAPL, YahooOpt(period1 = start))
91
91
"""
92
92
function yahoo (sym:: AbstractString = " ^GSPC" , opt:: YahooOpt = YahooOpt ())
93
93
host = rand ([" query1" , " query2" ])
94
- url = " https://$host .finance.yahoo.com/v7 /finance/download /$sym "
94
+ url = " https://$host .finance.yahoo.com/v8 /finance/chart /$sym "
95
95
res = HTTP. get (url, query = opt)
96
96
@assert res. status == 200
97
- csv = CSV. File (res. body, missingstring = " null" )
98
- sch = TimeSeries. Tables. schema (csv)
99
- TimeArray (csv, timestamp = first (sch. names)) |> cleanup_colname!
97
+
98
+ json_arr = JSON3. read (res. body)
99
+ quotes = json_arr. chart. result[1 ]. indicators. quote[1 ]
100
+ input_table = (; timestamp = Dates. Date .(Dates. unix2datetime .(json_arr. chart. result[1 ]. timestamp)),
101
+ Open = Vector (quotes. open),
102
+ High = Vector (quotes. high),
103
+ Low = Vector (quotes. low),
104
+ Close = Vector (quotes. close),
105
+ AdjClose = Vector (json_arr. chart. result[1 ]. indicators. adjclose[1 ]. adjclose),
106
+ Volume = Vector (quotes. volume)
107
+ )
108
+
109
+ TimeArray (input_table, timestamp = :timestamp )
100
110
end
101
111
102
112
yahoo (s:: Symbol , opt:: YahooOpt = YahooOpt ()) = yahoo (string (s), opt)
0 commit comments