Add the following code to your project's shard.yml under:
dependencies
to use in production
- OR -
development_dependencies
to use in development
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.
$ brew install ta-lib
Download ta-lib-0.4.0-msvc.zip
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:
- Download and Unzip
ta-lib-0.4.0-msvc.zip
- Move the Unzipped Folder
ta-lib
toC:\
- Download and Install Visual Studio Community 2015
- Remember to Select
[Visual C++]
Feature- 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:
https://www.lfd.uci.edu/~gohlke/pythonlibs/#ta-lib
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
usingmake -jX
it will fail but that's OK! Simply rerunmake -jX
followed by[sudo] make install
.
shards install
):
VCR
(for caching API requests)halite
(HTTP requests)crystal_talib
(TA-Lib C bindings)require 'algo-backtester'
bars = TiingoDataDownloader.new.query("AAPL", 3.months.ago, Time.now)
data = DataHandler.new(stream: bars)
strategy = Strategy.new("buy_and_hold")
strategy.set_algo(
RunMonthlyAlgorithm.new,
SignalAlgorithm.new(direction: :buy)
)
strategy.add_child Asset.new("AAPL")
backtest = Backtest.new(initial_cash: 1000.0_f64, data: data, strategy: strategy)
backtest.run
backtest.statistics.print_summary
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)