Skip to content

Commit

Permalink
Moves Strategy class to subdir
Browse files Browse the repository at this point in the history
  • Loading branch information
kenorb committed Sep 9, 2024
1 parent f2bb79a commit 8446e65
Show file tree
Hide file tree
Showing 14 changed files with 114 additions and 31 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/test-strategy.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ jobs:
- EATest
- MailTest
- MarketTest
- StrategyTest
- StrategyTest-RSI
- SummaryReportTest
- TradeTest
version: [5]
Expand Down
2 changes: 1 addition & 1 deletion EA.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
File renamed without changes.
26 changes: 13 additions & 13 deletions Strategy.mqh → Strategy/Strategy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -1285,4 +1285,4 @@ class Strategy : public Taskable<DataParamEntry> {
return SerializerNodeObject;
}
};
#endif // STRATEGY_MQH
#endif // STRATEGY_H
4 changes: 2 additions & 2 deletions Strategy.struct.h → Strategy/Strategy.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 12 additions & 0 deletions Strategy/tests/Makefile
Original file line number Diff line number Diff line change
@@ -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)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions tests/Strategy.test.cpp → Strategy/tests/Strategy.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions tests/StrategyTest.mq5 → Strategy/tests/Strategy.test.mq5
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion tests/CompileTest.mq5
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 8446e65

Please sign in to comment.