Python stock trading simulator

Python stock trading simulator

Posted: SUPERBASES Date: 17.06.2017

I am interested about playing with algorithmic trading strategies. Does anyone know if there exists simulator or benchmark data I could possibly play with offline without actually making any investments?

This question is pretty broad; as it is, there is no mention of which instruments you're interested in. For the moment, I will assume you're interested in stocks You can get free end-of-day stock data from Yahoo Finance , which is sufficient for longer-term trading timelines; keep in mind that the shorter the trading cycle, the more stringent your data resolution needs to be.

If you are willing to put several thousand into a trading account, any number of brokers will be happy to send you live market intra-day market feeds; but you don't need money in an account for paper trading at least with my broker. I think the broker that is most flexible for programmers is Interactive Brokers. You can get sub-second data from them via an API , just understand they won't give you Tick-level granularity; they summarize their feeds, the specific details vary so it's better just to talk to them if you have tight granularity requirements.

Python Programming Tutorial - How to Make a Stock Screener

As for off-line simulation, you can do that with Ninja Trader, Interactive Brokers , and many other online brokers see What online brokers offer APIs? Keep it or toss in the trash for whatever value it brings. As a general rule, the shorter the timeframe, the more difficult the trades, and the harder it is to consistently make money. If you're unsure where to start with timelines, look at trading cycles of days or weeks at a time; then if you see too many opportunities passing you by, refine your system to a smaller timeline.

python stock trading simulator

The other thing to consider is how often you want to touch this code and tweak algorithms. The general rule is, as the trading cycles get shorter, you do more calibration and maintenance on your algorithms. It is not that unusual to find an algorithmic trader who wrote a good Swing-Trading platform that has worked as-is for the last decade.

On the other hand, Day Trading Algorithms tend to require more care and feeding based on changes in market conditions. Trade management is a rather big topic, and one you'll find addressed in-depth if you lurk around trader boards like Elite Trader. While it may sound out of place to discuss some of this in the same thread about automated trading platforms, I'm sure you'd agree that your assumptions and attitude have insidious ways of leeching into your code. I will share a few things off the top of my head:.

The information set forth herein has been obtained or derived from sources believed by author to be reliable. This data has been provided to you solely for information purposes and does not constitute an offer or solicitation of an offer, or any advice or recommendation, to purchase any securities or other financial instruments, and may not be construed as such. By using any of this information, you expressly agree that all risks associated with the performance and quality of the information is assumed solely by you.

The author shall not be liable for any direct, indirect, incidental, special or consequential damages arising out of the use of or inability to use the information, even if the author has been advised of the possibility of such damages. The information is made available by the author "as is" and "with all faults".

Is this the kind of data you're looking for? Ohio Department of Finance, Financial Data Finder. This page might also be of help: Yahoo Finance Download, HTTP Interface parameters. Not offline, but still a good link to give to other readers: Its primarily used for backtesting algorithmic trading strategies. It is very fast and can download and get data from a variety of free sources. Try with Cloud based backtesting Engines like Quantconnect and Quantopian. Quantopian is a python based IDE where you can write strategies and backtest online.

You can do simulation trades as well as real trades with Interactive Broker. Quanconnect is similar to Quantopian and they used. Net Based IDE and you can run simulation trades and live trader with the discount broker tradier.

QuantGo lets you rent high frequency data sets rather than buying them. I really like it because it's only a couple hundred per month instead of thousands. Quandl has some good free data sets if you are only interested in trading at longer time intervals.

Their stock data API is pretty slick link. One alternative would be PyAlgoTrade http: Its an open source Python library to backtest trading strategies. By posting your answer, you agree to the privacy policy and terms of service. Stack Overflow Questions Developer Jobs Documentation beta Tags Users. Sign up or log in to customize your list.

Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us. Log In Sign Up. Join the Stack Overflow Community. Stack Overflow is a community of 7. Join them; it only takes a minute: Bob 1, 12 54 Stocks Bonds Commodities Forex Derivatives like Futures or Options For the moment, I will assume you're interested in stocks Trading Timeframe As a general rule, the shorter the timeframe, the more difficult the trades, and the harder it is to consistently make money.

Trading Style Closely related to timelines are your trading tactics. I will share a few things off the top of my head: Success is primarily about preventing losing trades. Good trades take care of themselves. Always trade with a stop-loss.

Conventional wisdom is, "Your first loss is your smallest loss". If things start going south, figure out a way to consistently get out while keeping most of your previous profits; holding losers is the fast path to becoming a boiled frog.

There is no such thing as "Too High" or "Too low". The market moves in herd-mentality and doesn't care what you think it should be doing. Closely related to point "3": Trade with the long-term trend. Fighting the trend affectionately known as "counter-trending" may sound attractive to natural contrarians, but you need to be very good to do it well.

Trading is enough work without trying to counter-trend. Trading within the hour after a Federal Reserve market announcement is very difficult; I think it's just better to be out of the market.

The quick profits can look seductive, but this is where the pros love to eat the amateur traders; brutal reversals can develop within a couple of minutes. Avoid trading on margin unless you have a proven technique that you have backtested with at least a couple years of data.

The first thrity-minutes and last hour of regular trading can see rapid changes in volatility. Regarding profit taking, "Bulls get fed, hogs get slaughtered" If you find that you are not making profits, consider evaluating your trading frequency; reducing your trades to a minimum is key to success, otherwise, slippage , commissions and fees on junk trades will eat your profits.

Coding Log every data point and decision you make in your code; three logging levels works for me.

Stock Market Simulation | Video Lectures | Introduction to Computer Science and Programming | Electrical Engineering and Computer Science | MIT OpenCourseWare

Trading is an inexact task, and tiny changes can blow up your previously-profitable algorithm. If something blows up, you need a way to compare against what was working. Prototype in a scripting language; if something is slow, you can always offload to a compiler later. I think python is a fantastic for quantitative finance Compute a compounded return series in Python I started off with plain-ole csv, but I'm in process of migrating to HDF5 for tick data archives Trade-simulation is deceptive: Simulated trades don't have problems filling due to low- liquidity or high-demand for the instrument; depending on market conditions, my real trades can see two or three seconds delay from the time I send the order to the time I get a fill.

Simulated trades also don't get data blackouts; be sure to include sudden data loss and how to recover in your plans.

Lower-cost brokers tend to suffer more blips and blackouts, but if your timeframe is longer, it may be something you can ignore.

Legal The information set forth herein has been obtained or derived from sources believed by author to be reliable. Ohio Department of Finance, Financial Data Finder This page might also be of help: Yahoo Finance Download, HTTP Interface parameters And this one: Free financial resources Not offline, but still a good link to give to other readers: Google Finance API I hope I understood the question correctly. Try with Cloud based backtesting Engines like Quantconnect and Quantopian Quantopian is a python based IDE where you can write strategies and backtest online.

Rajandran R 1 1 Reed Jessen 89 7.

Error (Forbidden)

Gabriel 1 4. Sign up or log in StackExchange. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Stack Overflow works best with JavaScript enabled. MathOverflow Mathematics Cross Validated stats Theoretical Computer Science Physics Chemistry Biology Computer Science Philosophy more 3. Meta Stack Exchange Stack Apps Area 51 Stack Overflow Talent.

Rating 4,5 stars - 428 reviews
inserted by FC2 system