Compare commits

...

34 Commits

Author SHA1 Message Date
oleg e23ddd5e44 progress 2025-05-18 19:35:51 -04:00
oleg 9bb868845f fix 2025-05-18 19:11:19 -04:00
oleg aced5b23e0 progress 2025-05-18 19:05:25 -04:00
oleg 9eb4f8e117 daily sim for docker.initial 2025-05-18 18:42:08 -04:00
oleg 3e49b5bf27 Merge branch 'master' of cloud21.cvtt.vpn:/opt/store/git/cvtt2/ops 2025-05-17 23:29:01 -04:00
oleg 0876776d60 progress 2025-05-17 19:30:00 -04:00
Cryptoval2 fb685ca91d cleaning 2025-05-16 16:00:44 +00:00
Cryptoval2 f1a83c8e33 . 2025-05-16 15:58:26 +00:00
Cryptoval2 26540a5294 cleaning 2025-05-16 15:57:12 +00:00
oleg c37d62637a Merge branch 'master' of cloud21.cvtt.vpn:/opt/store/git/cvtt2/ops 2025-05-16 11:36:33 -04:00
oleg bcb257add4 deprecated 2025-05-16 11:36:12 -04:00
Cryptoval2 ccc45b06ea utils upgrade 2025-05-16 15:16:01 +00:00
Cryptoval2 ebcf3ac20b Merge branch 'master' of cloud21.cvtt.vpn:/opt/store/git/cvtt2/ops 2025-05-16 13:28:39 +00:00
Cryptoval2 d66bf5f48b 2.1.3,remove cvttdata 2025-05-16 13:28:00 +00:00
oleg 5c3fd357ab Merge branch 'master' of cloud21.cvtt.vpn:/opt/store/git/cvtt2/ops 2025-05-15 18:28:08 -04:00
Cryptoval2 1432794197 2.1.2,fix 2025-05-15 19:40:31 +00:00
Cryptoval2 52dd9997ca 2.1.1,archive_logs interface change 2025-05-15 19:30:09 +00:00
oleg 066bdbdb93 new aggregate features are added to research 2025-05-05 15:31:56 -04:00
Cryptoval2 f59c729c6f flexible target directory for loading sim data 2025-04-16 17:15:03 +00:00
Cryptoval2 df04d764c8 prepare crypto sim enhanced 2025-03-24 17:25:57 +00:00
Cryptoval2 06610de992 OPS-10 2025-03-21 17:04:23 +00:00
oleg 9aaf356048 OPS-6 2025-03-18 13:47:51 -04:00
oleg f2bb798fff fix 2025-03-07 23:16:48 -05:00
oleg b0a0080a4a replacing "latest" with real docker image tag 2025-03-07 23:12:38 -05:00
oleg e35b15f024 replacing "latest" with real docker image tag 2025-03-07 23:09:39 -05:00
oleg 3bd31b7d8b crypto_md_day - specific docker tag 2025-03-07 23:02:06 -05:00
oleg 085308ff9c using specific version for md_recorder 2025-03-07 22:42:46 -05:00
oleg 9f789738e9 using HA trading-calendar and config service 2025-02-03 15:31:34 -05:00
oleg d5e1f0a446 fix 2025-01-27 18:24:47 -05:00
oleg f639bd41f5 docker build imagages script fix 2025-01-27 18:15:30 -05:00
oleg a35bcf089e minor 2025-01-27 17:07:28 -05:00
oleg 5bf02ae67a release_version.txt -> VERSION 2025-01-27 16:41:22 -05:00
oleg 43c50befc4 docker to use CONFIG_SERVICE 2025-01-24 11:39:04 -05:00
oleg 48ecf7cca2 storage healthcheck - ignore known_hosts 2025-01-22 17:48:13 -05:00
38 changed files with 792 additions and 293 deletions
+1
View File
@@ -0,0 +1 @@
2.1.7,docker prepare sim - crypto - progress
@@ -17,7 +17,7 @@ is_container_running() {
fi
}
export CalendarURL=http://cloud23.cvtt.vpn:8000/api/v1/markets/hours?mic=XNYS
export CalendarURL=https://trading-calendar.cvtt.net/api/v1/markets/hours?mic=XNYS
is_business_day() {
dt=${1}
@@ -3,7 +3,7 @@
ValidJobs=('BNBFUT_CLD21' 'BNBSPOT_CLD21' 'COINBASE_CLD21' 'BNBFUT_CVTTDATA' 'BNBSPOT_CVTTDATA' 'COINBASE_CVTTDATA')
# runs on host to start container
usage() {
echo "Usage: $0 <job_name; one of (${ValidJobs[@]})>"
echo "Usage: $0 <job_name; one of (${ValidJobs[@]})> [image_tag]"
exit 1
}
@@ -35,6 +35,12 @@ if ! is_valid "${job}"; then
usage
fi
ImageTag=${2}
if [ "${ImageTag}" == "" ] ; then
ImageTag="1.6.9"
fi
DockerImage=cloud21.cvtt.vpn:5500/md_recorder:${ImageTag}
ContainerName="md_recorder.${job}"
if is_container_running "$ContainerName"; then
@@ -44,16 +50,17 @@ fi
Cmd="docker run"
Cmd="${Cmd} -d"
Cmd="${Cmd} --rm"
Cmd="${Cmd} --network=host"
Cmd="${Cmd} --pull=always"
Cmd="${Cmd} --name=${ContainerName}"
Cmd="${Cmd} -v /home/cvtt/.creds:/.creds"
Cmd="${Cmd} -v /home/cvtt/prod/data:/app/data"
Cmd="${Cmd} -v /home/cvtt/prod/logs:/logs"
Cmd="${Cmd} cloud21.cvtt.vpn:5500/md_recorder:latest"
Cmd="${Cmd} ${job}"
Cmd+=" -d"
Cmd+=" --rm"
Cmd+=" --network=host"
# Cmd+=" --pull=always"
Cmd+=" --name=${ContainerName}"
Cmd+=" -v /home/cvtt/.creds:/.creds"
Cmd+=" -v /home/cvtt/prod/data:/app/data"
Cmd+=" -v /home/cvtt/prod/logs:/logs"
Cmd+=" -e CONFIG_SERVICE=cloud16.cvtt.vpn:6789"
Cmd+=" ${DockerImage}"
Cmd+=" ${job}"
echo ${Cmd}
eval ${Cmd}
@@ -45,15 +45,16 @@ if is_container_running "$ContainerName"; then
fi
Cmd="docker run"
Cmd="${Cmd} -d"
Cmd="${Cmd} --rm"
Cmd="${Cmd} --network=host"
Cmd="${Cmd} --pull=always"
Cmd="${Cmd} --name=${ContainerName}"
Cmd="${Cmd} -v /home/cvtt/.creds:/.creds"
Cmd="${Cmd} -v /home/cvtt/prod/logs:/logs"
Cmd="${Cmd} cloud21.cvtt.vpn:5500/md_recorder_monitor:latest"
Cmd="${Cmd} ${Instance} ${AdminPort}"
Cmd+=" -d"
Cmd+=" --rm"
Cmd+=" --network=host"
Cmd+=" --pull=always"
Cmd+=" --name=${ContainerName}"
Cmd+=" -v /home/cvtt/.creds:/.creds"
Cmd+=" -v /home/cvtt/prod/logs:/logs"
Cmd+=" -e CONFIG_SERVICE=cloud16.cvtt.vpn:6789"
Cmd+=" cloud21.cvtt.vpn:5500/md_recorder_monitor:latest"
Cmd+=" ${Instance} ${AdminPort}"
echo ${Cmd}
eval ${Cmd}
+6 -5
View File
@@ -14,9 +14,9 @@ dist_user=cvttdist
dist_host="cloud21.cvtt.vpn"
dist_ssh_port="22"
dist_locations="cloud21.cvtt.vpn:22 hs01.cvtt.vpn:22"
# ---------------- Settings
dist_locations="cloud21.cvtt.vpn:22 hs01.cvtt.vpn:22"
version_file="VERSION"
# ---------------- cmdline
prj=
brnch=master
@@ -145,11 +145,12 @@ if [ "${?}" != "0" ]; then
fi
release_version=$(cat release_version.txt | awk -F',' '{print $1}')
whats_new=$(cat release_version.txt | awk -F',' '{print $2}')
release_version=$(cat ${version_file} | awk -F',' '{print $1}')
whats_new=$(cat ${version_file} | awk -F',' '{print $2}')
echo "--------------------------------"
echo "Version file: ${version_file}"
echo "Release version: ${release_version}"
confirm
@@ -175,7 +176,7 @@ if [ "${project}" == "cvtt-rust" ]; then
release_dir=${prj_dir}/dist/${project}
cmd_arr+=("mkdir -p ${release_dir}")
cmd_arr+=("cp release_version.txt ${release_dir}")
cmd_arr+=("cp ${version_file} ${release_dir}")
jq_cmd="jq '.packages[] | select(.targets[].kind[] == \"bin\") | .name'"
apps=$(cargo metadata --no-deps --format-version 1 --manifest-path=${prj_dir}/Cargo.toml | eval $jq_cmd | uniq)
+79 -7
View File
@@ -5,6 +5,11 @@ usage() {
echo
exit 1
}
error_exit() {
echo "ERROR: ${1}"
exit 1
}
# --- Settings
RootDir=${1}
if [ -z "${RootDir}" ] ; then
@@ -14,7 +19,7 @@ fi
RegistryService=cloud21.cvtt.vpn:5500
RegistryProtocol=http
ConfigUrl=http://cloud23.cvtt.vpn:6789/admin/docker_images
ConfigUrl=http://cloud16.cvtt.vpn:6789/admin/docker_images
ReleaseHost="cloud21.cvtt.vpn"
@@ -37,6 +42,7 @@ build_docker_image() {
image_name=${2}
docker_dev_path=${3}
project=${4}
test_script=${5}
echo "Building ${title}..."
echo "ImageName=${image_name}"
@@ -76,29 +82,93 @@ build_docker_image() {
Cmd+=" -t ${image_name}:${image_version}"
Cmd+=" -f ${DockerDir}/Dockerfile ${RootDir}"
echo ${Cmd}
eval ${Cmd} 1>&2 || exit
eval ${Cmd} 1>&2 || error_exit "Docker build failed"
if [ ! -z "${test_script}" ] && [ "${test_script}" != "null" ]; then
if [ ! -f ${DockerDir}/${test_script} ]; then
error_exit "Test script ${test_script} is missing"
fi
echo "Running test script ${test_script} for ${image_name}"
Cmd="docker cp ${DockerDir}/${test_script} ${image_name}:/"
echo ${Cmd}
eval ${Cmd} 1>&2 || error_exit "Test script copy failed"
Cmd="docker exec ${image_name} chmod +x /${test_script}"
echo ${Cmd}
eval ${Cmd} 1>&2 || error_exit "Test script chmod failed"
Cmd="docker run"
Cmd+=" --rm"
Cmd+=" -d"
Cmd+=" --name test-container"
Cmd+=" ${image_name}"
Cmd+=" /bin/bash -c /${TestScript}"
echo ${Cmd}
eval ${Cmd} 1>&2 || error_exit "Test script run failed"
echo "Removing test script ${test_script} from ${image_name}"
Cmd="docker exec ${image_name} rm /${test_script}"
echo ${Cmd}
eval ${Cmd} 1>&2 || error_exit "Test script remove failed"
fi
: <<'COMMENT'
-------------------------
Every single docker_dev project must have a test script
image_test.sh
that is copied to the image's root directory.
-------------------------
Cmd="docker run"
Cmd+=" --rm"
Cmd+=" -d"
Cmd+=" --name test-container"
Cmd+=" ${image_name}"
Cmd+=" /bin/bash -c /${TestScript}"
echo ${Cmd}
eval ${Cmd} 1>&2 || exit 1
# Get the exit status of the test script
docker wait test-container
# Check the exit status of the container
EXIT_STATUS=$?
# Analyze the exit status
if [ ${EXIT_STATUS} -ne 0 ]; then
echo "Tests Failed"
exit 1
fi
COMMENT
Cmd="docker tag"
Cmd+=" ${image_name}:latest"
Cmd+=" ${RegistryService}/${image_name}:latest"
echo ${Cmd}
eval ${Cmd} || exit
eval ${Cmd} || error_exit "Docker tag failed"
Cmd="docker tag"
Cmd+=" ${image_name}:${image_version}"
Cmd+=" ${RegistryService}/${image_name}:${image_version}"
echo ${Cmd}
eval ${Cmd} || exit
eval ${Cmd} || error_exit "Docker tag 2failed"
Cmd="docker push"
Cmd+=" ${RegistryService}/${image_name}:latest"
echo ${Cmd}
eval ${Cmd} || exit
eval ${Cmd} || error_exit "Docker push failed"
Cmd="docker push"
Cmd+=" ${RegistryService}/${image_name}:${image_version}"
echo ${Cmd}
eval ${Cmd} || exit
eval ${Cmd} || error_exit "Docker push 2 failed"
echo "Removing the copy of ${project} from ${RootDir}"
Cmd="rm -rf ${RootDir}/${project}"
@@ -166,6 +236,7 @@ get_latest_dist_version() {
echo "${Version}"
}
echo "------------------------------------- Starting ${0} ${*}"
echo RootDir=${RootDir}
cd ${RootDir}
@@ -188,8 +259,9 @@ for item in "${Jobs[@]}"; do
image_name=$(echo "$item" | jq -r '.value.image_name')
docker_dev_path=$(echo "$item" | jq -r '.value.docker_dev_path')
project=$(echo "$item" | jq -r '.value.based_on_project')
test_script=$(echo "$item" | jq -r '.value.test_script')
build_docker_image "$title" "$image_name" "$docker_dev_path" "$project"
build_docker_image "$title" "$image_name" "$docker_dev_path" "$project" "${test_script}"
done
Cmd="rm -rf ${RootDir}/docker_dev"
+1 -1
View File
@@ -10,7 +10,7 @@ if [ "" == "${prj}" ] ; then
usage
fi
Cmd="pushd /home/oleg/develop/cvtt2"
Cmd="pushd /home/oleg/develop/cvtt2-ops"
Cmd="${Cmd} && (cd ${prj}"
Cmd="${Cmd} && git pushall)"
Cmd="${Cmd} && ./build_release.sh -p ${prj}"
+1 -1
View File
@@ -9,7 +9,7 @@ get_user_hosts() {
local User=${1}
local Domain=${2}
Cmd="curl -s http://cloud23.cvtt.vpn:6789/admin/cvtt_hosts"
Cmd="curl -s http://cloud16.cvtt.vpn:6789/admin/cvtt_hosts"
Cmd="${Cmd} | ${HOME}/bin/hjson -j"
Cmd="${Cmd} | jq -r"
Cmd="${Cmd} --arg domain \"${Domain}\""
+44
View File
@@ -0,0 +1,44 @@
#!/bin/bash
usage() {
echo "Usage: ${0} <docker_image_tag> <host> [<date>]"
exit 1
}
# ------- Settings
DockerRegistry=cloud21.cvtt.vpn:5500
# ------- Settings
ImageTag=${1}
host=${2}
date=${3}
if [ -z ${ImageTag} ] ; then
usage
fi
if [ -z ${host} ] ; then
usage
fi
if [ -z ${date} ] ; then
date=$(date -d "yesterday" +%Y%m%d)
fi
DockerImage=${DockerRegistry}/crypto_md_day:${ImageTag}
Cmd="docker run"
Cmd+=" --pull=always"
Cmd+=" --network=host"
Cmd+=" --name=crypto_md_day.${host}.${date}"
Cmd+=" --rm"
Cmd+=" --volume=${HOME}/.creds:/.creds"
Cmd+=" -e CONFIG_SERVICE=cloud16.cvtt.vpn:6789"
Cmd+=" ${DockerImage}"
Cmd+=" -h ${host}"
Cmd+=" -d ${date}"
# Cmd+=" -s coinbase,bnbspot,bnbfut"
Cmd+=" -s coinbase,bnbspot"
echo $Cmd
eval $Cmd
+66
View File
@@ -0,0 +1,66 @@
#!/bin/bash
ValidJobs=('BNBFUT_CLD21' 'BNBSPOT_CLD21' 'COINBASE_CLD21' 'BNBFUT_CVTTDATA' 'BNBSPOT_CVTTDATA' 'COINBASE_CVTTDATA')
# runs on host to start container
usage() {
echo "Usage: $0 <job_name; one of (${ValidJobs[@]})> [image_tag]"
exit 1
}
is_valid() {
local job=$1
for valid_job in "${ValidJobs[@]}";
do
# echo "job=$job valid_job=$valid_job"
if [[ "${job}" == "${valid_job}" ]]; then
return 0
fi
done
return 1
}
is_container_running() {
local container_name=$1
if [ "$(docker ps --filter "name=^/${container_name}$" --filter "status=running" -q)" ]; then
return 0 # true
else
return 1 # false
fi
}
job=${1}
if ! is_valid "${job}"; then
usage
fi
ImageTag=${2}
if [ "${ImageTag}" == "" ] ; then
ImageTag="1.6.9"
fi
DockerImage=cloud21.cvtt.vpn:5500/md_recorder:${ImageTag}
ContainerName="md_recorder.${job}"
if is_container_running "$ContainerName"; then
echo "Container ${ContainerName} is already running. Aborted."
exit
fi
Cmd="docker run"
Cmd+=" -d"
Cmd+=" --rm"
Cmd+=" --network=host"
# Cmd+=" --pull=always"
Cmd+=" --name=${ContainerName}"
Cmd+=" -v /home/cvtt/.creds:/.creds"
Cmd+=" -v /home/cvtt/prod/data:/app/data"
Cmd+=" -v /home/cvtt/prod/logs:/logs"
Cmd+=" -e CONFIG_SERVICE=cloud16.cvtt.vpn:6789"
Cmd+=" ${DockerImage}"
Cmd+=" ${job}"
echo ${Cmd}
eval ${Cmd}
@@ -0,0 +1,60 @@
#!/bin/bash
usage() {
echo "Usage: $0 <instance (CLD21,CVTTDATA)> [<admin_port (def. 7225)>]"
exit 1
}
ValidInstances=('CLD21' 'CVTTDATA')
is_valid() {
local inst=$1
for valid_inst in "${ValidInstances[@]}";
do
if [[ "$inst" == "$valid_inst" ]]; then
return 0
fi
done
return 1
}
is_container_running() {
local container_name=$1
if [ "$(docker ps --filter "name=^/${container_name}$" --filter "status=running" -q)" ]; then
return 0 # true
else
return 1 # false
fi
}
Instance=${1}
if ! is_valid "${Instance}"; then
usage
fi
AdminPort=7225
if [ "${2}" != "" ]; then
AdminPort=${2}
fi
ContainerName="md_recorder_monitor.${Instance}"
if is_container_running "$ContainerName"; then
echo "Container ${ContainerName} is already running. Aborted."
exit
fi
Cmd="docker run"
Cmd+=" -d"
Cmd+=" --rm"
Cmd+=" --network=host"
Cmd+=" --pull=always"
Cmd+=" --name=${ContainerName}"
Cmd+=" -v /home/cvtt/.creds:/.creds"
Cmd+=" -v /home/cvtt/prod/logs:/logs"
Cmd+=" -e CONFIG_SERVICE=cloud16.cvtt.vpn:6789"
Cmd+=" cloud21.cvtt.vpn:5500/md_recorder_monitor:latest"
Cmd+=" ${Instance} ${AdminPort}"
echo ${Cmd}
eval ${Cmd}
-26
View File
@@ -1,26 +0,0 @@
#!/bin/bash
host=${1}
date=${2}
DockerRegistry=cloud21.cvtt.vpn:5500
DockerImage=${DockerRegistry}/crypto_md_day
if [ -z ${date} ] ; then
date=$(date -d "yesterday" +%Y%m%d)
fi
Cmd="docker run"
Cmd="${Cmd} --pull=always"
Cmd="${Cmd} --network=host"
Cmd="${Cmd} --name=crypto_md_day.${host}.${date}"
Cmd="${Cmd} --rm"
Cmd="${Cmd} --volume=${HOME}/.creds:/.creds"
Cmd="${Cmd} ${DockerImage}"
Cmd="${Cmd} -h ${host}"
Cmd="${Cmd} -d ${date}"
# Cmd="${Cmd} -s coinbase,bnbspot,bnbfut"
Cmd="${Cmd} -s coinbase,bnbspot"
echo $Cmd
eval $Cmd
+20 -13
View File
@@ -1,7 +1,7 @@
#!/bin/bash
usage() {
echo "Usage: $0 -N <num_symbols> [-L <LogDir>] [-d <YYYYMMDD Date>]"
echo "Usage: $0 -N <num_symbols> [-L <LogDir>] [-d <YYYYMMDD Date>] [-t <docker_image_tag>]"
exit 1
}
@@ -15,7 +15,7 @@ is_container_running() {
fi
}
export CalendarURL=http://cloud23.cvtt.vpn:8000/api/v1/markets/hours?mic=XNYS
export CalendarURL=https://trading-calendar.cvtt.net/api/v1/markets/hours?mic=XNYS
is_business_day() {
dt=${1}
@@ -45,12 +45,12 @@ export -f get_prev_business_day
# ----- Settings
DockerRegistry=cloud21.cvtt.vpn:5500
DockerImage=${DockerRegistry}/alpaca_hbar #:latest
ContainerName=alpaca_hbar
LogDir=/home/cvtt/prod/logs
ImageTag=0.1.7
# ----- Settings
while getopts ":d:N:L:" opt; do
while getopts ":d:N:L:t:" opt; do
case ${opt} in
d )
date_to_load=$OPTARG
@@ -61,6 +61,9 @@ while getopts ":d:N:L:" opt; do
L )
LogDir=$OPTARG
;;
t )
ImageTag=$OPTARG
;;
\? )
echo "Invalid option: -$OPTARG" >&2
usage
@@ -72,6 +75,9 @@ while getopts ":d:N:L:" opt; do
esac
done
DockerImage=${DockerRegistry}/alpaca_hbar:${ImageTag} #:latest
if is_container_running "$ContainerName"; then
echo "Container ${ContainerName} is already running."
exit 3
@@ -86,16 +92,17 @@ fi
echo "date_to_load=${date_to_load}"
Cmd="docker run"
Cmd="${Cmd} --pull=always"
Cmd="${Cmd} --network=host"
Cmd="${Cmd} --name=${ContainerName}"
Cmd="${Cmd} --rm"
Cmd="${Cmd} --volume=${LogDir}:/logs"
Cmd="${Cmd} --volume=${HOME}/.creds:/.creds"
Cmd="${Cmd} ${DockerImage}"
Cmd="${Cmd} -d ${date_to_load}"
Cmd+=" --pull=always"
Cmd+=" --network=host"
Cmd+=" --name=${ContainerName}"
Cmd+=" --rm"
Cmd+=" --volume=${LogDir}:/logs"
Cmd+=" --volume=${HOME}/.creds:/.creds"
Cmd+=" -e CONFIG_SERVICE=cloud16.cvtt.vpn:6789"
Cmd+=" ${DockerImage}"
Cmd+=" -d ${date_to_load}"
if [ -n "${NumSymbols}" ]; then
Cmd="${Cmd} -N ${NumSymbols}"
Cmd+=" -N ${NumSymbols}"
fi
echo $Cmd
+19 -13
View File
@@ -1,7 +1,7 @@
#!/bin/bash
usage() {
echo "Usage: $0 -S <symbols> [-L <LogDir>] [-d <YYYYMMDD Date>]"
echo "Usage: $0 -S <symbols> [-L <LogDir>] [-d <YYYYMMDD Date>] [-t <docker_image_tag>]"
exit 1
}
@@ -15,7 +15,7 @@ is_container_running() {
fi
}
export CalendarURL=http://cloud23.cvtt.vpn:8000/api/v1/markets/hours?mic=XNYS
export CalendarURL=https://trading-calendar.cvtt.net/api/v1/markets/hours?mic=XNYS
is_business_day() {
dt=${1}
@@ -45,12 +45,12 @@ export -f get_prev_business_day
# ----- Settings
DockerRegistry=cloud21.cvtt.vpn:5500
DockerImage=${DockerRegistry}/alpaca_qat #:latest
ContainerName=alpaca_qat
LogDir=/home/cvtt/prod/logs
ImageTag=0.1.7
# ----- Settings
while getopts ":d:S:L:" opt; do
while getopts ":d:S:L:t:" opt; do
case ${opt} in
d )
date_to_load=$OPTARG
@@ -61,6 +61,9 @@ while getopts ":d:S:L:" opt; do
L )
LogDir=$OPTARG
;;
t )
ImageTag=$OPTARG
;;
\? )
echo "Invalid option: -$OPTARG" >&2
usage
@@ -82,6 +85,8 @@ if is_container_running "$ContainerName"; then
exit 3
fi
DockerImage=${DockerRegistry}/alpaca_qat:${ImageTag} #:latest
if [ -z "${date_to_load}" ]; then
echo "date_to_load is empty"
date_to_load=$(get_prev_business_day $(date -d "yesterday" '+%Y-%m-%d'))
@@ -91,15 +96,16 @@ fi
echo "date_to_load=${date_to_load}"
Cmd="docker run"
Cmd="${Cmd} --pull=always"
Cmd="${Cmd} --network=host"
Cmd="${Cmd} --name=${ContainerName}"
Cmd="${Cmd} --rm"
Cmd="${Cmd} --volume=${LogDir}:/logs"
Cmd="${Cmd} --volume=${HOME}/.creds:/.creds"
Cmd="${Cmd} ${DockerImage}"
Cmd="${Cmd} -d ${date_to_load}"
Cmd="${Cmd} -S ${Symbols}"
Cmd+=" --pull=always"
Cmd+=" --network=host"
Cmd+=" --name=${ContainerName}"
Cmd+=" --rm"
Cmd+=" --volume=${LogDir}:/logs"
Cmd+=" --volume=${HOME}/.creds:/.creds"
Cmd+=" -e CONFIG_SERVICE=cloud16.cvtt.vpn:6789"
Cmd+=" ${DockerImage}"
Cmd+=" -d ${date_to_load}"
Cmd+=" -S ${Symbols}"
echo $Cmd
eval $Cmd
+1
View File
@@ -8,6 +8,7 @@ Cmd+=" --network=host"
Cmd+=" --name=crypto_exch_stats"
Cmd+=" --volume=${HOME}/prod/data:/app/data"
Cmd+=" --volume=${HOME}/prod/logs:/logs"
Cmd+=" -e CONFIG_SERVICE=cloud16.cvtt.vpn:6789"
Cmd+=" cloud21.cvtt.vpn:5500/crypto_exch_stats:latest"
echo ${Cmd}
-1
View File
@@ -1 +0,0 @@
1.9.5,homestore ==> hs01
+275
View File
@@ -0,0 +1,275 @@
#!/bin/bash
if [ $# -ne 2 ]; then
echo "Usage: $0 <source_database_file> <features_database_file>"
exit 1
fi
SRC_DB=$1
DEST_DB=$2
if [ ! -f "$SRC_DB" ]; then
echo "Error: Source database file $SRC_DB does not exist"
exit 1
fi
echo "Creating feature tables in $DEST_DB using data from $SRC_DB..."
# Create md_1min_trade_features table
echo "Creating md_1min_trade_features table..."
sqlite3 "$DEST_DB" "
DROP TABLE IF EXISTS md_1min_trade_features;
CREATE TABLE IF NOT EXISTS md_1min_trade_features (
bin_tstamp TEXT,
tstamp_ns INTEGER,
exchange_id TEXT,
instrument_id TEXT,
price_mean REAL,
price_median REAL,
volume REAL,
vwap REAL,
signed_volume REAL,
order_flow_imbalance REAL,
num_trades INTEGER,
avg_trade_size REAL,
PRIMARY KEY (bin_tstamp, exchange_id, instrument_id)
);"
# Create index for md_1min_trade_features
echo "Creating index for md_1min_trade_features..."
sqlite3 "$DEST_DB" "
CREATE UNIQUE INDEX IF NOT EXISTS md_1min_trade_features_uidx
ON md_1min_trade_features(bin_tstamp, exchange_id, instrument_id);"
# Populate md_1min_trade_features using source database
echo "Populating md_1min_trade_features..."
sqlite3 "$SRC_DB" "ATTACH DATABASE '$DEST_DB' AS dest;
WITH trade_metrics AS (
SELECT
tstamp,
strftime('%Y-%m-%d %H:%M:00', tstamp) as bin_tstamp,
exchange_id,
instrument_id,
px as price,
qty,
CASE
WHEN condition = 'B' THEN qty
WHEN condition = 'S' THEN -qty
ELSE 0
END as signed_qty
FROM md_trades
),
trade_metrics_agg AS (
SELECT
bin_tstamp,
exchange_id,
instrument_id,
COUNT(*) as cnt,
MIN(tstamp) as min_tstamp,
MAX(tstamp) as max_tstamp
FROM trade_metrics
GROUP BY bin_tstamp, exchange_id, instrument_id
)
INSERT INTO dest.md_1min_trade_features
SELECT
tm.bin_tstamp,
CAST(strftime('%s', tm.bin_tstamp) * 1000000000 AS INTEGER) as tstamp_ns,
tm.exchange_id,
tm.instrument_id,
AVG(price) as price_mean,
AVG(CASE WHEN rank_num >= FLOOR(cnt/2.0) AND rank_num <= CEIL(cnt/2.0) THEN price ELSE NULL END) as price_median,
SUM(qty) as volume,
SUM(price * qty) / SUM(qty) as vwap,
SUM(signed_qty) as signed_volume,
SUM(CASE WHEN signed_qty > 0 THEN signed_qty ELSE 0 END) -
SUM(CASE WHEN signed_qty < 0 THEN ABS(signed_qty) ELSE 0 END) as order_flow_imbalance,
COUNT(*) as num_trades,
AVG(qty) as avg_trade_size
FROM (
SELECT
tm.*,
tma.cnt,
ROW_NUMBER() OVER (PARTITION BY tm.bin_tstamp, tm.exchange_id, tm.instrument_id ORDER BY price) as rank_num
FROM trade_metrics tm
JOIN trade_metrics_agg tma
ON tm.bin_tstamp = tma.bin_tstamp
AND tm.exchange_id = tma.exchange_id
AND tm.instrument_id = tma.instrument_id
) tm
GROUP BY tm.bin_tstamp, tm.exchange_id, tm.instrument_id;"
# Create md_1min_quote_features table in destination database
echo "Creating md_1min_quote_features table..."
sqlite3 "$DEST_DB" "
DROP TABLE IF EXISTS md_1min_quote_features;
CREATE TABLE IF NOT EXISTS md_1min_quote_features (
bin_tstamp TEXT,
tstamp_ns INTEGER,
exchange_id TEXT,
instrument_id TEXT,
mid_price_open REAL,
mid_price_high REAL,
mid_price_low REAL,
mid_price_close REAL,
mid_price_mean REAL,
rel_spread_mean REAL,
rel_spread_min REAL,
rel_spread_max REAL,
rel_spread_first REAL,
rel_spread_last REAL,
l1_imbalance_mean REAL,
l1_imbalance_min REAL,
l1_imbalance_max REAL,
l1_imbalance_first REAL,
l1_imbalance_last REAL,
micro_price_mean REAL,
micro_price_min REAL,
micro_price_max REAL,
micro_price_first REAL,
micro_price_last REAL,
weighted_mid_mean REAL,
weighted_mid_min REAL,
weighted_mid_max REAL,
weighted_mid_first REAL,
weighted_mid_last REAL,
PRIMARY KEY (bin_tstamp, exchange_id, instrument_id)
);"
# Create index for md_1min_quote_features
echo "Creating index for md_1min_quote_features..."
sqlite3 "$DEST_DB" "
CREATE UNIQUE INDEX IF NOT EXISTS md_1min_quote_features_uidx
ON md_1min_quote_features(bin_tstamp, exchange_id, instrument_id);"
# Populate md_1min_quote_features using source database
echo "Populating md_1min_quote_features..."
sqlite3 "$SRC_DB" "ATTACH DATABASE '$DEST_DB' AS dest;
INSERT INTO dest.md_1min_quote_features
SELECT
strftime('%Y-%m-%d %H:%M:00', tstamp) as bin_tstamp,
CAST(strftime('%s', tstamp) * 1000000000 AS INTEGER) as tstamp_ns,
exchange_id,
instrument_id,
FIRST_VALUE((ask_px + bid_px) / 2.0) OVER w as mid_price_open,
MAX((ask_px + bid_px) / 2.0) as mid_price_high,
MIN((ask_px + bid_px) / 2.0) as mid_price_low,
LAST_VALUE((ask_px + bid_px) / 2.0) OVER w as mid_price_close,
AVG((ask_px + bid_px) / 2.0) as mid_price_mean,
AVG((ask_px - bid_px) / ((ask_px + bid_px) / 2.0)) as rel_spread_mean,
MIN((ask_px - bid_px) / ((ask_px + bid_px) / 2.0)) as rel_spread_min,
MAX((ask_px - bid_px) / ((ask_px + bid_px) / 2.0)) as rel_spread_max,
FIRST_VALUE((ask_px - bid_px) / ((ask_px + bid_px) / 2.0)) OVER w as rel_spread_first,
LAST_VALUE((ask_px - bid_px) / ((ask_px + bid_px) / 2.0)) OVER w as rel_spread_last,
AVG((bid_qty - ask_qty) / (bid_qty + ask_qty)) as l1_imbalance_mean,
MIN((bid_qty - ask_qty) / (bid_qty + ask_qty)) as l1_imbalance_min,
MAX((bid_qty - ask_qty) / (bid_qty + ask_qty)) as l1_imbalance_max,
FIRST_VALUE((bid_qty - ask_qty) / (bid_qty + ask_qty)) OVER w as l1_imbalance_first,
LAST_VALUE((bid_qty - ask_qty) / (bid_qty + ask_qty)) OVER w as l1_imbalance_last,
AVG((ask_px * bid_qty + bid_px * ask_qty) / (bid_qty + ask_qty)) as micro_price_mean,
MIN((ask_px * bid_qty + bid_px * ask_qty) / (bid_qty + ask_qty)) as micro_price_min,
MAX((ask_px * bid_qty + bid_px * ask_qty) / (bid_qty + ask_qty)) as micro_price_max,
FIRST_VALUE((ask_px * bid_qty + bid_px * ask_qty) / (bid_qty + ask_qty)) OVER w as micro_price_first,
LAST_VALUE((ask_px * bid_qty + bid_px * ask_qty) / (bid_qty + ask_qty)) OVER w as micro_price_last,
AVG((ask_px * ask_qty + bid_px * bid_qty) / (bid_qty + ask_qty)) as weighted_mid_mean,
MIN((ask_px * ask_qty + bid_px * bid_qty) / (bid_qty + ask_qty)) as weighted_mid_min,
MAX((ask_px * ask_qty + bid_px * bid_qty) / (bid_qty + ask_qty)) as weighted_mid_max,
FIRST_VALUE((ask_px * ask_qty + bid_px * bid_qty) / (bid_qty + ask_qty)) OVER w as weighted_mid_first,
LAST_VALUE((ask_px * ask_qty + bid_px * bid_qty) / (bid_qty + ask_qty)) OVER w as weighted_mid_last
FROM md_quotes
GROUP BY strftime('%Y-%m-%d %H:%M:00', tstamp), exchange_id, instrument_id
WINDOW w AS (
PARTITION BY strftime('%Y-%m-%d %H:%M:00', tstamp), exchange_id, instrument_id
ORDER BY tstamp
RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
);"
# Copy the md_1min_bars table to destination database
echo "Copying md_1min_bars to destination..."
sqlite3 "$DEST_DB" "
DROP TABLE IF EXISTS md_1min_bars;
CREATE TABLE IF NOT EXISTS md_1min_bars (
bin_tstamp TEXT,
tstamp_ns INTEGER,
exchange_id TEXT,
instrument_id TEXT,
open REAL,
high REAL,
low REAL,
close REAL,
volume REAL,
vwap REAL,
num_trades INTEGER,
PRIMARY KEY (bin_tstamp, exchange_id, instrument_id)
);"
echo "Creating index for md_1min_bars..."
sqlite3 "$DEST_DB" "
CREATE UNIQUE INDEX IF NOT EXISTS md_1min_bars_uidx
ON md_1min_bars(bin_tstamp, exchange_id, instrument_id);"
echo "Populating md_1min_bars..."
sqlite3 "$SRC_DB" "ATTACH DATABASE '$DEST_DB' AS dest;
INSERT INTO dest.md_1min_bars
SELECT * FROM md_1min_bars;"
# Create the combined features view in destination database
echo "Creating combined features view..."
sqlite3 "$DEST_DB" "
DROP VIEW IF EXISTS md_1min_features_view;
CREATE VIEW IF NOT EXISTS md_1min_features_view AS
SELECT
b.bin_tstamp,
b.tstamp_ns,
b.exchange_id,
b.instrument_id,
-- OHLCV data from md_1min_bars
b.open,
b.high,
b.low,
b.close,
b.volume,
b.vwap,
b.num_trades,
-- Quote features
q.mid_price_open,
q.mid_price_high,
q.mid_price_low,
q.mid_price_close,
q.mid_price_mean,
q.rel_spread_mean,
q.rel_spread_min,
q.rel_spread_max,
q.rel_spread_first,
q.rel_spread_last,
q.l1_imbalance_mean,
q.l1_imbalance_min,
q.l1_imbalance_max,
q.l1_imbalance_first,
q.l1_imbalance_last,
q.micro_price_mean,
q.micro_price_min,
q.micro_price_max,
q.micro_price_first,
q.micro_price_last,
q.weighted_mid_mean,
q.weighted_mid_min,
q.weighted_mid_max,
q.weighted_mid_first,
q.weighted_mid_last,
-- Trade features
t.price_mean as trade_price_mean,
t.price_median as trade_price_median,
t.signed_volume,
t.order_flow_imbalance,
t.avg_trade_size
FROM md_1min_bars b
LEFT JOIN md_1min_quote_features q
ON b.bin_tstamp = q.bin_tstamp
AND b.exchange_id = q.exchange_id
AND b.instrument_id = q.instrument_id
LEFT JOIN md_1min_trade_features t
ON b.bin_tstamp = t.bin_tstamp
AND b.exchange_id = t.exchange_id
AND b.instrument_id = t.instrument_id;"
echo "Feature tables created and populated successfully in $DEST_DB!"
+13 -4
View File
@@ -1,7 +1,10 @@
#!/usr/bin/env bash
usage() {
echo "Usage: $0 [-h <host (hs01*/cloud21)>] [-d <YYYYMMDD> (yesterday*)] [-s <source> (cvttdata/cloud21*)>]"
echo -n "Usage: $0 [-h <host (hs01*/cloud21)>]"
echo -n " [-d <YYYYMMDD> (yesterday*)]"
echo -n " [-s <source> (cloud28/cloud21*)>]"
echo " [-t <target_dir> (/opt/jupyter_gpu/data/crypto_md)]"
exit 1
}
@@ -19,11 +22,15 @@ is_valid() {
return 1
}
# ------- D E F A U L T S
date=""
host=hs01
source=cloud21
TargetDir="/opt/jupyter_gpu/data/crypto_md"
# ------- D E F A U L T S
while getopts ":h:d:s:" opt; do
while getopts ":h:d:s:t:" opt; do
case ${opt} in
d )
date=$OPTARG
@@ -34,6 +41,9 @@ while getopts ":h:d:s:" opt; do
s )
source=$OPTARG
;;
t )
TargetDir=$OPTARG
;;
\? )
echo "Invalid option: -$OPTARG" >&2
usage
@@ -57,7 +67,7 @@ if ! is_valid "${host}" "${valid_hosts[@]}" ; then
usage
fi
valid_sources=('cloud21' 'cvttdata')
valid_sources=('cloud21' 'cloud28')
if ! is_valid ${source} ${valid_sources[@]} ; then
echo "Source '${source}' is not valid"
usage
@@ -82,7 +92,6 @@ SourceFile=$(date -d ${date} "+%Y%m%d.mktdata.db")
SourceFileZip="${SourceFile}.gz"
SourceFilePath=$(date -d ${date} "+${SourceRootDir}/%Y/%m/${SourceFileZip}")
TargetDir="/opt/jupyter_gpu/data/crypto_md"
TargetFile=$(date -d ${date} "+%Y%m%d.mktdata.ohlcv.db")
TargetFilePath="${TargetDir}/${TargetFile}"
@@ -1,44 +0,0 @@
#!/bin/bash
Python=/home/cvtt/.pyenv/python3.12-venv/bin/python3.12
RootDir=/home/cvtt/prod
export PYTHONPATH=${RootDir}
host=${1}
if [ "${host}" == "cvttdata" ]
then
ArchiveRootDir=/home/cvtt/prod/archive/md_archive/crypto/cvttdata
CredKey=TSDB_MD_CVTTDATA_RO
elif [ "${host}" == "cloud21" ]
then
ArchiveRootDir=/home/cvtt/prod/archive/md_archive/crypto/cloud21
CredKey=TSDB_MD_CLD21_RO
else
echo "Unknown host ${host}. ${0} Aborted."
exit 1
fi
mkdir -p ${ArchiveRootDir}
yesterday=$(date -d "yesterday" +%Y%m%d)
Schemas=${2}
if [ "${Schemas}" == "" ]
then
Schemas="coinbase,bnbspot,bnbfut"
fi
echo "Schemas=${Schemas}"
Cmd=
Cmd="${Python}"
Cmd="${Cmd} ${RootDir}/cvttpy/research/utils/archive_ts_md.py"
Cmd="${Cmd} --config=http://cloud23.cvtt.vpn:6789/apps/md_recorder"
Cmd="${Cmd} --db_credentials_key=${CredKey}"
Cmd="${Cmd} --date=${yesterday}"
Cmd="${Cmd} --schemas=${Schemas}"
Cmd="${Cmd} --root_dir=${ArchiveRootDir}"
Cmd="${Cmd} --format=SQLite"
Cmd="${Cmd} --compress"
echo ${Cmd}
eval ${Cmd}
echo "${0} ${*} Done."
+2 -2
View File
@@ -3,7 +3,7 @@
usage() {
echo -n "Usage: ${0}"
echo -n " [-c <config (dflt: apps/cvtt_eqt_alpaca)>]"
echo -n " [-s <config_serverice (dflt: http://cloud23.cvtt.vpn:6789)>]"
echo -n " [-s <config_serverice (dflt: http://cloud16.cvtt.vpn:6789)>]"
echo -n " [-N <name (dflt: ALPACA-SNDBX)>]"
echo
exit 1
@@ -23,7 +23,7 @@ export PYTHONPATH=${RootDir}
StatusChannel=Status-CVTT
AlertChannel=Alerts-CVTT
Sender=${RootDir}/ops/utils/send_mmost.sh
ConfigService=http://cloud23.cvtt.vpn:6789
ConfigService=http://cloud16.cvtt.vpn:6789
Config=apps/cvtt_eqt_alpaca
Name="ALPACA-SNDBX"
+1 -1
View File
@@ -13,7 +13,7 @@ RootDir="${HOME}/prod"
AlertChannel=Alerts-CVTT
Sender=${RootDir}/ops/utils/send_mmost.sh
ConfigUrl=http://cloud23.cvtt.vpn:6789/admin/cvtt_hosts
ConfigUrl=http://cloud16.cvtt.vpn:6789/admin/cvtt_hosts
HOSTS_CONFIG=$(curl -s ${ConfigUrl} | ${HOME}/bin/hjson -j)
+1 -1
View File
@@ -12,7 +12,7 @@ RootDir="${HOME}/prod"
AlertChannel=Alerts-CVTT
Sender=${RootDir}/ops/utils/send_mmost.sh
ConfigUrl=http://cloud23.cvtt.vpn:6789/admin/cvtt_services
ConfigUrl=http://cloud16.cvtt.vpn:6789/admin/cvtt_services
SERVICES_CONFIG=$(curl -s ${ConfigUrl} | ${HOME}/bin/hjson -j)
+17 -14
View File
@@ -18,14 +18,14 @@ get_user_hosts() {
local User=${1}
local Domain=${2}
Cmd="curl -s http://cloud23.cvtt.vpn:6789/admin/cvtt_hosts"
Cmd="${Cmd} | ${HOME}/bin/hjson -j"
Cmd="${Cmd} | jq -r"
Cmd="${Cmd} --arg domain \"${Domain}\""
Cmd="${Cmd} --arg usr \"${User}\""
Cmd="${Cmd} '.[\$domain] | to_entries[] | select(.value.users[] | contains(\$usr)) | .key'"
Cmd="curl -s http://cloud16.cvtt.vpn:6789/admin/cvtt_hosts"
Cmd+=" | ${HOME}/bin/hjson -j"
Cmd+=" | jq -r"
Cmd+=" --arg domain \"${Domain}\""
Cmd+=" --arg usr \"${User}\""
Cmd+=" '.[\$domain] | to_entries[] | select(.value.users[] | contains(\$usr)) | .key'"
Cmd="${Cmd} | sed 's/\$/.${Domain}/'"
Cmd+=" | sed 's/\$/.${Domain}/'"
eval ${Cmd}
}
@@ -66,13 +66,16 @@ function storage_check() {
else
port=22
fi
Cmd="ssh -p ${port} $host"
Cmd="${Cmd} eval \"df -hTl"
Cmd="${Cmd} -x squashfs"
Cmd="${Cmd} -x tmpfs"
Cmd="${Cmd} -x vfat"
Cmd="${Cmd} -x devtmpfs"
Cmd="${Cmd} | grep -v Filesystem\""
Cmd="ssh -p ${port}"
Cmd+=" -o StrictHostKeyChecking=no"
Cmd+=" -o UserKnownHostsFile=/dev/null"
Cmd+=" $host"
Cmd+=" eval \"df -hTl"
Cmd+=" -x squashfs"
Cmd+=" -x tmpfs"
Cmd+=" -x vfat"
Cmd+=" -x devtmpfs"
Cmd+=" | grep -v Filesystem\""
IFS=$'\n' ; lines=$(eval ${Cmd})
for ln in $lines
+2 -2
View File
@@ -4,7 +4,7 @@ Start=${1}
NumJobs=${2}
InstListFile=${3}
export CalendarURL=http://cloud23.cvtt.vpn:8000/api/v1/markets/hours?mic=XNYS
export CalendarURL=https://trading-calendar.cvtt.net/api/v1/markets/hours?mic=XNYS
is_business_day() {
dt=${1}
@@ -46,7 +46,7 @@ echo "Start=${Start} End=${End} NumJobs=${NumJobs}"
export PYTHONPATH=/home/cvtt/prod
export Python=/home/cvtt/.pyenv/python3.12-venv/bin/python3
export Config=http://cloud23.cvtt.vpn:6789/apps/minimal_md
export Config=http://cloud16.cvtt.vpn:6789/apps/minimal_md
export PyScript=/home/cvtt/prod/cvttpy/exchanges/alpaca/hist_md/hist_md_bars.py
export OutputDir=/home/cvtt/prod/archive/md_archive/equity/alpaca_md # Local
@@ -5,7 +5,7 @@ export PYTHONPATH=${HOME}/prod
Python=${HOME}/.pyenv/python3.12-venv/bin/python3
Script=${HOME}/prod/cvttpy/exchanges/alpaca/hist_md/rl_calc_loader.py
DbFile=${HOME}/prod/data/rel_liquidity.db
Config=http://cloud23.cvtt.vpn:6789/apps/minimal_md_eqt
Config=http://cloud16.cvtt.vpn:6789/apps/minimal_md_eqt
Cmd="${Python}"
Cmd="${Cmd} ${Script}"
@@ -3,7 +3,7 @@
is_business_day() {
dt=${1}
CalendarURL=http://cloud23.cvtt.vpn:8000/api/v1/markets/hours?mic=XNYS
CalendarURL=https://trading-calendar.cvtt.net/api/v1/markets/hours?mic=XNYS
open_time=$(curl -s "${CalendarURL}&start=${dt}&end=${dt}" | jq '.[] | .open_time')
if [ -n "${open_time}" ]; then
return 0
@@ -26,9 +26,11 @@ run_checklist() {
declare -A Commands
Commands=(
["hs01:cloud21"]="ssh cvtt@hs01.cvtt.vpn ls -l /works/cvtt/md_archive/crypto/cloud21/${yr}/${mn} | tail -5"
["hs01:cvttdata"]="ssh cvtt@hs01.cvtt.vpn ls -l /works/cvtt/md_archive/crypto/cvttdata/${yr}/${mn} | tail -5"
["cloud21:cloud21"]="ssh cvtt@cloud21.cvtt.vpn ls -l /opt/store/cvtt/md_archive/crypto/cloud21/${yr}/${mn} | tail -5"
["cloud21:cvttdata"]="ssh cvtt@cloud21.cvtt.vpn ls -l /opt/store/cvtt/md_archive/crypto/cvttdata/${yr}/${mn} | tail -5"
["hs01:cloud28"]="ssh cvtt@hs01.cvtt.vpn ls -l /works/cvtt/md_archive/crypto/cloud28/${yr}/${mn} | tail -5"
["hs01:sim"]="ssh cvtt@hs01.cvtt.vpn ls -l /works/cvtt/md_archive/crypto/sim/ | tail -5"
["cloud21:cloud21"]="ssh cvtt@cloud21.cvtt.vpn ls -l /works/cvtt/md_archive/crypto/cloud21/${yr}/${mn} | tail -5"
["cloud21:cloud28"]="ssh cvtt@cloud21.cvtt.vpn ls -l /works/cvtt/md_archive/crypto/cloud28/${yr}/${mn} | tail -5"
["cloud21:sim"]="ssh cvtt@cloud21.cvtt.vpn ls -l /works/cvtt/md_archive/crypto/sim | tail -5"
["gpushnik"]="ssh oleg@gpushnik.cvtt.vpn 'ls -l /opt/jupyter_gpu/data/crypto_md | tail -10'"
)
+10 -1
View File
@@ -29,12 +29,14 @@ run_checklist() {
Commands["hs01"]+="ssh cvtt@hs01.cvtt.vpn ls -l /works/cvtt/md_archive/equity/alpaca_md/${yr}/${sym} | tail -3; "
done
Commands["hs01"]+="echo"
Commands["hs01:sim"]="ssh cvtt@hs01.cvtt.vpn ls -l /works/cvtt/md_archive/equity/alpaca_md/sim | tail -5"
Commands["cloud21"]=""
for sym in ${CheckSymbols}; do
Commands["cloud21"]+="ssh cvtt@cloud21.cvtt.vpn ls -l /opt/store/cvtt/md_archive/equity/alpaca_md/${yr}/${sym} | tail -3; "
Commands["cloud21"]+="ssh cvtt@cloud21.cvtt.vpn ls -l /works/cvtt/md_archive/equity/alpaca_md/${yr}/${sym} | tail -3; "
done
Commands["cloud21"]+="echo"
Commands["cloud21:sim"]="ssh cvtt@cloud21.cvtt.vpn ls -l /works/cvtt/md_archive/equity/alpaca_md/sim | tail -5"
Commands["gpushnik"]="ssh oleg@gpushnik.cvtt.vpn 'ls -l /opt/jupyter_gpu/data/eqty_md | tail -10'"
@@ -46,6 +48,13 @@ run_checklist() {
done
}
tmpfile=$(mktemp)
function cleanup {
cd ${HOME}
rm -f ${tmpfile}
}
trap cleanup EXIT
# run_checklist
tmpfile=$(mktemp)
@@ -4,7 +4,7 @@ export PYTHONPATH=/home/cvtt/prod
Cmd="/home/cvtt/.pyenv/python3.12-venv/bin/python3"
Cmd="${Cmd} /home/cvtt/prod/cvttpy/apps/research/exchange_trading_stats.py"
Cmd="${Cmd} --config=http://cloud23.cvtt.vpn:6789/apps/tests/listen_market_data"
Cmd="${Cmd} --config=http://cloud16.cvtt.vpn:6789/apps/tests/listen_market_data"
Cmd="${Cmd} --active_exchanges=OKX,GEMINI,BITSTAMP,COINBASE_AT,BNBSPOT,KRAKEN"
Cmd="${Cmd} --instruments=OKX:PAIR-BTC-USDT,GEMINI:PAIR-BTC-USD,BITSTAMP:PAIR-BTC-USD,COINBASE:PAIR-BTC-USD,BNBSPOT:PAIR-BTC-USDT,KRAKEN:PAIR-BTC-USD"
Cmd="${Cmd} --db_file=/home/cvtt/prod/data/exchange_trading_stats.db"
@@ -1,99 +1,60 @@
#!/bin/bash
# SQLite DDL for simulation
# =========================
# -- md_quotes
# -- md_1min_bars
usage() {
echo "Usage: $0 -d YYYMMDD Date> [-O <output dir (./) >]"
exit 1
}
# --------------------- Settings
SourceHost=cloud21.cvtt.vpn
SourceRootDir=/opt/store/cvtt/md_archive/crypto
DbSource=cloud21
# SOURCE_HOST=cloud21.cvtt.vpn
# SOURCE_ROOT_DIR=/opt/store/cvtt/md_archive/crypto
# DB_SOURCE=cloud28
# OUTPUT_DIR=/tmp
# DATE=20250516
# RSYNC_TARGETS="cvtt@hs01.cvtt.vpn:/works/cvtt/md_archive/crypto/sim/ cvtt@cloud21.cvtt.vpn:/opt/store/cvtt/md_archive/crypto/sim/"
# --------------------- Settings
while getopts ":d:O:" opt; do
case ${opt} in
d )
Date=$OPTARG
;;
O )
OutputDir=$OPTARG
;;
\? )
echo "Invalid option: -$OPTARG" >&2
usage
;;
: )
echo "Option -$OPTARG requires an argument." >&2
usage
;;
esac
done
if [ -z ${Date} ] ; then
echo "date is not specified"
usage
if [ -z ${DATE} ] ; then
DATE=$(date -d 'yesterday' +'%Y%m%d')
fi
if [ -z ${OutputDir} ] ; then
OutputDir=.
if [ -z ${OUTPUT_DIR} ] ; then
OUTPUT_DIR=.
fi
mkdir -p ${OutputDir}
# --- Binance
Instruments=( PAIR-ADA-USDT )
Instruments+=( PAIR-BCH-USDT )
Instruments+=( PAIR-BTC-USDT )
Instruments+=( PAIR-DOT-USDT )
Instruments+=( PAIR-ETH-USDT )
Instruments+=( PAIR-LTC-USDT )
Instruments+=( PAIR-SOL-USDT )
Instruments+=( PAIR-USDC-USDT )
Instruments+=( PAIR-XRP-USDT )
echo "DATE=${DATE} SOURCE_HOST=${SOURCE_HOST}"
# --- Coinbase
Instruments+=( PAIR-ADA-USD )
Instruments+=( PAIR-BCH-USD )
Instruments+=( PAIR-BTC-USD )
Instruments+=( PAIR-DOT-USD )
Instruments+=( PAIR-ETH-USD )
Instruments+=( PAIR-LTC-USD )
Instruments+=( PAIR-SOL-USD )
Instruments+=( PAIR-XRP-USD )
mkdir -p ${OUTPUT_DIR}
echo "Date=${Date} Instruments=${Instruments[@]} OutputDir=${OutputDir}"
echo Getting data from ${DataHost} ...
year=$(date -d ${Date} +"%Y")
month=$(date -d ${Date} +"%m")
SourceDir="${SourceRootDir}/${DbSource}/${year}/${month}"
SourceFile="${SourceDir}/${Date}.mktdata.db.gz"
year=$(date -d ${DATE} +"%Y")
month=$(date -d ${DATE} +"%m")
SourceDir="${SOURCE_ROOT_DIR}/${DB_SOURCE}/${year}/${month}"
SourceFile="${DATE}.mktdata.db.gz"
SourceFilePath="${SourceDir}/${SourceFile}"
Cmd="rsync -ahv"
Cmd+=" ${SourceHost}:${SourceFile}"
Cmd+=" $OutputDir/"
Cmd+=" -e 'ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'"
Cmd+=" ${SOURCE_HOST}:${SourceFile}"
Cmd+=" $OUTPUT_DIR/"
echo ${Cmd}
eval ${Cmd}
Cmd="(cd ${OutputDir} && gunzip *.db.gz)"
if [ ! -f ${OUTPUT_DIR}/${SourceFile} ] ; then
echo "File ${OUTPUT_DIR}/${SourceFile} NOT FOUND"
exit
fi
Cmd="(cd ${OUTPUT_DIR} && gunzip -f *.db.gz)"
echo ${Cmd}
eval ${Cmd}
SourceDbFile="${OutputDir}/${Date}.mktdata.db"
ResultDbFile="${OutputDir}/${Date}.crypto_sim_md.db"
SourceDbFile="${OUTPUT_DIR}/${DATE}.mktdata.db"
ResultDbFile="${OUTPUT_DIR}/${DATE}.crypto_sim_md.db"
echo "SourceDbFile=${SourceDbFile}"
echo "Creating Result Database File ${ResultDbFile}"
cleanup() {
rm ${SourceDbFile}
}
trap cleanup EXIT
echo "Creating table md_trades ..."
sqlite3 ${ResultDbFile} <<EOF
.echo ON
CREATE TABLE IF NOT EXISTS md_trades (
tstamp text,
tstamp_ns integer,
@@ -106,12 +67,14 @@ CREATE TABLE IF NOT EXISTS md_trades (
condition text,
tape text
);
CREATE UNIQUE INDEX IF NOT EXISTS md_trades_uidx
ON md_trades(tstamp_ns, exchange_id, instrument_id);
EOF
echo "Creating table md_quotes ..."
sqlite3 ${ResultDbFile} <<EOF
.echo ON
CREATE TABLE IF NOT EXISTS md_quotes (
tstamp text,
tstamp_ns integer,
@@ -130,6 +93,7 @@ EOF
echo "Creating table md_1min_bars ..."
sqlite3 ${ResultDbFile} <<EOF
.echo ON
CREATE TABLE IF NOT EXISTS md_1min_bars (
tstamp text,
tstamp_ns integer,
@@ -149,6 +113,7 @@ EOF
echo "Loading md_trades ..."
sqlite3 ${ResultDbFile} <<EOF
.echo ON
ATTACH '${SourceDbFile}' AS source_db;
BEGIN;
INSERT OR IGNORE INTO md_trades SELECT
@@ -186,6 +151,7 @@ EOF
echo "Loading md_quotes ..."
sqlite3 ${ResultDbFile} <<EOF
.echo ON
ATTACH '${SourceDbFile}' AS source_db;
BEGIN;
INSERT OR IGNORE INTO md_quotes SELECT
@@ -224,6 +190,7 @@ EOF
echo "Loading md_1min_bars ..."
sqlite3 ${ResultDbFile} <<EOF
.echo ON
ATTACH '${SourceDbFile}' AS source_db;
BEGIN;
INSERT OR IGNORE INTO md_1min_bars SELECT
@@ -260,25 +227,16 @@ COMMIT;
DETACH source_db;
EOF
Cmd="rm ${SourceDbFile}"
echo ${Cmd}
eval ${Cmd}
Cmd="gzip ${ResultDbFile}"
echo ${Cmd}
eval ${Cmd}
Cmd="rsync -ahvv ${ResultDbFile}.gz cvtt@hs01.cvtt.vpn:/works/cvtt/md_archive/crypto/sim/"
echo ${Cmd}
eval ${Cmd}
Cmd="rsync -ahvv ${ResultDbFile}.gz cvtt@cloud21.cvtt.vpn:/opt/store/cvtt/md_archive/crypto/sim/"
echo ${Cmd}
eval ${Cmd}
Cmd="rm ${ResultDbFile}.gz"
echo ${Cmd}
eval ${Cmd}
for tgt in ${RSYNC_TARGETS} ; do
Cmd="rsync -ahv"
Cmd+=" -e 'ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'"
Cmd+=" ${ResultDbFile}.gz ${tgt}"
echo ${Cmd}
eval ${Cmd}
done
echo Done $0 ${*}
@@ -15,7 +15,7 @@ is_business_day() {
dt=${1}
date=$(date -d "${dt}" +"%Y-%m-%d")
CalendarURL=http://cloud23.cvtt.vpn:8000/api/v1/markets/hours?mic=XNYS
CalendarURL=https://trading-calendar.cvtt.net/api/v1/markets/hours?mic=XNYS
URL="${CalendarURL}&start=${date}&end=${date}"
open_time=$(curl -s "${URL}" | jq '.[] | .open_time')
if [ -n "${open_time}" ]; then
@@ -104,6 +104,7 @@ echo "Creating Result Database File ${ResultDbFile}"
echo "Creating table md_trades ..."
sqlite3 ${ResultDbFile} <<EOF
.echo ON
CREATE TABLE IF NOT EXISTS md_trades (
tstamp text,
tstamp_ns integer,
@@ -122,6 +123,7 @@ EOF
echo "Creating table md_quotes ..."
sqlite3 ${ResultDbFile} <<EOF
.echo ON
CREATE TABLE IF NOT EXISTS md_quotes (
tstamp text,
tstamp_ns integer,
@@ -166,6 +168,7 @@ for sym in ${Symbols[@]}; do
echo "Loading md_trades and md_quotes from ${src_qat_db} ..."
sqlite3 ${ResultDbFile} <<EOF
.echo ON
ATTACH '${src_qat_db}' AS source_db;
BEGIN;
INSERT OR IGNORE INTO md_trades SELECT
@@ -200,6 +203,7 @@ EOF
echo "Loading md_1min_bars from ${src_hbar_db} ..."
sqlite3 ${ResultDbFile} <<EOF
.echo ON
ATTACH '${src_hbar_db}' AS source_db;
BEGIN;
INSERT OR IGNORE INTO md_1min_bars SELECT
@@ -220,7 +224,7 @@ COMMIT;
DETACH source_db;
EOF
Cmd="rm ${src_hbar_db} ${src_qat_db}"
Cmd="rm ${src_hbar_db} ${src_qat_db}"
echo ${Cmd}
eval ${Cmd}
done
+1 -1
View File
@@ -47,7 +47,7 @@ function rsync_load_version() {
if ssh -q -p ${port} ${user}@${host} "test -d ${rel_dir}/${Project}/${Version}"
then
echo "Directory found..."
rsync_cmd="rsync -ahvv -e \"ssh -p ${port}\""
rsync_cmd="rsync -ahv -e \"ssh -p ${port}\""
rsync_cmd="${rsync_cmd} ${user}@${host}:${rel_dir}/${Project}/${Version}"
rsync_cmd="${rsync_cmd} ${LocalSoftwareDir}/${Project}/"
echo ${rsync_cmd}
+1 -1
View File
@@ -6,7 +6,7 @@ SUBDIRS += configs
FILES=
FILES += release_version.txt
FILES += VERSION
all: install
+43 -16
View File
@@ -1,36 +1,63 @@
#!/bin/bash
function usage {
echo "Usage: ${0} <log directory> [days (default 2)]"
echo -n "Usage: ${0}"
echo -n " -L <log directory>"
echo -n " [ -A <archive_logs_dir> (default /works/archive/logs)]"
echo -n " [-D <older than time criteria> (default: '2 days ago')]"
echo
exit 1
}
echo Starting $0 $*
LogDir=${1}
# ---- D e f a u l t s
LogArchiveDir=/works/archive/logs
DateCriteria="2 days ago"
# ---- D e f a u l t s
# ---------------- cmdline
while getopts "A:L:D:" opt; do
case ${opt} in
A )
LogArchiveDir=$OPTARG
;;
L )
LogDir=$OPTARG
;;
D )
DateCriteria=$OPTARG
;;
\? )
echo "Invalid option: -$OPTARG" >&2
usage
;;
: )
echo "Option -$OPTARG requires an argument." >&2
usage
;;
esac
done
# ---------------- cmdline
if [ "${LogDir}" == "" ]
then
usage
fi
Days=${2}
if [ "${Days}" == "" ]
then
Days=2
fi
Cmd="mkdir -p ${LogArchiveDir}"
echo ${Cmd} && eval ${Cmd}
DateCriteria="${Days} days ago"
echo "Looking for log files older than '${DateCriteria}' in ${LogDir}"
Oldest=$(date -d "${DateCriteria}" '+%Y-%m-%d')
Oldest=$(date -d "${DateCriteria}" '+%Y-%m-%d %H:%M:%S')
echo "Looking for log files older than ${DateCriteria} in ${LogDir}"
Cmd="find ${LogDir}/ '(' -name '*.log' -o -name '*.log.*' ')' -type f -not -newermt \"${Oldest}\""
echo $Cmd
LogArchiveDir=${HOME}/prod/archive/logs
mkdir -p ${LogArchiveDir}
echo "find ${LogDir}/ '(' -name '*.log' -o -name '*.log.*' ')' -type f -not -newermt ${Oldest})"
files=$(find ${LogDir}/ '(' -name '*.log' -o -name '*.log.*' ')' -type f -not -newermt ${Oldest})
files=$(eval ${Cmd})
if [ "$files" == "" ]
then
echo "No files found older than ${Oldest} in ${LogDir}"
+38 -21
View File
@@ -1,40 +1,57 @@
#!/bin/bash
# FOR cloud hosts with limited disk space - move to storage server
# FOR hosts with limited disk space - move to storage server
function usage {
echo "Usage: ${0} <host> <from_dir> <days>"
echo -n "Usage: ${0}"
echo -n " -H <host_label>"
echo -n " [ -A <archive_dir> (default /works/archive)]"
echo -n " [-D <older than time criteria> (default: '2 days ago')]"
echo
exit 1
}
echo Starting $0 $*
# ---- D e f a u l t s
ArchiveDir=/works/archive
DateCriteria="2 days ago"
FromHost=$(hostname -s)
# ---- D e f a u l t s
# ---------------- cmdline
while getopts "A:H:D:" opt; do
case ${opt} in
A )
ArchiveDir=$OPTARG
;;
H )
FromHost=$OPTARG
;;
D )
DateCriteria=$OPTARG
;;
\? )
echo "Invalid option: -$OPTARG" >&2
usage
;;
: )
echo "Option -$OPTARG requires an argument." >&2
usage
;;
esac
done
# ---------------- cmdline
if [ "${FromHost}" == "" ]
then
usage
fi
ArchiveDir=${2}
if [ "${ArchiveDir}" == "" ]
then
usage
fi
Days=${3}
if [ "${Days}" == "" ]
then
Days=2
fi
DateCriteria="${Days} days ago"
TargetHost=cloud21.cvtt.vpn
TargetRootDir=/opt/store/cvtt/archive
Oldest=$(date -d "${DateCriteria}" '+%Y-%m-%d')
Now=$(date '+%Y%m%d_%H%M%S')
Oldest=$(date -d "${DateCriteria}" '+%Y-%m-%d %H:%M:%S')
echo "Looking for log files older than ${DateCriteria} in ${ArchiveDir}"
Cmd="find ${ArchiveDir}/"
@@ -45,7 +62,7 @@ Cmd="${Cmd} -o -name '*.logs.*'"
Cmd="${Cmd} -o -name '*.tgz'"
Cmd="${Cmd} ')'"
Cmd="${Cmd} -type f"
Cmd="${Cmd} -not -newermt ${Oldest}"
Cmd="${Cmd} -not -newermt \"${Oldest}\""
echo ${Cmd}
files=$(eval ${Cmd})