Skip to content

Commit

Permalink
download multiple tickers
Browse files Browse the repository at this point in the history
  • Loading branch information
ranaroussi committed Jun 22, 2023
1 parent d0518b8 commit 8e15bd0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions quantstats/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,15 @@ def _prepare_returns(data, rf=0., nperiods=None):


def download_returns(ticker, period="max", proxy=None):
params = {
"tickers": ticker,
"proxy": proxy,
}
if isinstance(period, _pd.DatetimeIndex):
p = {"start": period[0], "proxy": proxy}
params["start"] = period[0]
else:
p = {"period": period, "proxy": proxy}
return _yf.Ticker(ticker).history(**p)['Close'].pct_change()
params["period"] = period
return _yf.download(**params)['Close'].pct_change()


def _prepare_benchmark(benchmark=None, period="max", rf=0.,
Expand Down

0 comments on commit 8e15bd0

Please sign in to comment.