Skip to content

Instantly share code, notes, and snippets.

@Fabiocke
Last active August 25, 2022 01:35
Show Gist options
  • Select an option

  • Save Fabiocke/dd3f9054c3e47c715198a54b9366f5a2 to your computer and use it in GitHub Desktop.

Select an option

Save Fabiocke/dd3f9054c3e47c715198a54b9366f5a2 to your computer and use it in GitHub Desktop.
import yfinance as yf
from datetime import datetime, timedelta
def cotacoes(ticker, dias):
# formata o nome do ticker
start = (datetime.today()-timedelta(dias)).strftime('%Y-%m-%d')
ticker=ticker+'.SA' if ticker[-3:] != '.SA' else ticker
# busca o ticker no yahoo finance
df = yf.download(ticker, start)
return df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment