diff --git a/trading/executor/.creds b/trading/executor/.creds index c4e3a39..4b66d91 100644 --- a/trading/executor/.creds +++ b/trading/executor/.creds @@ -1,14 +1,12 @@ { - "COINBASE_ADV_TRD": { - "api_key": "nKIyZxS95J4MsY4N" - , "secret_key": "sih7Txx3htlTWJrQ3EiuRS3qRfv7qZ4P" - , "account_uuid": "???" - , "book_id": "CVTT_BK01" + "__dummy__": null + , "ALPACA_SANDBOX": { + "api_key": "PKLZSLFZMFMN1R28K9HK" + , "secret_key": "SKbxwLWJNs4kpn618DgGaopN6x1xzKwLM4Z7aymA" } - , "COINBASE_ADV_RO": { - "api_key": "Ip4QpRtRHBmWNpc3" - , "secret_key": "N6ZEMdIdUYUldkJRTUcCRKUFot4Fp2j0" - , "account_uuid": "???" - , "book_id": "CVTT_BK01" + , "MATTERMOST": { + "url": "https://mattermost.cryptovaltrading.com" + , "team": "CVTT" + , "bearer": "5ysaaxjeijrwjbmhuzcuos9ano" } } diff --git a/trading/executor/Dockerfile b/trading/executor/Dockerfile index 5eae005..aefb1a3 100644 --- a/trading/executor/Dockerfile +++ b/trading/executor/Dockerfile @@ -1,29 +1,24 @@ FROM python:3.10-slim -WORKDIR / -COPY docker_dev/executor/requirements.txt / -RUN pip install --upgrade pip -RUN pip install -r /requirements.txt +ARG FROM_DIR=docker_dev/trading/executor +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/executor/.creds /.creds +COPY ${FROM_DIR}/.creds /.creds + + +COPY ${FROM_DIR}/run_executor.sh /run_executor.sh +RUN chmod +x /run_executor.sh RUN mkdir /logs +WORKDIR / +SHELL ["/bin/bash", "-c"] ENV PYTHONPATH=/ +ENTRYPOINT [ "/run_executor.sh" ] -# 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", \ - "--admin_port=7220", \ - "--active_exchanges=COINBASE_AT", \ - "--credentials_file=/.creds", \ - "--log_file=/logs/%T.EXECUTOR_APP.log" \ -] diff --git a/trading/executor/run_executor.sh b/trading/executor/run_executor.sh new file mode 100755 index 0000000..0c9e8f9 --- /dev/null +++ b/trading/executor/run_executor.sh @@ -0,0 +1,81 @@ +#!/bin/bash + +# runs in container + +# CMD [ \ +# "python3.10", \ +# "cvttpy/apps/executor_app.py", \ +# "--config=http://cloud16.cvtt.vpn:6789/apps/cvtt", \ +# "--admin_port=7220", \ +# "--active_exchanges=COINBASE_AT", \ +# "--credentials_file=/.creds", \ +# "--log_file=/logs/%T.EXECUTOR_APP.log" \ +# ] + +# [program:executor_alpaca] +# directory=/home/cvtt/prod +# command=/home/cvtt/.pyenv/python3.10-venv/bin/python3 +# -u /home/cvtt/prod/cvttpy/apps/executor_app.py +# --config=http://cloud16.cvtt.vpn:6789/apps/cvtt_eqt_alpaca +# --active_exchanges=ALPACA_SNDBX-MDPORTAL +# --admin_port=7222 +# --log_level=INFO +# --log_file=/home/cvtt/prod/logs/%%T.EXECUTOR_APP.log +# # --debug_mode + + + +# runs on host to start container +usage() { + echo -n "Usage: $0" + echo -n " -b " + echo -n " [-c ]" + echo -n " [-e ]" + echo -n " [-a "] + echo + exit 1 +} + + + +# ConfigServer=cloud16.cvtt.vpn +ConfigServer=cloud23.cvtt.vpn:6789 +ActiveExchanges=ALPACA_SNDBX +AdminPort=7222 + + +while getopts ":c:e:a:" opt; do + case ${opt} in + c ) + ConfigServer=$OPTARG + ;; + e ) + ActiveExchanges=$OPTARG + ;; + a ) + AdminPort=$OPTARG + ;; + \? ) + echo "Invalid option: -$OPTARG" >&2 + usage + ;; + : ) + echo "Option -$OPTARG requires an argument." >&2 + usage + ;; + esac +done + +Cmd="python3.10" +Cmd="${Cmd} cvttpy/apps/executor_app.py" +Cmd="${Cmd} --config=http://${ConfigServer}/apps/cvtt_eqt_alpaca" +Cmd="${Cmd} --credentials_file=/.creds" +Cmd="${Cmd} --allow_dynamic_exch_inst" +Cmd="${Cmd} --active_exchanges=${ActiveExchanges}" +Cmd="${Cmd} --admin_port=${AdminPort}" +Cmd="${Cmd} --log_file=/logs/%T.EXECUTOR_APP.${Book}.log" +# Cmd="${Cmd} --compress_log" +echo ${Cmd} +eval ${Cmd} + +