Option FanaticOptions, stock, futures, and system trading, backtesting, money management, and much more!

Debugging the Missing Time Spread Backtrades (Part 2)

By way of review, the idea is to log relevant variables in places where spreads could or should be found and aren’t. I left off discussing where in the program I need to insert code to do this.

In case I want to log in the ‘find_spread’ branch, let’s review the sub-branches:

What are the relevant variables to log?

I increasingly suspect len(dte_list) should be looked at first. On any given day it should be > 2 for at least two matching options (one potential spread). As a first attempt, I will append current_date to a new list dates_without_enough_matches at the top of the ‘find_spread’ ELSE sub-branch for any day that does not meet this criterion.

Surprisingly, the list is empty! This suggests failure to match strike price is not the issue.

Just to be transparent, I am now moving the following line to the end of the ‘find_spread’ ELSE sub-branch:

      current_date = int(float(stats[1])) #updating

Since the previous elif executes on the same current_date (and strike price match), by implication this sub-branch takes place on the next day. Updating current_date at the beginning of this sub-branch forced me to use “current_date – 1” in following lines, which may not be accurate in case of weekends, holidays, etc. Updating at the end eliminates this problem. While not part of the current debugging effort, in scrutinizing this part of the program I saw opportunity for improvement.

I will continue next time.

No comments posted.

Leave a Reply

Your email address will not be published. Required fields are marked *