SMA crossing signals for QQQ over 12 years

26 views
Skip to first unread message

Peter Anderson

unread,
Dec 1, 2012, 5:22:26 PM12/1/12
to talib...@googlegroups.com
I ran 3600 combinations of slow/fast SMA crossings to find good signals for a 12 year period on QQQ. The results showed returns as high as 170+%. A scatter plot of the results is attached.

Pete
QQQ, 12 year SMA.png

Peter Anderson

unread,
Dec 1, 2012, 5:55:33 PM12/1/12
to talib...@googlegroups.com
The same run for AAPL showed gains as high as 1400% ! !

Peter Cawthron

unread,
Dec 1, 2012, 5:57:58 PM12/1/12
to talib...@googlegroups.com
Looks good. What do the colours mean?

P

On 1 December 2012 22:22, Peter Anderson <pande...@yahoo.com> wrote:
I ran 3600 combinations of slow/fast SMA crossings to find good signals for a 12 year period on QQQ. The results showed returns as high as 170+%. A scatter plot of the results is attached.

Pete

--
You received this message because you are subscribed to the Google Groups "talibpython" group.
To post to this group, send email to talib...@googlegroups.com.
 
 

Pablo Torre

unread,
Dec 1, 2012, 6:49:45 PM12/1/12
to talib...@googlegroups.com, talib...@googlegroups.com
Interesting. A few questions:

What's your avg holding period? (how long r u in each trade)?
Max drawdown? 
Sharpe?
How does it benchmark against buy n hold? 

Regards,

Pablo Torre
Customer Service & Trade Support. 


Sent from my iPhone. 
--

Peter Cawthron

unread,
Dec 1, 2012, 6:53:36 PM12/1/12
to talib...@googlegroups.com

OK. I get it!

P.

Peter Anderson

unread,
Dec 1, 2012, 7:34:05 PM12/1/12
to talib...@googlegroups.com
Red is gains in the range of 140-150%, blue is gains of 150-160%, green is gains of 160+%

Peter Anderson

unread,
Dec 1, 2012, 7:46:04 PM12/1/12
to talib...@googlegroups.com
Good questions. If I recall correctly, buy n hold is about zero for 2000-2012. I'll add all that to the program. I'm a little worried about the learning curve for date arithmetic, but it should be good education.

Shakti D

unread,
Dec 1, 2012, 9:07:10 PM12/1/12
to talib...@googlegroups.com
Hi Pete
I think that is a good analysis , Is there a source from where we can get intraday quotes ? Instead of running this algo over per day data do you think it will reveal similar results if we run over 1 days quotes ?
Cheers
Shakti

Peter Anderson

unread,
Dec 2, 2012, 1:27:35 AM12/2/12
to talib...@googlegroups.com
Buy and hold was -2.3% for actuals, 23% for adjusted prices. Don't know avg holding period yet, but there were only 11 buy/sell pairs in 12 years for the best performing pair of 50/143 days that returned 97% based on actuals. The program did not sell short, only buy long. I'm planning to add selling short, and it should add significantly to performance, since there were two crashes during the period.


On Saturday, December 1, 2012 6:49:45 PM UTC-5, Pablo Torre wrote:

Peter Anderson

unread,
Dec 2, 2012, 1:31:17 AM12/2/12
to talib...@googlegroups.com
Sorry that last reply referred to SPY, not QQQ. Time to get some rest.

Peter Anderson

unread,
Dec 2, 2012, 1:34:07 AM12/2/12
to talib...@googlegroups.com
Shakti, I really have no clue how this approach would work on intraday data. The best way to find out would be to run it and see.

Pete

Shakti D

unread,
Dec 2, 2012, 1:38:08 AM12/2/12
to talib...@googlegroups.com
Yeah .. get hold of some sites to pull intraday data 

Peter Cawthron

unread,
Dec 2, 2012, 5:52:53 AM12/2/12
to talib...@googlegroups.com
I found this:

import urllib2
import urllib
import numpy as np
from datetime import datetime
urldata
= {}
 
urldata
['q'] = ticker = 'JPM'       # stock symbol
urldata
['x'] = 'NYSE'               # exchange symbol
urldata
['i'] = '60'                 # interval
urldata
['p'] = '1d'                 # number of past trading days (max has been 15d)
urldata
['f'] = 'd,o,h,l,c,v'        # requested data d is time, o is open, c is closing, h is high, l is low, v is volume
 
url_values
= urllib.urlencode(urldata)
url
= 'http://www.google.com/finance/getprices'
full_url
= url + '?' + url_values
req
= urllib2.Request(full_url)
response
= urllib2.urlopen(req).readlines()
getdata
= response
del getdata[0:7]
numberoflines
= len(getdata)
returnMat
= np.zeros((numberoflines, 5))
timeVector
= []
 
index
= 0
for line in getdata:
    line
= line.strip('a')
    listFromLine
= line.split(',')
    returnMat
[index,:] = listFromLine[1:6]
    timeVector
.append(int(listFromLine[0]))
    index
+= 1
 
# convert Unix or epoch time to something more familiar
for x in timeVector:
   
if x > 500:
        z
= x
        timeVector
[timeVector.index(x)] = datetime.fromtimestamp(x)
   
else:
        y
= z+x*60 # multiply by interval
        timeVector
[timeVector.index(x)] = datetime.fromtimestamp(y)
 
tdata
= np.array(timeVector)
time
= tdata.reshape((len(tdata),1))
intradata
= np.concatenate((time, returnMat), axis=1) # array of all data with the properly formated times

which produces this:

In[7]   intradata[0:9]
Out[7]: 
array([[2012-11-30 14:30:00, 41.07, 41.07, 40.99, 40.99, 900.0],
       [2012-11-30 14:31:00, 41.06, 41.15, 40.97, 41.04, 71901.0],
       [2012-11-30 14:32:00, 41.07, 41.12, 41.01, 41.05, 37925.0],
       [2012-11-30 14:33:00, 41.12, 41.12, 41.035, 41.065, 49409.0],
       [2012-11-30 14:34:00, 41.175, 41.19, 41.08, 41.13, 78433.0],
       [2012-11-30 14:35:00, 41.1801, 41.1801, 41.09, 41.15, 48421.0],
       [2012-11-30 14:36:00, 41.09, 41.18, 41.03, 41.18, 68530.0],
       [2012-11-30 14:37:00, 41.08, 41.09, 41.04, 41.085, 51140.0],
       [2012-11-30 14:38:00, 41.12, 41.12, 41.053, 41.08, 57380.0]], dtype=object)



P.

Peter Cawthron

unread,
Dec 2, 2012, 6:03:04 AM12/2/12
to talib...@googlegroups.com
Sorry, I forget. We don't want to use Google!

P

Pablo Torre

unread,
Dec 2, 2012, 9:41:33 AM12/2/12
to talib...@googlegroups.com, talib...@googlegroups.com
Bats has free real time quotes in their website. I think they have an API since I've seen many other sites that pull their data. 


Regards,

Pablo Torre
Customer Service & Trade Support. 


Sent from my iPhone. 

Pablo Torre

unread,
Dec 2, 2012, 9:42:59 AM12/2/12
to talib...@googlegroups.com, talib...@googlegroups.com
Very interesting. 


Regards,

Pablo Torre
Customer Service & Trade Support. 


Sent from my iPhone. 

Dr. Nils Koesters

unread,
Dec 2, 2012, 10:08:13 AM12/2/12
to talib...@googlegroups.com
Bats seemingly being http://www.batstrading.com/ ?

Pablo Torre

unread,
Dec 2, 2012, 10:42:14 AM12/2/12
to talib...@googlegroups.com, talib...@googlegroups.com
Yes. That's them. They also have a site for EU markets.

Regards,

Pablo Torre
Customer Service & Trade Support.

Phone: 416-646 1442
Mobile:+506 8730 9157

Sent from my iPhone.

On 2012-12-02, at 9:08, "Dr. Nils Koesters" <nils.k...@gmail.com> wrote:

> Bats seemingly being http://www.batstrading.com/ ?
>

Shakti D

unread,
Dec 2, 2012, 10:44:48 AM12/2/12
to talib...@googlegroups.com
Can anyone share the link from where we can download intraday quotes ? I am not able to find the same in www.batstrading.com

Pablo Torre

unread,
Dec 2, 2012, 10:47:30 AM12/2/12
to talib...@googlegroups.com, talib...@googlegroups.com


Regards,

Pablo Torre
Customer Service & Trade Support. 


Sent from my iPhone. 

Pablo Torre

unread,
Dec 2, 2012, 10:56:16 AM12/2/12
to Pablo Torre, talib...@googlegroups.com
Thats the wrong API. I'll keep looking for it. 


Regards,

Pablo Torre
Customer Service & Trade Support. 


Sent from my iPhone. 

Pablo Torre

unread,
Jan 4, 2014, 11:56:43 AM1/4/14
to talib...@googlegroups.com, talib...@googlegroups.com


Regards,

Pablo Torre
Customer Service & Trade Support. 


Sent from my iPhone. 
On 2012-12-02, at 9:44, Shakti D <shak...@gmail.com> wrote:

Reply all
Reply to author
Forward
0 new messages