Skip to content

Commit

Permalink
Merge pull request #150 from EA31337/dev
Browse files Browse the repository at this point in the history
Development improvements
  • Loading branch information
kenorb authored Jun 21, 2019
2 parents 0262bd4 + 5686ea9 commit ba5ef8d
Show file tree
Hide file tree
Showing 21 changed files with 362 additions and 153 deletions.
12 changes: 7 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ env:
- CMD="docker-compose run RunHelp; scripts/eval.sh help; scripts/run_backtest.sh -?"
- CMD="sudo scripts/provision.sh"
- CMD="make docker-ci DOCKER_TAG=$DOCKER_TAG; [[ '$TRAVIS_PULL_REQUEST' = 'false' ]] && make docker-push DOCKER_TAG=$DOCKER_TAG || true"
# - CMD="make docker-ci DOCKER_TAG=$DOCKER_TAG && docker run ea-tester:$DOCKER_TAG install_mt 5" # @fixme
- CMD="docker-compose run $DOCKER_ARG TestSyntaxVagrantfile; docker-compose run $DOCKER_ARG TestSyntaxBash; docker-compose run $DOCKER_ARG TestSyntaxShellcheck"
- CMD="docker-compose run $DOCKER_ARG RunCompileMql"
- CMD="docker-compose run $DOCKER_ARG ScriptPrintPaths"
- CMD="docker-compose run $DOCKER_ARG TestHSTHeader; docker-compose run TestFXTHeader"
- CMD="docker-compose run $DOCKER_ARG TestLotstep4"
# @fixme: Error: Expected lot step for 5 digits: 0.01, found: 0.1.
# - CMD="docker-compose run $DOCKER_ARG TestLotstep5"
# - CMD="docker-compose run $DOCKER_ARG TestLotstep5" # @fixme
- CMD="docker-compose run $DOCKER_ARG TestTimeframes"
- CMD="docker-compose run $DOCKER_ARG TestBands"
- CMD="docker-compose run $DOCKER_ARG TestEnvelopes"
- CMD="docker-compose run $DOCKER_ARG TestModellingQuality"
- CMD="docker-compose run $DOCKER_ARG RunInstallMt4"
- CMD="docker-compose run $DOCKER_ARG RunInstallMt4x"
- CMD="docker-compose run $DOCKER_ARG RunInstallMt5"
# - CMD="docker-compose run $DOCKER_ARG RunInstallMt4" # @fixme
# - CMD="docker-compose run $DOCKER_ARG RunInstallMt4x" # @fixme
# - CMD="docker-compose run $DOCKER_ARG RunInstallMt5" # @fixme
- CMD="docker-compose run $DOCKER_ARG DockerLargeFiles"

# Tests which suppose to be working in older versions only.
Expand Down Expand Up @@ -79,5 +79,7 @@ cache:
apt: true
pip: true
directories:
- /var/cache
- /var/lib/docker
- $HOME/.cache
- $HOME/.docker
10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ WORKDIR /home/ubuntu

# Build-time variables.
ARG BT_DEST=/opt/results
ARG MT_VER
ARG HTTPS_PROXY
ARG HTTP_PROXY
ARG MT_VER=4.0.0.1010
ARG PROVISION_AHK=1
ARG PROVISION_CHARLES=1
ARG PROVISION_MONO=0
ARG PROVISION_SSH=0
ARG PROVISION_SUDO=1
ARG PROVISION_VNC=1
Expand All @@ -42,13 +46,13 @@ RUN chown ubuntu:root $BT_DEST
VOLUME $BT_DEST

# Default backtest inputs.
ENV MT_VER 4.0.0.1010
ENV MT_VER $MT_VER

# Run test.
USER ubuntu
ADD conf /opt/conf
ADD tests /opt/tests
RUN eval.sh install_mt
RUN eval.sh install_mt $MT_VER
RUN eval.sh install_mteditor
RUN run_backtest.sh -s PrintPaths -v

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ DOCKER_CFG := ${HOME}/.docker/config.json
BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
BUILD_VREF := $(shell git rev-parse --short HEAD)
.PHONY: docker-load docker-build docker-login docker-tag docker-pull docker-push docker-run docker-save docker-clean
docker-ci: docker-load docker-build docker-save
docker-ci: docker-build
docker-load:
if [[ -f $(DOCKER_TAR) ]]; then gzip -dc $(DOCKER_TAR) | docker load; fi
docker-build:
Expand Down
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,6 @@ to list available commands. Here is the list:
# Run platform and kill it.
# Usage: quick_run
--
# Set input value in the SET file.
# Usage: input_set [key] [value] [file]
--
# Get input value from the SET file.
# Usage: input_get [key] [file]
--
# Set value in the INI file.
# Usage: ini_set [key] [value] [file]
--
Expand Down
Binary file removed conf/accounts-d4.ini
Binary file not shown.
Binary file removed conf/accounts-d5.ini
Binary file not shown.
12 changes: 7 additions & 5 deletions conf/mt4-tester.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ Profile=default
;MarketWatch=set2.set

; Login - the number of the account to connect to at startup. If this parameter is not specified, the current login will be used.
Login=1809640
Login=3923113

; Password - the password that allows entering the system. This parameter will be ignored if the client terminal stores personal data on the disk and the account to be connected is in the list.
Password=xxx
Password=ple3eay
; m1tsapk
; ple3eay (investor)

; Server - the name of the trade server to be connected to. The server name is the same as the name of the corresponding .srv file stored in the /config directory. This parameter will be ignored if the information about the account to be connected was stored on the disk (e.g. MetaQuotes-demo).
Server=default
Server=FXCM-USDDemo01

; AutoConfiguration - "true" or "false" depending on whether the autoconfiguration setting should be enabled or not. If this parameter is not specified, the value from the current server settings will be used.
AutoConfiguration=false
Expand Down Expand Up @@ -153,12 +155,12 @@ TestDateEnable=true
;
; The date, from which to start testing, appeared as YYYY.MM.DD.
; If this parameter has not been specified, this date is 1970.01.01
TestFromDate=2017.01.01
TestFromDate=2018.01.01

;
; The date, on which to finish testing, appeared as YYYY.MM.DD.
; If this parameter has not been specified, this date is 1970.01.01
TestToDate=2017.01.31
TestToDate=2018.01.31

;
; The name of the test report file.
Expand Down
45 changes: 42 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ services:
image: ea31337/ea-tester:EURUSD-2018-DS
volumes:
- ./scripts:/opt/scripts
# - ../EA-Tester/scripts:/opt/scripts
- ./tests:/opt/tests
- ./conf:/opt/conf
environment:
BT_DAYS: 10-12
BT_MONTHS: 1
Expand All @@ -72,6 +73,8 @@ services:
image: ea31337/ea-tester:EURUSD-2018-DS
volumes:
- ./scripts:/opt/scripts
- ./tests:/opt/tests
- ./conf:/opt/conf
environment:
BT_DAYS: 10-12
BT_MONTHS: 1
Expand All @@ -81,6 +84,8 @@ services:
image: ea31337/ea-tester:EURUSD-2018-DS
volumes:
- ./scripts:/opt/scripts
- ./tests:/opt/tests
- ./conf:/opt/conf
environment:
BT_DAYS: 10-12
BT_MONTHS: 1
Expand All @@ -90,23 +95,39 @@ services:
image: ea31337/ea-tester:EURUSD-2018-DS
volumes:
- ./scripts:/opt/scripts
- ./tests:/opt/tests
- ./conf:/opt/conf
environment:
BT_DAYS: 10-12
BT_MONTHS: 1
RUN_ON_START: clean_ea
TestLeverage:
command: run_backtest -e TestLeverage
image: ea31337/ea-tester:EURUSD-2018-DS
volumes:
- ./scripts:/opt/scripts
- ./tests:/opt/tests
- ./conf:/opt/conf
environment:
BT_DAYS: 10-12
BT_MONTHS: 1
TestLotstep4:
command: run_backtest -e TestLotstep -D 4
command: run_backtest -e TestLotstep -D4 -l 0.1
image: ea31337/ea-tester:EURUSD-2018-DS
volumes:
- ./scripts:/opt/scripts
- ./tests:/opt/tests
- ./conf:/opt/conf
environment:
BT_DAYS: 10-12
BT_MONTHS: 1
TestLotstep5:
command: run_backtest -e TestLotstep -D 5
command: run_backtest -e TestLotstep -D5 -l 0.01
image: ea31337/ea-tester:EURUSD-2018-DS
volumes:
- ./scripts:/opt/scripts
- ./tests:/opt/tests
- ./conf:/opt/conf
environment:
BT_DAYS: 10-12
BT_MONTHS: 1
Expand All @@ -115,6 +136,8 @@ services:
image: ea31337/ea-tester:EURUSD-2018-DS
volumes:
- ./scripts:/opt/scripts
- ./tests:/opt/tests
- ./conf:/opt/conf
environment:
BT_DAYS: 10-12
BT_MONTHS: 1
Expand All @@ -123,6 +146,8 @@ services:
image: ea31337/ea-tester:EURUSD-2018-DS
volumes:
- ./scripts:/opt/scripts
- ./tests:/opt/tests
- ./conf:/opt/conf
environment:
BT_DAYS: 10-12
BT_MONTHS: 1
Expand All @@ -132,6 +157,8 @@ services:
image: ea31337/ea-tester:EURUSD-2018-DS
volumes:
- ./scripts:/opt/scripts
- ./tests:/opt/tests
- ./conf:/opt/conf
environment:
BT_DAYS: 10-12
BT_MONTHS: 1
Expand All @@ -140,6 +167,8 @@ services:
image: ea31337/ea-tester:EURUSD-2018-DS
volumes:
- ./scripts:/opt/scripts
- ./tests:/opt/tests
- ./conf:/opt/conf
environment:
BT_DAYS: 10-12
BT_MONTHS: 1
Expand All @@ -148,6 +177,8 @@ services:
image: ea31337/ea-tester:EURUSD-2018-DS
volumes:
- ./scripts:/opt/scripts
- ./tests:/opt/tests
- ./conf:/opt/conf
environment:
BT_DAYS: 10-12
BT_MONTHS: 1
Expand All @@ -156,6 +187,8 @@ services:
image: ea31337/ea-tester:EURUSD-2018-DS
volumes:
- ./scripts:/opt/scripts
- ./tests:/opt/tests
- ./conf:/opt/conf
environment:
BT_DAYS: 10-12
BT_MONTHS: 1
Expand All @@ -164,6 +197,8 @@ services:
image: ea31337/ea-tester:EURUSD-2018-DS
volumes:
- ./scripts:/opt/scripts
- ./tests:/opt/tests
- ./conf:/opt/conf
environment:
BT_DAYS: 10-12
BT_MONTHS: 1
Expand All @@ -172,6 +207,8 @@ services:
image: ea31337/ea-tester:EURUSD-2018-DS
volumes:
- ./scripts:/opt/scripts
- ./tests:/opt/tests
- ./conf:/opt/conf
environment:
BT_DAYS: 10-12
BT_MONTHS: 1
Expand All @@ -183,3 +220,5 @@ services:
image: ea31337/ea-tester:dev
volumes:
- ./scripts:/opt/scripts
- ./tests:/opt/tests
- ./conf:/opt/conf
91 changes: 16 additions & 75 deletions scripts/.funcs.cmds.inc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -384,25 +384,6 @@ compile_and_test() {
$CWD/run_backtest.sh -e "$@"
}

# Experts SET file. Returns exported filename.
# Usage: export_set [EA/pattern] (dst/file) (...args)
export_set() {
local name=${1:-$TEST_EXPERT}
local dstfile=${2:-${name}.set}
local ea_path=$name
local ahk_path="$(winepath -w "$SCR"/ahk/export_set.ahk)"
[ ! -s "$name" ] && ea_path=$(ea_find "${name##/}")
[ ! -f "$EXPERTS_DIR/$ea_path" ] && { echo "Error: Cannot find EA: ${name}!" >&2; return; }
[[ "$ea_path" =~ 'mq' ]] && compile_ea "$name" >&2
set_display >&2
ini_set "^Expert" "$(basename ${ea_path/\//\\\\} .${ea_path##*.})" "$TERMINAL_INI"
WINEPATH="$(winepath -w "$TERMINAL_DIR");C:\\Apps\\AHK" \
timeout 60 \
wine AutoHotkey /ErrorStdOut "$ahk_path" "${dstfile}" ${@:3}
[ -n "$OPT_VERBOSE" ] && times >&2
echo "${dstfile}"
}

# Copy ini settings from templates.
# Usage: ini_copy
ini_copy() {
Expand All @@ -428,8 +409,14 @@ ea_find() {
file=${file##*/}
fi
[ -f "$file" ] && { echo "$file"; return; }
local exact=$(find -L . "$ROOT" ~ -maxdepth 4 -type f '(' -iname "$file" -o -iname "${file%.*}.mq?" -o -name "${file%.*}.ex?" ')' -print -quit)
local match=$(find -L . "$ROOT" ~ -maxdepth 4 -type f '(' -iname "*${file%.*}*.mq?" -o -iname "*${file%.*}*.ex?" ')' -print -quit)
exact=$(
find -L . "$ROOT" ~ -maxdepth 4 -type f '(' -iname "$file" -o -iname "${file%.*}.mq?" ')' -print -quit || \
find -L . "$ROOT" ~ -maxdepth 4 -type f '(' -iname "$file" -o -name "${file%.*}.ex?" ')' -print -quit
)
[ -z "$exact" ] && match=$(
find -L . "$ROOT" ~ -maxdepth 4 -type f -iname "*${file%.*}*.mq?" -print -quit || \
find -L . "$ROOT" ~ -maxdepth 4 -type f -iname "*${file%.*}*.ex?" -print -quit
)
[ -n "$exact" ] && echo ${exact#./} || echo ${match#./}
cd - &>/dev/null
}
Expand All @@ -448,8 +435,14 @@ script_find() {
file=${file##*/}
fi
[ -f "$file" ] && { echo "$file"; return; }
local exact=$(find -L . "$ROOT" ~ -maxdepth 4 -type f '(' -iname "$file" -o -name "${file%.*}.ex?" ')' -print -quit)
local match=$(find -L . "$ROOT" ~ -maxdepth 4 -type f '(' -iname "*${file%.*}*.mq?" -o -iname "*${file%.*}*.ex?" ')' -print -quit)
exact=$(
find -L . "$ROOT" ~ -maxdepth 4 -type f '(' -iname "$file" -o -iname "${file%.*}.mq?" ')' -print -quit || \
find -L . "$ROOT" ~ -maxdepth 4 -type f '(' -iname "$file" -o -iname "${file%.*}.ex?" ')' -print -quit
)
[ -z "$exact" ] && match=$(
find -L . "$ROOT" ~ -maxdepth 4 -type f -iname "*${file%.*}*.mq?" -print -quit || \
find -L . "$ROOT" ~ -maxdepth 4 -type f -iname "*${file%.*}*.ex?" -print -quit
)
[ -n "$exact" ] && echo ${exact#./} || echo ${match#./}
cd - &>/dev/null
}
Expand Down Expand Up @@ -826,57 +819,6 @@ quick_run() {
show_logs 40
}
# Set input value in the SET file.
# Usage: input_set [key] [value] [file]
input_set() {
local key="$1"
local value="$2"
local file="${3:-$TESTER_DIR/$EA_SETFILE}"
[ -s "$file" ]
read -ra vargs <<<$EX_ARGS
vargs+=("-u NONE")
if [ -n "$value" ]; then
echo "Setting '$key' to '$value' in $(basename "$file")" >&2
ex +"%s/$key=\zs.*$/$value/" -scwq! ${vargs[@]} "$file" >&2 || exit 1
else
echo "Value for '$key' is empty, ignoring." >&2
fi
}
# Get input value from the SET file.
# Usage: input_get [key] [file]
input_get() {
local key="$1"
local file="${2:-$TESTER_DIR/$EA_SETFILE}"
[ -s "$file" ]
value="$(grep -om1 "$key=[.0-9a-zA-Z-]\+" "$file" | cut -d= -f2-)"
echo $value
}
# Copy input value from the SET file to MQL file.
# Usage: input_copy [key] [src_file] [dst_file] (dst_file2...)
input_copy() {
local key=$1
local file_src=$2
local retries=5
read -ra files <<<${@:3}
read -ra vargs <<<$EX_ARGS
vargs+=("-u NONE")
[ -s "$file_src" ]
for file_dst in "${files[@]}"; do
[ -s "$file_dst" ]
value=$(input_get "^$key" "$file_src")
echo "Setting '$key' to '$value' in $(basename "$file_dst")" >&2
retries=5
while ! ex +"%s/\s${key}[^=]=[^0-9]\zs[^;]\+/${value}/" -scwq! ${vargs[@]} "$file_dst" >&2; do
sleep 1
((retries-=1))
echo "Retrying ($retries left)..." >&2
[ $retries -le 0 ] && break
done
done
}
# Set value in the INI file.
# Usage: ini_set [key] [value] [file]
ini_set() {
Expand Down Expand Up @@ -1028,5 +970,4 @@ set_digits() {
set_symbol_value $digits $SRAW_OFF_DIGITS
psize="0.$(for ((i=1;i<=digits-1;i++)); do printf 0; done)1"
set_symbol_double $psize $SRAW_OFF_PSIZE
cp $VFLAG "$ROOT/conf/accounts-d${digits}.ini" "$TERMINAL_DIR"/config/accounts.ini
}
Loading

0 comments on commit ba5ef8d

Please sign in to comment.