-
Notifications
You must be signed in to change notification settings - Fork 2k
Genetic algorithm to fine tune strategy parameters #299
Changes from all commits
592634f
9781900
7cf94d4
b2ff5c2
d72cc47
24b694d
bc9a113
a386b98
0ff26ff
ae5f839
d77c7c4
e76d0c5
1cb6396
a1a3092
138f7ce
0a86fad
8f10078
fdc2403
4bba339
3be8612
85d58b1
a07ab14
09e79a8
9fa1c23
3420221
8c3ce41
329e72b
7874e5a
d584a0c
359434f
d9ec7d9
48755fa
1dd9c12
96a0303
ade45c5
8f2934b
fd0c9c0
028db1f
2bac433
5cebf49
f9c24ee
9397f89
5f1a7ff
d2da758
13dae71
215da0c
de0747a
70b2da5
af2d5d6
54a0cf0
9043e2e
adf6e4c
bb656e9
a7cf31b
3eab688
3d5226d
85a6949
0c16a8b
4cb7f07
4139f94
f3b4485
ee2e157
552642c
7d36a00
fdb51a0
8ae56aa
a6349bb
76f80a6
14f4218
520bd65
e698dad
d937be6
2627b18
d26dc67
59d35f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,97 @@ | ||
FROM node:latest | ||
|
||
ADD . /app | ||
|
||
|
||
# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh" | ||
# | ||
# PLEASE DO NOT EDIT IT DIRECTLY. | ||
# | ||
|
||
|
||
# ensure local python is preferred over distribution python | ||
ENV PATH /usr/local/bin:$PATH | ||
|
||
# http://bugs.python.org/issue19846 | ||
# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK. | ||
ENV LANG C.UTF-8 | ||
|
||
# runtime dependencies | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
tcl \ | ||
tk \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
ENV GPG_KEY 0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D | ||
ENV PYTHON_VERSION 3.6.0 | ||
|
||
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'" | ||
ENV PYTHON_PIP_VERSION 9.0.1 | ||
|
||
RUN set -ex \ | ||
&& buildDeps=' \ | ||
tcl-dev \ | ||
tk-dev \ | ||
' \ | ||
&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \ | ||
\ | ||
&& wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \ | ||
&& wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \ | ||
&& export GNUPGHOME="$(mktemp -d)" \ | ||
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY" \ | ||
&& gpg --batch --verify python.tar.xz.asc python.tar.xz \ | ||
&& rm -r "$GNUPGHOME" python.tar.xz.asc \ | ||
&& mkdir -p /usr/src/python \ | ||
&& tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz \ | ||
&& rm python.tar.xz \ | ||
\ | ||
&& cd /usr/src/python \ | ||
&& ./configure \ | ||
--enable-loadable-sqlite-extensions \ | ||
&& make -j$(nproc) \ | ||
&& make install \ | ||
&& ldconfig \ | ||
\ | ||
# explicit path to "pip3" to ensure distribution-provided "pip3" cannot interfere | ||
&& if [ ! -e /usr/local/bin/pip3 ]; then : \ | ||
&& wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \ | ||
&& python3 /tmp/get-pip.py "pip==$PYTHON_PIP_VERSION" \ | ||
&& rm /tmp/get-pip.py \ | ||
; fi \ | ||
# we use "--force-reinstall" for the case where the version of pip we're trying to install is the same as the version bundled with Python | ||
# ("Requirement already up-to-date: pip==8.1.2 in /usr/local/lib/python3.6/site-packages") | ||
# https://github.com/docker-library/python/pull/143#issuecomment-241032683 | ||
&& pip3 install --no-cache-dir --upgrade --force-reinstall "pip==$PYTHON_PIP_VERSION" \ | ||
# then we use "pip list" to ensure we don't have more than one pip version installed | ||
# https://github.com/docker-library/python/pull/100 | ||
&& [ "$(pip list |tac|tac| awk -F '[ ()]+' '$1 == "pip" { print $2; exit }')" = "$PYTHON_PIP_VERSION" ] \ | ||
\ | ||
&& find /usr/local -depth \ | ||
\( \ | ||
\( -type d -a -name test -o -name tests \) \ | ||
-o \ | ||
\( -type f -a -name '*.pyc' -o -name '*.pyo' \) \ | ||
\) -exec rm -rf '{}' + \ | ||
&& apt-get purge -y --auto-remove $buildDeps \ | ||
&& rm -rf /usr/src/python ~/.cache | ||
|
||
# make some useful symlinks that are expected to exist | ||
RUN cd /usr/local/bin \ | ||
&& { [ -e easy_install ] || ln -s easy_install-* easy_install; } \ | ||
&& ln -s idle3 idle \ | ||
&& ln -s pydoc3 pydoc \ | ||
&& ln -s python3 python \ | ||
&& ln -s python3-config python-config | ||
|
||
|
||
|
||
|
||
RUN apt-get update | ||
RUN apt install -y graphviz libgraphviz-dev pkg-config | ||
RUN PKG_CONFIG_ALLOW_SYSTEM_LIBS=OHYESPLEASE pip install pygraphviz | ||
ADD zen/requirements.txt / | ||
RUN pip3 install -r /requirements.txt | ||
WORKDIR /app | ||
RUN /usr/local/bin/npm install | ||
RUN npm update | ||
|
||
|
||
RUN npm install |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import datetime | ||
import shlex | ||
|
||
import subprocess | ||
from fabric.api import run, cd,local | ||
|
||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: one newline too much |
||
def sim(instrument, days, popsize, strategy): | ||
with cd('zenbot'): | ||
params = dict(instrument=instrument, days=days, strategy=strategy, popsize=popsize, | ||
timestamp=datetime.datetime.now().strftime('%Y-%m-%d-%H-%M')) | ||
cmd = "cd zen && python -m scoop main.py {instrument} {days} {popsize} {strategy}".format(**params) | ||
total = '(nohup docker-compose exec -T server bash -c "{cmd}" > {instrument}_{strategy}_{days}_{popsize}_{timestamp}.out 2>&1 &) && sleep 1'.format( | ||
cmd=cmd, **params) | ||
print(total) | ||
run(total) | ||
|
||
|
||
def remote(cmd,logfile): | ||
with cd('zenbot'): | ||
total = '(nohup docker-compose exec -T server bash -c "{cmd}" > {logfile} 2>&1 &) && sleep 1'.format(cmd=cmd, | ||
logfile=logfile) | ||
print(total) | ||
run(total) | ||
|
||
def backfill_remote(TOTAL_DAYS): | ||
products = ['gdax.BTC-EUR','gdax.BTC-USD','gdax.BTC-GBP']+['gdax.ETH-BTC','poloniex.ETH-BTC'] | ||
for instrument in products: | ||
cmd = '/app/zenbot.sh backfill {instrument} --days {days}'.format(days=TOTAL_DAYS, instrument=instrument) | ||
remote(cmd,'backfill_'+instrument) | ||
def backfill_local(TOTAL_DAYS): | ||
products = ['gdax.BTC-EUR','gdax.BTC-USD','gdax.BTC-GBP']+['gdax.ETH-BTC','poloniex.ETH-BTC'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand why this is a constant now (for demo purposes) but if we plan on merging this in at some point, we should try and use the |
||
for instrument in products: | ||
cmd = '/app/zenbot.sh backfill {instrument} --days {days}'.format(days=TOTAL_DAYS, instrument=instrument) | ||
local(cmd) | ||
|
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to just create your own docker.
Also, to run this, I had to run
mkdir -p logs/hof
, so perhaps aRUN mkdir -p zen/logs/hof
here around the end?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get a weird error related to npm in docker. When you guys were building your docker, did you stumble upon this?
server_1 | module.js:471
server_1 | throw err;
server_1 | ^
server_1 |
server_1 | Error: Cannot find module 'semver'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are using arphenos dockerfile you need to copy at least package.json into you workdir before the npm install command.
or just copy the app into the working dir:
COPY . /app