-
-
Notifications
You must be signed in to change notification settings - Fork 542
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
263 additions
and
86 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 |
---|---|---|
|
@@ -5,4 +5,5 @@ research | |
tensorboard | ||
agents | ||
data/tensorboard | ||
data/agents | ||
data/agents | ||
data/postgres |
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
**/__pycache__ | ||
data/tensorboard/* | ||
data/agents/* | ||
data/postgres/* | ||
data/log/* | ||
*.pkl | ||
*.db |
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
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 |
---|---|---|
@@ -1,23 +1,36 @@ | ||
import numpy as np | ||
|
||
from deco import concurrent | ||
from lib.RLTrader import RLTrader | ||
from lib.cli.RLTraderCLI import RLTraderCLI | ||
from lib.util.logger import init_logger | ||
from update_data import download_async | ||
|
||
np.warnings.filterwarnings('ignore') | ||
trader_cli = RLTraderCLI() | ||
args = trader_cli.get_args() | ||
|
||
|
||
@concurrent(processes=args.proc_number) | ||
def run_concurrent_optimize(trader: RLTrader, args): | ||
trader.optimize(args.trials, args.trials, args.parallel_jobs) | ||
|
||
|
||
if __name__ == '__main__': | ||
logger = init_logger(__name__, show_debug=args.debug) | ||
trader = RLTrader(**vars(args), logger=logger) | ||
|
||
if args.command == 'optimize': | ||
trader.optimize(n_trials=args.trials, n_parallel_jobs=args.parallel_jobs) | ||
run_concurrent_optimize(trader, args) | ||
elif args.command == 'train': | ||
trader.train(n_epochs=args.epochs) | ||
elif args.command == 'test': | ||
trader.test(model_epoch=args.model_epoch, should_render=args.no_render) | ||
elif args.command == 'opt-train-test': | ||
trader.optimize(args.trials, args.parallel_jobs) | ||
trader.train(n_epochs=args.train_epochs, test_trained_model=args.no_test, render_trained_model=args.no_render) | ||
run_concurrent_optimize(trader, args) | ||
trader.train( | ||
n_epochs=args.train_epochs, | ||
test_trained_model=args.no_test, | ||
render_trained_model=args.no_render | ||
) | ||
elif args.command == 'update-static': | ||
download_async() |
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,2 @@ | ||
[Defaults] | ||
mini-batches=11 |
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,68 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}") | ||
CWD=$(realpath "${SCRIPT_DIR}") | ||
|
||
if [[ -z $1 ]]; then | ||
echo "Should have 1 argument: cpu or gpu" | ||
exit | ||
fi | ||
|
||
TYPE=$1 | ||
shift; | ||
|
||
if [[ -n $2 ]]; then | ||
docker build \ | ||
--tag 'trader-rl-postgres' \ | ||
--build-arg ID=$(id -u) \ | ||
--build-arg GI=$(id -g) \ | ||
-f "$CWD/docker/Dockerfile.backend" "$CWD" | ||
|
||
mkdir -p "$CWD/data/postgres" | ||
docker run \ | ||
--detach \ | ||
--publish 5432:5432 \ | ||
--tty \ | ||
--user "$(id -u):$(id -g)" \ | ||
--volume "$CWD/data/postgres":"/var/lib/postgresql/data/trader-data" \ | ||
trader-rl-postgres-dev | ||
shift | ||
fi | ||
|
||
if [[ $TYPE == 'gpu' ]]; then | ||
GPU=1 | ||
else | ||
GPU=0 | ||
fi | ||
|
||
MEM=$(cat /proc/meminfo | grep 'MemTotal:' | awk '{ print $2 }') | ||
CPUS=$(cat /proc/cpuinfo | grep -P 'processor.+[0-7]+' | wc -l) | ||
|
||
MEM_LIMIT=$((MEM/4*3)) | ||
CPU_LIMIT=$((CPUS/4*3)) | ||
|
||
if [ $CPU_LIMIT == 0 ];then | ||
CPU_LIMIT=1 | ||
fi | ||
|
||
if [ $GPU == 0 ]; then | ||
N="trader-rl-cpu-dev" | ||
docker build --tag $N -f "$CWD/docker/Dockerfile.cpu" "$CWD" | ||
else | ||
N="trader-rl-gpu-dev" | ||
docker build --tag $N -f "$CWD/docker/Dockerfile.gpu" "$CWD" | ||
fi | ||
|
||
docker rm -fv rl_trader_dev || true | ||
docker run \ | ||
--name 'rl_trader_dev' \ | ||
--user $(id -u):$(id -g) \ | ||
--entrypoint 'bash' \ | ||
--interactive \ | ||
--memory "${MEM_LIMIT}b" \ | ||
--cpus "${CPU_LIMIT}" \ | ||
--tty \ | ||
--volume "${CWD}":/code \ | ||
"$N" |
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 |
---|---|---|
@@ -1,11 +1,12 @@ | ||
FROM python:3.6.8-jessie | ||
|
||
ADD ./requirements.base.txt /code/ | ||
ADD ./requirements.no-gpu.txt /code/requirements.txt | ||
|
||
WORKDIR /code | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y build-essential mpich | ||
&& apt-get install -y build-essential mpich libpq-dev | ||
|
||
# should merge to top RUN to avoid extra layers - for debug only :/ | ||
RUN pip install -r requirements.txt |
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 |
---|---|---|
@@ -1,9 +1,10 @@ | ||
FROM python:3.6.8-jessie | ||
|
||
ADD ./requirements.base.txt /code/ | ||
ADD ./requirements.txt /code/ | ||
|
||
WORKDIR /code | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y build-essential mpich \ | ||
&& apt-get install -y build-essential mpich libpq-dev \ | ||
&& pip install -r requirements.txt |
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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
FROM python:3.6.8-jessie | ||
|
||
ADD ./requirements.base.txt /code/ | ||
ADD ./requirements.no-gpu.txt /code/ | ||
ADD ./requirements.tests.txt /code/requirements.txt | ||
|
||
WORKDIR /code | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y build-essential mpich \ | ||
&& apt-get install -y build-essential mpich libpq-dev \ | ||
&& pip install --progress-bar off --requirement requirements.txt |
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
Oops, something went wrong.