This commit is contained in:
2024-12-20 13:47:06 -05:00
parent 539034a93c
commit 98146f0fc0
27 changed files with 5 additions and 5 deletions
@@ -0,0 +1,3 @@
.git
**/__pycache__
.pipenv
+24
View File
@@ -0,0 +1,24 @@
FROM python:3.12-slim
ARG FROM_DIR=docker_dev/trading/trader
COPY ${FROM_DIR}/requirements.txt /
RUN pip install --upgrade pip --root-user-action=ignore
RUN pip install -r /requirements.txt --root-user-action=ignore
COPY cvttpy /cvttpy
COPY ${FROM_DIR}/.creds /.creds
COPY ${FROM_DIR}/run_trader.sh /run_trader.sh
RUN chmod +x /run_trader.sh
RUN mkdir /logs
WORKDIR /
SHELL ["/bin/bash", "-c"]
ENV PYTHONPATH=/
ENTRYPOINT [ "/run_trader.sh" ]
@@ -0,0 +1,6 @@
aiohttp>=3.7.4.post0
redis>=5.0.8
nest-asyncio>=1.5.5
hjson>=3.1.0
sortedcontainers>=2.4.0
pandas>=1.5.3
+71
View File
@@ -0,0 +1,71 @@
#!/bin/bash
# runs in container
# --------------------------------------------------------------------------
# runs on host to start container
usage() {
echo -n "Usage: $0"
echo -n " -b <book>"
echo -n " -A <algo> (dflt: TRDALGO_001)"
echo -n " [-c <config (dflt: http://cloud23.cvtt.vpn:6789/apps/cvtt_eqt_alpaca)>]"
echo -n " [-e <active_exchanges (ALPACA_SNDBX-MDPORTAL)>]"
echo -n " [-a <admin_port (7223)>"]
echo -n " [-z (compress log)"]
echo
exit 1
}
Config=http://cloud23.cvtt.vpn:6789/apps/cvtt_eqt_alpaca
ActiveExchanges=ALPACA_SNDBX-MDPORTAL
AdminPort=7226
Algo=TRDALGO_001
Book=""
COMPRESS_LOG=false
while getopts "b:c:e:a:A:z" opt; do
case ${opt} in
c ) Config=$OPTARG ;;
e ) ActiveExchanges=$OPTARG ;;
a ) AdminPort=$OPTARG ;;
z ) COMPRESS_LOG=true ;;
b ) Book=$OPTARG ;;
A ) Algo=$OPTARG ;;
\? )
echo "Invalid option: -$OPTARG" >&2
usage
;;
: )
echo "Option -$OPTARG requires an argument." >&2
usage
;;
esac
done
if [ "${Book}" == "" ]; then
echo "Book is missing"
usage
fi
Cmd="python3.12"
Cmd="${Cmd} cvttpy/apps/trader_app.py"
Cmd="${Cmd} --config=${Config}"
Cmd="${Cmd} --credentials_file=/.creds"
Cmd="${Cmd} --book=${Book}"
Cmd="${Cmd} --algo=${Algo}"
# Cmd="${Cmd} --allow_dynamic_exch_inst"
Cmd="${Cmd} --active_exchanges=${ActiveExchanges}"
Cmd="${Cmd} --admin_port=${AdminPort}"
Cmd="${Cmd} --log_file=/logs/%T.TRADER.${Book}.log"
if ${COMPRESS_LOG}; then
Cmd="${Cmd} --compress_log"
fi
echo ${Cmd}
eval ${Cmd}