All Projects → gobacktest → gobacktest

gobacktest / gobacktest

Licence: MIT license
event-driven backtesting framework written in golang

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to gobacktest

piker
#nontina, #paperhands,, #pwnzebotz, #tradezbyguille
Stars: ✭ 63 (-64.8%)
Mutual labels:  finance, financial-analysis, algorithmic-trading
Sequence-to-Sequence-Learning-of-Financial-Time-Series-in-Algorithmic-Trading
My bachelor's thesis—analyzing the application of LSTM-based RNNs on financial markets. 🤓
Stars: ✭ 64 (-64.25%)
Mutual labels:  finance, financial-analysis, algorithmic-trading
Pyportfolioopt
Financial portfolio optimisation in python, including classical efficient frontier, Black-Litterman, Hierarchical Risk Parity
Stars: ✭ 2,502 (+1297.77%)
Mutual labels:  finance, financial-analysis, algorithmic-trading
pyEX
Python interface to IEX and IEX cloud APIs
Stars: ✭ 407 (+127.37%)
Mutual labels:  finance, financial-analysis, algorithmic-trading
Research
Notebooks based on financial machine learning.
Stars: ✭ 714 (+298.88%)
Mutual labels:  finance, algorithmic-trading
wallstreet
Stock Quotes and Charts for the Terminal
Stars: ✭ 75 (-58.1%)
Mutual labels:  finance, financial-analysis
Gobacktest
event-driven backtesting framework written in golang
Stars: ✭ 113 (-36.87%)
Mutual labels:  finance, algorithmic-trading
Alphalens
Performance analysis of predictive (alpha) stock factors
Stars: ✭ 2,130 (+1089.94%)
Mutual labels:  finance, algorithmic-trading
Qlib
Qlib is an AI-oriented quantitative investment platform, which aims to realize the potential, empower the research, and create the value of AI technologies in quantitative investment. With Qlib, you can easily try your ideas to create better Quant investment strategies. An increasing number of SOTA Quant research works/papers are released in Qlib.
Stars: ✭ 7,582 (+4135.75%)
Mutual labels:  finance, algorithmic-trading
Turingtrader
The Open-Source Backtesting Engine/ Market Simulator by Bertram Solutions.
Stars: ✭ 132 (-26.26%)
Mutual labels:  finance, algorithmic-trading
Algorithmictrading
This repository contains three ways to obtain arbitrage which are Dual Listing, Options and Statistical Arbitrage. These are projects in collaboration with Optiver and have been peer-reviewed by staff members of Optiver.
Stars: ✭ 157 (-12.29%)
Mutual labels:  finance, algorithmic-trading
quantlib
The idiomatic rust implementation of the QuantLib C++ quantitative finance library
Stars: ✭ 89 (-50.28%)
Mutual labels:  finance, financial-analysis
portfoliolab
PortfolioLab is a python library that enables traders to take advantage of the latest portfolio optimisation algorithms used by professionals in the industry.
Stars: ✭ 104 (-41.9%)
Mutual labels:  finance, algorithmic-trading
Algobot
A C++ stock market algorithmic trading bot
Stars: ✭ 78 (-56.42%)
Mutual labels:  finance, algorithmic-trading
Quantmod
Quantitative Financial Modelling Framework
Stars: ✭ 578 (+222.91%)
Mutual labels:  finance, algorithmic-trading
Reddit Hyped Stocks
A web application to explore currently hyped stocks on Reddit
Stars: ✭ 173 (-3.35%)
Mutual labels:  finance, algorithmic-trading
Mlfinlab
MlFinLab helps portfolio managers and traders who want to leverage the power of machine learning by providing reproducible, interpretable, and easy to use tools.
Stars: ✭ 2,676 (+1394.97%)
Mutual labels:  finance, algorithmic-trading
Ttr
Technical analysis and other functions to construct technical trading rules with R
Stars: ✭ 238 (+32.96%)
Mutual labels:  finance, algorithmic-trading
Pandapy
PandaPy has the speed of NumPy and the usability of Pandas 10x to 50x faster (by @firmai)
Stars: ✭ 474 (+164.8%)
Mutual labels:  finance, algorithmic-trading
Introneuralnetworks
Introducing neural networks to predict stock prices
Stars: ✭ 486 (+171.51%)
Mutual labels:  finance, algorithmic-trading

Go Doc Travis Coverage Status Go Report Card Software License

Heads up: This is a framework in development, with only basic functionality.


gobacktest - Fundamental stock analysis backtesting

An event-driven backtesting framework to test stock trading strategies based on fundamental analysis. Preferably this package will be the core of a backend service exposed via a REST API.

Usage

Basic example:

package main

import (
  "github.com/dirkolbrich/gobacktest"
  "github.com/dirkolbrich/gobacktest/data"
  "github.com/dirkolbrich/gobacktest/strategy"
)

func main() {
  // initiate a new backtester
  test := gobacktest.New()

  // define and load symbols
  symbols := []string{"TEST.DE"}
  test.SetSymbols(symbols)

  // create a data provider and load the data into the backtest
  data := &data.BarEventFromCSVFile{FileDir: "../testdata/test/"}
  data.Load(symbols)
  test.SetData(data)

  // choose a strategy
  strategy := strategy.BuyAndHold()

  // create an asset and append it to the strategy
  strategy.SetChildren(gobacktest.NewAsset("TEST.DE"))
  
  // load the strategy into the backtest
  test.SetStrategy(strategy)

  // run the backtest
  test.Run()

  // print the results of the test
  test.Stats().PrintResult()
}

More example tests are in the /examples folder.

The single parts of the backtester can be set independently:

// initiate new backtester
test := &Backtest{}

// set the portfolio with initial cash and a default size and risk manager
portfolio := &gobacktest.Portfolio{}
portfolio.SetInitialCash(10000)

sizeManager := &gobacktest.Size{DefaultSize: 100, DefaultValue: 1000}
portfolio.SetSizeManager(sizeManager)

riskManager := &gobacktest.Risk{}
portfolio.SetRiskManager(riskManager)

test.SetPortfolio(portfolio)

// create a new strategy with an algo stack
strategy := gobacktest.NewStrategy("basic")
strategy.SetAlgo(
    algo.CreateSignal("buy"), // always create a buy signal on a data event
)

// create an asset and append to strategy
strategy.SetChildren(gobacktest.NewAsset("TEST.DE"))

// load the strategy into the backtest
test.SetStrategy(strategy)

// create an execution provider and load it into the backtest
exchange := &gobacktest.Exchange{
    Symbol:      "TEST",
    Commission:  &FixedCommission{Commission: 0},
    ExchangeFee: &FixedExchangeFee{ExchangeFee: 0},
}
test.SetExchange(exchange)

// choose a statistic and load into it the backtest
statistic := &gobacktest.Statistic{}
test.SetStatistic(statistic)

Dependencies

None so far. Only the standard library.

Basic components

These are the basic components of an event-driven framework.

  1. BackTester - general test case, bundles the following elements into a single test
  2. EventHandler - the different types of events, which travel through this system - data event, signal event, order event and fill event
  3. DataHandler - interface to a set of data, e.g historical quotes, fundamental data, dividends etc.
  4. StrategyHandler - generates a buy/sell signal based on the data
  5. PortfolioHandler - generates orders and manages profit & loss
    • (SizeHandler) - manages the size of an order
    • (RiskHandler) - manages the risk allocation of a portfolio
  6. ExecutionHandler - sends orders to the broker and receives the “fills” or signals that the stock has been bought or sold
  7. StatisticHandler - tracks all events during the backtests and calculates useful statistics like equity return, drawdown or sharp ratio etc., could be used to replay the complete backtest for later reference
    • (ComplianceHandler) - tracks and documents all trades to the portfolio for compliance reasons

Infrastructure example

An overviev of the infrastructure of a complete backtesting and trading environment. Taken from the production roadmap of QuantRocket.

  • General
    • API gateway
    • configuration loader
    • logging service
    • cron service
  • Data
    • database backup and download service
    • securities master services
    • historical market data service
    • fundamental data service
    • earnings data service
    • dividend data service
    • real-time market data service
    • exchange calendar service
  • Strategy
    • performance analysis service - tearsheet
  • Portfolio
    • account and portfolio service
    • risk management service
  • Execution
    • trading platform gateway service
    • order management and trade ledger service
    • backtesting and trading engine

Resources

Articles

These links to articles are a good starting point to understand the intentions and basic functions of an event-driven backtesting framework.

Other backtesting frameworks

General information on Quantitative Finance

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].