How can we calculate alpha of an equity using nsepython plugin

Please sugggest how to calculate alpha of a stock inse.

NSEPython is a Python wrapper created to scrap the NSEIndia APIs. It is an educational project.

Use appropriate threads for -

  • Documentation
  • Feature Request
  • Bug Reporting


1 Like

Thats an interesting idea of content. I will check up once I get some free time for Unofficed’s new contents later tomorrow maybe.

Thank you Dexter….will look forward to your response

Yes. I am deving this course.

How to find the beta of Indian stocks using Python? - Unofficed

Deadline was crossed 2 years ago. I will do the alpha one in next 48 hours.

Sure.…thank you…I have been trying to
Find solution for the same but no

Hi Dexter…any update…how can we calculate alpha for equity stocks?

Suruchi Daga

I did the content yesterday I am waiting for some newton guy to validate before I share it to public.


Thank you for addressing the issue. Looking forward to the final solution.

Suruchi Daga

1 Like

Yes, just wait till someone I know goes through it and validates it. (Usually takes less than a day but maybe all busy due to weekend and festivities) As I have no employees to oversee, its all other co-traders.

Hi Dexter… Nsefetch method is not working…have followed the suggestions shared in Solution: equity_history() function doesn't work - #4 by dexter but no luck.

Please suggest.

Its a complex platform-specific issue.

Try nsepythonserver in Google Collab and get back to me once.

Ok…I will try and then update you.

I am runing nsepython plugin in local not on any server. Hence, server plugin will not work.
Pls suggest an alternate.

Suruchi Daga

Creating an open-source wrapper doesn’t allow me time to personally delve into your system.

Consider using the server edition in Google Collab as it is system environment independent and will operate effectively. If you prefer having it work on your laptop, you might want to hire a coder for assistance.

Ok…no worries….I will try alternates on my own.

Waiting for alpha solution.

Suruchi Daga

That was done. Click on this link.

Hi Dexter…I had read this article before too but unable to convert it into code using python.
It will be great if you could share the pointers around the same.

Suruchi Daga

The code is in the article. Open it

I found the algorithm but not code.

Calculate Expected Return with the Capital Asset Pricing Model (CAPM):

Using CAPM, we calculate the expected return of the stock. This calculation considers the risk-free rate, beta, and the difference between the benchmark return and the risk-free rate. It represents the return expected for the level of risk associated with the stock.

Expected Return = Risk-free Rate + Beta * (Benchmark Return – Risk-free Rate)

Determine Alpha:

Finally, we compute Jensen’s Alpha by subtracting the expected return from the historical return. A positive alpha indicates that the stock has outperformed the benchmark, while a negative alpha suggests underperformance.

Alpha = Actual Stock Return – Expected Return

The value of Alpha offers insights:

  • A positive Alpha indicates that the stock has outperformed the benchmark index.
  • A negative Alpha means the stock has underperformed compared to the benchmark.
  • An Alpha of zero suggests the stock’s performance matched the benchmark.

Absolutely! Dive into the treasure hunt on my website.

If navigating through it feels like an extravagant waste of time, imagine my position! Do you really think I have the luxury of limitless idle hours to lavish?