
The Fantasy Stock Exchange app on Facebook gives you up to $50 million in play money to trade securities on the major market indices (NYSE, Nasdaq, etc) using a combination of buy/sells and short/covers.
One thing the FSX app does not currently offer is a way to place stop loss orders. Say you’ve purchased 500 shares of the el Goog at $510. You think it’ll go up, but don’t want to hold on if the stock drops off precipitously, say to $500 or less. So you place a stop loss order with your broker or automated trading system to automatically sell your GOOG shares if the price hits $500.
With FSX Trader you can do the following (all automated if run using a cron job):
- sell a stock when it reaches a high of $X
- cover a stock if it reaches a low of $X
- short a stock if it reaches a specified high
- buy a stock if it reaches a pre-determined low
It’s a simple ruby command-line app configured via a YAML file on your localhost. (target audience would definitely have to be a bit geeky + into stocks)
How to Install the App on OSX or Linux (command-line based)
If you want to tinker around with the command-line client app itself, grab the gem using:
sudo gem install fsxtrader
Documentation is located at fsxtrader.rubyforge.org (rdoc).
Settuping up FSX Trader
Once installed, to setup the config file which by default is located at ~/.fsx_config.yml:
fsxtrader setup
Next, edit that file by hand or using your system editor with:
fsxtrader edit
To see if it actually works, you might place an order to buy AAPL if it’s price is greater than $1, or some other kind of trade that will always execute.
Next to actually kick off FSX Trader and potentially make trades for you (if your trading conditions are met), do a:
fsxtrader
To get more help on the various command-line options:
fsxtrader --help
Making it Useful
If this is to actually be useful, you’ll need to setup some kind of cron job for it and then remember to enter your stop-loss, etc orders into the YAML file as you trade. See the documentation for more on this.
Inspect the Code
If you want to see how I’m automating interaction with Facebook using WWW::Mechanize, stay tuned for future posts or visit the download page and grab the fsxtrader-1.0.0.tgz file.
The following should work on OSX/linux:
wget http://rubyforge.org/frs/download.php/24414/fsxtrader-1.0.0.tgz
tar xvzf fsxtrader-1.0.0.tgz
cd fsxtrader-1.0.0
And open in your favorite text editor. The files to look at are: lib/fsxtrader.rb and all those in lib/fsxtrader/.
Anyway, I don’t expect this to be a massively popular Ruby gem, but if you’re a stock geek like me, check it out and let me know what you think!







