mirror of
https://github.com/KhizarImran/backtestingfx.git
synced 2026-08-06 16:57:51 +00:00
feat: column-aware CSV loading and changelog
- Replaced manual CSV parsing with csv crate, columns now looked up by name - Fixed Rust example path and contract_size - Added CHANGELOG.md for release tracking Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,27 +1,23 @@
|
||||
use backtestingfx::types::Bar;
|
||||
use backtestingfx::broker::Broker;
|
||||
use backtestingfx::strategy::Strategy;
|
||||
use backtestingfx::engine::Engine;
|
||||
use backtestingfx::data::load_csv;
|
||||
|
||||
use _backtestingfx::broker::Broker;
|
||||
use _backtestingfx::data::load_csv;
|
||||
use _backtestingfx::engine::Engine;
|
||||
use _backtestingfx::strategy::Strategy;
|
||||
use _backtestingfx::types::Bar;
|
||||
|
||||
struct BuyEveryBar;
|
||||
|
||||
impl Strategy for BuyEveryBar {
|
||||
fn next (&mut self, bar: &Bar, broker: &mut Broker) {
|
||||
fn next(&mut self, bar: &Bar, broker: &mut Broker) {
|
||||
broker.close_all(bar.close, bar.timestamp); //closes any open positions
|
||||
broker.buy(bar.close, 1.0, bar.timestamp, None, None); // can be more complicated with buy, sells, close position, close all etc.
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let data = load_csv("examples/data/eurusd_lse_1h.csv");
|
||||
let mut engine = Engine::new(data, 10_000.0, 0.0, 0.00010);
|
||||
let data = load_csv("data/EURUSD_1H.csv");
|
||||
let mut engine = Engine::new(data, 10_000.0, 0.0, 0.00010, 1.0, 1.0);
|
||||
let mut strategy = BuyEveryBar;
|
||||
|
||||
let stats = engine.run(&mut strategy);
|
||||
println!("{}", stats);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user