I have developed a trading algorithm, surprisingly simple in nature (I did start off with grand plans of applying Machine Learning to this problem as I am a data scientist by trade).
I would place the code here, but I would like to do some appropriate backtesting before throwing it open for peer review. In any case, I am seeing accuracies of predicted_trading_signal
compared with perfect_insight
of $+80\%$ across many of the russell 2000 group, which as a data scientist, and a rational person seems too good to be true. To this end, I would like to know if this is an appropriate test
Here is some pseudocode:
# generate trading signal up onto data[i]
predicted_trading_signal = some_algo(data[:i])
# generate perfect insight signal
perfect_insight = another_algo(data[i], data[i+1])
# where data[i+1] is say the next day
if some_statistical_property_of_data > lambda:
if predicted_trading_signal == perfect_insight:
correct+=1
else:
incorrect+=1
# after running over all windows of interest for a particular stock
accuracy = 100.0* correct /float(correct + incorrect)
I wish I could be more concrete with the code!
- Is this a valid approach to computing accuracy
- is conditioning on information up until todays date and using the following days price typical in testing strategies without data leakage (a subtle problem to a naive person such as myself in trading)
- Is there a better approach?
My final question (hopefully this is considered part of the bigger question - I hate multiple questions in one post on mathstackexchange)
Can I determine the profit-loss calculation as $$ P_i = \text{trading_signal}_{i-1}\left(S_{i} - S_{i-1}\right)\cdot C_{i-i} $$
Here
- $C_{i-1}$ is the initial capital invested.
- $S_i$ stock price
- $\text{trading_signal}_{i-1}$ is initial trading signal