Skip to content

Commit

Permalink
Adds BacktestEa and BacktestStrategy initial classes
Browse files Browse the repository at this point in the history
  • Loading branch information
kenorb committed Sep 9, 2024
1 parent 9ad2adf commit aea74bc
Show file tree
Hide file tree
Showing 11 changed files with 355 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test-platform-backtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ jobs:
matrix:
test:
- Backtest.test
- BacktestEa.test
- BacktestStrategy.test
version: [5]
max-parallel: 4
steps:
Expand Down
9 changes: 1 addition & 8 deletions Platform/Backtest/Backtest.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

/**
* @file
* Implements Backtest class for internally backtesting strategies.
* Implements Backtest class for internally backtesting.
*/

#ifndef __MQL__
Expand All @@ -36,7 +36,6 @@
class Backtest {
protected:
// Class variables.
EA *ea;

/**
* Init code (called on constructor).
Expand All @@ -53,10 +52,4 @@ class Backtest {
Init();
}

/**
* Class constructor.
*/
Backtest(EAParams &_eparam) : ea(new EA(_eparam)) {
Init();
}
};
63 changes: 63 additions & 0 deletions Platform/Backtest/BacktestEa.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//+------------------------------------------------------------------+
//| EA31337 framework |
//| Copyright 2016-2024, EA31337 Ltd |
//| https://ea31337.github.io |
//+------------------------------------------------------------------+

/*
* This file is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

/**
* @file
* Implements BacktestEa class for internally backtesting EA.
*/

#ifndef __MQL__
// Allows the preprocessor to include a header file when it is needed.
#pragma once
#endif

// Includes.
#include "Backtest.h"
#include "../../EA.mqh"

class BacktestEa : public Backtest {
protected:
// Class variables.
EA *ea;

/**
* Init code (called on constructor).
*/
void Init() {
// ...
}

public:
/**
* Class constructor.
*/
BacktestEa() {
Init();
}

/**
* Class constructor.
*/
BacktestEa(EAParams &_eparam) : ea(new EA(_eparam)) {
Init();
}
};
63 changes: 63 additions & 0 deletions Platform/Backtest/BacktestStrategy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//+------------------------------------------------------------------+
//| EA31337 framework |
//| Copyright 2016-2024, EA31337 Ltd |
//| https://ea31337.github.io |
//+------------------------------------------------------------------+

/*
* This file is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

/**
* @file
* Implements BacktestStrategy class for internally backtesting strategy.
*/

#ifndef __MQL__
// Allows the preprocessor to include a header file when it is needed.
#pragma once
#endif

// Includes.
#include "Backtest.h"
#include "../../Strategy.mqh"

class BacktestStrategy : public Backtest {
protected:
// Class variables.
Strategy *strat;

/**
* Init code (called on constructor).
*/
void Init() {
// ...
}

public:
/**
* Class constructor.
*/
BacktestStrategy() {
Init();
}

/**
* Class constructor.
*/
BacktestStrategy(Strategy *_strat) : strat(_strat) {
Init();
}
};
34 changes: 34 additions & 0 deletions Platform/Backtest/tests/BacktestEa.test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//+------------------------------------------------------------------+
//| EA31337 framework |
//| Copyright 2016-2024, EA31337 Ltd |
//| https://ea31337.github.io |
//+------------------------------------------------------------------+

/*
* This file is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* @file
* Test C++ compilation of Backtest class.
*/

// Includes.
#include "../Backtest.h"

int main(int argc, char **argv) {
// @todo

return 0;
}
28 changes: 28 additions & 0 deletions Platform/Backtest/tests/BacktestEa.test.mq4
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//+------------------------------------------------------------------+
//| EA31337 framework |
//| Copyright 2016-2024, EA31337 Ltd |
//| https://ea31337.github.io |
//+------------------------------------------------------------------+

/*
* This file is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* @file
* Test functionality of BacktestEa class.
*/

// Includes.
#include "BacktestEa.test.mq5"
50 changes: 50 additions & 0 deletions Platform/Backtest/tests/BacktestEa.test.mq5
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//+------------------------------------------------------------------+
//| EA31337 framework |
//| Copyright 2016-2024, EA31337 Ltd |
//| https://ea31337.github.io |
//+------------------------------------------------------------------+

/*
* This file is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* @file
* Test functionality of BacktestEa class.
*/

// Includes.
#include "../../../Test.mqh"
#include "../BacktestEa.h"

// Test BacktestEa.
bool TestBacktestEa01() {
bool _result = true;
// @todo
return _result;
}

/**
* Implements OnInit().
*/
int OnInit() {
bool _result = true;
assertTrueOrFail(TestBacktestEa01(), "Fail!");
return _result && GetLastError() == 0 ? INIT_SUCCEEDED : INIT_FAILED;
}

/**
* Implements Tick event handler.
*/
void OnTick() {}
34 changes: 34 additions & 0 deletions Platform/Backtest/tests/BacktestStrategy.test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//+------------------------------------------------------------------+
//| EA31337 framework |
//| Copyright 2016-2024, EA31337 Ltd |
//| https://ea31337.github.io |
//+------------------------------------------------------------------+

/*
* This file is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* @file
* Test C++ compilation of Backtest class.
*/

// Includes.
#include "../Backtest.h"

int main(int argc, char **argv) {
// @todo

return 0;
}
28 changes: 28 additions & 0 deletions Platform/Backtest/tests/BacktestStrategy.test.mq4
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//+------------------------------------------------------------------+
//| EA31337 framework |
//| Copyright 2016-2024, EA31337 Ltd |
//| https://ea31337.github.io |
//+------------------------------------------------------------------+

/*
* This file is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* @file
* Test functionality of BacktestStrategy class.
*/

// Includes.
#include "BacktestStrategy.test.mq5"
50 changes: 50 additions & 0 deletions Platform/Backtest/tests/BacktestStrategy.test.mq5
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//+------------------------------------------------------------------+
//| EA31337 framework |
//| Copyright 2016-2024, EA31337 Ltd |
//| https://ea31337.github.io |
//+------------------------------------------------------------------+

/*
* This file is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* @file
* Test functionality of BacktestStrategy class.
*/

// Includes.
#include "../../../Test.mqh"
#include "../BacktestStrategy.h"

// Test BacktestStrategy.
bool TestBacktestStrategy01() {
bool _result = true;
// @todo
return _result;
}

/**
* Implements OnInit().
*/
int OnInit() {
bool _result = true;
assertTrueOrFail(TestBacktestStrategy01(), "Fail!");
return _result && GetLastError() == 0 ? INIT_SUCCEEDED : INIT_FAILED;
}

/**
* Implements Tick event handler.
*/
void OnTick() {}
Loading

0 comments on commit aea74bc

Please sign in to comment.