Shard Detail

algo-backtester v0.1.0

An event-based backtester with a tree-hierarchy written in Crystal lang.

Install & Use

Add the following code to your project's shard.yml under:

dependencies to use in production
- OR -
development_dependencies to use in development

  github: fossabot/algo-backtest


Build Status FOSSA Status

Tree-Based Algorithmic Backtester

A modular, tree-based algorithmic backtester. The backtester is event-driven, has a historical stock price downloader via Tiingo's API and integrates with TA-Lib to integrate technical analysis into strategies.


Add algo-backtester to your shards.yml.


To use the TA-Lib integration, you need to have the TA-Lib already installed. You should probably follow their installation directions for your platform, but some suggestions are included below for reference.

Mac OS X
$ brew install ta-lib

Download and unzip to C:\ta-lib.

This is a 32-bit binary release. If you want to use 64-bit Python, you will need to build a 64-bit version of the library. Some unofficial (and unsupported) instructions for building on 64-bit Windows 10, here for reference:

  1. Download and Unzip
  2. Move the Unzipped Folder ta-lib to C:\
  3. Download and Install Visual Studio Community 2015
    • Remember to Select [Visual C++] Feature
  4. Build TA-Lib Library
    • From Windows Start Menu, Start [VS2015 x64 Native Tools Command Prompt]
    • Move to C:\ta-lib\c\make\cdr\win32\msvc
    • Build the Library nmake

You might also try these unofficial windows binaries for both 32-bit and 64-bit:


Download ta-lib-0.4.0-src.tar.gz and:

$ tar -xzf ta-lib-0.4.0-src.tar.gz
$ cd ta-lib/
$ ./configure --prefix=/usr
$ make
$ sudo make install

If you build TA-Lib using make -jX it will fail but that's OK! Simply rerun make -jX followed by [sudo] make install.


  • TA-Lib
  • Crystal dependencies (installed automatically via shards install):
    • VCR (for caching API requests)
    • halite (HTTP requests)
    • crystal_talib (TA-Lib C bindings)


require 'algo-backtester'

  bars ="AAPL", 3.months.ago,

  data = bars)

  strategy ="buy_and_hold")
  strategy.set_algo(, :buy)

  backtest = 1000.0_f64, data: data, strategy: strategy)




  • Add more specs (currently specs exist for non-algorithm classes/structs; need to extend to Algorithms)
  • Add better documentation
  • Add algorithms for more TA-Lib functions (currently just shows SMA as a prototype)
  • Compute + print more statistics (currently only shows Sharpe, Sortino and Cumulative Return)


  1. Fork it (
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request



FOSSA Status