**Automate your trading**

1/ The first step in automating your trading is defining whatever steps you're doing manually.

I just roughly sketched out some of the actions I do on a regular basis manually. Trading automation - rough sketch out of list of functions w
2/ When designing an automated trading system, it helps to write out the list of things you do during the trading hours, and design a scalable, reusable system accordingly.

This calls for functional or object-oriented programming to be put into use.
3/ Before you design the system, you write everything down in simple English language.

This helps clarify what all minutiae are involved.

A step you consider very small and intuitive, takes a lot of effort in reality to think in code.
4/ For ex: You may "just" be looking at option chain and deciding which strike to buy if your strike decision is based on OI and Volatility.

But in background, you have to pull the data of all strikes, their respective option type, get the relevant details one after another.
5/ Strike calculation to decide which strike to trade is also mathematical. You have to create a formula for doing that and code it up.

Like this, simple things take nuanced thought when it comes to automation.
6/ The first action we do is LOGIN.

We enter username, password.
We enter OTP or 2fa PIN.
We login.

This may not be as straight forward with API, but quite similar.

But before logging in, we check for connection to broker.

If not, we keep trying until we're able to connect.
7/ Once we login, we check if we can see the historical data and charts.

We check if previous day's data has been updated.

We check our margin, cash position in the account.

We check if the data connectivity is working fine.

Once it's 9:15, we check if the data is streaming.
8/ We may create a watchlist with a specific list of stocks for the day, based on some conditions.

For ex: If you only trade gapping stocks on the pre-open, you look at the price at 9:08, and create a watchlist.

You search for each individual stock and add it to watchlist.
9/ If you trade FNO, you will then search for relevant options and futures.

Then, you decide the strike price, the expiry date, etc., and get those into the watchlist.

You may even have to decide strike price on the go.
10/ If you have screeners, those screeners require historical data to screen for conditions that you need fulfilled.

It could be yesterday's intraday data.

It could be last week, month's data.

The screeners use such historical data to decide which ones to shortlist.
11/ You might also want to check until what point the historical data is available.

On charts, it says "data not available beyond this point".

At that point, you readjust your lookback period.

You'd want to adjust the historical data for different timeframes and check data.
12/ If you have any positions, you'll want to check the current status of positions in real time.

You'll need to receive streaming data to be updated about each item on your watchlist, tick by tick.

If you take your decisions based on a specific timeframe bar, you need that.
13/ Maybe you don't believe in zerodha's data being correct.

What do I do if the opening range data is wrong? I check with Google data and verify.

Otherwise, I check with Fyers.

So, data redundancy/accuracy is important.
14/ Then, once you're ready to trade, you choose the specific watchlist item to trade.

Say you want to trade 100 lots of Nifty Futures. That's your contract. You get the data about Nifty Futures, and create contract with 100 lot quantity to buy/sell.
15/ These are some of the things we do before placing orders.

This was just a rough sketch. But each of these actions require a piece of code to work as a holistic system.

And each mentioned action will have like few steps (some would have many steps) programmatically.
16/ It's then important to understand that these are all unique and different pieces of one system.

All of these pieces/actions have to work smoothly, independently, and work together when they need to.

Modularity, reusability, etc., are all important when you build a system.
17/ I'll cover ordering, order monitoring, different order types, etc., in a separate post.

Essentially, what I want to convey is, the actions that we do manually and think as simple, have nuances happening in the background while coding.
18/ This is why it's important to have a testbed where you can test everything, even the live trading, before you actually push the system live to automate.

Without testing, going live is a recipe for disaster.

And, without meticulous planning, testing is futile.
19/ So, to think about automation, first start listing down EVERYTHING you do manually, in simple steps.

This is your algorithm.

Now, you need a programming language (that broker supports) and an API (that the broker offers) to automate.
20/ Your duty is to soak up all the information about the broker API from their documentation, test everything locally, and then proceed with further development.

And, always be cautious at every step of the way if you're using a live trading account.
21/ As I build my own automation system, I'll cover each of these modules in detail in the coming days.

That said, do give it a thought, and see what all you can automate (from hourly scans to live scans updated every second for breakouts, you can automate scanning process too)

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Shravan Venkataraman 🔥🚀💰

Shravan Venkataraman 🔥🚀💰 Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @theBuoyantMan

2 Dec
1/ In this thread, I'll cover the things you do regularly during trading in terms of **execution** and how to approach execution from the perspective of automation.

#TradingAutomation Image
2/ You may think execution is easy.

But that is only because you are attuned to it and you don't pay mindful attention to the sheer number of actions and decisions you take throughout the trading day, in terms of execution.

The following are some of the actions you do.
3/ Once your strategy says you've to put on a position

- you pick the relevant scrip to put on a trade
- you decide the required qty/lot size to trade
- based on the signal, it has to be a buy or sell order
- based on the strategy, it has to be a market or limit order.
Read 33 tweets
1 Dec
This is a raw output of the one lot backtest I did on one of the strategies I trade currently.

Essentially after all the optimisation and out of sample testing I want to look at the performance of the system holistically for the last 10 years.

This starts with a one lot test.
After that, I test for scenario where I'd use the equivalent of maxDD amount to compound each lot and scale the system.

If I test that, the risk of ruin is higher (as at some point you get wiped out having only max DD amount per lot, and facing the same maxDD)
These tests are very optimistic in it that they assume FILLS at the exact price point (which may not be possible). So, there are calculations to be made after this step.

That said, you see 2017? That's when our account got wiped out in this manner of scaling 1 lot per maxDD amt.
Read 5 tweets
24 Nov
Here's how writing can be leveraged to build an audience online:

1) Write a long form essay, publish it in your blog.
2) Convert that to a Youtube video series, as a talking head video or an illustrated presentation
3) Convert all the filmed videos to audio, publish as podcast.
4) Get the highlights from the essay, publish as tweets.
5) Create quotes in the form of illustrations/images, publish on Instagram and Facebook.
6) Extract highlights of the video series, publish on TikTok.
7) Extract those highlights as audio, and publish as byte-sized podcast.
8) Publish the long-form essay as downloadable PDF/ePub in exchange for people's email. Build your email List.
9) Publish independent sections of the essay as tweetstorms/threads.
10) Publish these threads as short essays on medium and other distribution platforms.
Read 6 tweets
23 Nov
Thank you, for all the wonderful people who took time to register your interest and comment on the form.

So, here's what I have thought about so far, with respect to the course.

1. 80% practical coding practice, with clear outcomes, assignments, and small projects, every week.
2. Working with financial and time-series data in some form from the very first day's assignment itself.

3. Developing algorithmic thinking from the standpoint of being able to write logic in English and then code.

4. Developing a mindset for backtesting and ideation approach.
5. A compound assignment like a mini-project every week. A compound project every 4 weeks, and one big project for the course completion.

6. Daily coding practice being built into the way the course will be structured - for you to build the habit of reading & writing code.
Read 9 tweets
23 Nov
Option selling is a game for larger players (probably those with at least 1-2cr in capital).

As a bare minimum, I suggest at least 50L in capital before you start thinking about option selling as a strategy to make money.
Intraday option selling and swing - both have their drawbacks, and both have potential to wipe you out.

Intraday - violent swings can move through your SL without executing.

Swing trades - gap up/down opens against you could lead to margin call.
While I'm oversimplifying the cases, it's very important to know where the landmines are so that you can avoid them.

If you don't even know where the landmines are and you're walking a field full of them, even if you're lucky 10 times, the 11th time you step on one, you die.
Read 6 tweets
22 Nov
If you're under 25 years of age,

and you have just begun trading in the financial markets

1) Don't take money to trade from your parents or family members.
2) Don't even think about option selling if your capital is less than 50L.
3) Trade only your money (not even friends')
4) Trade only the portion of your money that, if you got wiped out, wouldn't faze you. This means, don't use all the money you got as capital.
5) Don't start with intraday. Don't even start with trading. Start with sim/demo (ex: IBKR)
6) Don't confuse favorable markets (since 2017-18) for your own genius or having "figured it out".
7) Don't over leverage. If you can't generate decent returns un levered, your strategies are shit anyway.
8) Don't look at derivatives unless you have traded cash stocks.
Read 4 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!