Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mt_read.py and mt_modify.py now operates on experts.ini file #168

Merged
merged 3 commits into from
Nov 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist: trusty
language: generic
sudo: required
group: deprecated-2017Q4
Expand Down
9 changes: 9 additions & 0 deletions scripts/.funcs.cmds.inc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,15 @@ set_digits() {
set_data_value digits $digits fxt
}

# Sets white-listed URLs. Separate URLs by a semicolon.
# Usage: add_url "http://example.com/;http://another.com"
add_url() {
local url=$1
[ -n "$url" ]
echo "$TERMINAL_INI"
mt_modify -m "webRequestUrl=$url" -t "experts-ini" -f "$EXPERTS_INI"
}

# Set account leverage in FXT files.
# Usage: set_leverage [value]
set_leverage() {
Expand Down
2 changes: 2 additions & 0 deletions scripts/.vars.inc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ WINE_PATH="${WINE_PATH:-$HOME/.wine/drive_c/Program Files}"
OUT="/opt"
CONF_TEST="mt4-tester.ini"
CONF_TERM="terminal.ini"
CONF_EXPERTS="experts.ini"
CONF_LAST="lastparameters.ini"
CONF_EA="ea.ini"
CONF_CUSTOM="custom.ini"
Expand All @@ -33,6 +34,7 @@ if [ -n "$TERMINAL_DIR" ]; then
TERMINAL_ARG="${TERMINAL_ARG:-/skipupdate /portable}"
TERMINAL_CNF="${TERMINAL_DIR}/config"
TERMINAL_INI="${TERMINAL_INI:-$TERMINAL_CNF/$CONF_TERM}"
EXPERTS_INI="${TERMINAL_INI:-$TERMINAL_CNF/$CONF_EXPERTS}"
TESTER_INI="${TESTER_INI:-$TERMINAL_CNF/$CONF_TEST}"
TESTER_DIR="$TERMINAL_DIR/tester"
TESTER_LOGS="$TESTER_DIR/logs"
Expand Down
13 changes: 13 additions & 0 deletions scripts/py/bstruct/bstruct_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,16 @@ class SrvRecord(BStruct):
_size = get_fields_size(_fields)
_truncate = True
assert(_size == 160)

# Experts.ini file (binary). MT4-only.
class ExpertsIni(BStruct):
_endianness = '<'
_fields = [
# Header layout.
('headerVersion', 'I'), # Version uint32 0 4 Header version (default: 400).
('unknown_0', '286s'), # Unknown data [286]byte 4 293 Unknown data.
('webRequestUrl', '4098s', pretty_print_wstring), # Web Request URL [2080]byte 294 4387 Account server name (szchar).
]
_truncate = True
_size = get_fields_size(_fields)
assert(_size == 4388)
3 changes: 2 additions & 1 deletion scripts/py/mt_modify.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def modify_content(strucc, args, offset, count, bundle=None):
argumentParser.add_argument('-f', '--file', action='store',
dest='inputFile', help='Input file', required=True)
argumentParser.add_argument('-t', '--type', action='store',
dest='inputType', help='Input type (fxt-header, hcc-header, hst-header, sel, srv, symbols-raw, symgroups, ticks-raw)' , required=True)
dest='inputType', help='Input type (fxt-header, hcc-header, hst-header, sel, srv, symbols-raw, symgroups, ticks-raw, experts-ini)' , required=True)
argumentParser.add_argument('-k', '--key-group' , action='store' , dest='keyGroup' , help='Group key' , required=False)
argumentParser.add_argument('-d', '--delete' , action='store_true', dest='doDelete' , help='Delete this record')
argumentParser.add_argument('-a', '--add' , action='store' , dest='doAdd' , help='Add a new record' , default=None)
Expand All @@ -268,5 +268,6 @@ def modify_content(strucc, args, offset, count, bundle=None):
elif args.inputType == 'symbols-raw': modify_content(SymbolsRaw, args, 0, 0, SymbolsRawBundle)
elif args.inputType == 'symgroups': modify_content(Symgroups, args, 0, 1)
elif args.inputType == 'ticks-raw': modify_content(TicksRaw, args, 0, 1)
elif args.inputType == 'experts-ini': modify_content(ExpertsIni, args, 0, 1)
else:
print('Not supported type: %s!' % args.inputType)
1 change: 1 addition & 0 deletions scripts/py/mt_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,6 @@ def dump_content(filename, offset, count, strucc):
elif args.inputType == 'symbols-raw': dump_content(args.inputFile, 0, 0, SymbolsRaw)
elif args.inputType == 'symgroups': dump_content(args.inputFile, 0, 0, Symgroups)
elif args.inputType == 'ticks-raw': dump_content(args.inputFile, 0, 0, TicksRaw)
elif args.inputType == 'experts-ini': dump_content(args.inputFile, 0, 0, ExpertsIni)
else:
print('Not supported type: {}!'.format(args.inputType))
6 changes: 6 additions & 0 deletions scripts/run_backtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,12 @@ if [ -n "$BT_LEVERAGE" ]; then
set_leverage $BT_LEVERAGE
fi

# Sets white-listed web-request URLs (if specified).
if [ -n "$EA_WHITELIST_URLS" ]; then
echo "Setting white-listed URLs ($EA_WHITELIST_URLS)..." >&2
add_url $EA_WHITELIST_URLS
fi

# Final checks.
if [ -n "$TEST_EXPERT" ]; then
[ -n "$(find "$TERMINAL_DIR" '(' -name "*.hst" -o -name "*.fxt" ')' -size +1 -print -quit)" ] \
Expand Down