Creating a trading system from scratch

How many lines of code you are comfortable with


  • Total voters
    61

UberMachine

Well-Known Member
#11
So, let's get started.
Let's implement this system in Excel before moving on to Python.
I started with Excel because
  1. Most people are familiar with Excel
  2. to compare and contrast results
  3. to see where Excel really lacks and programming really takes over
(Meanwhile, I don't use Excel, I use WPS spreadsheets since I am on Linux)

So, let's implement this in Excel (Attachment enclosed)
  1. Download bhav copy from NSE website
  2. Filter the NIFTY 50 stocks
  3. Calculate the daily returns
  4. Select the stocks with the highest returns for the day (prevclose/close)-1
  5. Short them the next day at the open price with a stop loss of 3%
See instructions in the Excel file for more details

More on Step 2
I put all the NIFTY 50 symbols in a separate sheet and filtered them in the first sheet using VLOOKUP and then filtered out all cells without N/A. This makes it easier to change the stock universe in future.

I have kept the Leverage to 1 in the Excel file. You can calculate the profit by the end of the day and I need you to post them. It must be the same for everyone. You can try this system live from tomorrow (you won't lose a lot).
Testing a new system on live data is popularly called walk-forward testing (paper trading)

This system makes money. As at the time of posting, its in green and you can backtest it for the last 3 years with your software

Freshers Warning
Don't get too much excited by the results in a few days
 

Attachments

UberMachine

Well-Known Member
#12
Experienced trades may notice that I overlooked a few important points such as slippage, type of order to be executed, commission, market movement and more. I just wanted to start simple before covering the other aspects.

This system makes money in backtests (infact a lot if you leverage) but would fail in real time and that's what we are going to calibrate.
I encourage everybody to take live trades to actually see what goes wrong (your max loss for the day is 600 and the probability of max loss is around 0.02% - 1 in 5000). So even if you are on 5X leverage, you aren't going to lose much and it would be a good learning experience.

This is a very well defined system. The original specifications would remain the same and we would be just adding to them in case of requirement. Given such a well-defined simple system, expect big difference in performance. I want you to get actively involved
 

UberMachine

Well-Known Member
#14
These are the results for yesterday (see BACKTEST sheet)
I arrived at the results by looking at the yesterday's prices and calculating the real BUY and SELL prices for the day.
This is a complete system. Its based on unambigious rules and we can evaluate it on a daily basis. We haven't backtested the system yet but assuming this makes profit, you can move forward.

I would implement the same system tomorrow in Python. Meanwhile, you can post your results based on this system.
 

Attachments

VJAY

Well-Known Member
#16
Dear UB,
Can you make this excell just copy paste bhavcopy to one sheet out put come automaticly....Is it possible?
 

UberMachine

Well-Known Member
#18
Dear UB,
Can you make this excell just copy paste bhavcopy to one sheet out put come automaticly....Is it possible?
It is possible but we need to have 2 bhav copies; one for generating orders and the other to evaluate performance. May I know which bhav copy is needed?
Also, these things are quite complicated in Excel and would be soon moving to Python.
And :up: for calculating the P/L. I think you calculated on last price which is also OK.
 
Last edited:

VJAY

Well-Known Member
#20
It is possible but we need to have 2 bhav copies; one for generating orders and the other to evaluate performance. May I know which bhav copy is needed?
Also, these things are quite complicated in Excel and would be soon moving to Python.
And :up: for calculating the P/L. I think you calculated on last price which is also OK.
Dear UB,
in excell its time consuming , sometime errors also if any step mistaken....if we put bhavcopy in one sheet all other things need to come automaticly...otherwise we need to 3-4 steps to get orders ...
trading that close price is not good as its comes only after market hours ...for live trading its better to close positions @ 3.15
 

Similar threads