Introduction to Algorithmic Trading at Indian Stock Markets using Python
Pushpak Dagade (~pushpak) |
For what audience is this talk intended?
For those interested in using the power of Python to book profits and save time by automating their trading strategies at Indian Stock Markets.
What is Algorithmic Trading?
Imagine if you can write a Python script which can, for example, automatically BUY 100 shares of company 'X' when its price hits 52 week low and SELL it when it rises by 2% of the purchase price or based on some other different strategy which suits you. Sounds cool, right?
Algorithmic Trading is the process of using computer programs, based on a predefined algorithm, for placing trades in order to generate profits at a speed and frequency that is impossible for a human trader.
(The above example is very basic. You can code very complex strategies!)
Tell me the advantages of Algorithmic Trading over Conventional Trading
Here are a few reasons why algorithmic trading can lead to high chances of success -
- Ability to take into account large number of factors for decision making, which can be practically impossible for a human
- Trades can be timed correctly. Manually placing trade involves delay which may result in significant price change by the time trade is placed
- Human error eliminated while placing trades
- Human emotions (greed/fear) taken out of execution, which otherwise may result in big losses
And lastly, you can use your precious time for something else! Just let your computer monitor the stock markets 24x7 and place trade orders for you.
Ok. Now that you have got me interested, tell me quickly what this TALK will cover.
For implementing Algorithmic Trading in Python, you need the following -
- Ability to query real time data (current stock price)
- Ability to query historical data
- A strategy (ie the Algorithm), which gives out predictions whether to BUY, SELL or HOLD.
- Backtesting framework to test the strategy
- Ability to place BUY/SELL trade order at Indian Stock Exchanges (NSE/BSE)
This TALK will demonstrate all the above mentioned points for the below strategy.
- Crossover(EMA(3), EMA(15)) --> Place Buy Order
- Crossover(EMA(15), EMA(3)) --> Place Sell Order
- Every Buy and Sell order is placed with 1% Stop Loss and 0.3% Target Price
This strategy generated an average profit of ~6% per month (~72% annually) on real data of TATASTEEL (NSE) during backtesting for the period 16th June - 14th August, 2017.
Click below to see the video of this backtesting strategy in action.
- Basics of Python
- [Optional] Basics of Trading is a plus. (I will introduce the relevant trading terms in the beginning of the TALK for those not familiar)
If you are interested in more information about this, please drop me a mail at firstname.lastname@example.org with your purpose for accessing other resources. Thanks.
I hold 3 degrees from IIT Delhi - Electronics, Computer Science & Physics. I first started using Python in 2009 and have been using ever since, everywhere possible - academics, work, hobby. I currently work at NVIDIA.
Sometime back, I worked for a startup, TapDiscover, where we created 2 fully functional Android apps. I was responsible for complete backend development using Django REST Framework. I have also worked with Numpy, Matplotlib, PyQt4. I read Python books in my free time. I heavily use Python for scripting in my current job.
PS: Python is my passion. I am a Hardware Engineer by profession.