Posts

News Article Scraping || Python || BeautifulSoup

I was learning about Sentiment Analysis and for that purpose, I was in need of news article in CSV format, so now to get those news articles in CSV format I came up with the solution of  Web scraping those articles with the help of a python library called " BeautifulSoup " which is a  Python package for parsing HTML and XML documents. It creates a parse tree for parsed pages that can be used to extract data from HTML, which is useful for web scraping. Now, how & what I did is shown here below in the code. #Importing libraries import  urllib.request,sys,time from  bs4  import  BeautifulSoup import  requests import  pandas  as  pd pagesToGet=  1 upperframe=[]   for  page  in   range ( 1 ,pagesToGet+ 1 ):      print ( 'processing page :' , page)     url =  'https://www.marketwatch.com/markets?mod=top_nav/?page=' +str(page)   ...

Commodity Channel Index ( CCI ) Using Python

Image
The CCI compares the  current price  to an  average price  over a period of time. The indicator fluctuates above or below zero, moving into positive or negative territory. While most values, approximately 75%, fall between -100 and +100, about 25% of the values fall outside this range, indicating a lot of weakness or strength in the price movement. CCI is calculated with the following formula: (Typical Price - Simple Moving Average) / (0.015 x Mean Deviation) When the CCI is above +100, this means the price is well above the average price as measured by the indicator. When the indicator is below -100, the price is well below the average price. A basic CCI strategy is used to track the CCI for movement above +100, which generates  buy signals , and movements below -100, which generates  sell  or  short  trade signals. Investors may only want to take the buy signals, exit when the sell signals occur, and then re-invest when the buy signal...

Moving Averages On Python || SMA & EWMA

Image
Moving average is a simple, technical analysis tool. Moving averages are usually calculated to identify the trend direction of a stock or to determine its support and resistance levels. It is a trend-following — or  lagging — indicator because it is based on past prices. There are various types of moving averages, like SMA & EMA so I tried to create a moving average indicator in which I have plotted 2 moving averages with the help of historical data. A simple moving average (SMA) is a calculation that takes the arithmetic mean of a given set of prices over the specific number of days in the past; for example, over the previous 15, 30, 100, or 200 days. Exponential moving averages (EMA) is a weighted average that gives greater importance to the price of a stock on more recent days, making it an indicator that is more responsive to new information.   # Load the necessary packages and modules from  pandas_datareader  import  data...

Net Present Value (NPV) On Python Using Numpy

Image
Net present value (NPV) is the difference between the present value of cash inflows and the present  value  of cash outflows over a period of time.   NPV is used in  capital budgeting  and investment planning. The NPV Rule is:- If  NPV > 0  Then the project is Accepted  If  NPV < 0 Then the project is Rejected The formula for calculating NPV is - = net present value = net cash flow at time t = discount rate = time of the cash flow This is how NPV is calculated manually with the generic formula, now we are going to use NumPy for calculating the NPV of a project. Here is an example. The initial investment is $100. The cash inflows in the next five years are $50, $60, $70, $100, and $20, starting from year one. If the discount rate is 11.2%, what is the project's NPV value?  #import Numpy  import  numpy  as  np #Put/define values in the cashflows & Interestrate. CF0 =...

Portfolio Optimization In Python

Image
  A portfolio is a collection of financial investments like stocks, bonds, commodities, cash, and cash equivalents, including  closed-end funds  and  exchange-traded funds  (ETFs), here in this topic I'm talking about stock portfolios. Portfolio optimization is the process of selecting the best portfolio, out of the set of all portfolios being considered, according to some objective. The objective typically maximizes factors such as expected return and minimizes financial risk. With the help of "daily returns", "annualized covariance matrix","portfolio variance","portfolio volatility" and "annual portfolio return" I'll do portfolio optimization on python. I'll take historical data of stocks with the help of "pandas DataReader" and then use statics formulas mentioned above to do the optimization and state what is the annual return and risk involved in the particular portfolio I've selected  I'm using Google ...

Moving Average Convergence/Divergence on Python

Image
I've created a Moving Average Convergence/Divergence (MACD) Indicator using Python programing language on Google Colab.  I also have an extra feature in my code which is "BUY & SELL" signal, whenever the MACD cross each other and gives a Buy or Sell signal it is reflected on the screen with "Red & Green" arrows, this is done by using the concept of "flag" which you will now see in my code. #import the Libraries import  pandas  as  pd import  numpy  as  np import  pandas_datareader  as  dr import  matplotlib.pyplot  as  plt plt.style.use( 'fivethirtyeight' ) from  google.colab  import  files uploaded = files.upload() df = pd.read_csv( 'CIPLA.NS.csv' ) df = df.set_index(pd.DatetimeIndex(df[ 'Date' ].values)) df #visually show the stock price plt.figure(figsize=( 12.2 ,  4.5 )) plt.plot(df[ 'Close' ], label= 'Close' ) plt.title( 'Clos...

Budget Symposium 2019 || 2019 Budget Explained through Presentation

Image
 I'm a student of finance doing B.com H. Financial markets in collaboration with BSE, There was a competition in my college named Budget Symposium, in that competition one who is participating has to create a presentation on Union Budget for the current year, that year was 2020. I participated and secured the second position in that competition, the experience was really fun and interesting too, I learned several new things which helped to learn and grow more.  Here I'm sharing that presentation which I created for that very same competition "Budget Symposium"   If you want to download the ppt you can download it from here. Budget Symposium ppt