moved some to cvtt_docker

This commit is contained in:
Oleg Sheynin 2025-04-25 17:52:29 -04:00
parent 99e9516830
commit 84569a7c24
70 changed files with 187 additions and 57 deletions

View File

@ -0,0 +1 @@
0.0.7

View File

@ -13,8 +13,11 @@ ValidImages+=(bookkeeper)
ValidImages+=(risk_manager)
ValidImages+=(quant)
ValidImages+=(trader)
BashFunctionCode=$(realpath $(dirname ${0}))/../dckr_bld_functions.sh
ImageVersion=$(cat $(realpath $(dirname ${0}))/VERSION)
ScriptPath=$(realpath $(dirname ${0}))
BashFunctionCode=${ScriptPath}/../dckr_bld_functions.sh
ImageVersion=$(cat ${ScriptPath}/VERSION)
# --- Settings
usage() {
@ -71,8 +74,9 @@ build_musvc_image() {
Project=${2}
ProjectVersion=${3}
DockerDir=$(realpath $(dirname ${0})/${ImageName})
cd ${DockerDir}
DockerDir=${ScriptPath}/${ImageName}
Cmd="cd ${DockerDir}"
echo ${Cmd} && eval ${Cmd}
if [ "${Project}" != "" ]; then
get_project_version ${Project} ${ProjectVersion}
@ -103,7 +107,6 @@ for ImageName in "${Images[@]}"; do
build_musvc_image ${ImageName} ${Project} ${ProjectVersion}
done
# echo "**** D E B U G E X I T" && exit
echo "***** ${0} D O N E"

View File

@ -3,6 +3,15 @@
LogDir=/logs
Cmd="python3.12"
if [ "${COORD_DEBUG}" == "Y" ]; then
Cmd+=" -m debugpy"
Cmd+=" --listen 0.0.0.0:5678"
if [ "${COORD_DEBUG_WAIT}" == "Y" ]; then
Cmd+=" --wait-for-client"
fi
fi
Cmd+=" cvttpy/apps/microservices/coordinator/coordinator.py"
Cmd+=" --config=${CONFIG_FILE:-/config/cvtt_musvc.cfg}"

View File

@ -7,3 +7,4 @@ python-dateutil>=2.8.2
types-python-dateutil>=2.8.19.6
cryptography>=43.0.0
PyJWT>=2.10.1
debugpy>=1.8.13

View File

@ -7,7 +7,7 @@ RUN pip install -r /requirements.txt --root-user-action=ignore
COPY cvttpy /cvttpy
RUN mkdir -p /logs /config
RUN mkdir -p /logs /config /data
SHELL ["/bin/bash", "-c"]

View File

@ -0,0 +1,9 @@
TRDSIM_VERSION=0.0.1
CONFIG_SERVICE=cloud16.cvtt.vpn:6789
CONFIG_FILE="/config/simulation.cfg"
TRDSIM_USER=1001:1001
TRDSIM_LOG_FILE=%T.trading_simulator.log
TRDSIM_ADD_ARGS=

View File

@ -0,0 +1,131 @@
@var DATA_DIR=/home/oleg/develop/simulation/data
@var FROM_TIME="2024-11-14 13:30:00"
@var INTERVAL="18 minutes"
# @var INTERVAL="5 minutes"
{
"refdata": @inc=http://@env{CONFIG_SERVICE}/refdata/refdata
, "comm": @inc=http://@env{CONFIG_SERVICE}/apps/common/comm
, "comm": @inc=http://@env{CONFIG_SERVICE}/apps/common/comm
, "comm_settings": "/comm/pubsub/redis/localhost"
, "simulation": {
# "speed_factor": 1.0,
"speed_factor": 0.0,
"time_events_interval_ms": 0
}
, "market_simulator" : {
"initial_positions": {
"exchange": "COINBASE",
"assets": {
"BTC": 0.5
, "ETH": 0.0
, "USD": 10_000.0
}
}
, "market_data": {
"sources": [
{
"loader_class": "cvttpy.trading.mkt_data.time_series.loaders.sqlite_loader.SqliteMdLoader"
, "file_name": "${DATA_DIR}/20250422.CNBS.BTC_USD.db"
, "table_name": "md_trades"
, "columns": [
"tstamp"
, "tstamp_ns as tm" # must have tm for DataFrame
, "tstamp_ns as local_time_ns" # must have for simrunner
, "exchange_id"
, "instrument_id"
, "px"
, "qty"
, "trade_id"
, "condition as agressor_side"
]
, "time_column": "tstamp"
, "exchange_id": "COINBASE"
, "instruments": ["PAIR-BTC-USD"]
, "md_type": "TRADES"
}
# , {
# "loader_class": "cvttpy.trading.mkt_data.time_series.loaders.tsdb_loader.TimescaleTSLoader"
# , "credentials_key": "TSDB_MD_CVTTDATA_RO"
# , "interval": ${INTERVAL}
# , "from_time": ${FROM_TIME} #"2024-10-03 09:00:00"
# , "exchange_id": "COINBASE"
# , "instruments": ["PAIR-BTC-USD"]
# , "md_type": "BOOK_TOP"
# , "table_name": "coinbase.md_booktops"
# , "columns": [
# "time",
# "local_time_ns",
# "exchange_id",
# "instrument_id",
# "bid_price",
# "bid_quantity",
# "ask_price",
# "ask_quantity",
# "'BT' as type",
# ]
# , "time_column": "time"
# }
]
, "api": {
"web_socket": {
"url": "ws://localhost:8080/ws"
}
}
}
, "order_entry": {
"execution": {
"execute_on": ["BOOK_TOP", "TRADES"]
"top_only": true
,"min_order_age_sec": 0.1
, "pricing_method": "BY_MKT_TRD_PRICE_BY_TRADE"
, "short_sale_allowed": false
, "fee_schedule": {
"taker_fee_rate": 0.006
"maker_fee_rate": 0.004
}
# , "presubscribe_md_types": ["BOOK_TOP", "TRADES"]
}
, "api": {
"web_socket": {
"url": "ws://localhost:8180/ws"
}
, "REST": {
"port": 8181
"new_order_url": ["POST", "http://localhost:8181/order"]
, "cancel_order_url": ["POST", "http://localhost:8181/cancel"]
, "cancel_all_url": ["POST", "http://localhost:8181/cancel_all"]
, "open_orders_url": ["GET", "http://localhost:8181/open_orders"]
, "order_status_url": ["GET", "http://localhost:8181/order_status"]
}
}
}
, "accounting": {
"api": {
"REST": {
"port": 8182
, "positions_url": ["GET", "http://localhost:8182/positions"]
, "trades_url": ["GET", "http://localhost:8182/trades"]
}
}
}
}
, "external_participants": [
{
"class": "cvttpy.apps.trading_simulator.participants.external_strategy.ExternalStrategySim"
"params": {
"reader": {
"source": "file:///home/oleg/develop/cvtt2/simulation/trading_instructions.json"
}
"listener": {
# communicate with coordinator
"coordinator_url": "http://localhost:12345"
, "book_id": "TESTBK_COINBS_01"
, "strategy_id": "DUMMY_STRATEGY"
}
}
}
]
}

View File

@ -0,0 +1,16 @@
# CVTT Microservices
services:
trdsim:
image: cloud21.cvtt.vpn:5500/trading_simulator:${TRDSIM_VERSION}
container_name: trading_simulator
pull_policy: always
user: ${TRDSIM_USER:-1001:1001}
environment:
CONFIG_SERVICE: ${CONFIG_SERVICE:-cloud16.cvtt.vpn:6789}
CONFIG_FILE: ${CONFIG_FILE:-http://${CONFIG_SERVICE}/apps/cvtt_musvc}
TRDSIM_LOG_FILE: ${TRDSIM_LOG_FILE:-%T.trader.log}
TRDSIM_ADD_ARGS: ${TRDSIM_ADD_ARGS:-}
volumes:
- ./config:/config
- ./data:/data
- ./logs:/logs

View File

@ -9,7 +9,7 @@ Cmd+=" --config=${CONFIG_FILE:-/config/simulation.cfg}"
Cmd+=" --simtime_file=${SIMTIME_FILE:-/data/simtime.bin}"
Cmd+=" --cfgvar=DATA_DIR=/data"
Cmd+=" --log_file=${LogDir}/$TRDSIM_LOG_FILE:-%T.trading_simulator.log}"
Cmd+=" --log_file=${LogDir}/${TRDSIM_LOG_FILE:-%T.trading_simulator.log}"
Cmd+=" ${TRDSIM_ADD_ARGS}"
echo ${Cmd}
exec ${Cmd}

View File

@ -0,0 +1,10 @@
aiohttp>=3.7.4.post0
nest-asyncio>=1.5.5
hjson>=3.1.0
sortedcontainers>=2.4.0
pandas>=1.5.3
# redis>=5.0.8
# python-dateutil>=2.8.2
# types-python-dateutil>=2.8.19.6
# cryptography>=43.0.0
# PyJWT>=2.10.1

View File

@ -1 +0,0 @@
0.0.6

View File

@ -1,9 +0,0 @@
aiohttp>=3.7.4.post0
nest-asyncio>=1.5.5
hjson>=3.1.0
sortedcontainers>=2.4.0
redis>=5.0.8
python-dateutil>=2.8.2
types-python-dateutil>=2.8.19.6
cryptography>=43.0.0
PyJWT>=2.10.1

View File

@ -1,21 +0,0 @@
FROM python:3.12-slim
ARG FROM_DIR=docker_dev/test/rsync_test
COPY ${FROM_DIR}/test.sh /test.sh
RUN apt-get update && apt-get install -y rsync openssh-client
COPY docker_dev/shared/id_rsa /root/.ssh/id_rsa
COPY docker_dev/shared/id_rsa.pub /root/.ssh/id_rsa.pub
RUN chmod 600 /root/.ssh/id_rsa /root/.ssh/id_rsa.pub
# Shared Volumes
RUN chmod +x /test.sh
WORKDIR /
SHELL ["/bin/bash", "-c"]
ENV PYTHONPATH=/
ENTRYPOINT [ "/test.sh" ]

View File

@ -1,19 +0,0 @@
#!/bin/bash
date > /testfile.txt
Source=/testfile.txt
Targets=
Targets="${Targets} cvtt@cloud21.cvtt.vpn:/tmp/"
Targets="${Targets} cvtt@hs01.cvtt.vpn:/tmp/"
for tgt in ${Targets}
do
Cmd="/usr/bin/rsync -ahv"
Cmd+=" -e 'ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'"
Cmd+=" ${Source} ${tgt}"
echo $Cmd
eval $Cmd
done