Giter Club home page Giter Club logo

asset-rebalancing's Introduction

Asset Allocation Rebalancing Backtester

A command-line tool to backtest possible asset allocations in an investment portfolio given historical data sample with periodic (e.g. yearly) returns for each asset class.

build status

Prerequisites

Node.js installed.

Usage

npm start ./data/<data-file>.json ./data/<backtest-combinations-file>.json <resultsLimit>

Input files

Example of a JSON data file with historical yearly returns. Each array element contains an object where key is an asset name and value is change of the asset's price value in percent.

[
  {
    "year": 1972,
    "stocks": 18.76,
    "bonds": 11.41,
    "gold": 42.57
  },
  {
    "year": 1973,
    "stocks": -14.31,
    "bonds": 4.32,
    "gold": 66.96
  }
  // ...
]

Example of backtest inputs JSON file that contains limits of asset allocations for every asset that will be used for backtesting. The key of each asset should be equal to the respective header in the Data file.

{
  "stocks": { "min": 0.5, "max": 1, "step": 0.1 },
  "bonds": { "min": 0, "max": 0.5, "step": 0.1 },
  "gold": { "min": 0.2, "max": 0.8, "step": 0.1 }
}

Backtest algorithm will iterate over all valid allocation combinations and print out first best results specified by the resultsLimit number.

That is, from the input file from the example above, allocations under test will be:

[
  { "stocks": 0.5, "bonds": 0, "gold": 0.5 },
  { "stocks": 0.5, "bonds": 0.5, "gold": 0 },
  { "stocks": 0.7, "bonds": 0.3, "gold": 0 },
  { "stocks": 0.7, "bonds": 0, "gold": 0.3 },
  { "stocks": 1, "bonds": 0, "gold": 0 }
]

Customization

By default backtesting outputs best results by the goemetric mean of total return and total return adjusted by subtracting maximal drawdown. When needed, index.ts can be adjusted to use any other comparer or filter.

asset-rebalancing's People

Contributors

iredchuk avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.