Hallo, I would like to find out how to calculate the correlation percentage or the basic point of a cryptocurrency / stock
Say Example; Stock A increased 10% how much do stock B increase? by how much and what are the formula to calculate it?
If anybody would give me the python code with explanation, will be appreciate it. Thank you .
It seems like you want to calculate the correlation coefficient between two securities. If this is the case, you can do this using the corr method of pandas library in Python.
For example, let's say you have a price of stock Apple and Microsoft stored in the AAPL and MSFT columns of the data dataframe.
data.AAPL.corr(data.MSFT)
The above code gives you the value of the correlation coefficient between Apple and Microsoft prices.
You can also refer to this link which talks about other methods of correlation calculation in Python.
Thank you for your reply, what I'm actually trying to find other than correlation coefficient value, instead I'm trying to find the percentage increase per time or basic point increase/decrease per time.
Right now I'm still not sure how correlation coefficient value can help me determine the % gain or decrease.
also how do I use python to scan all coins/stock to find out which coin mostly correlated to each other and by what timeframe or date.
say for e.g. I would like to know all the coins in binance and I would like to know which coin are mostly correlated with each other through what kind of system.
Hi Charles
As per your original query, I believe Linear Regression is the technique you are looking for, based on your example of quantum of change in Stock B, if Stock A moves by 10%.
You can follow this link. In step 2, just replace "x" and "y" with stock prices. The rest of the procedure is the same.
With regards to your second query, you can simply write a code that fetches all the coin prices from Binance using their API. Then calculate the correlation between these coins by the procedure described by Vibhu in the comments above.
If the above does not answer your query, you might want to look into a concept called cointegration. The link describes cointegration in a simple manner. Let us know if you want us to elaborate on this.
Thanks,
Rishabh