-
Notifications
You must be signed in to change notification settings - Fork 7
/
action.yml
245 lines (243 loc) · 8.83 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# action.yml
---
author: kenorb
branding:
icon: bar-chart
color: green
description: Runs MQL program
inputs:
Currency:
default:
description: Deposit currency to use.
Expert:
default:
description: The name of the EA file to run.
Login:
default:
description: Account number.
Password:
default:
description: Password to the account.
Period:
default:
description: The default timeframe of the chart.
RunnerTimeout:
default: 600
description: Time to wait for platform to finish the test.
Server:
default:
description: Trade server.
Script:
default:
description: The name of the script to run.
TestDeposit:
description: Initial deposit to use for testing.
default: 10000
TestExecutionMode:
default: 0
description: Trading execution mode.
TestFromDate:
default:
description: The date to start testing (yyyy.mm.dd).
TestExpert:
default:
description: The name of the Expert Advisor file to test.
TestExpertParameters:
default:
description: The name of the SET file with EA parameters.
TestLeverage:
default:
description: Leverage to use for testing/optimization.
TestModel:
description: Specifies type of modelling to use.
default: 1
TestOptimization:
default: 0
description: Specifies testing mode.
TestOptimizationCriterion:
default:
description: Specifies optimization criterion.
TestPeriod:
description: Timeframe to use for the test.
TestReport:
default:
description: Specifies the name of the test report file
TestReplaceReport:
default:
description: Specifies whether to enable overwriting of the report file.
TestScriptParameters:
default:
description: The name of the SET file with script parameters.
TestSpread:
description: Specifies spread to use in points.
TestSymbol:
default: EURUSD
description: Symbol pair to test.
TestToDate:
default:
description: The date to finish testing (yyyy.mm.dd).
UrlExpert:
default: https://github.com/EA31337/EA31337-Libre/releases/download/v1.013/EA31337-Libre-v1.013.ex5
description: URL of Expert Advisor to download.
UrlPlatform:
default: https://download.mql5.com/cdn/web/metaquotes.software.corp/mt5/mt5setup.exe
description: URL of the platform to install.
Version:
default: 5
description: Version of platform to use.
name: EA Tester
outputs:
platform_fact:
description: Platform fact output.
value: ${{ steps.platform-fact-output.outputs.platform-fact || '{}' }}
runs:
steps:
- name: Creates playbook
uses: DamianReeves/[email protected]
with:
path: ansible/run.yml
write-mode: overwrite
contents: |
---
- name: Run test
hosts: all
tasks:
- name: Include main role
ansible.builtin.import_role:
name: ea31337.mt_runner
vars:
metatrader_setup_url: ${{ inputs.UrlPlatform }}
metatrader_version: ${{ inputs.Version }}
mt_runner_bt_mt4_config:
AutoConfiguration: !!str false
DataServer: 127.0.0.1:443
EnableDDE: !!str false
EnableNews: !!str false
Expert: ${{ inputs.Expert }}
ExpertParameters: ${{ inputs.TestExpertParameters }}
ExpertsDllConfirm: !!str false
ExpertsDllImport: !!str true
ExpertsEnable: !!str true
ExpertsExpImport: !!str true
ExpertsTrades: !!str true
ExpertsTradesConfirm: false
FTPAccount: 12345
FTPEnable: !!str false
FTPLogin: anonymous
FTPPassiveMode: !!str false
FTPPassword: anonymous
FTPPath: /inetpub
FTPPeriod: 10
FTPServer: ftp.example.com
Login: ${{ inputs.Login }}
Password: ${{ inputs.Password }}
Period: ${{ inputs.Period }}
Profile: default
ProxyEnable: !!str false
ProxyLogin: user45
ProxyPassword: xxx
ProxyServer: example.com:3128
ProxyType: HTTP
Script: ${{ inputs.Script }}
ScriptParameters:
Server: ${{ inputs.Server }}
Symbol: ${{ inputs.TestSymbol }}
Template: # popular.tpl
TestDateEnable: !!str true
TestExpert: ${{ inputs.TestExpert }}
TestExpertParameters: ${{ inputs.TestExpertParameters }}
TestFromDate: ${{ inputs.TestFromDate }}
TestModel: ${{ inputs.TestModel }}
TestOptimization: ${{ inputs.TestOptimization }}
TestPeriod: ${{ inputs.TestPeriod }}
TestReplaceReport: ${{ inputs.TestReplaceReport }}
TestReport: ${{ inputs.TestReport }}
TestShutdownTerminal: !!str true
TestSpread: 10
TestSymbol: ${{ inputs.TestSymbol }}
TestToDate: ${{ inputs.TestToDate }}
TestVisualEnable: !!str false
mt_runner_bt_mt5_config:
Common:
Login: ${{ inputs.Login }}
Password: ${{ inputs.Password }}
Server: ${{ inputs.Server }}
StartUp:
Expert: ${{ inputs.Expert }}
ExpertParameters: ${{ inputs.TestExpertParameters }}
Period: ${{ inputs.Period }}
Script: ${{ inputs.Script }}
ScriptParameters: ${{ inputs.TestScriptParameters }}
Symbol: ${{ inputs.TestSymbol }}
Template:
Tester:
Deposit: ${{ inputs.TestDeposit }}
ExecutionMode: ${{ inputs.TestExecutionMode }}
Expert: ${{ inputs.TestExpert }}
ExpertParameters: ${{ inputs.TestExpertParameters }}
ForwardDate:
ForwardMode: 0
FromDate: ${{ inputs.TestFromDate }}
Leverage: ${{ inputs.TestLeverage }}
Login: ${{ inputs.Login }}
Model: ${{ inputs.TestModel }}
Optimizaton: ${{ inputs.TestOptimization }}
OptimizationCriterion: ${{ inputs.TestOptimizationCriterion }}
Period: ${{ inputs.TestPeriod }}
Report: ${{ inputs.TestReport }}
ReplaceReport: ${{ inputs.TestReplaceReport }}
ShutdownTerminal: 1
Symbol: ${{ inputs.TestSymbol }}
ToDate: ${{ inputs.TestToDate }}
Visual: 0
mt_runner_get_url_list:
- dest: "{{ mt_runner_mt_path }}/MQL${{ inputs.Version }}/Experts"
url: "${{ inputs.UrlExpert }}"
mt_runner_timeout: ${{ inputs.RunnerTimeout }}
- name: Creates requirements
uses: DamianReeves/[email protected]
with:
path: ansible/requirements.yml
write-mode: overwrite
contents: |
---
roles:
- name: ea31337.mt_runner
scm: git
src: https://github.com/EA31337/ansible-role-mt-runner.git
version: dev
- name: Runs playbook
uses: dawidd6/action-ansible-playbook@v2
with:
configuration: |
[defaults]
nocows = false
stdout_callback = yaml
directory: ansible
options: |
--connection local
--inventory localhost,
--verbose
playbook: run.yml
requirements: requirements.yml
- id: platform-fact-output
name: Sets platform fact output
env:
MT_VERSION: "${{ inputs.Version }}"
run: |
import json, os
try:
with open("/etc/ansible/facts.d/metatrader.fact", "r") as file:
fact_obj = json.load(file)
except FileNotFoundError:
print("Error: Fact file not found.")
# Serialize the data back into a JSON string.
fact_plain = json.dumps(fact_obj)
try:
with open(os.getenv("GITHUB_OUTPUT"), "a") as file_out:
file_out.write(f"platform-fact={fact_plain}\n")
print(f"platform-fact={fact_plain}\n")
except FileNotFoundError:
print("Error: Output file not found.")
shell: python
using: composite