I've got a quanitative trading model I want to test out in the real stock market. Right now, I'm writing some code to pull "live" quotes from yahoo, feed them to my model, and keep track of the trades my model makes. However, I feel like I'm re-investing the wheel. Sites like Investopedia have free stock trading "simulators" and I was wondering if there were any sites like this that also provide a free api. I'm primarily interesting in 3 things:

  1. Web service that I can interact with by GETing a url (i.e. www.site.com/?trade&id=1234&pw=abcd&action=BUY&shares=100)
  2. Supports placing orders
  3. Can return current positions

Or is this too much to ask for a free service?


This question sounds a lot like this one.

It's going to be difficult to find everything you need completely for free. In order to simulate trading sensibly, you will need a real-time data feed, and even the Yahoo! quotes you are getting are delayed (unless you are already paying for Yahoo's real-time service). If you have the cash available (and are willing to tolerate the monthly data fees of $10/month, which are waived if you actually trade), Interactive Brokers has a Paper Trader which is fully functional and simulates all the rules and limitations of your actual account.

AFAIK, IB is the top choice for semi-professional retail traders. For examples on this site, see 1, 2, 3, 4.

  • $\begingroup$ How much trading do you need to do to get the fees waived? $\endgroup$ – Zach Jul 27 '11 at 13:40
  • $\begingroup$ @Zach I think your data fees are reduced by \$1 for every \$3 of trading fees, so generate at least \$30/month in trading fees if you want to avoid being billed for data fees separately. $\endgroup$ – Tal Fishman Jul 27 '11 at 14:22
  • $\begingroup$ Great, thank you. $\endgroup$ – Zach Jul 28 '11 at 14:59

Whilst not free, Collective2 is, in my opinion, reasonably priced.

  • $\begingroup$ I actually based my request off Collective2... their web API is great, but I just wish it was free. Out of curiosity, have you used their site for automatic execution at a brokerage? I was thinking of setting up something like this: My Model -> Collective2 -> Interactive Brokers, and was wondering how well that would work for autotrading. I could of course connect my model directly to the IB API, but it looks like that's a pain to configure. How easy is Collective2 to use? $\endgroup$ – Zach Jul 19 '11 at 13:27
  • $\begingroup$ I've only used manual entry on their API for paper trading. $\endgroup$ – babelproofreader Jul 20 '11 at 11:33

You might want to look into Tradery as I think it allows you to run a test system for free (including back-testing).

  • $\begingroup$ Unfortunately, Tradery doesn't have an API for their virtual accounts. $\endgroup$ – Zach Jul 18 '11 at 21:08
  • 1
    $\begingroup$ Thought that there was - but you had to write the code within the tradery system. There was a question on StackOverflow a while ago with a list of Trading APIs. stackoverflow.com/questions/744699/real-life-trading-api $\endgroup$ – davewasthere Jul 20 '11 at 13:22

I've looked at Tradery and tried Collective2. Collective2 made it real easy, but it's not free. So I implemented the similar thing under Matlab by connecting to Google Finance Portfolio.

You can use the codes in the link below as a template; it's in matlab/java. One downside is that Google Finance Portfolio only saves the transaction date (YYYYMMDD) but not time (HHmmss), so intraday orders in the transaction history will not have the transaction time. If you use Matlab and want to try it out, use the 32-bit Matlab to run the codes.



I've been lurking here for a while now... hope these codes will be of some use to the members here. Happy (paper) trading.

  • $\begingroup$ Hey Ted, thanks for becoming an active particant. I look forward to seeing you around. $\endgroup$ – Tal Fishman Nov 26 '11 at 22:24

If you're willing to write a bit more code, the QuantSoftware ToolKit is able to backtest algorithms. Pulling stock data from Yahoo is simply a function call - it's even cached. If you know Python (especially NumPy and Pandas), you're ready to go.

From the wiki:

Key components of QSTK are:

  • Data: A data access package that enables fast reading of historical data (qstkutil.DataAccess).

  • Processing tools: Uses pandas, a Python package designed for time series evaluation of equity data.

  • Portfolio optimization: Using the CVXOPT library.

  • Event studies: An efficient event analyzer, Event_Profiler.

  • Simulation: A simple backtester, quicksim, that includes transaction cost modeling.

The source is also on GitHub.


Not the answer you're looking for? Browse other questions tagged or ask your own question.