Amazon stock price analysis in python

Amazon(AMZN) focuses on e-commerce, cloud computing 

Amazon.com, Inc. (ticker symbol: AMZN) is a global leader in e-commerce, cloud computing, and digital services. Founded in 1994, Amazon has grown into one of the largest and most influential companies in the world. Here’s a detailed overview:

Company Overview

  • Name: Amazon.com, Inc.
  • Type: Publicly Traded Company
  • Industry: E-commerce, Cloud Computing, Digital Services, and Technology
  • Headquarters: Seattle, Washington, USA
  • Founded: July 5, 1994
  • Founder: Jeff Bezos

Business Segments

  • E-Commerce: Amazon started as an online bookstore and has expanded to become one of the world’s largest online retailers. The company sells a wide range of products, including electronics, clothing, household items, and more.
  • Amazon Marketplace: Allows third-party sellers to list and sell products on Amazon’s platform, contributing to its vast product assortment.
  • Amazon Prime: A subscription service offering benefits such as free shipping, streaming of movies and TV shows, and exclusive deals.
  • Amazon Web Services (AWS): Amazon’s cloud computing division provides a wide range of cloud services, including computing power, storage, and databases. AWS is a major revenue driver and a leader in the cloud industry.
  • Key Services: Includes Elastic Compute Cloud (EC2), Simple Storage Service (S3), and Lambda among others.
  • Clientele: Serves businesses of all sizes, from startups to large enterprises.
  • Digital Content and Services: Amazon offers various digital products and services, including:
  • Amazon Prime Video: A streaming service offering movies, TV shows, and original content.
  • Amazon Music: A music streaming service providing access to a vast library of songs and playlists.
  • Kindle: E-readers and digital books, including e-books and audiobooks through the Kindle store.
  • Devices: Amazon designs and manufactures consumer electronics, including:
  • Echo: Smart speakers powered by Amazon’s virtual assistant, Alexa.
  • Fire Tablets: Affordable tablets with access to Amazon’s content ecosystem.
  • Fire TV: Streaming devices that offer access to various streaming services.
  • Retail and Physical Stores: Amazon has ventured into physical retail with:
  • Amazon Go: Checkout-free convenience stores using sensor technology.
  • Whole Foods Market: Acquired in 2017, a high-end grocery chain.
  • Amazon Fresh: Grocery delivery and pickup services.

Market Position

  • Global Presence: Amazon operates in numerous countries, providing a significant online retail and cloud computing presence globally.
  • Revenue: The company generates substantial annual revenue from its diverse business segments, with a major portion coming from AWS.
  • Market Capitalization: Amazon is one of the largest companies in the world by market capitalization, often ranking among the top technology and e-commerce giants.

Financial Performance

  • Revenue Growth: Amazon has demonstrated consistent revenue growth, driven by its expanding e-commerce operations and the success of AWS.
  • Profitability: While the company has historically reinvested much of its revenue into growth initiatives, AWS contributes significantly to its profitability.

Key Achievements

  • Innovation: Amazon is known for its innovative approach to technology and business, including advancements in logistics, cloud computing, and artificial intelligence.
  • Customer Experience: The company is renowned for its customer-centric approach, focusing on convenience, selection, and competitive pricing.

Strategic Initiatives

  • Technology Investment: Amazon invests heavily in technology and infrastructure to support its e-commerce and cloud computing businesses.
  • Sustainability: The company is committed to sustainability, aiming to achieve net-zero carbon by 2040 and investing in renewable energy projects.
  • Expansion: Amazon continues to expand into new markets and sectors, including healthcare and autonomous delivery.

Stock Market

  • Listing: Amazon is listed on the NASDAQ stock exchange.
  • Stock Performance: The company’s stock has experienced significant growth over the years, reflecting its success and market dominance.

Leadership

  • CEO: As of the latest update, Andy Jassy is the CEO of Amazon, having succeeded Jeff Bezos in July 2021.
  • Jeff Bezos: Founder and former CEO, who led the company through its growth into a global powerhouse.

Corporate Social Responsibility (CSR)

  • Community Engagement: Amazon supports various community initiatives, including education, disaster relief, and housing.
  • Philanthropy: The company engages in charitable activities through AmazonSmile and other initiatives, contributing to various social causes.

Recent Developments

  • Innovation and Acquisitions: Amazon continues to innovate and acquire companies to enhance its capabilities and expand its market presence.
  • Regulatory Scrutiny: The company faces scrutiny and regulatory challenges related to antitrust issues, labor practices, and data privacy.
Analyzing Amazon's stock price using Python involves collecting historical price data, performing data analysis, and creating visualizations to gain insights into the company's stock performance. Here's a step-by-step guide on how to conduct Amazon stock price analysis in Python:

Import Libraries:
Start by importing the necessary Python libraries for data manipulation, analysis, and visualization. Commonly used libraries include pandas, numpy, matplotlib, and yfinance to fetch historical data:

Python
Copy code
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import yfinance as yf
Data Retrieval:
Use the yfinance library or other financial data sources to fetch historical data for Amazon's stock. Specify the start and end dates for the data you want to analyze:

Python
Copy code
amazon = yf.download('AMZN', start='2020-01-01', end='2021-12-31')
Data Exploration:
Explore the fetched data to understand its structure and contents. Use functions like head(), tail(), describe(), and info() to inspect the dataset:

Python
Copy code
print(amazon.head())
Data Visualization:
Create visualizations to analyze the historical performance of Amazon's stock. Common visualizations include line charts to visualize price movements:

Python
Copy code
plt.figure(figsize=(12, 6))
plt.plot(amazon['Adj Close'], label='Amazon')
plt.title('Amazon Stock Price')
plt.xlabel('Date')
plt.ylabel('Price')
plt.legend()
plt.show()
Technical Analysis (Optional):
Perform technical analysis by calculating and visualizing technical indicators like moving averages, relative strength index (RSI), and MACD. Libraries like ta-lib can be used for these calculations.

Statistical Analysis (Optional):
Conduct statistical analysis to calculate summary statistics, volatility measures, and correlations with other assets. numpy and pandas are useful for these calculations.

Sentiment Analysis (Optional):
Consider incorporating sentiment analysis of news articles or social media data related to Amazon to understand market sentiment's impact on the stock price.

Fundamental Analysis (Optional):
Analyze fundamental factors affecting Amazon, such as earnings reports, revenue growth, and market share, which can influence the stock's performance.

Prediction and Forecasting (Optional):
You can use time series forecasting techniques like ARIMA or machine learning models to make predictions about future Amazon stock price movements.

Risk Management and Decision Making:
Based on your analysis, formulate investment strategies, set risk management parameters, and make informed investment decisions regarding Amazon's stock.

Regular Updates:
Keep your analysis up to date with the latest data to adapt to changing market conditions and make timely decisions.

Remember that investing in stocks carries risks, and it's crucial to do thorough research, consider factors like company news and market trends, and potentially consult with financial experts before making investment decisions based on your analysis of Amazon's stock price or any other stock.

What are alternative sources to get financial data?

There are a number of alternative sources like Quandal, intrinsic, google others.

!pip install yfinance
import pandas as pd
import numpy as np
import yfinance as yf

How to get  AMZN financial data from Yahoo Finance in Python?

df = yf.download('AMZN',
 start='2020-01-01',
 end='2021-08-28',
 progress=False)
df.tail(9)
import matplotlib.pyplot as plt

How to plot Amazon's close price?

df['Close'].plot(figsize=(12,8))
<matplotlib.axes._subplots.AxesSubplot at 0x7f2c61f1cc50>
amazon close price

How to plot Amazon close price volume?

df[['Close''Volume']].plot(subplots=True, style='b',
figsize=(128))
array([<matplotlib.axes._subplots.AxesSubplot object at 0x7f2c61e14c90>,
       <matplotlib.axes._subplots.AxesSubplot object at 0x7f2c61e39590>],
      dtype=object)
amazon close price volume

How to describe Amazon mean median and other statistics?

df.describe()

df['simple_rtn'] = df.Close.pct_change()
df['log_rtn'] = np.log(df.Close/df.Close.shift(1))
df['log_rtn'].plot(subplots=True, style='b',
figsize=(128))
array([<matplotlib.axes._subplots.AxesSubplot object at 0x7f2c61899a10>],
      dtype=object)
amazon log close price

How to convert AMZN Stock prices into log and simple returns in Python?

df['log_rtn'].tail(12)
Date 2021-08-12 0.003454 2021-08-13 -0.002889 2021-08-16 0.001523 2021-08-17 -0.017438 2021-08-18 -0.012646 2021-08-19 -0.004217 2021-08-20 0.003820 2021-08-23 0.020391 2021-08-24 0.012146 2021-08-25 -0.001999 2021-08-26 0.005085 2021-08-27 0.010091 Name: log_rtn, dtype: float64
import cufflinks as cf
from plotly.offline import iplot, init_notebook_mode
init_notebook_mode()

How to plot log returns in Python?

df_rolling = df[['simple_rtn']].rolling(window=21) \
.agg(['mean''std'])
df_rolling.columns = df_rolling.columns.droplevel()
df_outliers = df.join(df_rolling)
import pandas as pd
import numpy as np
import yfinance as yf
import seaborn as sns
import scipy.stats as scs
import statsmodels.api as sm
import statsmodels.tsa.api as smt

How to compare stock price and vix?

df = yf.download(['AMZN''^VIX'],
start='1985-01-01',
end='2021-08-28',
progress=False)
df = df[['Adj Close']]
df.columns = df.columns.droplevel(0)
df = df.rename(columns={'AMZN''amzn''^VIX''vix'})
df.tail()
df['log_rtn'] = np.log(df.amzn / df.amzn.shift(1))
df['vol_rtn'] = np.log(df.vix / df.vix.shift(1))
df.dropna(how='any', axis=0, inplace=True)
corr_coeff = df.log_rtn.corr(df.vol_rtn)
corr_coeff = df.log_rtn.corr(df.vol_rtn)
ax = sns.regplot(x='log_rtn', y='vol_rtn', data=df,
line_kws={'color''red'})
ax.set(title=f'AMZN vs. VIX ($\\rho$ = {corr_coeff:.2f})',
ylabel='VIX log returns',
xlabel='AMZN log returns')
[Text(0, 0.5, 'VIX log returns'),
 Text(0.5, 0, 'AMZN log returns'),
 Text(0.5, 1.0, 'AMZN vs. VIX ($\\rho$ = -0.33)')]
amazon  close price  and vix

How to plot distribution of stock price and Q-Q plot?

r_range = np.linspace(min(df.log_rtn), max(df.log_rtn), num=1000)
mu = df.log_rtn.mean()
sigma = df.log_rtn.std()
norm_pdf = scs.norm.pdf(r_range, loc=mu, scale=sigma)
fig, ax = plt.subplots(12, figsize=(168))
# histogram
sns.distplot(df.log_rtn, kde=False, norm_hist=True, ax=ax[0])
ax[0].set_title('Distribution of AMZN returns', fontsize=16)
ax[0].plot(r_range, norm_pdf, 'g', lw=2,
label=f'N({mu:.2f}{sigma**2:.4f})')
ax[0].legend(loc='upper left');
# Q-Q plot
qq = sm.qqplot(df.log_rtn.values, line='s', ax=ax[1])
ax[1].set_title('Q-Q plot', fontsize = 16)
/usr/local/lib/python3.7/dist-packages/seaborn/distributions.py:2557: FutureWarning:

`distplot` is a deprecated function and will be removed in a future version. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `histplot` (an axes-level function for histograms).

Text(0.5, 1.0, 'Q-Q plot')
amazon  distribution return and qq plot
df.log_rtn.plot(title='Daily AMZN returns')

How to plot daily Amazon stock price?

<matplotlib.axes._subplots.AxesSubplot at 0x7f2c3ecc2e10>
amazon daily return

How to plot absolute return and autocorrelation?

N_LAGS = 50
SIGNIFICANCE_LEVEL = 0.05
acf = smt.graphics.plot_acf(df.log_rtn,
lags=N_LAGS,
alpha=SIGNIFICANCE_LEVEL
)
amazon autocorelation daily return
fig, ax = plt.subplots(21, figsize=(1210))
smt.graphics.plot_acf(df.log_rtn ** 2, lags=N_LAGS,
alpha=SIGNIFICANCE_LEVEL, ax = ax[0])
ax[0].set(title='Autocorrelation Plots',
ylabel='Squared Returns')
smt.graphics.plot_acf(np.abs(df.log_rtn), lags=N_LAGS,
alpha=SIGNIFICANCE_LEVEL, ax = ax[1])
ax[1].set(ylabel='Absolute Returns',
xlabel='Lag')
[Text(0, 0.5, 'Absolute Returns'), Text(0.5, 0, 'Lag')]
amazon autocorelation daily return 1

How to plot AMZN stock price 252 days and 21 days moving volatility?

df['moving_std_252'] = df[['log_rtn']].rolling(window=252).std()
df['moving_std_21'] = df[['log_rtn']].rolling(window=21).std()
fig, ax = plt.subplots(31, figsize=(1815),
sharex=True)
df.plot(ax=ax[0])
ax[0].set(title='AMZN time series',
ylabel='Stock price ($)')
df.log_rtn.plot(ax=ax[1])
ax[1].set(ylabel='Log returns (%)')
df.moving_std_252.plot(ax=ax[2], color='r',
label='Moving Volatility 252d')
df.moving_std_21.plot(ax=ax[2], color='g',
label='Moving Volatility 21d')
ax[2].set(ylabel='Moving Volatility',
xlabel='Date')
ax[2].legend()
<matplotlib.legend.Legend at 0x7f2c36643f50>
amazon moving volatility daily return

Post a Comment

0 Comments