moved some to cvtt_docker
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
FROM python:3.12-slim
|
||||
|
||||
COPY requirements.txt /
|
||||
|
||||
RUN pip install --upgrade pip --root-user-action=ignore
|
||||
RUN pip install -r /requirements.txt --root-user-action=ignore
|
||||
|
||||
COPY cvttpy /cvttpy
|
||||
|
||||
RUN mkdir -p /logs /config /data
|
||||
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
|
||||
ENV PYTHONPATH=/
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
@@ -0,0 +1 @@
|
||||
0.0.1
|
||||
Executable
+87
@@ -0,0 +1,87 @@
|
||||
#!/bin/bash
|
||||
|
||||
# --- Settings
|
||||
RegistryService=cloud21.cvtt.vpn:5500
|
||||
ImageName=trading_simulator
|
||||
BashFunctionCode=$(realpath $(dirname ${0}))/../dckr_bld_functions.sh
|
||||
ImageVersion=$(cat $(realpath $(dirname ${0}))/VERSION)
|
||||
# --- Settings
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 -L <library>:<library_version> [-V <image_version>] "
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
# ---------------- cmdline
|
||||
while getopts "I:V:L:" opt; do
|
||||
case ${opt} in
|
||||
V )
|
||||
ImageVersion=$OPTARG
|
||||
;;
|
||||
L )
|
||||
Library=$OPTARG
|
||||
;;
|
||||
\? )
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
usage
|
||||
;;
|
||||
: )
|
||||
echo "Option -$OPTARG requires an argument." >&2
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
# ---------------- cmdline
|
||||
|
||||
if [ "${ImageName}" == "" ]
|
||||
then
|
||||
usage
|
||||
fi
|
||||
|
||||
if [ "${ImageVersion}" == "" ]
|
||||
then
|
||||
usage
|
||||
fi
|
||||
|
||||
DockerDir=$(realpath $(dirname ${0})/${ImageName})
|
||||
cd ${DockerDir}
|
||||
|
||||
Project=
|
||||
ProjectVersion=
|
||||
if [ "${Library}" != "" ] ; then
|
||||
IFS=':' read -ra parts <<< "${Library}"
|
||||
Project=${parts[0]}
|
||||
ProjectVersion=${parts[1]}
|
||||
fi
|
||||
# exit
|
||||
|
||||
build_musvc_image() {
|
||||
ImageName=${1}
|
||||
Project=${2}
|
||||
ProjectVersion=${3}
|
||||
|
||||
DockerDir=$(realpath $(dirname ${0}))
|
||||
cd ${DockerDir}
|
||||
|
||||
if [ "${Project}" != "" ]; then
|
||||
get_project_version ${Project} ${ProjectVersion}
|
||||
fi
|
||||
|
||||
function cleanup {
|
||||
cd ${DockerDir}
|
||||
rm -rf cvttpy
|
||||
}
|
||||
trap cleanup RETURN
|
||||
|
||||
build_docker_image ${ImageName} ${RegistryService} ${ImageVersion} ${Project} ${ProjectVersion}
|
||||
}
|
||||
|
||||
|
||||
source ${BashFunctionCode}
|
||||
build_musvc_image ${ImageName} ${Project} ${ProjectVersion}
|
||||
|
||||
# echo "**** D E B U G E X I T" && exit
|
||||
echo "***** ${0} D O N E"
|
||||
|
||||
|
||||
@@ -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=
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
LogDir=/logs
|
||||
|
||||
Cmd="python3.12"
|
||||
Cmd+=" cvttpy/apps/trading_simulator/main.py"
|
||||
|
||||
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+=" ${TRDSIM_ADD_ARGS}"
|
||||
echo ${Cmd}
|
||||
exec ${Cmd}
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user