# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.

import yfinance as yf
import pandas as pd
import requests
from bs4 import BeautifulSoup
import plotly.graph_objects as go
from plotly.subplots import make_subplots

def make_graph(stock_data, revenue_data, stock):
    fig = make_subplots(rows=2, cols=1, shared_xaxes=True, subplot_titles=("Historical Share Price", "Historical Revenue"), vertical_spacing = .3)
    fig.add_trace(go.Scatter(x=pd.to_datetime(stock_data.Date, infer_datetime_format=True), y=stock_data.Close.astype("float"), name="Share Price"), row=1, col=1)
    fig.add_trace(go.Scatter(x=pd.to_datetime(revenue_data.Date, infer_datetime_format=True), y=revenue_data.Revenue.astype("float"), name="Revenue"), row=2, col=1)
    fig.update_xaxes(title_text="Date", row=1, col=1)
    fig.update_xaxes(title_text="Date", row=2, col=1)
    fig.update_yaxes(title_text="Price ($US)", row=1, col=1)
    fig.update_yaxes(title_text="Revenue ($US Millions)", row=2, col=1)
    fig.update_layout(showlegend=False,
    height=900,
    title=stock,
    xaxis_rangeslider_visible=True)
    fig.show()

def print_hi(name):
    # Use a breakpoint in the code line below to debug your script.
    print(f'Hi, {name}')  # Press Ctrl+F8 to toggle the breakpoint.


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    # print_hi('PyCharm')
    Tesla = yf.Ticker('TSLA')

    tesla_data = Tesla.history(period="max")

    tesla_data.reset_index(inplace=True)
    print(tesla_data.head())

    url = "https://www.macrotrends.net/stocks/charts/TSLA/tesla/revenue"
    html_data = requests.get(url).text

    soup = BeautifulSoup(html_data, "html.parser")
    soup.find_all('title')

    tesla_revenue = pd.DataFrame(columns=['Date', 'Revenue'])

    for row in soup.find_all("tbody")[1].find_all("tr"):
        col = row.find_all("td")
        date = col[0].text
        revenue = col[1].text.replace("$", "").replace(",", "")

        tesla_revenue = tesla_revenue.append({"Date": date, "Revenue": revenue}, ignore_index=True)

    tesla_revenue.dropna(inplace=True)
    tesla_revenue = tesla_revenue[tesla_revenue['Revenue'] != ""]

    print(tesla_revenue.tail())

    make_graph(tesla_data, tesla_revenue, 'Tesla')



# See PyCharm help at https://www.jetbrains.com/help/pycharm/

d1a535bf4ab30adabce392c6fa34d16b363d1b6c
<mask token>


def print_hi(name):
    print(f'Hi, {name}')


<mask token>

<mask token>


def make_graph(stock_data, revenue_data, stock):
    fig = make_subplots(rows=2, cols=1, shared_xaxes=True, subplot_titles=(
        'Historical Share Price', 'Historical Revenue'), vertical_spacing=0.3)
    fig.add_trace(go.Scatter(x=pd.to_datetime(stock_data.Date,
        infer_datetime_format=True), y=stock_data.Close.astype('float'),
        name='Share Price'), row=1, col=1)
    fig.add_trace(go.Scatter(x=pd.to_datetime(revenue_data.Date,
        infer_datetime_format=True), y=revenue_data.Revenue.astype('float'),
        name='Revenue'), row=2, col=1)
    fig.update_xaxes(title_text='Date', row=1, col=1)
    fig.update_xaxes(title_text='Date', row=2, col=1)
    fig.update_yaxes(title_text='Price ($US)', row=1, col=1)
    fig.update_yaxes(title_text='Revenue ($US Millions)', row=2, col=1)
    fig.update_layout(showlegend=False, height=900, title=stock,
        xaxis_rangeslider_visible=True)
    fig.show()


def print_hi(name):
    print(f'Hi, {name}')


<mask token>

<mask token>


def make_graph(stock_data, revenue_data, stock):
    fig = make_subplots(rows=2, cols=1, shared_xaxes=True, subplot_titles=(
        'Historical Share Price', 'Historical Revenue'), vertical_spacing=0.3)
    fig.add_trace(go.Scatter(x=pd.to_datetime(stock_data.Date,
        infer_datetime_format=True), y=stock_data.Close.astype('float'),
        name='Share Price'), row=1, col=1)
    fig.add_trace(go.Scatter(x=pd.to_datetime(revenue_data.Date,
        infer_datetime_format=True), y=revenue_data.Revenue.astype('float'),
        name='Revenue'), row=2, col=1)
    fig.update_xaxes(title_text='Date', row=1, col=1)
    fig.update_xaxes(title_text='Date', row=2, col=1)
    fig.update_yaxes(title_text='Price ($US)', row=1, col=1)
    fig.update_yaxes(title_text='Revenue ($US Millions)', row=2, col=1)
    fig.update_layout(showlegend=False, height=900, title=stock,
        xaxis_rangeslider_visible=True)
    fig.show()


def print_hi(name):
    print(f'Hi, {name}')


if __name__ == '__main__':
    Tesla = yf.Ticker('TSLA')
    tesla_data = Tesla.history(period='max')
    tesla_data.reset_index(inplace=True)
    print(tesla_data.head())
    url = 'https://www.macrotrends.net/stocks/charts/TSLA/tesla/revenue'
    html_data = requests.get(url).text
    soup = BeautifulSoup(html_data, 'html.parser')
    soup.find_all('title')
    tesla_revenue = pd.DataFrame(columns=['Date', 'Revenue'])
    for row in soup.find_all('tbody')[1].find_all('tr'):
        col = row.find_all('td')
        date = col[0].text
        revenue = col[1].text.replace('$', '').replace(',', '')
        tesla_revenue = tesla_revenue.append({'Date': date, 'Revenue':
            revenue}, ignore_index=True)
    tesla_revenue.dropna(inplace=True)
    tesla_revenue = tesla_revenue[tesla_revenue['Revenue'] != '']
    print(tesla_revenue.tail())
    make_graph(tesla_data, tesla_revenue, 'Tesla')

import yfinance as yf
import pandas as pd
import requests
from bs4 import BeautifulSoup
import plotly.graph_objects as go
from plotly.subplots import make_subplots


def make_graph(stock_data, revenue_data, stock):
    fig = make_subplots(rows=2, cols=1, shared_xaxes=True, subplot_titles=(
        'Historical Share Price', 'Historical Revenue'), vertical_spacing=0.3)
    fig.add_trace(go.Scatter(x=pd.to_datetime(stock_data.Date,
        infer_datetime_format=True), y=stock_data.Close.astype('float'),
        name='Share Price'), row=1, col=1)
    fig.add_trace(go.Scatter(x=pd.to_datetime(revenue_data.Date,
        infer_datetime_format=True), y=revenue_data.Revenue.astype('float'),
        name='Revenue'), row=2, col=1)
    fig.update_xaxes(title_text='Date', row=1, col=1)
    fig.update_xaxes(title_text='Date', row=2, col=1)
    fig.update_yaxes(title_text='Price ($US)', row=1, col=1)
    fig.update_yaxes(title_text='Revenue ($US Millions)', row=2, col=1)
    fig.update_layout(showlegend=False, height=900, title=stock,
        xaxis_rangeslider_visible=True)
    fig.show()


def print_hi(name):
    print(f'Hi, {name}')


if __name__ == '__main__':
    Tesla = yf.Ticker('TSLA')
    tesla_data = Tesla.history(period='max')
    tesla_data.reset_index(inplace=True)
    print(tesla_data.head())
    url = 'https://www.macrotrends.net/stocks/charts/TSLA/tesla/revenue'
    html_data = requests.get(url).text
    soup = BeautifulSoup(html_data, 'html.parser')
    soup.find_all('title')
    tesla_revenue = pd.DataFrame(columns=['Date', 'Revenue'])
    for row in soup.find_all('tbody')[1].find_all('tr'):
        col = row.find_all('td')
        date = col[0].text
        revenue = col[1].text.replace('$', '').replace(',', '')
        tesla_revenue = tesla_revenue.append({'Date': date, 'Revenue':
            revenue}, ignore_index=True)
    tesla_revenue.dropna(inplace=True)
    tesla_revenue = tesla_revenue[tesla_revenue['Revenue'] != '']
    print(tesla_revenue.tail())
    make_graph(tesla_data, tesla_revenue, 'Tesla')

# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.

import yfinance as yf
import pandas as pd
import requests
from bs4 import BeautifulSoup
import plotly.graph_objects as go
from plotly.subplots import make_subplots

def make_graph(stock_data, revenue_data, stock):
    fig = make_subplots(rows=2, cols=1, shared_xaxes=True, subplot_titles=("Historical Share Price", "Historical Revenue"), vertical_spacing = .3)
    fig.add_trace(go.Scatter(x=pd.to_datetime(stock_data.Date, infer_datetime_format=True), y=stock_data.Close.astype("float"), name="Share Price"), row=1, col=1)
    fig.add_trace(go.Scatter(x=pd.to_datetime(revenue_data.Date, infer_datetime_format=True), y=revenue_data.Revenue.astype("float"), name="Revenue"), row=2, col=1)
    fig.update_xaxes(title_text="Date", row=1, col=1)
    fig.update_xaxes(title_text="Date", row=2, col=1)
    fig.update_yaxes(title_text="Price ($US)", row=1, col=1)
    fig.update_yaxes(title_text="Revenue ($US Millions)", row=2, col=1)
    fig.update_layout(showlegend=False,
    height=900,
    title=stock,
    xaxis_rangeslider_visible=True)
    fig.show()

def print_hi(name):
    # Use a breakpoint in the code line below to debug your script.
    print(f'Hi, {name}')  # Press Ctrl+F8 to toggle the breakpoint.


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    # print_hi('PyCharm')
    Tesla = yf.Ticker('TSLA')

    tesla_data = Tesla.history(period="max")

    tesla_data.reset_index(inplace=True)
    print(tesla_data.head())

    url = "https://www.macrotrends.net/stocks/charts/TSLA/tesla/revenue"
    html_data = requests.get(url).text

    soup = BeautifulSoup(html_data, "html.parser")
    soup.find_all('title')

    tesla_revenue = pd.DataFrame(columns=['Date', 'Revenue'])

    for row in soup.find_all("tbody")[1].find_all("tr"):
        col = row.find_all("td")
        date = col[0].text
        revenue = col[1].text.replace("$", "").replace(",", "")

        tesla_revenue = tesla_revenue.append({"Date": date, "Revenue": revenue}, ignore_index=True)

    tesla_revenue.dropna(inplace=True)
    tesla_revenue = tesla_revenue[tesla_revenue['Revenue'] != ""]

    print(tesla_revenue.tail())

    make_graph(tesla_data, tesla_revenue, 'Tesla')



# See PyCharm help at https://www.jetbrains.com/help/pycharm/
