Created
November 25, 2020 04:19
-
-
Save dpaluy/1463dcd0241d4595d0d74a9ec4666272 to your computer and use it in GitHub Desktop.
Get Live Market Data from Yahoo Finance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pip install yfinance | |
| pip install plotly |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Raw Package | |
| import numpy as np | |
| import pandas as pd | |
| #Data Source | |
| import yfinance as yf | |
| #Data viz | |
| import plotly.graph_objs as go | |
| #Interval required 1 minute | |
| data = yf.download(tickers='UBER', period='1d', interval='1m') | |
| #declare figure | |
| fig = go.Figure() | |
| #Candlestick | |
| fig.add_trace(go.Candlestick(x=data.index, | |
| open=data['Open'], | |
| high=data['High'], | |
| low=data['Low'], | |
| close=data['Close'], name = 'market data')) | |
| # Add titles | |
| fig.update_layout( | |
| title='Uber live share price evolution', | |
| yaxis_title='Stock Price (USD per Shares)') | |
| # X-Axes | |
| fig.update_xaxes( | |
| rangeslider_visible=True, | |
| rangeselector=dict( | |
| buttons=list([ | |
| dict(count=15, label="15m", step="minute", stepmode="backward"), | |
| dict(count=45, label="45m", step="minute", stepmode="backward"), | |
| dict(count=1, label="HTD", step="hour", stepmode="todate"), | |
| dict(count=3, label="3h", step="hour", stepmode="backward"), | |
| dict(step="all") | |
| ]) | |
| ) | |
| ) | |
| #Show | |
| fig.show() |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
source: https://towardsdatascience.com/python-how-to-get-live-market-data-less-than-0-1-second-lag-c85ee280ed93