Raspberry pi backtesting


Junior member
22 3
Just wanted to gauge interest:

As an eod trader who opens/closes at the open, I've developed a system for auto-downloading quotes from yahoo into a mysql database on a raspberry pi. It runs on open markets every 5 minutes and I retrieve the data into AmiBroker to do tech analysis on.

It's a fairly messy project at the moment with a limited frontend, but a pretty powerful backend that lets me see my open positions at a glance via webpage along with my stops and any alerts to tell me I need to close anything. I have it run as a webserver, so I can check on-the-go.

It also does a load of backtesting that I wanted to do for proof of concept (rather than optimization) - I feed it entries (from the past) and I can play with parameters on my exit strategy to see what happens. I actually started developing it for backtesting and it's sort of evolved.

I'm happy to share it (in its current messy state) and will try and refine it to make it a little more user friendly and not require you to know how to use mysql and linux bash but it would help if I knew
a) whether anyone at all is interested in it and
b) what elements if any you are interested in


5 0
Hi, I see you uses amibroker.I am a beginner trader and I jus tbought amibroker pro a couple months ago.And I can not get started with it .So maybe you can tell me how to start using it


Well-known member
437 12

you naturally did read the manuals, the -now free- book "Introduction to Amibroker" --- all available from the AmibrokerDotCom homepage. And you naturally watched the videos on that site. So you now only need to search for "Amibroker" at youtube...... and watch these videos as welll and you should be ready to go.


Junior member
22 3
Ok here it is!

Usual caveats - I will not be held responsible if this destroys your computer / raspberry pi etc! (it will not do that!)

You need to install
mysql and create the following:-

and you need to create a database called 'stsystem'

Some basic mysql will be helpful to make use of this, so if you get stuck here it's probably not worth pursuing any further!

Put all the files into a folder called stsystem in the home directory. Make sure all the script files are executable (chmod +x *.sh)

The tickers.txt file contains most of the NYSE, Nasdaq and FTSE symbols that you might want, but modify this to whatever you want.

If you run setup (cd into stsystem and ./setup.sh), it'll ask about preferences. This was for a backtesting strategy that has subsequently been removed, so just ignore it and use the defaults (the only input you may want to change is how far back you want data to go - default is start of 2008). You want to change the response to y for the tickers question.

If everything is running correctly, it should at this point be querying all the tickers in your list to work out what exchange they are on.

When it's complete you will have a tickers table in your database.

This will take a while, but now you want to get all your historic data...

once that's done you can set up your crontab so that it automatically updates your data...

crontab -e

This is what you want to add...
*/5 * * * 1-5 /home/pi/stsystem/get_current_quotes.sh >/dev/null 2>&1
* * * * 1-5 /home/pi/stsystem/exchange_open.sh >/dev/null 2>&1
#23 21 * * 1-5 /home/pi/stsystem/run_scanner.sh >/dev/null 2>&1
0 9 * * 6 /home/pi/stsystem/update_all_tickers.sh >/dev/null 2>&1

If you get as far as this, then you should have everything set up so that the system pulls quotes every 5 mins when the relavent exchange is open and consolidates with the historic data every saturday morning.

For integration with amibroker, you need to install the odbc plugin


I had issues with antivirus, so maybe disable it while you set up.

In order to allow your mysql database to be accessed over a network, you need to create another user...
user 'amibroker' pass 'password' host '%' (% should let you access over the network)
figure out how to grant privileges (I've forgotten - sorry!!)

You need to create a new database in amibroker and use the settings in these screenshots...

In answer to your question Hittfeld, I'm using WIn 7 via parallels on a Mac.

There are a few bits in this programming that I haven't gone into that I'll explain if anyone gets as far as this - the scanner for example.

Hope it helps someone!!


  • stsystem.zip
    38.4 KB · Views: 144
  • database.PNG
    37.3 KB · Views: 548
  • configure.PNG
    66.5 KB · Views: 397
AdBlock Detected

We get it, advertisements are annoying!

But it's thanks to our sponsors that access to Trade2Win remains free for all. By viewing our ads you help us pay our bills, so please support the site and disable your AdBlocker.

I've Disabled AdBlock