Crates.io | rs-backtester |
lib.rs | rs-backtester |
version | 0.1.2 |
source | src |
created_at | 2025-01-02 14:00:49.333091 |
updated_at | 2025-01-08 19:36:02.963595 |
description | Financial backesting library |
homepage | |
repository | https://github.com/nicferrari/backtester |
max_upload_size | |
id | 1501564 |
size | 853,742 |
rs-backtester is a financial backtesting library written entirely in Rust with the purpose of being easy-to-use yet flexible enough to allow a quick implementation of different strategies
To get started:
use std::error::Error;
use rs_backtester::backtester::{Backtest, Commission};
use rs_backtester::datas::Data;
use rs_backtester::strategies::{sma_cross};
use rs_backtester::report::{report};
let quotes = Data::load("GOOG.csv","GOOG")?;
let quotes = Data::new_from_yahoo("GOOG","1d","6mo")?;
let sma_cross_strategy = sma_cross(quotes.clone(), 10,20);
let sma_cross_tester = Backtest::new(quotes.clone(),sma_cross_strategy.clone(),100000f64, Commission::default());
report(sma_cross_tester);
sma_cross_tester.log(&["date","open","high","low","close","position","account","indicator"]);
plot(sma_cross_tester,plot_config)?;
sma_cross_tester.to_csv("sma_cross.csv")?;