Trading Signals

How do I extract trading signals from the SVM strategy?  I want to evaluate my strategy against future data.  



Thanks,

J

Hello John, thanks for your query! Well, there are many ways you can do that. 



The idea is that you need to have a set of features for which you'll label the position you take. For example, one such feature can be the difference between the daily open and close. 

 

AAPL['Open-Close'] = AAPL.Open - AAPL.Close

Here you're creating a new feature from the AAPL daily opening and closing prices.

Now once we have this, we can very easily reckon the signal. Just make sure the Df['Close']  of a certain day is greater than the Df['Close'] of the day before. Here is how that can be done, 
 
y = np.where(Df['Close'].shift(-1) > Df['Close'],1,-1)

Here, we're creating a new vector where we put in 1 if the close of a given day is greater than the close of the previous day ( because you'd want your algorithm to buy it) and -1 if it's not. 

So, for the SVM, AAPL['Open-Close']  will be the predictor(X) and the vector y will be the target variable. 

Of course, there are many other ways the signal can be generated. Do get back, if you'd like to discuss further! 
 

Dear Sir,



I was about to ask the same question and found John's post here. I have a question regarding your answer:



Should we generate the labels for the future? for example after generating the target variable by your method should we do y.shift(-1) so we use the feature for today to predict what will happen tomorrow?



Thanks in advance,

Hi Mohammed



If you check the code above for "y", that is what we are in fact doing. We compare tomorrow's price (Df['Close'].shift(-1)) with today's price (Df['Close']) and give a "Buy" signal, for today as per the condition.



Therefore, we need not separately do "y.shift(-1)" again. 



Hope that answers your query.











 

Yes got it now. Thanks a lot!