Hello,
I'm developing a script which analyzes financial trades. I want to find out the average number of trades open at the same time. I have the start and end dates of each trade, but I cannot figure out a way to do this properly.
I have found a few ways to compare date ranges and see if they overlap... However the problem is that I think it needs to be recursive.. Because I really need to compare each trade to all the other trades.
For instance, trade #1 might be a very long trade lasting several weeks. During this time dozens of other trades open and close. Using a simple date overlap method, I would find dozens of trades "open at the same time" as trade #1. However this does not help me find the average number of open trades, because these trades all had their own open/close dates which may or may not overlap with the rest of them. All I know for sure is that they all overlap with trade #1 at some point in time.
So I would greatly appreciate anyone's input on this. Again I'm looking for the average number of trades open at one time.
In reply to Recursive method to check overlap of many date ranges by bigbot
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |