Creating a trading system from scratch

How many lines of code you are comfortable with


  • Total voters
    61

UberMachine

Well-Known Member
Just want to ask why can't we add one variable for leveraging....India vix..
When the India vix is above 17 we deleverage because there already be volatility in market....and add more leverage when vix is below 12 as market will be consolidating??
Definitely :up:, you can try it out.
Just need daily data for VIX (I think its available) to check the condition before placing orders.
We could also check whether we perform better on volatile/non-volatile days before making a decision. I haven't tested it so far.
 

UberMachine

Well-Known Member
master Ub

from fast bt to my problem
  • Case 2.2open high low close buy sell
  • 1022-o
  • 1022-h
  • 950-l
  • 1012-c
  • 1025-buy
  • 1000-sell
    • Low High range = 950 to 1022
    • Sell buy range = 1000 to 1025
  • Same as the above with Sell being executed at close price

    -BUY at 1000​
    -SELL at 1012​

for backtesting the system is made to be used as soon as possible when market opens
what if i make a position at 10 am


suppose my order is opened and executed at 10am at 1000 and sl is 980 , day closes at 1012

the backtester will know my entry price and the close is in direction of profit
but day low before 10am was 950 ie below my 2%sl,so backtester will show me sl was hit

so will the backtester be limited to 9:15 only or something can be done for such situations
update
read basic assumption 1:D of fast bt
As you have mentioned, the generalized assumption is you open and close positions within a fixed timeframe and limit your loss. I preferred end of day for flexibilty and better replication and easy availability of reliable data.

@Shivam_
Regarding your case, you are going to enter only at 10:00 am, So you need to have prices starting from 10:00 till the end of the day. Replacing this data source would get your desired results. So, most possibly your ohlc starting from 10:00 would look like 996 1022 994 1012. But there are a few prerequisites
  1. Your dataframe must have ohlc prices starting from 10:00, implying you place orders only at 10:00
  2. If you place orders only at 10:00 based on certain conditions, with other orders being placed at 9:15, you could separate out this condition logic and create a new strategy
  3. And if you want to run a hourly strategy, just provide the hourly data
fastbt runs your simulation for each time bar specified in the dataframe timestampcolumn. So if the dataframe is on a weekly basis, you get weekly results, and in case of hourly, you get hourly results. For now, you need to do this data pre-processing yourself.
 

UberMachine

Well-Known Member
There are 2 ways to make your strategy robust. Either cut losses early by stop loss or hold your positions with conviction and calculate maximum drawdown. In both the cases, you don't know your expected profit but in the first case, you know your max possible loss on any day.

This assumption is necessary for replicating our strategies and discover shortcomings. You can violate this assumption but you need to have the necessary data to violate it. Most strategies concentrate only on entry position (except MA crossover) and leave the exit position for the trader to decide and this is one of the important drawbacks. Most solve this based on either personal experience or using optimization but I prefer a time based approach as it makes a life lot easier. It also helps me take my eye off the trading screen.
 
There are 2 ways to make your strategy robust. Either cut losses early by stop loss or hold your positions with conviction and calculate maximum drawdown. In both the cases, you don't know your expected profit but in the first case, you know your max possible loss on any day.

This assumption is necessary for replicating our strategies and discover shortcomings. You can violate this assumption but you need to have the necessary data to violate it. Most strategies concentrate only on entry position (except MA crossover) and leave the exit position for the trader to decide and this is one of the important drawbacks. Most solve this based on either personal experience or using optimization but I prefer a time based approach as it makes a life lot easier. It also helps me take my eye off the trading screen.
Can you share more light on fastbt simulation
 

VJAY

Well-Known Member
Try opening MicrosoftExcel application only instead of a file.
Microsoft Excel is usually in the folder C:\Program Files (x86)\Microsoft Office\Office15.
More info here
If this also fails, would think about something
Dear UB,
Yes its working!!!!
 

UberMachine

Well-Known Member
Notebook converted to script.
You could run the trading_system.py script from your cmd for automatic order generation.
Download from github or clone it

The following features are added
  1. Automatic bhav copy download (no need to save file for the trading system)
  2. Option to diversify among sectors
  3. Script for linux and windows for automation
Rest of the development would be done based on the fastbt library
 

Similar threads