-
-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #621 from EA31337/dev-exchange
Initial Exchange class
- Loading branch information
Showing
8 changed files
with
280 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--- | ||
name: Test Exchange | ||
|
||
# yamllint disable-line rule:truthy | ||
on: | ||
pull_request: | ||
paths: | ||
- 'Exchange/**.h' | ||
- 'Exchange/**.mq?' | ||
- '.github/workflows/test-exchange.yml' | ||
push: | ||
paths: | ||
- 'Exchange/**.h' | ||
- 'Exchange/**.mq?' | ||
- '.github/workflows/test-exchange.yml' | ||
|
||
jobs: | ||
|
||
Compile: | ||
runs-on: windows-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Compile | ||
uses: fx31337/mql-compile-action@master | ||
with: | ||
init-platform: true | ||
path: 'Exchange/tests' | ||
verbose: true | ||
- name: Print compiled files | ||
run: '(Get-ChildItem -Recurse -Path . -Include *.ex[45]).fullname' | ||
shell: powershell | ||
- name: Upload artifacts (MQL4) | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: files-ex4 | ||
path: '**/*.ex4' | ||
- name: Upload artifacts (MQL5) | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: files-ex5 | ||
path: '**/*.ex5' | ||
|
||
Exchange-Tests-MQL4: | ||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: Exchange/tests | ||
needs: Compile | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
test: | ||
- Exchange.test | ||
steps: | ||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: files-ex4 | ||
- name: Run ${{ matrix.test }} | ||
uses: fx31337/mql-tester-action@master | ||
with: | ||
Script: ${{ matrix.test }} | ||
timeout-minutes: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
//+------------------------------------------------------------------+ | ||
//| EA31337 framework | | ||
//| Copyright 2016-2021, EA31337 Ltd | | ||
//| https://github.com/EA31337 | | ||
//+------------------------------------------------------------------+ | ||
|
||
/* | ||
* 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/>. | ||
* | ||
*/ | ||
|
||
/** | ||
* Exchange class. | ||
*/ | ||
#ifndef EXCHANGE_H | ||
#define EXCHANGE_H | ||
|
||
// Includes. | ||
#include "../Account.mqh" | ||
#include "../DictObject.mqh" | ||
#include "../SymbolInfo.mqh" | ||
#include "../Trade.mqh" | ||
#include "Exchange.struct.h" | ||
|
||
class Exchange { | ||
protected: | ||
DictObject<string, Account> accounts; | ||
DictObject<string, SymbolInfo> symbols; | ||
DictObject<string, Trade> trades; | ||
ExchangeParams eparams; | ||
|
||
public: | ||
/** | ||
* Class constructor without parameters. | ||
*/ | ||
Exchange(){}; | ||
|
||
/** | ||
* Class constructor with parameters. | ||
*/ | ||
Exchange(ExchangeParams &_eparams) : eparams(_eparams){}; | ||
|
||
/** | ||
* Class deconstructor. | ||
*/ | ||
~Exchange() {} | ||
|
||
/* Adders */ | ||
|
||
/** | ||
* Adds account to the list. | ||
*/ | ||
void AccountAdd(Account &_account, string _name) { accounts.Set(_name, _account); } | ||
|
||
/** | ||
* Adds symbol to the list. | ||
*/ | ||
void SymbolAdd(SymbolInfo &_sinfo, string _name) { symbols.Set(_name, _sinfo); } | ||
|
||
/* Removers */ | ||
|
||
/** | ||
* Removes account from the list. | ||
*/ | ||
void AccountRemove(string _name) { accounts.Unset(_name); } | ||
|
||
/** | ||
* Removes symbol from the list. | ||
*/ | ||
void SymbolRemove(string _name) { symbols.Unset(_name); } | ||
}; | ||
#endif // EXCHANGE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
//+------------------------------------------------------------------+ | ||
//| EA31337 framework | | ||
//| Copyright 2016-2021, EA31337 Ltd | | ||
//| https://github.com/EA31337 | | ||
//+------------------------------------------------------------------+ | ||
|
||
/* | ||
* 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 | ||
* Includes Exchange's structs. | ||
*/ | ||
|
||
#ifndef __MQL__ | ||
// Allows the preprocessor to include a header file when it is needed. | ||
#pragma once | ||
#endif | ||
|
||
// Forward class declaration. | ||
class Exchange; | ||
|
||
/* Defines struct for Exchange parameters. */ | ||
struct ExchangeParams { | ||
// Constructors. | ||
ExchangeParams() {} | ||
ExchangeParams(const ExchangeParams &_eparams) {} | ||
long id; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//+------------------------------------------------------------------+ | ||
//| EA31337 framework | | ||
//| Copyright 2016-2021, EA31337 Ltd | | ||
//| https://github.com/EA31337 | | ||
//+------------------------------------------------------------------+ | ||
|
||
/* | ||
* 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 Exchange class. | ||
*/ | ||
|
||
// Includes. | ||
#include "Exchange.test.mq5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//+------------------------------------------------------------------+ | ||
//| EA31337 framework | | ||
//| Copyright 2016-2021, EA31337 Ltd | | ||
//| https://github.com/EA31337 | | ||
//+------------------------------------------------------------------+ | ||
|
||
/* | ||
* 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 Exchange class. | ||
*/ | ||
|
||
// Includes. | ||
#include "../../Test.mqh" | ||
#include "../Exchange.h" | ||
|
||
// Test classes. | ||
class ExchangeDummy : public Exchange {}; | ||
|
||
// Global variables. | ||
ExchangeDummy ex_dummy; | ||
|
||
/** | ||
* Implements OnInit(). | ||
*/ | ||
int OnInit() { | ||
bool _result = true; | ||
return _result && GetLastError() == ERR_NO_ERROR ? INIT_SUCCEEDED : INIT_FAILED; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters