Skip to content

A common library to be used for back-testing trading algorithms.

Notifications You must be signed in to change notification settings

SamKelsey/backTester

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maven Central Coverage

BackTester

A library for backtesting trading algorithms. BackTester can be used to test your trading algorithms against years of historic data with only a few lines of code. Quickly see if your algorithm has potential or if you need to iterate!

Maven dependency

<dependency>
   <groupId>io.github.samkelsey</groupId>
   <artifactId>backtester</artifactId>
   <version>${backtester.version}</version>
</dependency>

Quickstart

To use with the default testing data, you need only 4 lines of code. Do the following steps:

  1. Create an algorithm class that implements Algorithm. See ExampleAlgorithm for a basic example.
  2. Instantiate an instance of DataSourceImpl.
  3. Instantiate an instance of BackTester using your Algorithm and DataSource from steps 1 & 2.
  4. Call backTester.run() to kick-off the simulation.
  5. View the results from the BrokerReader returned by the simulation!

Example

public class BackTesterExample {

   public static void main(String[] args) throws BackTesterException, IOException {
      Algorithm algorithm = new ExampleAlgorithm();
      DataSource dataSource = new DataSourceImpl();
     
      BackTester backTester = new BackTester(algorithm, dataSource);
     
      BrokerReader broker = backTester.run();
      broker.getPortfolio();
   }
}

The above example will return a BrokerReader, as a result. With this, you can view the effectiveness of your trading algorithm by looking at the final state of your broker account! 😃

Advanced uses

BackTester also allows for you to try out your own algorithms against your own datasets! For more information on how to do this, visit our documentation.

About

A common library to be used for back-testing trading algorithms.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages