diff --git a/relative_liquidity/Dockerfile b/market_data/relative_liquidity/Dockerfile similarity index 100% rename from relative_liquidity/Dockerfile rename to market_data/relative_liquidity/Dockerfile diff --git a/relative_liquidity/HOWTO.md b/market_data/relative_liquidity/HOWTO.md similarity index 100% rename from relative_liquidity/HOWTO.md rename to market_data/relative_liquidity/HOWTO.md diff --git a/relative_liquidity/requirements.txt b/market_data/relative_liquidity/requirements.txt similarity index 100% rename from relative_liquidity/requirements.txt rename to market_data/relative_liquidity/requirements.txt diff --git a/executor/.creds b/trading/executor/.creds similarity index 100% rename from executor/.creds rename to trading/executor/.creds diff --git a/executor/Dockerfile b/trading/executor/Dockerfile similarity index 100% rename from executor/Dockerfile rename to trading/executor/Dockerfile diff --git a/executor/requirements.txt b/trading/executor/requirements.txt similarity index 100% rename from executor/requirements.txt rename to trading/executor/requirements.txt diff --git a/quant/.creds b/trading/quant/.creds similarity index 100% rename from quant/.creds rename to trading/quant/.creds diff --git a/quant/Dockerfile b/trading/quant/Dockerfile similarity index 100% rename from quant/Dockerfile rename to trading/quant/Dockerfile diff --git a/quant/requirements.txt b/trading/quant/requirements.txt similarity index 100% rename from quant/requirements.txt rename to trading/quant/requirements.txt diff --git a/trading/risk_mgr/.creds b/trading/risk_mgr/.creds new file mode 100644 index 0000000..0a3b012 --- /dev/null +++ b/trading/risk_mgr/.creds @@ -0,0 +1,7 @@ +{ + "__dummy__": null + , "ALPACA_SANDBOX": { + "api_key": "PKLZSLFZMFMN1R28K9HK" + , "secret_key": "SKbxwLWJNs4kpn618DgGaopN6x1xzKwLM4Z7aymA" + } +} diff --git a/trading/risk_mgr/Dockerfile b/trading/risk_mgr/Dockerfile new file mode 100644 index 0000000..79cd66d --- /dev/null +++ b/trading/risk_mgr/Dockerfile @@ -0,0 +1,23 @@ +FROM python:3.10-slim + +ARG FROM_DIR=docker_dev/market_data/md_portal + +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_md_portal.sh /run_md_portal.sh +RUN chmod +x /run_md_portal.sh + +RUN mkdir /logs + + +WORKDIR / +SHELL ["/bin/bash", "-c"] +ENV PYTHONPATH=/ +ENTRYPOINT [ "/run_md_portal.sh" ] + diff --git a/trading/risk_mgr/requirements.txt b/trading/risk_mgr/requirements.txt new file mode 100644 index 0000000..99d9a78 --- /dev/null +++ b/trading/risk_mgr/requirements.txt @@ -0,0 +1,7 @@ +aiohttp>=3.7.4.post0 +nest-asyncio>=1.5.5 +hjson>=3.1.0 +sortedcontainers>=2.4.0 +aioredis>=2.0.1 +python-dateutil>=2.8.2 +types-python-dateutil>=2.8.19.6 diff --git a/trading/risk_mgr/run_risk_mgr.sh b/trading/risk_mgr/run_risk_mgr.sh new file mode 100755 index 0000000..fb44706 --- /dev/null +++ b/trading/risk_mgr/run_risk_mgr.sh @@ -0,0 +1,81 @@ +#!/bin/bash + +# runs in container + +# [program:risk_manager_alpaca] +# directory=/home/cvtt/prod +# command=/home/cvtt/.pyenv/python3.10-venv/bin/python3 +# -u /home/cvtt/prod/cvttpy/apps/risk_manager_app.py +# --config=http://cloud16.cvtt.vpn:6789/apps/cvtt_eqt_alpaca +# --active_exchanges=ALPACA_SNDBX-MDPORTAL +# --book=ALPACA_BK02 +# # --redis_settings=cvtt-prod-02 +# --dynamic_instruments=ALPACA_SNDBX +# --admin_port=7223 +# --log_level=INFO +# --log_file=/home/cvtt/prod/logs/%%T.RISK_MGR_APP.log +# # --debug_mode +# autostart=true +# autorestart=true +# startretries=1 +# startsecs=3 +# priority=2 + + +# runs on host to start container +usage() { + echo -n "Usage: $0 -c " + echo -n " -e " + echo -n " -a " + echo -n " -b " + echo + exit 1 +} + + + +# ConfigServer=cloud16.cvtt.vpn +ConfigServer=cloud23.cvtt.vpn:6789 +ActiveExchanges=ALPACA_SNDBX-MDPORTAL +PortalName=MD_PORTAL_ALPACA +AdminPort=7223 + + +while getopts ":c:e:a:n:" opt; do + case ${opt} in + c ) + ConfigServer=$OPTARG + ;; + e ) + ActiveExchanges=$OPTARG + ;; + a ) + AdminPort=$OPTARG + ;; + n ) + PortalName=$OPTARG + ;; + \? ) + echo "Invalid option: -$OPTARG" >&2 + usage + ;; + : ) + echo "Option -$OPTARG requires an argument." >&2 + usage + ;; + esac +done + + +Cmd="python3.10" +Cmd="${Cmd} cvttpy/apps/md/md_portal.py" +Cmd="${Cmd} --config=http://${ConfigServer}/apps/cvtt_eqt_alpaca" +Cmd="${Cmd} --credentials_file=/.creds" +Cmd="${Cmd} --active_exchanges=${ActiveExchanges}" +Cmd="${Cmd} --admin_port=${AdminPort}" +Cmd="${Cmd} --log_file=/logs/%T.${PortalName}.log" +# Cmd="${Cmd} --compress_log" +echo ${Cmd} +eval ${Cmd} + +