A guide to knowing about portfolio optimization and implementing it through the Python language.

Image for post
Image for post
Photo by Scott Graham (Unsplash)

What is portfolio optimization?

Portfolio optimization is the process of choosing the best portfolio among the set of all portfolios.

How is portfolio optimization done?

The naive way is to select a group of random allocations and figure out which one has the best Sharpe Ratio. This is known as the Monte Carlo Simulation where randomly a weight is assigned to each security in the portfolio and then the mean daily return and standard deviation of daily return is calculated. This helps in calculating the Sharpe Ratio for randomly selected allocations.

To know more about Sharpe Ratio, check out my previous article:

But the naive way is time taking…


A guide to knowing about portfolio allocation and implementing it through the Python language.

Image for post
Image for post
Photo by Clay Banks (Unsplash)

What is a portfolio?

A collection of financial investments is a portfolio. The financial investments can be cash, stocks, bonds, commodities and any other cash equivalents.

What is portfolio allocation?

An investment strategy where the risk and reward are balanced of the portfolio’s assets according to the user’s investment goals, tolerance of risk and investment horizon is called portfolio allocation.

How to implement using python?

→ Import packages

The basic packages like Pandas will be imported. Along with it, the Quandl package is imported to get the data.

>>> import pandas as pd
>>> import quandl
>>> import matplotlib.pyplot as plt
>>> %matplotlib inline

→ Data

The start and end date is decided…

Data Visualization

A guide to the step-by-step implementation of ARIMA models using Python.

Image for post
Image for post
Photo by Matthew Henry (Unsplash)

ARIMA which is the short form for ‘Auto-Regressive Integrated Moving Average’ is used on time series data and it gives insights on the past values like lags and forecast errors that can be used for forecasting future values.

To know more about ARIMA models, check out the article below:

How to implement ARIMA models to help forecasting/predicting?

The steps involved are as follows:

  1. Analyzing the time series data by plotting or visualizing it.
  2. Converting the time series data in a stationary form.
  3. Plotting the ACF and PACF plots.
  4. Constructing the ARIMA model.
  5. Making predictions using the model created.

Implementation using Python

→ Import packages

The basic packages like NumPy and pandas…

This article talks about ARIMA models and the concept behind them.

Image for post
Image for post
Photo by Carlos Muza (Unsplash)

What are ARIMA models?

ARIMA stands for Auto-Regressive Integrated Moving Average. It is a model used for statistical analysis of the time-series data. It helps to gain better insights into the data and predict future trends. It works very well with sales data. It is the generalization of the ARMA (autoregressive moving average) model.

  • A series is an ‘integrated (I)’ series if it has to be made stationary using differencing.

A dataset is stationary if it has a constant mean, variance and covariance over time. Differencing is the process of subtracting an observation from the previous time step observation until the data is stationary…

A guide to understanding and implementing ETS model for time series data using Python.

Image for post
Image for post
Photo by Isaac Smith (Unsplash)

What is time series decomposition?

Time series decomposition is the breaking down of the series into its trend, seasonality and noise components. It helps in understanding the time series data better while using it to analyze and forecast.

What is ETS model?

ETS stands for Error-Trend-Seasonality and is a model used for the time series decomposition. It decomposes the series into the error, trend and seasonality component. It is a univariate forecasting model used when dealing with time-series data. It focuses on trend and seasonal components. This model consists of various concepts like trend methods model, exponential smoothing and ETS decomposition.

It helps in creating a model to fit…

This article will help you understand EWMA and the implementation using Python.

Image for post
Image for post
Photo by Luke Chesser (Unsplash)

What is EWMA?

EWMA stands for Exponentially Weighted Moving Average. It processes data in such a way that it gives less importance and weightage to the data which is further past in time. So it gives more weightage to the data that is recent.

Why is EWMA needed?

It is a better version of the SMA (Simple moving average) since SMA uses small windows for calculations leading to more noise. There is a lag in the start of the plot and it never reaches the peak. It also fails to give any information about future…

A brief introduction to statsmodel which helps in dealing with time-series data.

Image for post
Image for post
Photo by Lukas Blazek (Unsplash)

In python, a very widely used library named statsmodel is used when dealing with time-series data. It is based on the statistical programming language R. This module helps in analyzing data, perform statistical functions and also create statistical models. It also has functions to plot.

So let’s dive into it!


The statsmodel is already included in the python environment file. In case a different environment like Anaconda is used then install by using the command below:

conda install statsmodels

→ Importing packages

The basic packages like NumPy and pandas to help deal with data are imported along with matplotlib to help with plottings.

Data Visualization

A practical implementation of stock analysis for car companies using Python to gain visual and financial insights.

The use of Python is tremendous and it helps in almost every use case. Through this article, I hope to introduce you to using Python in stock analysis. Right from obtaining the data of stocks to visualizing it and gaining insights, everything is explained here. The financial terms are emphasized in simpler terms along with the code for implementation to help understand the concepts better.

Image for post
Image for post
Photo by Chris Liverani (Unsplash)

To facilitate the process of learning, 3 famous car company stocks are considered: Toyota, BMW and Tesla. These stocks behave differently and help distinguish and gain insights. So let’s get started!

→Importing packages

We will start off…

A guide to help implement various Pandas functions on stock data.

When dealing with time-series data, it has a different format and usually has a DateTime index and its corresponding value. Some examples of time-series data can be stock market data, count of sunspots, or temperature reading of the atmosphere.

In this article, I will take you through the different Pandas methods that can be used with time-series stock data.

Image for post
Image for post
Photo by Chris Liverani on Unsplash

Understanding datetime index

When dealing with time-series data, date and time information is a must and is always given. But the date and time information is not always in columns separated. There is…

A guide to understanding how to procure data for doing financial analysis using Python.

Image for post
Image for post
Photo by Jason Briscoe on Unsplash

When you plan to work on using Python for finance, a particular form of data is needed. This data should be concerned with financial values. In this article, I will introduce two methods to get financial data using the Python language.

1) Method 1: Pandas — datareader

The first method that I have mentioned deals with getting data using Pandas-datareader. Pandas is an open-source Python library that is used for performing data analysis and is used as a manipulation tool. Check out this article mentioned below to know about Pandas in detail.

Jayashree domala

Self-driven woman who wishes to deliver creative and engaging ideas and solutions in the field of technology.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store