From 8ec343416ca6270785abcd5e14530d2489670d8d Mon Sep 17 00:00:00 2001 From: Oleg Sheynin Date: Fri, 19 Jan 2024 15:07:12 -0500 Subject: [PATCH] progress --- executor/build.sh => build.sh | 21 +++++++++++++++------ executor/deploy.sh => deploy.sh | 4 ++-- executor/.creds | 1 - executor/Dockerfile | 8 ++++++-- quant/.creds | 14 ++++++++++++++ quant/Dockerfile | 33 +++++++++++++++++++++++++++++++++ quant/requirements.txt | 6 ++++++ 7 files changed, 76 insertions(+), 11 deletions(-) rename executor/build.sh => build.sh (75%) rename executor/deploy.sh => deploy.sh (85%) create mode 100644 quant/.creds create mode 100644 quant/Dockerfile create mode 100644 quant/requirements.txt diff --git a/executor/build.sh b/build.sh similarity index 75% rename from executor/build.sh rename to build.sh index 88c9890..f28b28f 100755 --- a/executor/build.sh +++ b/build.sh @@ -1,10 +1,18 @@ #!/bin/bash function usage { - echo "Usage: ${0} " + echo "Usage: ${0} " exit } +AppName=${1} + +if [ "${AppName}" == "" ] +then + usage +fi +shift + TgtHostname=${1} if [ "${TgtHostname}" == "" ] @@ -14,19 +22,20 @@ fi # --- Settings -DockerDir=$(dirname ${0}) -RootDir=${DockerDir}/../.. +DockerDir=$(realpath $(dirname ${0})/${AppName}) +RootDir=$(realpath ${DockerDir}/../..) -cd ${RootDir} - -ImageName=cvtt_executor +ImageName=${AppName} ImageDir=${HOME}/docker_images mkdir -p ${ImageDir} TgtImageDir=/home/cvtt/docker_images + Version=$(cat ${RootDir}/cvttpy/release_version.txt) +cd ${RootDir} + Cmd="docker build -t ${ImageName} -t ${ImageName}:${Version} -f ${DockerDir}/Dockerfile ." echo ${Cmd} eval ${Cmd} diff --git a/executor/deploy.sh b/deploy.sh similarity index 85% rename from executor/deploy.sh rename to deploy.sh index 04be489..a240e5c 100755 --- a/executor/deploy.sh +++ b/deploy.sh @@ -2,7 +2,7 @@ # ===== MUST RUN ON TARGET HOST -ImageName=cvtt_executor +ImageName=${1} ImageDir=/home/cvtt/docker_images AdminPort=7220 @@ -10,7 +10,7 @@ LogDir=/home/cvtt/prod/logs mkdir -p ${LogDir} -docker image rm -f ${ImageName} +docker image rm -f ${ImageName}:* docker rm -f ${ImageName} docker load -i ${ImageDir}/${ImageName}.img.tar docker run -d --network="host" --name=${ImageName} -p ${AdminPort}:${AdminPort} -v ${LogDir}:/logs ${ImageName} diff --git a/executor/.creds b/executor/.creds index d8d269b..c4e3a39 100644 --- a/executor/.creds +++ b/executor/.creds @@ -11,5 +11,4 @@ , "account_uuid": "???" , "book_id": "CVTT_BK01" } - } diff --git a/executor/Dockerfile b/executor/Dockerfile index 01f1901..b1de69d 100644 --- a/executor/Dockerfile +++ b/executor/Dockerfile @@ -13,13 +13,17 @@ COPY docker_dev/executor/.creds /.creds RUN mkdir /logs ENV PYTHONPATH=/ + +# default config +ENV CONFIG=http://cloud16.cvtt.vpn:6789/apps/cvtt + CMD [ \ "python3.10", \ "cvttpy/apps/executor_app.py", \ - "--config=http://cloud16.cvtt.vpn:6789/apps/cvtt", \ + "--config=${CONFIG}", \ "--admin_port=7220", \ "--active_exchanges=COINBASE_AT", \ - "--credentials_file=/.creds", \ + "--credentials_file=/.creds", \ "--log_file=/logs/%T.EXECUTOR_APP.log" \ ] diff --git a/quant/.creds b/quant/.creds new file mode 100644 index 0000000..c4e3a39 --- /dev/null +++ b/quant/.creds @@ -0,0 +1,14 @@ +{ + "COINBASE_ADV_TRD": { + "api_key": "nKIyZxS95J4MsY4N" + , "secret_key": "sih7Txx3htlTWJrQ3EiuRS3qRfv7qZ4P" + , "account_uuid": "???" + , "book_id": "CVTT_BK01" + } + , "COINBASE_ADV_RO": { + "api_key": "Ip4QpRtRHBmWNpc3" + , "secret_key": "N6ZEMdIdUYUldkJRTUcCRKUFot4Fp2j0" + , "account_uuid": "???" + , "book_id": "CVTT_BK01" + } +} diff --git a/quant/Dockerfile b/quant/Dockerfile new file mode 100644 index 0000000..7e812c6 --- /dev/null +++ b/quant/Dockerfile @@ -0,0 +1,33 @@ +FROM python:3.10-slim + +WORKDIR / +COPY docker_dev/quant/requirements.txt / + +RUN pip install --upgrade pip +RUN pip install -r /requirements.txt + + +COPY cvttpy /cvttpy +COPY docker_dev/quant/.creds /.creds + +RUN mkdir /logs + +ENV PYTHONPATH=/ + +# default config +ENV CONFIG=http://cloud16.cvtt.vpn:6789/apps/cvtt +ENV BOOK_ID=CVTT_CLD17_BK01 +# ENV INSTRUMENTS="COINBASE:PAIR-BTC-USD" + +CMD [ \ + "python3.10", \ + "cvttpy/apps/quant_app.py", \ + "--config=${CONFIG}", \ + "--credentials_file=/.creds", \ + "--active_exchanges=COINBASE_AT", \ + # "--instruments=${INSTRUMENTS}", \ + "--instruments=COINBASE:PAIR-BTC-USD", \ + "--book=${BOOK_ID}" \ + "--admin_port=7221", \ + "--log_file=/logs/%T.QUANT.log" \ +] diff --git a/quant/requirements.txt b/quant/requirements.txt new file mode 100644 index 0000000..d43cacf --- /dev/null +++ b/quant/requirements.txt @@ -0,0 +1,6 @@ +aiohttp>=3.7.4.post0 +aioredis>=2.0.1 +nest-asyncio>=1.5.5 +hjson>=3.1.0 +# sortedcontainers>=2.4.0 +pandas>=1.5.3