From 8446e65f5973460fa39e2fce0bedd7d1d9cbd98d Mon Sep 17 00:00:00 2001 From: kenorb Date: Mon, 9 Sep 2024 22:28:32 +0100 Subject: [PATCH] Moves Strategy class to subdir --- .github/workflows/test-strategy.yml | 73 +++++++++++++++++++ .github/workflows/test.yml | 2 - EA.mqh | 2 +- Strategy.enum.h => Strategy/Strategy.enum.h | 0 Strategy.mqh => Strategy/Strategy.h | 26 +++---- .../Strategy.struct.h | 4 +- .../Strategy.struct.pricestop.h | 2 +- Strategy/tests/Makefile | 12 +++ .../tests/Strategy-RSI.test.mq4 | 0 .../tests/Strategy-RSI.test.mq5 | 12 +-- {tests => Strategy/tests}/Strategy.test.cpp | 4 +- .../tests/Strategy.test.mq4 | 0 .../tests/Strategy.test.mq5 | 6 +- tests/CompileTest.mq5 | 2 +- 14 files changed, 114 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/test-strategy.yml rename Strategy.enum.h => Strategy/Strategy.enum.h (100%) rename Strategy.mqh => Strategy/Strategy.h (99%) rename Strategy.struct.h => Strategy/Strategy.struct.h (99%) rename Strategy.struct.pricestop.h => Strategy/Strategy.struct.pricestop.h (99%) create mode 100644 Strategy/tests/Makefile rename tests/StrategyTest-RSI.mq4 => Strategy/tests/Strategy-RSI.test.mq4 (100%) rename tests/StrategyTest-RSI.mq5 => Strategy/tests/Strategy-RSI.test.mq5 (96%) rename {tests => Strategy/tests}/Strategy.test.cpp (94%) rename tests/StrategyTest.mq4 => Strategy/tests/Strategy.test.mq4 (100%) rename tests/StrategyTest.mq5 => Strategy/tests/Strategy.test.mq5 (98%) diff --git a/.github/workflows/test-strategy.yml b/.github/workflows/test-strategy.yml new file mode 100644 index 000000000..0577f4c47 --- /dev/null +++ b/.github/workflows/test-strategy.yml @@ -0,0 +1,73 @@ +--- +name: Test Strategy + +env: + TEST_PATH: Strategy/tests + TEST_SKIP: ${{ secrets.MT5_LOGIN == '' }} + +# yamllint disable-line rule:truthy +on: + pull_request: + paths: + - .github/workflows/test-strategy.yml + - Strategy/** + push: + paths: + - .github/workflows/test-strategy.yml + - Strategy/** + +jobs: + + compile: + name: Compile + uses: ./.github/workflows/compile-mql.yml + with: + artifact_prefix: mt + path: Strategy/tests + skip_cleanup: true + + test: + defaults: + run: + shell: bash + working-directory: ${{ env.TEST_PATH }} + name: Test + needs: compile + runs-on: ubuntu-latest + strategy: + matrix: + test: + - Strategy.test + - Strategy-RSI.test. + version: [5] + max-parallel: 4 + steps: + - uses: actions/download-artifact@v4 + with: + name: files-ex${{ matrix.version }} + - name: List compiled files + run: find . -name '*.ex?' -type f -print + - if: ${{ env.TEST_SKIP != true && env.TEST_SKIP != 'true' }} + name: Run ${{ matrix.test }} + uses: fx31337/mql-tester-action@master + with: + Login: ${{ secrets.MT5_LOGIN }} + Password: ${{ secrets.MT5_PASSWORD }} + Server: MetaQuotes-Demo + TestDeposit: 2000 + TestExpert: ${{ matrix.test }} + TestFromDate: ${{ matrix.year }}.01.01 + TestPeriod: M1 + TestSymbol: EURUSD + TestToDate: ${{ matrix.year }}.01.14 + # yamllint disable-line rule:line-length + UrlExpert: file://${{ github.workspace }}/${{ env.TEST_PATH }}/${{ matrix.test }}.ex${{ matrix.version }} + Version: 5 + - if: ${{ failure() && runner.debug == '1' }} + uses: mxschmitt/action-tmate@v3 + timeout-minutes: 20 + + cleanup: + name: Clean-up + needs: [compile] + uses: ./.github/workflows/cleanup.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d80482805..e4c38cdd7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,8 +46,6 @@ jobs: - EATest - MailTest - MarketTest - - StrategyTest - - StrategyTest-RSI - SummaryReportTest - TradeTest version: [5] diff --git a/EA.mqh b/EA.mqh index 82b5c9cb2..21f7aec76 100644 --- a/EA.mqh +++ b/EA.mqh @@ -46,7 +46,7 @@ #include "Storage/Data.struct.h" #include "Storage/Dict/Dict.h" #include "Storage/Dict/DictObject.h" -#include "Strategy.mqh" +#include "Strategy/Strategy.h" #include "SummaryReport.mqh" #include "Task/Task.h" #include "Task/TaskAction.enum.h" diff --git a/Strategy.enum.h b/Strategy/Strategy.enum.h similarity index 100% rename from Strategy.enum.h rename to Strategy/Strategy.enum.h diff --git a/Strategy.mqh b/Strategy/Strategy.h similarity index 99% rename from Strategy.mqh rename to Strategy/Strategy.h index 4f51cc261..f397ef318 100644 --- a/Strategy.mqh +++ b/Strategy/Strategy.h @@ -21,25 +21,25 @@ */ // Prevents processing this includes file for the second time. -#ifndef STRATEGY_MQH -#define STRATEGY_MQH +#ifndef STRATEGY_H +#define STRATEGY_H // Forward declaration. class Trade; // Includes. -#include "Indicator/Indicator.h" -#include "Market.mqh" -#include "Math/Math.h" -#include "Storage/Data.struct.h" -#include "Storage/Dict/Dict.h" -#include "Storage/Object.h" -#include "Storage/String.h" +#include "../Indicator/Indicator.h" +#include "../Market.mqh" +#include "../Math/Math.h" +#include "../Storage/Data.struct.h" +#include "../Storage/Dict/Dict.h" +#include "../Storage/Object.h" +#include "../Storage/String.h" #include "Strategy.enum.h" #include "Strategy.struct.h" -#include "Task/TaskManager.h" -#include "Task/Taskable.h" -#include "Trade.mqh" +#include "../Task/TaskManager.h" +#include "../Task/Taskable.h" +#include "../Trade.mqh" // Defines. // Primary inputs. @@ -1285,4 +1285,4 @@ class Strategy : public Taskable { return SerializerNodeObject; } }; -#endif // STRATEGY_MQH +#endif // STRATEGY_H diff --git a/Strategy.struct.h b/Strategy/Strategy.struct.h similarity index 99% rename from Strategy.struct.h rename to Strategy/Strategy.struct.h index 178197aed..74adf6efc 100644 --- a/Strategy.struct.h +++ b/Strategy/Strategy.struct.h @@ -31,10 +31,10 @@ #endif // Includes. -#include "Serializer/Serializer.h" +#include "../Serializer/Serializer.h" #include "Strategy.enum.h" #include "Strategy.struct.pricestop.h" -#include "Task/Task.struct.h" +#include "../Task/Task.struct.h" // Forward class declaration. class Strategy; diff --git a/Strategy.struct.pricestop.h b/Strategy/Strategy.struct.pricestop.h similarity index 99% rename from Strategy.struct.pricestop.h rename to Strategy/Strategy.struct.pricestop.h index 772a3862f..9794e49fd 100644 --- a/Strategy.struct.pricestop.h +++ b/Strategy/Strategy.struct.pricestop.h @@ -35,7 +35,7 @@ struct ChartParams; struct IndicatorParams; // Includes. -#include "Platform/Chart/Chart.struct.h" +#include "../Platform/Chart/Chart.struct.h" /* Structure for strategy price stops. */ struct StrategyPriceStop { diff --git a/Strategy/tests/Makefile b/Strategy/tests/Makefile new file mode 100644 index 000000000..e792364f0 --- /dev/null +++ b/Strategy/tests/Makefile @@ -0,0 +1,12 @@ +CC := g++ # C++ compiler +CFLAGS := -Wall -Wextra -std=c++17 -w # Compiler flags +SRCS := $(wildcard *.cpp) # Get all .cpp files in the current directory +OBJS := $(SRCS:.cpp=.o) # Object files corresponding to the source files + +all: $(OBJS) + +%.o: %.cpp + $(CC) $(CFLAGS) -c $< -o $@ + +clean: + rm -v $(OBJS) diff --git a/tests/StrategyTest-RSI.mq4 b/Strategy/tests/Strategy-RSI.test.mq4 similarity index 100% rename from tests/StrategyTest-RSI.mq4 rename to Strategy/tests/Strategy-RSI.test.mq4 diff --git a/tests/StrategyTest-RSI.mq5 b/Strategy/tests/Strategy-RSI.test.mq5 similarity index 96% rename from tests/StrategyTest-RSI.mq5 rename to Strategy/tests/Strategy-RSI.test.mq5 index 0ce6b299b..9b8c7df7d 100644 --- a/tests/StrategyTest-RSI.mq5 +++ b/Strategy/tests/Strategy-RSI.test.mq5 @@ -28,12 +28,12 @@ //#define __debug_verbose__ // Includes. -#include "../Indicator/tests/classes/IndicatorTfDummy.h" -#include "../Indicators/Oscillator/Indi_RSI.h" -#include "../Indicators/Tick/Indi_TickMt.h" -#include "../Platform/Chart/ChartMt.h" -#include "../Strategy.mqh" -#include "../Test.mqh" +#include "../../Indicator/tests/classes/IndicatorTfDummy.h" +#include "../../Indicators/Oscillator/Indi_RSI.h" +#include "../../Indicators/Tick/Indi_TickMt.h" +#include "../../Platform/Chart/ChartMt.h" +#include "../Strategy.h" +#include "../../Test.mqh" // Define strategy classes. class Stg_RSI : public Strategy { diff --git a/tests/Strategy.test.cpp b/Strategy/tests/Strategy.test.cpp similarity index 94% rename from tests/Strategy.test.cpp rename to Strategy/tests/Strategy.test.cpp index 30f554008..a3af9807d 100644 --- a/tests/Strategy.test.cpp +++ b/Strategy/tests/Strategy.test.cpp @@ -25,8 +25,8 @@ */ // Includes. -#include "../Strategy.mqh" -#include "../Platform/Platform.h" +#include "../Strategy.h" +#include "../../Platform/Platform.h" int main(int argc, char **argv) { // @todo diff --git a/tests/StrategyTest.mq4 b/Strategy/tests/Strategy.test.mq4 similarity index 100% rename from tests/StrategyTest.mq4 rename to Strategy/tests/Strategy.test.mq4 diff --git a/tests/StrategyTest.mq5 b/Strategy/tests/Strategy.test.mq5 similarity index 98% rename from tests/StrategyTest.mq5 rename to Strategy/tests/Strategy.test.mq5 index 6ebf91b9e..468f7963e 100644 --- a/tests/StrategyTest.mq5 +++ b/Strategy/tests/Strategy.test.mq5 @@ -28,9 +28,9 @@ struct DataParamEntry; // Includes. -#include "../Indicators/Indi_Demo.mqh" -#include "../Strategy.mqh" -#include "../Test.mqh" +#include "../../Indicators/Indi_Demo.mqh" +#include "../Strategy.h" +#include "../../Test.mqh" // Define strategy classes. class Stg1 : public Strategy { diff --git a/tests/CompileTest.mq5 b/tests/CompileTest.mq5 index 6cc33363b..59d0e9de2 100644 --- a/tests/CompileTest.mq5 +++ b/tests/CompileTest.mq5 @@ -84,7 +84,7 @@ struct IndicatorParams; #include "../Socket.mqh" #include "../Std.h" #include "../Storage/Singleton.h" -#include "../Strategy.mqh" +#include "../Strategy/Strategy.h" #include "../Storage/String.h" #include "../SummaryReport.mqh" #include "../Exchange/SymbolInfo/SymbolInfo.h"