Hi, I have purchased and completed this course called."TRADING WITH MACHINE LEARNING: CLASSIFICATION AND SVM", I have since worked with the code and I understand it but I'm still missing one thing; how can I make future predictions with this code? It seems the SVM model is built on ticker data that has allready completed vs actually predicting the furture and building the model off of those results, is this true? Does this code model after the ticker data is complete? If so, can that really be called a prediction?
Please advise,
Thanks,
William
Hi William,
Thank you for posting your query. When predicting time series data, we took care that the future data was not inluded in the calculations. You can verify this in the code, where we used .shift(1) for all the technical indiactors that we used. This ensures that whatever signal is generated, it can be generated at the close of the previous candle. Since, the prediction was made at the end of the last candle, we cannot take the execution price at that last close, so we assumed the execution to be at the current candles open. Correspondingly, we used the future open price to calculate the profit by shifting the future returns by shift(-1). Also, our signal criterion was generated using only the train data.
To answer your question from a execution point of you: The sequence of events while trading live should be as follows:
candle 1 Opens ---- Calculate the indicators using the available data and use them to make a prediction, then hit the market.
candle 2 Opens ---- Close the previous position and open a new one if the signal is different ,and Calcualte the profit for the previous prediction, by using the execution prices (open1 and open2).
And repeat this process at the Open of every candle. Hope this helps your understanding. Please, let us know if need further help.
Thanks, that helped clarify some confusion but there is still another piece I am missing. In your execution list you state that after candle 1 closes I should calculate the indicators and make a prediction but I believe I still need the open value from candle stick 2 before I calculate and make a prediction - right? Because that is how the training and testing of the SVM takes place; all rows are shifted by 1 except the open column, so the same should be true for a future prediction. Thanks aga
Hi William, Sorry for the confusion regarding the strategy execution. I have updated the execution process in my previous comment to explain what is shown in the Ipython notebook. We make the prediction and calculation after the candle opens and not at the close.
Hi, it's been awhile, almost 2 years to the day :)
I'm still lost on how to use this in a live setting.
Okay, I need to use the open price on the current candle to make the live preditcion but I also need all of the column data(indicators and returns) to make the prediction as well, not just the open column. I find that I cannot do this because the current row's Ret column Df['Ret'] = (Df['Open'].shift(-1)-Df['Open'])/Df['Open'] returns a nan so I cannot use it with cls.predict(ss1.transform("current row with open candle")).
Thanks for any insight you can give me,
Wiiliam
Hello William,
You will get a NaN only for the first row. You can drop that particular first row both for the inputs and the target. Do get back if you face issues with this.