diff --git a/trading/quant/Dockerfile b/trading/quant/Dockerfile index cedc88b..e326e0b 100644 --- a/trading/quant/Dockerfile +++ b/trading/quant/Dockerfile @@ -1,36 +1,24 @@ FROM python:3.10-slim -WORKDIR / -COPY docker_dev/quant/requirements.txt / -RUN pip install --upgrade pip -RUN pip install -r /requirements.txt - -RUN apt-get update && apt-get install -y \ - apt-utils \ - libpq-dev \ - build-essential +ARG FROM_DIR=docker_dev/trading/quant +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 docker_dev/quant/.creds /.creds +COPY ${FROM_DIR}/.creds /.creds + + +COPY ${FROM_DIR}/run_quant.sh /run_quant.sh +RUN chmod +x /run_quant.sh RUN mkdir /logs +WORKDIR / +SHELL ["/bin/bash", "-c"] ENV PYTHONPATH=/ +ENTRYPOINT [ "/run_quant.sh" ] -# default config -ENV CONFIG=http://cloud16.cvtt.vpn:6789/apps/cvtt -ENV BOOK_ID=CVTT_CLD17_BK01 -CMD [ \ - "python3.10", \ - "cvttpy/apps/quant_app.py", \ - "--config=http://cloud16.cvtt.vpn:6789/apps/cvtt", \ - "--credentials_file=/.creds", \ - "--active_exchanges=COINBASE_AT", \ - "--instruments=COINBASE:PAIR-BTC-USD", \ - "--book=CVTT_CLD17_BK01", \ - "--admin_port=7221", \ - "--log_file=/logs/%T.QUANT.log" \ -] diff --git a/trading/quant/run_quant.sh b/trading/quant/run_quant.sh new file mode 100755 index 0000000..5a839a0 --- /dev/null +++ b/trading/quant/run_quant.sh @@ -0,0 +1,84 @@ +#!/bin/bash + +# runs in container +#command=/home/cvtt/.pyenv/python3.10-venv/bin/python3 +# -u /home/cvtt/prod/cvttpy/apps/quant_app.py +# --config=http://cloud16.cvtt.vpn:6789/apps/cvtt_eqt_alpaca +# --active_exchanges=ALPACA_SNDBX-MDPORTAL +# --book=ALPACA_BK02 +# --strategy=DAILY_STOCK_001 +# --dynamic_instruments=ALPACA_SNDBX +# --admin_port=7224 +# --log_level=INFO +# --log_file=/home/cvtt/prod/logs/%%T.QUANT_APP.log +# # --debug_mode + +# runs on host to start container +usage() { + echo -n "Usage: $0" + echo -n " -b " + + echo -n " -S (dflt: TRDALGO_001)" + + echo -n " [-c ]" + echo -n " [-e ]" + echo -n " [-a "] + echo + exit 1 +} + +ConfigServer=cloud23.cvtt.vpn:6789 +ActiveExchanges=ALPACA_SNDBX-MDPORTAL +AdminPort=7224 +Strategy=DAILY_STOCK_001 +Book="" + + +while getopts ":b:c:e:a:S:" opt; do + case ${opt} in + c ) + ConfigServer=$OPTARG + ;; + e ) + ActiveExchanges=$OPTARG + ;; + a ) + AdminPort=$OPTARG + ;; + b ) + Book=$OPTARG + ;; + S ) + Strategy=$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.10" +Cmd="${Cmd} cvttpy/apps/quant_app.py" +Cmd="${Cmd} --config=http://${ConfigServer}/apps/cvtt_eqt_alpaca" +Cmd="${Cmd} --credentials_file=/.creds" +Cmd="${Cmd} --book=${Book}" +Cmd="${Cmd} --strategy=${Strategy}" +Cmd="${Cmd} --allow_dynamic_exch_inst" +Cmd="${Cmd} --active_exchanges=${ActiveExchanges}" +Cmd="${Cmd} --admin_port=${AdminPort}" +Cmd="${Cmd} --log_file=/logs/%T.QUANT.${Book}.log" +Cmd="${Cmd} --compress_log" +echo ${Cmd} +eval ${Cmd} + + diff --git a/trading/trader/run_trader.sh b/trading/trader/run_trader.sh index 57582d0..80bf29b 100755 --- a/trading/trader/run_trader.sh +++ b/trading/trader/run_trader.sh @@ -40,7 +40,7 @@ Algo=TRDALGO_001 Book="" -while getopts ":b:c:e:a:" opt; do +while getopts ":b:c:e:a:A:" opt; do case ${opt} in c ) ConfigServer=$OPTARG