Monthly Archives: September 2010

The Chronic: A Ruby Time Library

So, I was trying to use Ruby to get the date 6 months ago.  This is usually accomplished using the core extensions in ActiveSupport, which is OK, but it was too much work.  Then, I found an awesome article talking about Chronic, a minimal date/time parsing library for Ruby:

$ irb -rrubygems -rchronic
irb(main):001:0> Chronic.parse('6 months ago')
=> 2010-03-25 21:10:10 -0400

Wow that’s like so awesome.  I wonder what else it can do…

irb(main):002:0> Chronic.parse('three days after memorial day')
=> 2010-09-28 23:00:00 -0400

Well, that didn’t work.  Maybe I’ll submit a patch…  How about this?:

irb(main):014:0> Chronic.parse('three days after today')
=> 2010-09-28 23:00:00 -0400
irb(main):015:0> Chronic.parse('three days after tomorrow')
=> 2010-09-29 12:00:00 -0400

Well, that worked.  Patch time!


Well, I added US non-religious holidays to chronic.  It took me a while to figure it out, but it works!

irb(main):001:0> Chronic.parse("MLK Day")
=> 2011-01-17 12:00:00 -0500
irb(main):002:0> Chronic.parse("christmas eve")
=> 2010-12-24 12:00:00 -0500
irb(main):005:0> Chronic.parse("christmas")
=> 2010-12-25 12:00:00 -0500

Of course, my original example still fails, because Memorial Day is very special:

# (last Monday of May, traditionally 30 May)
text.gsub!(/\bMemorial Day\b/i, 'last monday in may')

The last selector still doesn’t work since it’s not an identifiable ordinal.  If someone wants to fix this, please do it.  Once things like “the last monday in may” work in all of Chronic, Memorial day will start working automatically.

You can get the ruby gem using the instructions here:

The git repository is here if you want to fork:

Deleting Bad Music with Amarok and BASH

I have been keeping track of bad music I have for a long time.  Today, I found out the number of bad tracks has hit 10,675.  That’s a lot of wasted space!  So, I tried to use an Amarok script to move the files to a directory I lovingly titled BADBADBAD, but it stopped after just a few tracks.  Strange…

Then, I saw in the Amarok playlist menu a way to export to a file!  Just add all the tracks you don’t like to a PLS file using the Export Playlist As… option, and run the following, replacing what’s necessary:

grep -E "^File" todelete.pls | cut -f 2 -d = | while read a; do mv "$a" /nexus/tardis/Music/BADBADBAD/; done

And you’re done!

hank@tardis:/nexus/tardis/Music/BADBADBAD$ du -sh
54G	.

I think a 54GB savings is pretty darn good!

I think TradeMonster might be the right answer

After spending quite a while looking at different online brokers, I think TradeMonster might be the one I’ll choose. Its commissions ($7.50/trade) are higher than TradeKing and Zecco (and barely higher than Scottrade), but I pay a lot less in commission every year than I do in margin interest. Trademonster’s margin interest rate is super-low, around 3.5% for $0-50,000. This will save me hundreds and hundreds of dollars per year over Scottrade. The cost in commissions will be a bit, but I’m estimating to save money overall. For a heavy margin trader that doesn’t day-trade, this is a pretty good deal.

Thoughts on Zecco

So, Zecco works OK, but there could be some major improvements to it.

1. Stock quotes in different tabs interfere with eachother. You’ll be reading about ADBE in one tab, and click to change the stock chart, and all of a sudden you’ll be looking at the chart for MSFT but it will still say ADBE at the top! This is really horrid, and I’m pretty sure I’m going to switch because of it.
2. The charting settings don’t seem to be saveable. I never want to see “Mountain” charts, only Candlesticks. I have to change this every single time. There’s a seperate popup window chart, but I hate popup windows.
3. The margin rates aren’t great – 7.5% for the amount I need. TradeKing is a full 1% less.
4. They don’t show your total daily percentage or dollar change in the positions pane – just the total gain in dollars and percent. I want the change for today! Scottrade had this and it was color coded too! This is not a hard feature to implement!
5. Their streaming quotes thing is pretty crappy – like, worse than Scottrade’s Java thing. And if I want the good one, I have to pay money. Lame!
6. They have a maximum character limit of 16 on password.  What possible reason is there for this?
7. Extremely slow transfers into the account. My request was processed the 20th, and it won’t be cleared until the 29th. Scottrade was instant! They would credit your account before the funds cleared once they verified your balance with your bank – it was awesome.

So, I think I might start the transfer process today.

TradeKing forces users to click their password so others can read it.

After learning about Zecco’s margin rates, I set out to find a brokerage with a very low margin rate, as this represents more of my cost than commissions.  Most traders will be different.  TradeKing seems to have a very low rate, and their commissions are very competitive with Zecco.  Yet the first thing I encountered when signing up for an account was the “ultra-secure” password entry:

Not only is this extremely insecure because of shoulder surfing, but it’s a problem for the blind.  Yet, TradeKing’s CEO seems to think this is OK as long as it stops some fraud due to keyloggers.  I can see their point, but anyone with a halfway secure password is going to shorten it to something reasonable to click, which makes the entire idea less secure than just allowing people to type.  And it’s your own fault if you get keylogged – if you’re worried about security, get virus protection and stop going to porn sites.  If you’re really worried, don’t use Windows.  The article discusses all the questions, but I’m very unhappy I can’t request to have this turned off unless I call customer service and say I have a disability.

Zecco: $0 Stock Trades! Too good to be true!?

Zecco is my new favorite discount brokerage.  They offer $4.50 trades for stocks and options, as well as $0 trades if you execute more than 25 trades a month or have more than $25,000 in your account.  This is huge, as it basically eliminates a big part of the cost of personal investing.  I highly recommend switching from whichever brokerage you’re using now.

They have a really nice user community interface that allows you to see what other users are doing in real-time, and how their portfolios are performing.  You can also opt to share your performance with others, though I have this turned off currently.

I managed to move my entire account from Scottrade just using a web browser and email (of course, I had to take a picture of a paper document I signed and send in an image of it).  But the ability to do this and avoid fax machines is very convenient.

I really like the options strategy builder.  It allows you to see a real-time plot of how different straddles, strangles, naked and covered options work.  It’s 100% customizable – you can plug in anything you want.

The only issue seems to be the margin rates, which are a lot higher than its competitors.  But if commissions are the main part of your cost, definitely consider Zecco.

Selling Covered Calls

I never really thought about it, but a good strategy would be to sell out of the money puts at your loss point depending on if you’re bullish on a stock. I always tell myself I should set stop loss orders at -5% on all my stock purchases, but I never do, and it ends up hurting my portfolio. This way, I could make some extra cash immediately from selling the contract, and the worst case is I have to sell the covered stock at the price I want!

Also, I could double that money buy selling an out-of-the-money call at my desired profit point – sure, this would be limiting my profit, which is normally unlimited, but I generally sell when I make 20-30% anyway, so why not make money on options when this doesn’t happen (which occurs more often)?

Update: I was wrong, I want to buy the puts or sell in the money calls. Selling in the money calls is a much better plan, since I can make a little premium going in, and still be protected from downside. Here’s a whole article about it.