diff --git a/trading/executor/run_executor.sh b/trading/executor/run_executor.sh index e176633..340bb46 100755 --- a/trading/executor/run_executor.sh +++ b/trading/executor/run_executor.sh @@ -28,7 +28,6 @@ # runs on host to start container usage() { echo -n "Usage: $0" - echo -n " -b " echo -n " [-c ]" echo -n " [-e ]" echo -n " [-a "] diff --git a/trading/trader/.creds b/trading/trader/.creds new file mode 100644 index 0000000..4b66d91 --- /dev/null +++ b/trading/trader/.creds @@ -0,0 +1,12 @@ +{ + "__dummy__": null + , "ALPACA_SANDBOX": { + "api_key": "PKLZSLFZMFMN1R28K9HK" + , "secret_key": "SKbxwLWJNs4kpn618DgGaopN6x1xzKwLM4Z7aymA" + } + , "MATTERMOST": { + "url": "https://mattermost.cryptovaltrading.com" + , "team": "CVTT" + , "bearer": "5ysaaxjeijrwjbmhuzcuos9ano" + } +} diff --git a/trading/trader/Dockerfile b/trading/trader/Dockerfile new file mode 100644 index 0000000..fdfe57a --- /dev/null +++ b/trading/trader/Dockerfile @@ -0,0 +1,24 @@ +FROM python:3.10-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" ] + + diff --git a/trading/trader/requirements.txt b/trading/trader/requirements.txt new file mode 100644 index 0000000..9c3895b --- /dev/null +++ b/trading/trader/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 diff --git a/trading/trader/run_trader.sh b/trading/trader/run_trader.sh new file mode 100755 index 0000000..57582d0 --- /dev/null +++ b/trading/trader/run_trader.sh @@ -0,0 +1,90 @@ +#!/bin/bash + +# runs in container +# -------------------------------------------------------------------------- +#[program:trader_alpaca] +#directory=/home/cvtt/prod +#command=/home/cvtt/.pyenv/python3.10-venv/bin/python3 +# -u /home/cvtt/prod/cvttpy/apps/trader_app.py +# --config=http://cloud16.cvtt.vpn:6789/apps/cvtt_eqt_alpac +# --active_exchanges=ALPACA_SNDBX-MDPORTAL +# --book=ALPACA_BK02 +# +# --dynamic_instruments=ALPACA_SNDBX +# --algo=TRDALGO_MOOMOC_01 +# --admin_port=7226 +# --log_level=INFO +# --log_file=/home/cvtt/prod/logs/%%T.TRADER_APP.log + +# runs on host to start container +usage() { + echo -n "Usage: $0" + echo -n " -b " + + echo -n " -A (dflt: TRDALGO_001)" + + echo -n " [-c ]" + echo -n " [-e ]" + echo -n " [-a "] + echo + exit 1 +} + + + +# ConfigServer=cloud16.cvtt.vpn +ConfigServer=cloud23.cvtt.vpn:6789 +ActiveExchanges=ALPACA_SNDBX-MDPORTAL +AdminPort=7226 +Algo=TRDALGO_001 +Book="" + + +while getopts ":b:c:e:a:" opt; do + case ${opt} in + c ) + ConfigServer=$OPTARG + ;; + e ) + ActiveExchanges=$OPTARG + ;; + a ) + AdminPort=$OPTARG + ;; + 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.10" +Cmd="${Cmd} cvttpy/apps/trader_app.py" +Cmd="${Cmd} --config=http://${ConfigServer}/apps/cvtt_eqt_alpaca" +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" +Cmd="${Cmd} --compress_log" +echo ${Cmd} +eval ${Cmd} + +