Posts

Showing posts from March, 2021

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 =...