Creating a trading system from scratch

How many lines of code you are comfortable with


  • Total voters
    61

ncube

Well-Known Member
Regarding price, if you go a few posts back, we buy only when we are sure that the price has fallen.
I keep a constant percentage on open price which is also implemented in the notebook.
I place a stop loss order to arrive at the exact limit price
@vinit_7801 , I explored the long-short portfolio on Nifty50 Stocks and the results were not that good. Maybe Long short can be tried on sector specific stocks..however I have not tested it. i.e Contrarian strategy: Short Leading sectors & long lagging one or momentum strategy:Long leading sector & short lagging.

These type of strategies work based on the law of large numbers and one need to have the patience to stick with the process, over a period of time the edge in the strategy should start working in your favor, and individual trades/days will not matter much.
 

ncube

Well-Known Member
To make things clear, the strategy gets around 800% returns in around 3 years as posted by @ncube .
But in reality, it gets around 6-8% return (after adjusting for slippages ,other charges and unexpected events) per annum. So at 5L, which is quite easy you get around 40% which is quite good.
Improving this strategy would get your around the 10-12% mark per annum but the best part is you can clone or make more strategies to smooth out and increase returns.
So the 800% benchmark return (I believe its compounded at a single leverage) is reduced to around 110% absolute returns in reality.
Just to clarify, 800% is the strategy return for total 5 stocks at single leverage measured daily (Not total investment). i,e 800% should be divided by 5 which will be around 160% for total invested capital. 800% at 5 x leverage. Sorry if this number was misleading.
 

UberMachine

Well-Known Member
Just to clarify, 800% is the strategy return for total 5 stocks at single leverage measured daily (Not total investment). i,e 800% should be divided by 5 which will be around 160% for total invested capital. 800% at 5 x leverage. Sorry if this number was misleading.
So, its on par with my 5X leverage.
Still, one of the reasons why backtests fail in practice. 160% returns reduced to just 22%
 

UberMachine

Well-Known Member
@vinit_7801 , I explored the long-short portfolio on Nifty50 Stocks and the results were not that good. Maybe Long short can be tried on sector specific stocks..however I have not tested it. i.e Contrarian strategy: Short Leading sectors & long lagging one or momentum strategy:Long leading sector & short lagging.

These type of strategies work based on the law of large numbers and one need to have the patience to stick with the process, over a period of time the edge in the strategy should start working in your favor, and individual trades/days will not matter much.
Actually, the exact reverse strategy doesn't work; it results in a net loss in the long run. Got to find a long strategy that's net profitable so that they could be merged.
One of the intuitive reasons may be, selling happens impusively while buying takes time based on trend. So if you have figured out a trend following system that works, then this could be a great combination
 

ncube

Well-Known Member
Actually, the exact reverse strategy doesn't work; it results in a net loss in the long run. Got to find a long strategy that's net profitable so that they could be merged.
One of the intuitive reasons may be, selling happens impusively while buying takes time based on trend. So if you have figured out a trend following system that works, then this could be a great combination
Another factor to be considered is the bullish trend in the last few years, the strategy performs well in bullish periods compared to bearish periods. One reason could be that during bullish periods the stocks which raises high result in many booking profits the next day bring the prices down. However during bearish periods stronger stocks tend to raise more and weaker stocks will go down further. Hence we can explore combining the market trend as one input, I feel it should improve the results further.
 
@vinit_7801 , I explored the long-short portfolio on Nifty50 Stocks and the results were not that good. Maybe Long short can be tried on sector specific stocks..however I have not tested it. i.e Contrarian strategy: Short Leading sectors & long lagging one or momentum strategy:Long leading sector & short lagging.

These type of strategies work based on the law of large numbers and one need to have the patience to stick with the process, over a period of time the edge in the strategy should start working in your favor, and individual trades/days will not matter much.
In this strategy requires huge amount of orders ......so any tips to minimize brokerage and slippage?????
 

UberMachine

Well-Known Member
Another factor to be considered is the bullish trend in the last few years, the strategy performs well in bullish periods compared to bearish periods. One reason could be that during bullish periods the stocks which raises high result in many booking profits the next day bring the prices down. However during bearish periods stronger stocks tend to raise more and weaker stocks will go down further. Hence we can explore combining the market trend as one input, I feel it should improve the results further.
Definitely but presently my system works with zero memory (it just looks back 1 day) and I target intraday returns rather than returns.
I am trying out creating a series of individual recommendtions which when combined would produce better results. Also, working on including more memory into the system (such as trend) but the real problem is setting them up automatically on a daily basis to do the execution.

Another reason this strategy works may be the fact that every possible information is incorporated into the pre open data itsel and it may provide an edge since we make the move early. This system has a doomsday scenario where all stocks open short and end high for around 15-20 days but the chances of it happening are way too low
 

UberMachine

Well-Known Member
In this strategy requires huge amount of orders ......so any tips to minimize brokerage and slippage?????
Not huge just 10-15 daily along with stop loss.
You can reduce brokerage by subscribing to some unlimited plan. Any way, STT and other charges would eat up.
This is part of the system and I don't see way to overcome it. Only good thing is they are linear so that they could be easily added up as a cost.
 
Not huge just 10-15 daily along with stop loss.
You can reduce brokerage by subscribing to some unlimited plan. Any way, STT and other charges would eat up.
This is part of the system and I don't see way to overcome it. Only good thing is they are linear so that they could be easily added up as a cost.
my question is why the 5 trades is it based on past experience or it a random number because backtest shows more sharpe and sortino ratio in 2,3,4 trades..?
 

Similar threads