From 99e9516830730d2e0c801658c43c5118a09c6bf6 Mon Sep 17 00:00:00 2001 From: Oleg Sheynin Date: Tue, 22 Apr 2025 20:07:03 -0400 Subject: [PATCH] progress --- trading_simulator/Dockerfile | 19 +++++++ trading_simulator/VERSION | 1 + trading_simulator/build.sh | 87 ++++++++++++++++++++++++++++++ trading_simulator/entrypoint.sh | 16 ++++++ trading_simulator/requirements.txt | 9 ++++ 5 files changed, 132 insertions(+) create mode 100644 trading_simulator/Dockerfile create mode 100644 trading_simulator/VERSION create mode 100755 trading_simulator/build.sh create mode 100755 trading_simulator/entrypoint.sh create mode 100644 trading_simulator/requirements.txt diff --git a/trading_simulator/Dockerfile b/trading_simulator/Dockerfile new file mode 100644 index 0000000..33e3bc2 --- /dev/null +++ b/trading_simulator/Dockerfile @@ -0,0 +1,19 @@ +FROM python:3.12-slim + +COPY requirements.txt / + +RUN pip install --upgrade pip --root-user-action=ignore +RUN pip install -r /requirements.txt --root-user-action=ignore + +COPY cvttpy /cvttpy + +RUN mkdir -p /logs /config + +SHELL ["/bin/bash", "-c"] + +ENV PYTHONPATH=/ + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/trading_simulator/VERSION b/trading_simulator/VERSION new file mode 100644 index 0000000..8a9ecc2 --- /dev/null +++ b/trading_simulator/VERSION @@ -0,0 +1 @@ +0.0.1 \ No newline at end of file diff --git a/trading_simulator/build.sh b/trading_simulator/build.sh new file mode 100755 index 0000000..f3ff95f --- /dev/null +++ b/trading_simulator/build.sh @@ -0,0 +1,87 @@ +#!/bin/bash + +# --- Settings +RegistryService=cloud21.cvtt.vpn:5500 +ImageName=trading_simulator +BashFunctionCode=$(realpath $(dirname ${0}))/../dckr_bld_functions.sh +ImageVersion=$(cat $(realpath $(dirname ${0}))/VERSION) +# --- Settings + +usage() { + echo "Usage: $0 -L : [-V ] " + exit 1 +} + + +# ---------------- cmdline +while getopts "I:V:L:" opt; do + case ${opt} in + V ) + ImageVersion=$OPTARG + ;; + L ) + Library=$OPTARG + ;; + \? ) + echo "Invalid option: -$OPTARG" >&2 + usage + ;; + : ) + echo "Option -$OPTARG requires an argument." >&2 + usage + ;; + esac +done +# ---------------- cmdline + +if [ "${ImageName}" == "" ] +then + usage +fi + +if [ "${ImageVersion}" == "" ] +then + usage +fi + +DockerDir=$(realpath $(dirname ${0})/${ImageName}) +cd ${DockerDir} + +Project= +ProjectVersion= +if [ "${Library}" != "" ] ; then + IFS=':' read -ra parts <<< "${Library}" + Project=${parts[0]} + ProjectVersion=${parts[1]} +fi +# exit + +build_musvc_image() { + ImageName=${1} + Project=${2} + ProjectVersion=${3} + + DockerDir=$(realpath $(dirname ${0})) + cd ${DockerDir} + + if [ "${Project}" != "" ]; then + get_project_version ${Project} ${ProjectVersion} + fi + + function cleanup { + cd ${DockerDir} + rm -rf cvttpy + } + trap cleanup RETURN + + build_docker_image ${ImageName} ${RegistryService} ${ImageVersion} ${Project} ${ProjectVersion} +} + + +source ${BashFunctionCode} +build_musvc_image ${ImageName} ${Project} ${ProjectVersion} + +# echo "**** D E B U G E X I T" && exit +echo "***** ${0} D O N E" + + diff --git a/trading_simulator/entrypoint.sh b/trading_simulator/entrypoint.sh new file mode 100755 index 0000000..f28fbc1 --- /dev/null +++ b/trading_simulator/entrypoint.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +LogDir=/logs + +Cmd="python3.12" +Cmd+=" cvttpy/apps/trading_simulator/main.py" + +Cmd+=" --config=${CONFIG_FILE:-/config/simulation.cfg}" +Cmd+=" --simtime_file=${SIMTIME_FILE:-/data/simtime.bin}" +Cmd+=" --cfgvar=DATA_DIR=/data" + +Cmd+=" --log_file=${LogDir}/$TRDSIM_LOG_FILE:-%T.trading_simulator.log}" +Cmd+=" ${TRDSIM_ADD_ARGS}" +echo ${Cmd} +exec ${Cmd} + diff --git a/trading_simulator/requirements.txt b/trading_simulator/requirements.txt new file mode 100644 index 0000000..e840a84 --- /dev/null +++ b/trading_simulator/requirements.txt @@ -0,0 +1,9 @@ +aiohttp>=3.7.4.post0 +nest-asyncio>=1.5.5 +hjson>=3.1.0 +sortedcontainers>=2.4.0 +redis>=5.0.8 +python-dateutil>=2.8.2 +types-python-dateutil>=2.8.19.6 +cryptography>=43.0.0 +PyJWT>=2.10.1