Monday, February 22, 2010

TaylorTrade weekly Stats (02/16/10-02/19/10)

Key Figures TaylorTrade SPY
Active Components29 1
Entries this period0 0
Exits this period0 0
IPOs this period0 0
Inactive this period0 0
Missing in PriceDB0 0

# 1yr Closing Highs 8 (6.90%) 0 (0.00%)
# 1yr Closing Lows 0 (0.00%) 0 (0.00%)

50sma > 200sma 99 (85.34%) 4 (100.00%)
50sma <= 200sma 17 (14.66%) 0 (0.00%)

# Higher Closes 79 (68.10%) 4 (100.00%)
# Lower Closes 37 (31.90%) 0 (0.00%)

Total Gains/Losses $34.76 (0.54%) $3.10 (0.71%)
Average True Range (2.27%) (1.14%)

* Results are cumulative for the period.

Sunday, February 21, 2010

Russell 3000 Weekly Stats (02/16/10-02/19/10)

Key Figures Russell 3000 IWV
Total Active Components2973 1
Total New Listings this period0 0
Total Inactive this period1 0
# All-time Closing Highs 101 (0.85%) 0 (0.00%)
# All-time Closing Lows 16 (0.13%) 0 (0.00%)

# Higher Closes 8175 (68.75%) 4 (100.00%)
# Lower Closes 3373 (28.37%) 0 (0.00%)

Total Gains/Losses $2351.58 (0.80%) $1.95 (0.76%)
Average True Range (3.16%) (1.10%)

* Results are cumulative for the period.

Price verification found 0 errors

Friday, February 19, 2010

Russell 3000 Daily Stats (02/19/10)

Key Figures Russell 3000 IWV
Total Active Components2972 1
Total New Listings this period0 0
Total Inactive this period1 0
# All-time Closing Highs 29 (0.98%) 0 (0.00%)
# All-time Closing Lows 3 (0.10%) 0 (0.00%)

# Higher Closes 1764 (59.35%) 1 (100.00%)
# Lower Closes 1110 (37.35%) 0 (0.00%)

Total Gains/Losses $258.09 (0.35%) $0.17 (0.26%)
Average True Range (3.08%) (1.03%)

* Results are cumulative for the period.

Price verification found 0 errors

Thursday, February 18, 2010

Russell 3000 Daily Stats (02/18/10)

Key Figures Russell 3000 IWV
Total Active Components2973 1
Total New Listings this period0 0
Total Inactive this period0 0
# All-time Closing Highs 30 (1.01%) 0 (0.00%)
# All-time Closing Lows 6 (0.20%) 0 (0.00%)

# Higher Closes 2043 (68.72%) 1 (100.00%)
# Lower Closes 849 (28.56%) 0 (0.00%)

Total Gains/Losses $473.62 (0.64%) $0.39 (0.60%)
Average True Range (3.09%) (0.91%)

* Results are cumulative for the period.

Price verification found 0 errors

Wednesday, February 17, 2010

Russell 3000 Daily Stats (02/17/10)

Key Figures Russell 3000 IWV
Total Active Components2973 1
Total New Listings this period0 0
Total Inactive this period0 0
# All-time Closing Highs 21 (0.71%) 0 (0.00%)
# All-time Closing Lows 3 (0.10%) 0 (0.00%)

# Higher Closes 1898 (63.84%) 1 (100.00%)
# Lower Closes 972 (32.69%) 0 (0.00%)

Total Gains/Losses $426.60 (0.58%) $0.39 (0.61%)
Average True Range (3.04%) (0.73%)

* Results are cumulative for the period.

Price verification found 0 errors

Tuesday, February 16, 2010

Russell 3000 Daily Stats (02/16/10)

Key Figures Russell 3000 IWV
Total Active Components2973 1
Total New Listings this period0 0
Total Inactive this period1 0
# All-time Closing Highs 21 (0.71%) 0 (0.00%)
# All-time Closing Lows 4 (0.13%) 0 (0.00%)

# Higher Closes 2471 (83.11%) 1 (100.00%)
# Lower Closes 443 (14.90%) 0 (0.00%)

Total Gains/Losses $1193.50 (1.65%) $1.00 (1.58%)
Average True Range (3.44%) (1.72%)

* Results are cumulative for the period.

Price verification found 0 errors

Sunday, February 14, 2010

TaylorTrade weekly Stats (02/08/10-02/12/10)

Key Figures TaylorTrade SPY
Active Components29 1
Entries this period0 0
Exits this period0 0
IPOs this period0 0
Inactive this period0 0
Missing in PriceDB0 0

# 1yr Closing Highs 3 (2.07%) 0 (0.00%)
# 1yr Closing Lows 0 (0.00%) 0 (0.00%)

50sma > 200sma 137 (94.48%) 5 (100.00%)
50sma <= 200sma 8 (5.52%) 0 (0.00%)

# Higher Closes 85 (58.62%) 2 (40.00%)
# Lower Closes 60 (41.38%) 3 (60.00%)

Total Gains/Losses $32.12 (0.41%) $1.38 (0.26%)
Average True Range (2.93%) (1.66%)

* Results are cumulative for the period.

Russell 3000 Weekly Stats (02/08/10-02/12/10)

Key Figures Russell 3000 IWV
Total Active Components2975 1
Total New Listings this period0 0
Total Inactive this period2 0
# All-time Closing Highs 38 (0.26%) 0 (0.00%)
# All-time Closing Lows 39 (0.26%) 0 (0.00%)

# Higher Closes 8768 (58.95%) 3 (60.00%)
# Lower Closes 5747 (38.64%) 2 (40.00%)

Total Gains/Losses $1593.90 (0.45%) $0.90 (0.29%)
Average True Range (3.71%) (1.69%)

* Results are cumulative for the period.

Price verification found 0 errors

Friday, February 12, 2010

Russell 3000 Daily Stats (02/12/10)

Key Figures Russell 3000 IWV
Total Active Components2974 1
Total New Listings this period0 0
Total Inactive this period1 0
# All-time Closing Highs 14 (0.47%) 0 (0.00%)
# All-time Closing Lows 7 (0.24%) 0 (0.00%)

# Higher Closes 1804 (60.66%) 1 (100.00%)
# Lower Closes 1092 (36.72%) 0 (0.00%)

Total Gains/Losses $316.38 (0.44%) $0.06 (0.09%)
Average True Range (3.63%) (1.52%)

* Results are cumulative for the period.

Price verification found 0 errors

Thursday, February 11, 2010

Trading Framework Part I: Tools I Use

I received a question from a reader regarding the software I use...more specifically...the open source software I use in trading. Instead of a direct response, I figured this type of question might be useful to other readers of this blog.

My basic trading framework is the following:
Operating System:Windows Vista Home Premium
Programming Languages:Python 2.6.2 & R 2.9.1
Databases:SQLite 2.4.1, Numpy 1.3.0, & CSV
Programming Editor:SciTE 1.78
Graphing Engines:Matplotlib 0.98.5 & R
GUI:HTML & JavaScript
Scheduler:Windows Task Scheduler
Shells:Command.com (DOS) & Cygwin (Bash)
Historical Quotes:CSI & Yahoo Finance

Operating System
Choosing Windows as the operating system is mainly out of convenience. As you can see above, the only real item that would prevent a full move to Linux is the historical quote provider, CSI. Everything else can run on another platform or a suitable alternative is available.

Another reason I've stayed with Windows is due to my current job (windows shop). But, I will admit, I have been very close to switching to a Mac the past few months or possibly OpenSUSE. Just haven't taken the bite yet.

On a side note, prior to my current employer...I worked for a University that was really ahead of its time. Every program we developed had to pass a compatibility test, "Could it easily run on another platform?" While this at times was an impossible task due to user requirements...we still always coded with this compatibility in mind. And I've kept this same philosophy in developing the trading simulation engine.

Programming Languages
I'm originally a Cobol programmer. Yes, that's right...if you've never heard of one...now you're reading a blog by one. Cobol programmers, the good ones, are very keen on whitespace. When you're throwing a lot of code around...the whitespace is what keeps you sane. And so, when I was trying out the various scripting languages back in the day...Python really struck my fancy. I spent the better part of 9 years trying to force programmers to keep the code pretty in Cobol. Only to see Python come around and truly force programmers to code clean. Over the years, I have worked in various other languages, but I've always stuck with Python.

I think another reason I chose Python was due to WealthLab's Scripting language (Pascal-based). I felt I could build an environment similar to WealthLab that would offer the same scripting ease. So far, Python has done a great job in keeping the framework simple and extensible.

Another language I have used from time to time in my trading is R. I use R mainly to analyze trading results. A few years ago, I actually developed a prototype of the trading simulation engine in R. But, it was too slow. The loops killed it. With the recent development of Revolution Computing's ParallelR...I've often wondered what the results would now be. But, I'm past the point of return with the engine in Python. But, as far as fast analysis of CSV files...it is really hard to beat R.

Databases
I struggled several years with how to store and retrieve the historical price series data for the trading simulation engine. The main problem was the data could not fit into memory yet access had to be extremely fast. So, for years I used plain CSV files to store the data.

Basically, reading the CSV files from CSI and writing out new price CSV files with my fixes from possible bad data along with additional calculated fields. At first I stored the data into 1 big CSV file. Then used either the DOS sort or Bash sort command to sort the file by date. I was afraid I would run into file size limits (at the time I was on Windows XP 32-bit). So, I started writing the data out to thousands of files broken down by date. Basically, each file was a date containing all the prices for that date. Worked really well...except analysis on the backend became difficult. Plus, it felt kludgy.

I had always tried to use regular databases for the pricing backend...but they couldn't handle the storage and retrieval rates I required. Just too slow. And yes, I tried all of them: MySQL, PostGreSQL, Firebird, Berkely DB, SQLite, etc.

It wasn't until I read an article by Bret Taylor covering how FriendFeed uses MySQL that I had an idea as to how to use a database to get the best of both worlds - fast storage & retrieval along with slick and easy access to the data. That's when I went back to SQLite and began a massive hacking of code while on a Texas Hill Country vacation. Really bumped the trading simulation engine to another level. The trick to fast storage & retrieval? Use less but bigger rows.

For a memory database? I use numpy. It's a fantastic in-memory multi-dimensional storage tool. I dump the price series from SQLite to numpy to enable row or column-wise retrieval. Only recently have I found the performance hit is a little too much. So, I've removed numpy from one side of the framework. And contemplating removing it from the other side as well. It takes more work to replicate numpy via a dictionary of dictionaries of lists. But, surprisingly, it is worth the effort when dealing with price series. Which means, I may not use numpy in the engine for long. Still a great tool to use for in-memory storage.

Graphing Engines and GUI
I really try to keep it simple in the front-end of the trading framework. I use Matplotlib to visualize price or trading results. And HTML along with Javascript to display trading statistics. Honestly, not a lot has gone into this side of things. Still very raw. My goal for 2010 is to work more in this area.

I have used R quite a bit in analyzing the output of the trading backtests. R is really powerful here. Quickly and easily chart and/or view pretty much any subset of the data you wish.

If there's certain items I look at over and over in the backtests...I'll typically replicate in Python & Matplotlib and include in the backtest results.

Editor, Schedulers, and Shells.
SciTE is hands down my favorite Python editor. I don't like the fancy IDE type stuff. SciTE keeps it simple.

Windows Task Scheduler is for the birds. I should know...my main job is centered around Enterprise Scheduling. But, the windows task scheduler gets the job done most of the time. I just have to code around a lot of the times it misses or doesn't get things quite right. Which is okay...that's life. That's one of the main reasons I have thought about switching to a nix box for cron and the like.

The DOS shell or Bash shell...I don't get too fancy in either. I do use the Bash shell quite a bit in performing global changes in the python code. Or back when the database was CSV based. Again, nix boxes win here. But, us windows developers hopefully can always get a copy of Cygwin to save the day.

Historical Quotes
I have used CSIdata for many years. Mainly for the following reasons:
  • Dividend-adjusted quotes which are essential if analyzing long-term trading systems.
  • Adjusted closing price - needed if you wish to test the exclusion of data based on the actual price traded - not the split-adjusted price.
  • CSV files - CSI does a great job of building and maintaining CSV files of price history.
  • Delisted data - I thought this would be a bigger deal but didn't really impact test results...but still nice to have for confirmation.
  • Data is used by several hedge funds and web sites such as Yahoo Finance.
The only drawback I have to CSI is the daily limit to the number of stocks you can export out of the product. It can get frustrating trying to work around the limit. Of course, you can always pony up for a higher limit.

This covers Part I of the series. Next up? The type of analysis I perform with the trading framework.

Later Trades,

MT

Russell 3000 Daily Stats (02/11/10)

Key Figures Russell 3000 IWV
Total Active Components2975 1
Total New Listings this period0 0
Total Inactive this period0 0
# All-time Closing Highs 13 (0.44%) 0 (0.00%)
# All-time Closing Lows 4 (0.13%) 0 (0.00%)

# Higher Closes 2486 (83.56%) 1 (100.00%)
# Lower Closes 423 (14.22%) 0 (0.00%)

Total Gains/Losses $979.61 (1.38%) $0.63 (1.00%)
Average True Range (3.94%) (1.85%)

* Results are cumulative for the period.

Price verification found 0 errors

Wednesday, February 10, 2010

Russell 3000 Daily Stats (02/10/10)

Key Figures Russell 3000 IWV
Total Active Components2975 1
Total New Listings this period0 0
Total Inactive this period0 0
# All-time Closing Highs 3 (0.10%) 0 (0.00%)
# All-time Closing Lows 8 (0.27%) 0 (0.00%)

# Higher Closes 1351 (45.41%) 0 (0.00%)
# Lower Closes 1530 (51.43%) 1 (100.00%)

Total Gains/Losses $-37.08 (-0.05%) $-0.07 (-0.11%)
Average True Range (3.46%) (1.43%)

* Results are cumulative for the period.

Price verification found 0 errors

Tuesday, February 09, 2010

Russell 3000 Daily Stats (02/09/10)

Key Figures Russell 3000 IWV
Total Active Components2975 1
Total New Listings this period0 0
Total Inactive this period0 0
# All-time Closing Highs 6 (0.20%) 0 (0.00%)
# All-time Closing Lows 5 (0.17%) 0 (0.00%)

# Higher Closes 2465 (82.86%) 1 (100.00%)
# Lower Closes 454 (15.26%) 0 (0.00%)

Total Gains/Losses $937.69 (1.33%) $0.85 (1.37%)
Average True Range (3.80%) (2.20%)

* Results are cumulative for the period.

Price verification found 0 errors

Monday, February 08, 2010

Russell 3000 Daily Stats (02/08/10)

Key Figures Russell 3000 IWV
Total Active Components2975 1
Total New Listings this period0 0
Total Inactive this period2 0
# All-time Closing Highs 2 (0.07%) 0 (0.00%)
# All-time Closing Lows 15 (0.50%) 0 (0.00%)

# Higher Closes 662 (22.25%) 0 (0.00%)
# Lower Closes 2248 (75.56%) 1 (100.00%)

Total Gains/Losses $-602.84 (-0.85%) $-0.57 (-0.91%)
Average True Range (3.71%) (1.44%)

* Results are cumulative for the period.

Price verification found 0 errors

Sunday, February 07, 2010

TaylorTrade weekly Stats (02/01/10-02/05/10)

Key Figures TaylorTrade SPY
Active Components29 1
Entries this period0 0
Exits this period0 0
IPOs this period0 0
Inactive this period0 0
Missing in PriceDB0 0
# 1yr Closing Highs 2 (0.80%) 0 (0.00%)
# 1yr Closing Lows 0 (0.00%) 0 (0.00%)

# Higher Closes 123 (49.20%) 3 (60.00%)
# Lower Closes 127 (50.80%) 2 (40.00%)

Total Gains/Losses $-29.10 (-0.21%) $-0.73 (-0.13%)
Average True Range (3.00%) (1.86%)

* Results are cumulative for the period.

Russell 3000 Weekly Stats (02/01/10-02/05/10)

Key Figures Russell 3000 IWV
Total Active Components2979 1
Total New Listings this period0 0
Total Inactive this period0 0
# All-time Closing Highs 30 (0.20%) 0 (0.00%)
# All-time Closing Lows 43 (0.29%) 0 (0.00%)

# Higher Closes 6851 (46.00%) 3 (60.00%)
# Lower Closes 7715 (51.80%) 2 (40.00%)

Total Gains/Losses $-867.29 (-0.24%) $-0.37 (-0.12%)
Average True Range (3.98%) (1.90%)

* Results are cumulative for the period.

Price verification found 0 errors

Friday, February 05, 2010

Russell 3000 Daily Stats (02/05/10)

Key Figures Russell 3000 IWV
Total Active Components2977 1
Total New Listings this period0 0
Total Inactive this period2 0
# All-time Closing Highs 3 (0.10%) 0 (0.00%)
# All-time Closing Lows 12 (0.40%) 0 (0.00%)

# Higher Closes 1765 (59.29%) 1 (100.00%)
# Lower Closes 1135 (38.13%) 0 (0.00%)

Total Gains/Losses $285.35 (0.40%) $0.17 (0.27%)
Average True Range (4.47%) (2.23%)

* Results are cumulative for the period.

Price verification found 0 errors

Thursday, February 04, 2010

Russell 3000 Daily Stats (02/04/10)

Key Figures Russell 3000 IWV
Total Active Components2979 1
Total New Listings this period0 0
Total Inactive this period0 0
# All-time Closing Highs 3 (0.10%) 0 (0.00%)
# All-time Closing Lows 16 (0.54%) 0 (0.00%)

# Higher Closes 159 (5.34%) 0 (0.00%)
# Lower Closes 2782 (93.39%) 1 (100.00%)

Total Gains/Losses $-2292.51 (-3.14%) $-2.04 (-3.17%)
Average True Range (4.71%) (3.19%)

* Results are cumulative for the period.

Price verification found 0 errors

Wednesday, February 03, 2010

Russell 3000 Daily Stats (02/03/10)

Key Figures Russell 3000 IWV
Total Active Components2979 1
Total New Listings this period0 0
Total Inactive this period0 0
# All-time Closing Highs 7 (0.23%) 0 (0.00%)
# All-time Closing Lows 8 (0.27%) 0 (0.00%)

# Higher Closes 932 (31.29%) 0 (0.00%)
# Lower Closes 1956 (65.66%) 1 (100.00%)

Total Gains/Losses $-427.90 (-0.58%) $-0.29 (-0.45%)
Average True Range (3.47%) (0.88%)

* Results are cumulative for the period.

Price verification found 0 errors

Tuesday, February 02, 2010

Russell 3000 Daily Stats (02/02/10)

Key Figures Russell 3000 IWV
Total Active Components2979 1
Total New Listings this period0 0
Total Inactive this period0 0
# All-time Closing Highs 13 (0.44%) 0 (0.00%)
# All-time Closing Lows 5 (0.17%) 0 (0.00%)

# Higher Closes 1816 (60.96%) 1 (100.00%)
# Lower Closes 1097 (36.82%) 0 (0.00%)

Total Gains/Losses $643.60 (0.88%) $0.78 (1.22%)
Average True Range (3.60%) (1.58%)

* Results are cumulative for the period.

Price verification found 0 errors