@@ -225,27 +225,20 @@ class YahooFinanceData(YahooFinanceCSVData):
225
225
Whether to use the dividend/split adjusted close and adjust all values
226
226
according to it.
227
227
228
- - ``urlhist``
229
-
230
- The url of the historical quotes in Yahoo Finance used to gather a
231
- ``crumb`` authorization cookie for the download
232
-
233
228
- ``urldown``
234
229
235
230
The url of the actual download server
236
231
237
232
- ``retries``
238
233
239
- Number of times (each) to try to get a ``crumb`` cookie and download
240
- the data
234
+ Number of times (each) to try to download the data
241
235
242
236
'''
243
237
244
238
params = (
245
239
('proxies' , {}),
246
240
('period' , 'd' ),
247
241
('reverse' , False ),
248
- ('urlhist' , 'https://finance.yahoo.com/quote/{}/history' ),
249
242
('urldown' , 'https://query1.finance.yahoo.com/v7/finance/download' ),
250
243
('retries' , 3 ),
251
244
)
@@ -260,47 +253,12 @@ def start_v7(self):
260
253
raise Exception (msg )
261
254
262
255
self .error = None
263
- url = self .p .urlhist .format (self .p .dataname )
264
256
265
257
sesskwargs = dict ()
266
258
if self .p .proxies :
267
259
sesskwargs ['proxies' ] = self .p .proxies
268
260
269
- crumb = None
270
- sess = requests .Session ()
271
- sess .headers ['User-Agent' ] = 'backtrader'
272
- for i in range (self .p .retries + 1 ): # at least once
273
- resp = sess .get (url , ** sesskwargs )
274
- if resp .status_code != requests .codes .ok :
275
- continue
276
-
277
- txt = resp .text
278
- i = txt .find ('CrumbStore' )
279
- if i == - 1 :
280
- continue
281
- i = txt .find ('crumb' , i )
282
- if i == - 1 :
283
- continue
284
- istart = txt .find ('"' , i + len ('crumb' ) + 1 )
285
- if istart == - 1 :
286
- continue
287
- istart += 1
288
- iend = txt .find ('"' , istart )
289
- if iend == - 1 :
290
- continue
291
-
292
- crumb = txt [istart :iend ]
293
- crumb = crumb .encode ('ascii' ).decode ('unicode-escape' )
294
- break
295
-
296
- if crumb is None :
297
- self .error = 'Crumb not found'
298
- self .f = None
299
- return
300
-
301
- crumb = urlquote (crumb )
302
-
303
- # urldown/ticker?period1=posix1&period2=posix2&interval=1d&events=history&crumb=crumb
261
+ # urldown/ticker?period1=posix1&period2=posix2&interval=1d&events=history
304
262
305
263
# Try to download
306
264
urld = '{}/{}' .format (self .p .urldown , self .p .dataname )
@@ -323,10 +281,11 @@ def start_v7(self):
323
281
324
282
urlargs .append ('interval={}' .format (intervals [self .p .timeframe ]))
325
283
urlargs .append ('events=history' )
326
- urlargs .append ('crumb={}' .format (crumb ))
327
284
328
285
urld = '{}?{}' .format (urld , '&' .join (urlargs ))
329
286
f = None
287
+ sess = requests .Session ()
288
+ sess .headers ['User-Agent' ] = 'backtrader'
330
289
for i in range (self .p .retries + 1 ): # at least once
331
290
resp = sess .get (urld , ** sesskwargs )
332
291
if resp .status_code != requests .codes .ok :
0 commit comments