Take the 2-minute tour ×
Personal Finance & Money Stack Exchange is a question and answer site for people who want to be financially literate. It's 100% free, no registration required.

Is there any real time trading platform in linux in which one can test automated trading scripts written in python by ordering to a broker in a trial or demo account? Is IbPy the way to go? But IB does not offer any trial account.

share|improve this question
4  
People's answers are naming specific service providers (businesses), which is what the OP is asking for. They're good answers. It is not a question about programming (i.e. about his software), but about (real-world) businesses. It would be off-topic on a programmer's forum: too 'domain-specific' (the domain in this case being finance/trading), and not even about the software. –  ChrisW Feb 23 '12 at 4:32
    
This topic was closed in a programmers forum stating it was out of topic. I heard that Marketcetera is a python program which allows to connect to any broker supporting FIX protocol although don't know which brokers do that. –  pappu Feb 23 '12 at 9:29
1  
This is a general question on a narrow topic. The only justification to close the question is if you assume that trading cannot be a personal finance activity. All you need to do is watch a single commercial segment on CNBC to see that good or bad, trading platforms for individual investors are a real thing. –  duffbeer703 Feb 24 '12 at 16:17
add comment

4 Answers

up vote 9 down vote accepted

A couple options that I know of:

  • Interactive Brokers offers a "paper trading" mode to its account holders that allows you to start with a pretend stack of money and place simulated trades to test trading ideas. They also provide an API that allows you to interface with their platform programmatically for retrieving quotes, placing orders, and the such. As you noted, however, it's not free; you must hold a funded brokerage account in order to qualify for access to their platform. In order to maintain an account, there are minimums for required equity and monthly activity (measured in dollars that you spend on commissions), so you won't get access to their platform without having a decent amount of skin in the game.

    IB's native API is Java-based; IbPy is an unofficial wrapper that makes the interface available in Python. I've not used IB at all myself, but I've heard good things about their API and its accessibility via IbPy.

  • TD Ameritrade also offers an API that is usable by its brokerage clients. They do not offer any such "paper trading" mode, so you would need to "execute" transactions based on quotes at the corresponding trade times and then keep track of your simulated account history yourself. The API supports quote retrieval, price history, and trade execution, among other functions. TDA might be more attractive than IB if you're looking for a low-cost link into market data, as I believe their minimum-equity levels are lower.

    To get access, you'll need to sign up for an API developer account, which I believe requires an NDA. I don't believe there is an official Python implementation of the API, but if you're a capable Python writer, you shouldn't have trouble hooking up to the published interfaces.

Some caveats: as when doing any strategy backtesting, you'll want to be sure to be pessimistic when doing so, so your optimism doesn't make your trades look more successful than they would be in the real world. At a minimum, you'll want to ensure that your simulations transact at the posted bid/ask prices, not necessarily the last trade's price, as well as any commissions and fees associated with the trade. A more robust scheme would also take into account the depth of the order book (also known as level 2 quotes), which can cause additional slippage in the prices at which you buy/sell your security. An even more robust scheme would take into account the potential latency of trade execution, looking at all prices over some time period that covers the maximum expected latency and simulating the trade at the worst-possible price.

share|improve this answer
    
The paper trading account at Interactive Brokers does not necessarily require you to have a minimum monthly turnover, if you do not have the minimum you simply pay an inactivity fee (interactivebrokers.com/en/index.php?f=4969) and your market data subscriptions, which i personally think is a good deal for what the paper trading account has to offer. –  Waldfee Jan 17 '13 at 16:05
    
It's also worth pointing out that even though TD Ameritrade doesn't state this on their site, if you ask for access to the API and don't have $25,000 in your account, your request will be rejected. (I know this from personal experience). –  John Bensin Apr 15 '13 at 13:49
add comment

You can have a look at betabrokers. It's an simulated stock trading platform which is entirely email-based. You start with 10 000$ and you make transactions with commands in the subject line of the email (e.g. "buy 250$ AAPL" or "cover 20 shares of AAPL").

It should be straightforward to add an email interface to your python script.

share|improve this answer
add comment

I don't think any open source trading project is going to offer trial or demo accounts. In fact, I'm not clear on what you mean by this. Are you looking for some example data sets so you can see how your algorithm would perform historically? If you contact whatever specific brokers that you'd like to interface with, they can provide things like connection tests, etc., but no one is going to let you do live trades on a trial or demo basis.

For more information about setting this sort of thing up at home, here's a good link: < http://www.stat.cmu.edu/~abrock/algotrading/index.html >. It's not Python specific, but should give you a good idea of what to do.

share|improve this answer
add comment

In Japan, there's a competition well-lasting since 2004 or so where you can run your own software agent in a virtual market. Market data is updated from the real world everyday. And if your agent proves good, the organizer puts it into the real market.

The language is unfortunately limited to Java only to my knowledge. OS is not limited since your agent is supposed to run on the organizer's environment. English might not be well supported on their web site...

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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