Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bbbdbb5473 | |||
| cade1cd055 | |||
| ed44757900 | |||
| 340283c0a9 | |||
| f4365d32e5 | |||
| 1fe5edcd74 | |||
| 8510226599 | |||
| 10105ad639 | |||
| 9b2bda6257 | |||
| 80a6ffeb18 | |||
| e7c02587c2 | |||
| cc2c07741a | |||
| 36d6914c8c | |||
| 86a58462bf | |||
| f0a639940b | |||
| 3fec261a46 | |||
| 618a7eb0cf | |||
| 512f5ce14d | |||
| 9a3215524e | |||
| 84a8c1cb31 | |||
| 4774bd9005 | |||
| 59e7002a59 | |||
| 1387893a14 | |||
| 87e1a0610b | |||
| 6a6046050c | |||
| 0e23024aab | |||
| d32bf31f4a | |||
| 65c87f97e6 | |||
| ae79f940fb | |||
| 80ae780f02 |
+45
-11
@@ -3,9 +3,11 @@
|
||||
# ---------------- Settings
|
||||
declare -A git_repo_arr
|
||||
|
||||
git_repo_arr[cvttpy]=git@cloud21.cvtt.vpn:/opt/store/git/cvttpy.git
|
||||
git_repo_arr[ops]=git@cloud21.cvtt.vpn:/opt/store/git/ops.git
|
||||
git_repo_arr[research]=git@cloud21.cvtt.vpn:/opt/store/git/research.git
|
||||
git_repo_arr[cvttpy]=git@cloud21.cvtt.vpn:/opt/store/git/cvtt2/cvttpy.git
|
||||
git_repo_arr[ops]=git@cloud21.cvtt.vpn:/opt/store/git/cvtt2/ops.git
|
||||
git_repo_arr[research]=git@cloud21.cvtt.vpn:/opt/store/git/cvtt2/research.git
|
||||
git_repo_arr[cvtt-rust]=git@cloud21.cvtt.vpn:/opt/store/git/cvtt2/cvtt-rust.git
|
||||
git_repo_arr[docker_dev]=git@cloud21.cvtt.vpn:/opt/store/git/cvtt2/docker_dev.git
|
||||
|
||||
dist_root=/home/cvttdist/software/cvtt2
|
||||
dist_user=cvttdist
|
||||
@@ -48,13 +50,29 @@ while getopts ":p:b:i" opt; do
|
||||
done
|
||||
# ---------------- cmdline
|
||||
|
||||
function confirm {
|
||||
confirm() {
|
||||
if [ "${interactive}" == "Y" ]; then
|
||||
echo "--------------------------------"
|
||||
echo -n "Press <Enter> to continue" && read
|
||||
fi
|
||||
}
|
||||
|
||||
rust_binaries() {
|
||||
res=()
|
||||
for binname in $(cargo metadata --no-deps --format-version 1 | jq -r '.packages[].targets[] | select(.kind | index("bin")) | .name'); do
|
||||
res+=("${binname}")
|
||||
done
|
||||
echo "${res[@]}"
|
||||
}
|
||||
|
||||
rust_libraries() {
|
||||
res=()
|
||||
for libname in $(cargo metadata --no-deps --format-version 1 | jq -r '.packages[].targets[] | select(.kind | index("lib")) | .name'); do
|
||||
res+=("lib${libname}.rlib")
|
||||
done
|
||||
echo "${res[@]}"
|
||||
}
|
||||
|
||||
if [ "${interactive}" == "Y" ]; then
|
||||
echo -n "Enter project [${prj}]: "
|
||||
read project
|
||||
@@ -149,6 +167,26 @@ cmd_arr+=("${Cmd}")
|
||||
Cmd="rm -rf .git"
|
||||
cmd_arr+=("${Cmd}")
|
||||
|
||||
SourceLoc=../${project}
|
||||
if [ "${project}" == "cvtt-rust" ]; then
|
||||
|
||||
cmd_arr+=("cd ${prj_dir}")
|
||||
|
||||
release_dir=${prj_dir}/dist/${project}
|
||||
|
||||
cmd_arr+=("mkdir -p ${release_dir}")
|
||||
cmd_arr+=("cp release_version.txt ${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)
|
||||
for app in ${apps[@]}; do
|
||||
app=${app//\"/} # remove quotes
|
||||
cmd_arr+=("cargo install --root ${release_dir} --path ${prj_dir}/apps/${app}")
|
||||
done
|
||||
|
||||
SourceLoc=${release_dir}
|
||||
fi
|
||||
|
||||
dist_path="${dist_root}/${project}/${release_version}"
|
||||
|
||||
for dist_loc in ${dist_locations}; do
|
||||
@@ -156,9 +194,9 @@ for dist_loc in ${dist_locations}; do
|
||||
dist_host=${dhp[0]}
|
||||
dist_port=${dhp[1]}
|
||||
Cmd="rsync -avzh"
|
||||
Cmd="${Cmd} --rsync-path=\"mkdir -p ${dist_path} && rsync\""
|
||||
Cmd="${Cmd} -e \"ssh -p ${dist_ssh_port}\""
|
||||
Cmd="${Cmd} ../${project} ${dist_user}@${dist_host}:${dist_path}/"
|
||||
Cmd="${Cmd} --rsync-path=\"mkdir -p ${dist_path}"
|
||||
Cmd="${Cmd} && rsync\" -e \"ssh -p ${dist_ssh_port}\""
|
||||
Cmd="${Cmd} $SourceLoc ${dist_user}@${dist_host}:${dist_path}/"
|
||||
cmd_arr+=("${Cmd}")
|
||||
done
|
||||
|
||||
@@ -179,8 +217,4 @@ do
|
||||
pwd && echo ${cmd} && eval ${cmd}
|
||||
done
|
||||
|
||||
echo "PROJECT ${project} **** P U L L N E W T A G S F R O M o r i g i n ****"
|
||||
echo "----"
|
||||
echo "(cd ${project}; git pull --tags; git pushall)"
|
||||
echo "----"
|
||||
echo "$0 Done ${project} ${release_version}"
|
||||
|
||||
Executable
+198
@@ -0,0 +1,198 @@
|
||||
#!/bin/bash
|
||||
|
||||
usage() {
|
||||
echo -n "Usage: ${0} <RootDir>"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
# --- Settings
|
||||
RootDir=${1}
|
||||
if [ -z "${RootDir}" ] ; then
|
||||
usage
|
||||
fi
|
||||
|
||||
RegistryService=cloud21.cvtt.vpn:5500
|
||||
RegistryProtocol=http
|
||||
|
||||
ConfigUrl=http://cloud23.cvtt.vpn:6789/admin/docker_images
|
||||
|
||||
|
||||
ReleaseHost="cloud21.cvtt.vpn"
|
||||
ReleasePort="22"
|
||||
ReleaseUser="cvttdist"
|
||||
ReleaseDir="/home/cvttdist/software/cvtt2"
|
||||
|
||||
DIMAGES_CONFIG=$(curl -s ${ConfigUrl} | ${HOME}/bin/hjson -j)
|
||||
|
||||
|
||||
SetVersionScript=${HOME}/prod/set_version.sh
|
||||
|
||||
|
||||
# --------------- D E B U G
|
||||
|
||||
mkdir -p ${RootDir}
|
||||
|
||||
build_docker_image() {
|
||||
title=${1}
|
||||
image_name=${2}
|
||||
docker_dev_path=${3}
|
||||
project=${4}
|
||||
|
||||
echo "Building ${title}..."
|
||||
echo "ImageName=${image_name}"
|
||||
echo "DockerDevPath=${docker_dev_path}"
|
||||
echo "BasedOnDist=${project}"
|
||||
|
||||
# Get Latest DIST version
|
||||
echo "Checking for latest version of ${project} on ${ReleaseUser}@${ReleaseHost}:${ReleaseDir}"
|
||||
image_version=$(get_latest_dist_version ${project})
|
||||
if [ -z "${image_version}" ]; then
|
||||
echo "No latest version found for ${project}"
|
||||
return
|
||||
fi
|
||||
echo "Latest version is ${image_version}"
|
||||
|
||||
if image_exists "${image_name}" "${image_version}"; then
|
||||
echo "Image $image_name:$image_version exists in the registry. Building is not required."
|
||||
return
|
||||
fi
|
||||
echo "Image $image_name:$image_version does not exist in the registry."
|
||||
echo "getting lastest version of ${project} on ${ReleaseUser}@${ReleaseHost}:${ReleaseDir}"
|
||||
|
||||
Cmd="${SetVersionScript} ${project} ${image_version}"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
|
||||
convert_symlink_to_dir ${project}
|
||||
|
||||
DockerDir=./docker_dev/${docker_dev_path}
|
||||
echo "Building ${title}... on ${DockerDev}"
|
||||
|
||||
Cmd="docker build"
|
||||
Cmd+=" -t ${image_name}"
|
||||
Cmd+=" -t ${image_name}:latest"
|
||||
Cmd+=" -t ${image_name}:${image_version}"
|
||||
Cmd+=" -f ${DockerDir}/Dockerfile ${RootDir}"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd} 1>&2 || exit
|
||||
|
||||
Cmd="docker tag"
|
||||
Cmd+=" ${image_name}:latest"
|
||||
Cmd+=" ${RegistryService}/${image_name}:latest"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd} || exit
|
||||
|
||||
Cmd="docker tag"
|
||||
Cmd+=" ${image_name}:${image_version}"
|
||||
Cmd+=" ${RegistryService}/${image_name}:${image_version}"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd} || exit
|
||||
|
||||
Cmd="docker push"
|
||||
Cmd+=" ${RegistryService}/${image_name}:latest"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd} || exit
|
||||
|
||||
Cmd="docker push"
|
||||
Cmd+=" ${RegistryService}/${image_name}:${image_version}"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd} || exit
|
||||
|
||||
echo "Removing the copy of ${project} from ${RootDir}"
|
||||
Cmd="rm -rf ${RootDir}/${project}"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
|
||||
print_all_reg_images ${project}
|
||||
}
|
||||
|
||||
convert_symlink_to_dir() {
|
||||
project=${1}
|
||||
if [ -L ${RootDir}/${project} ]; then
|
||||
echo "Converting symlink ${RootDir}/${project} to directory"
|
||||
|
||||
Cmd="mv ${RootDir}/${project} ${RootDir}/${project}.symlink"
|
||||
echo ${Cmd} && eval ${Cmd}
|
||||
|
||||
src_path=$(readlink -f ${RootDir}/${project}.symlink)
|
||||
|
||||
Cmd="cp -r ${src_path} ${RootDir}/${project}"
|
||||
echo ${Cmd} && eval ${Cmd}
|
||||
fi
|
||||
if [ -d ${project} ]; then
|
||||
echo "${RootDir}/${project} is a Directory"
|
||||
fi
|
||||
Cmd="rm ${RootDir}/${project}.symlink"
|
||||
echo ${Cmd} && eval ${Cmd}
|
||||
}
|
||||
|
||||
image_exists() {
|
||||
image_name=${1}
|
||||
version=${2}
|
||||
response=$(curl -s -o /dev/null -w "%{http_code}" "${RegistryProtocol}://${RegistryService}/v2/${image_name}/manifests/${version}" -H "Accept: application/vnd.docker.distribution.manifest.v2+json")
|
||||
if [ "$response" -eq 200 ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
print_all_reg_images() {
|
||||
project=${1}
|
||||
|
||||
repositories=$(curl -s "${RegistryProtocol}://${RegistryService}/v2/_catalog" | jq -r '.repositories[]')
|
||||
|
||||
for repo in $repositories; do
|
||||
# Fetch all tags for the repository
|
||||
tags=$(curl -s "${RegistryProtocol}://${RegistryService}/v2/$repo/tags/list" | jq -r '.tags[]')
|
||||
|
||||
# List each tag
|
||||
for tag in $tags; do
|
||||
if [ "${project}" == "" ];then
|
||||
echo "$repo:$tag"
|
||||
else
|
||||
echo "$repo:$tag" | grep ${project}
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
get_latest_dist_version() {
|
||||
project=${1}
|
||||
|
||||
Version=$(ssh -q -p ${ReleasePort} ${ReleaseUser}@${ReleaseHost} "ls -tr ${ReleaseDir}/${project} | tail -1" )
|
||||
echo "${Version}"
|
||||
}
|
||||
|
||||
echo RootDir=${RootDir}
|
||||
|
||||
cd ${RootDir}
|
||||
|
||||
echo "Getting latest version of docker_dev"
|
||||
Cmd="${SetVersionScript} docker_dev latest"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
|
||||
convert_symlink_to_dir docker_dev
|
||||
|
||||
Jobs=()
|
||||
while IFS= read -r item; do
|
||||
Jobs+=("$item")
|
||||
done < <(echo "${DIMAGES_CONFIG}" | jq -c 'to_entries[]')
|
||||
|
||||
for item in "${Jobs[@]}"; do
|
||||
# Extract key (name) and values
|
||||
title=$(echo "$item" | jq -r '.key')
|
||||
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')
|
||||
|
||||
build_docker_image "$title" "$image_name" "$docker_dev_path" "$project"
|
||||
done
|
||||
|
||||
Cmd="rm -rf ${RootDir}/docker_dev"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
|
||||
#===============================================================================
|
||||
#===============================================================================
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
usage() {
|
||||
echo -n "Usage: ${0} <grep_filter>"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
# --- Settings
|
||||
RegistryService=cloud21.cvtt.vpn:5500
|
||||
RegistryProtocol=http
|
||||
|
||||
print_all_reg_images() {
|
||||
project=${1}
|
||||
|
||||
repositories=$(curl -s "${RegistryProtocol}://${RegistryService}/v2/_catalog" | jq -r '.repositories[]')
|
||||
|
||||
for repo in $repositories; do
|
||||
# Fetch all tags for the repository
|
||||
tags=$(curl -s "${RegistryProtocol}://${RegistryService}/v2/$repo/tags/list" | jq -r '.tags[]')
|
||||
|
||||
# List each tag
|
||||
echo "REPO: $repo"
|
||||
for tag in $tags; do
|
||||
if [ "${project}" == "" ];then
|
||||
echo "$repo:$tag"
|
||||
else
|
||||
echo "$repo:$tag" | grep ${project}
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
print_all_reg_images ${1}
|
||||
File diff suppressed because one or more lines are too long
@@ -50,7 +50,7 @@ ContainerName=alpaca_hbar
|
||||
LogDir=/home/cvtt/prod/logs
|
||||
# ----- Settings
|
||||
|
||||
while getopts ":d:S:L:" opt; do
|
||||
while getopts ":d:N:L:" opt; do
|
||||
case ${opt} in
|
||||
d )
|
||||
date_to_load=$OPTARG
|
||||
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
Cmd="docker run"
|
||||
Cmd+=" -d"
|
||||
Cmd+=" --rm"
|
||||
Cmd+=" --pull=always"
|
||||
Cmd+=" --network=host"
|
||||
Cmd+=" --name=crypto_exch_stats"
|
||||
Cmd+=" --volume=${HOME}/prod/data:/app/data"
|
||||
Cmd+=" --volume=${HOME}/prod/logs:/logs"
|
||||
Cmd+=" cloud21.cvtt.vpn:5500/crypto_exch_stats:latest"
|
||||
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
# Cmd+=" cloud21.cvtt.vpn:5500/relative_liquidity:latest"
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
1.7.3,alpaca md HBAR
|
||||
1.9.1,16->23
|
||||
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
# by chatGPT
|
||||
# ==========================================
|
||||
# homestore.cvtt.vpn SETTINGS
|
||||
# ==========================================
|
||||
|
||||
# Define source and destination base directories
|
||||
SOURCE_BASE_DIR="/works/cvtt/md_archive/equity/alpaca_md.OLD" # Replace with your actual source directory
|
||||
DESTINATION_BASE_DIR="/works/cvtt/md_archive/equity/alpaca_md" # Replace with your destination directory
|
||||
|
||||
# Loop through all .db.gz files in the source directory
|
||||
find "$SOURCE_BASE_DIR" -type f -name "*.db.gz" | while read -r file; do
|
||||
# Extract relevant directory components from the path
|
||||
relative_path="${file#$SOURCE_BASE_DIR/}"
|
||||
ticker=$(echo "$relative_path" | cut -d'/' -f2)
|
||||
year=$(echo "$relative_path" | cut -d'/' -f3)
|
||||
original_date=$(basename "$file" | cut -d'.' -f1)
|
||||
|
||||
# Define the new file name and destination path
|
||||
new_file_name="${original_date}.${ticker}.alpaca_1m_bars.db.gz"
|
||||
destination_dir="$DESTINATION_BASE_DIR/$year/A/$ticker"
|
||||
|
||||
# Create the destination directory if it doesn't exist
|
||||
mkdir -p "$destination_dir"
|
||||
#echo DEBUG mkdir -p "$destination_dir"
|
||||
|
||||
# Move and rename the file
|
||||
mv "$file" "$destination_dir/$new_file_name"
|
||||
#echo DEBUG mv "$file" "$destination_dir/$new_file_name"
|
||||
|
||||
echo "Moved $file to $destination_dir/$new_file_name"
|
||||
done
|
||||
@@ -167,10 +167,10 @@ EOF
|
||||
echo "Loading files"
|
||||
for stock in "${Stocks[@]}"; do
|
||||
StockLetter="${stock:0:1}"
|
||||
SourceFile=$(${date} -d ${md_date} "+%Y%m%d.${stock}.1min.db")
|
||||
SourceFile=$(${date} -d ${md_date} "+%Y%m%d.${stock}.alpaca_1m_bars.db")
|
||||
|
||||
SourceFileZip="${SourceFile}.gz"
|
||||
SourceFilePath=$(${date} -d ${md_date} "+${SourceRootDir}/${StockLetter}/${stock}/%Y/${SourceFileZip}")
|
||||
SourceFilePath=$(${date} -d ${md_date} "+${SourceRootDir}/%Y/${StockLetter}/${stock}/${SourceFileZip}")
|
||||
echo ${SourceFilePath}
|
||||
|
||||
download_file ${SourceFilePath}
|
||||
@@ -180,6 +180,3 @@ if [ -f ${TargetFilePath} ]; then
|
||||
chmod 600
|
||||
ls -lh ${TargetFilePath}
|
||||
fi
|
||||
|
||||
# mkdir -p /tmp/aaa
|
||||
# cp -r ${tmp_dir}/* /tmp/aaa/
|
||||
|
||||
Executable
+151
@@ -0,0 +1,151 @@
|
||||
#!/bin/bash
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 -S <symbols> -d <YYYYMMDD Date> [-O <output dir (./) >]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# --------------------- Settings
|
||||
SourceHost=cloud21.cvtt.vpn
|
||||
SourceRootDir=/opt/store/cvtt/md_archive/crypto/alpaca_md
|
||||
# --------------------- Settings
|
||||
|
||||
|
||||
is_business_day() {
|
||||
dt=${1}
|
||||
date=$(date -d "${dt}" +"%Y-%m-%d")
|
||||
|
||||
CalendarURL=http://cloud23.cvtt.vpn:8000/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
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
|
||||
}
|
||||
export -f is_business_day
|
||||
|
||||
|
||||
while getopts ":d:S:O:" opt; do
|
||||
case ${opt} in
|
||||
d )
|
||||
Date=$OPTARG
|
||||
;;
|
||||
S )
|
||||
SymList=$OPTARG
|
||||
;;
|
||||
O )
|
||||
OutputDir=$OPTARG
|
||||
;;
|
||||
\? )
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
usage
|
||||
;;
|
||||
: )
|
||||
echo "Option -$OPTARG requires an argument." >&2
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z ${SymList} ] ; then
|
||||
echo "symbols are not specified"
|
||||
usage
|
||||
fi
|
||||
if [ -z ${Date} ] ; then
|
||||
echo "date is not specified"
|
||||
usage
|
||||
fi
|
||||
if [ -z ${OutputDir} ] ; then
|
||||
OutputDir=.
|
||||
fi
|
||||
mkdir -p ${OutputDir}
|
||||
|
||||
if ! is_business_day ${Date}; then
|
||||
echo "${Date} is not business day"
|
||||
usage
|
||||
fi
|
||||
|
||||
OLD_IFS=${IFS}
|
||||
IFS=","
|
||||
read -ra Symbols <<< "${SymList}"
|
||||
IFS=${OLD_IFS}
|
||||
|
||||
echo "Date=${Date} Symbols=${Symbols[@]} OutputDir=${OutputDir}"
|
||||
echo Getting data from ${DataHost} ...
|
||||
|
||||
year=$(date -d ${Date} +"%Y")
|
||||
for sym in ${Symbols[@]}; do
|
||||
inst_id="STOCK-${sym}"
|
||||
capital=${sym:0:1}
|
||||
SourceDir="${SourceRootDir}/${year}/${capital}/${sym}"
|
||||
SourceHbarFile="${SourceDir}/${Date}.${sym}.alpaca_1m_bars.db.gz"
|
||||
SourceQatFile="${SourceDir}/${Date}.${sym}.alpaca_qat.db.gz"
|
||||
|
||||
for src_file in ${SourceHbarFile} ${SourceQatFile}; do
|
||||
Cmd="rsync -ahv"
|
||||
Cmd+=" ${SourceHost}:${src_file}"
|
||||
Cmd+=" $OutputDir/"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
done
|
||||
done
|
||||
|
||||
Cmd="(cd ${OutputDir} && gunzip *.db.gz)"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
|
||||
ResultDbFile="${OutputDir}/${Date}.alpaca_sim_md.db"
|
||||
echo "Creating Result Database File ${ResultDbFile}"
|
||||
sym=${Symbols[0]}
|
||||
for db_file in ${OutputDir}/${Date}.${sym}.alpaca_1m_bars.db ${OutputDir}/${Date}.${sym}.alpaca_qat.db ; do
|
||||
Cmd="sqlite3"
|
||||
Cmd+=" ${db_file} .schema"
|
||||
Cmd+=" | sqlite3 ${ResultDbFile}"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
done
|
||||
|
||||
set -f # not to expand *
|
||||
|
||||
for sym in ${Symbols[@]}; do
|
||||
src_hbar_db=${OutputDir}/${Date}.${sym}.alpaca_1m_bars.db
|
||||
src_qat_db=${OutputDir}/${Date}.${sym}.alpaca_qat.db
|
||||
for srcdb in ${src_hbar_db} ${src_qat_db} ; do
|
||||
|
||||
tables=$(sqlite3 ${srcdb} .tables)
|
||||
for table in $(sqlite3 ${srcdb} .tables) ; do
|
||||
echo "Loading from ${srcdb}.${table} ..."
|
||||
sqlite3 ${ResultDbFile} <<EOF
|
||||
ATTACH '${srcdb}' AS source_db;
|
||||
BEGIN;
|
||||
INSERT INTO ${table} SELECT * FROM source_db.${table};
|
||||
COMMIT;
|
||||
DETACH source_db;
|
||||
EOF
|
||||
done
|
||||
Cmd="rm ${srcdb}"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
done
|
||||
done
|
||||
|
||||
Cmd="gzip ${ResultDbFile}"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
|
||||
Cmd="rsync -ahvv ${ResultDbFile}.gz homestore.cvtt.vpn:/works/cvtt/md_archive/equity/alpaca_md/sim/"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
|
||||
Cmd="rsync -ahvv ${ResultDbFile}.gz cloud21.cvtt.vpn:/opt/store/cvtt/md_archive/equity/alpaca_md/sim/"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
|
||||
Cmd="rm ${ResultDbFile}.gz"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
|
||||
echo Done $0 ${*}
|
||||
Executable
+151
@@ -0,0 +1,151 @@
|
||||
#!/bin/bash
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 -S <symbols> -d <YYYYMMDD Date> [-O <output dir (./) >]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# --------------------- Settings
|
||||
SourceHost=cloud21.cvtt.vpn
|
||||
SourceRootDir=/opt/store/cvtt/md_archive/equity/alpaca_md
|
||||
# --------------------- Settings
|
||||
|
||||
|
||||
is_business_day() {
|
||||
dt=${1}
|
||||
date=$(date -d "${dt}" +"%Y-%m-%d")
|
||||
|
||||
CalendarURL=http://cloud23.cvtt.vpn:8000/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
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
|
||||
}
|
||||
export -f is_business_day
|
||||
|
||||
|
||||
while getopts ":d:S:O:" opt; do
|
||||
case ${opt} in
|
||||
d )
|
||||
Date=$OPTARG
|
||||
;;
|
||||
S )
|
||||
SymList=$OPTARG
|
||||
;;
|
||||
O )
|
||||
OutputDir=$OPTARG
|
||||
;;
|
||||
\? )
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
usage
|
||||
;;
|
||||
: )
|
||||
echo "Option -$OPTARG requires an argument." >&2
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z ${SymList} ] ; then
|
||||
echo "symbols are not specified"
|
||||
usage
|
||||
fi
|
||||
if [ -z ${Date} ] ; then
|
||||
echo "date is not specified"
|
||||
usage
|
||||
fi
|
||||
if [ -z ${OutputDir} ] ; then
|
||||
OutputDir=.
|
||||
fi
|
||||
mkdir -p ${OutputDir}
|
||||
|
||||
if ! is_business_day ${Date}; then
|
||||
echo "${Date} is not business day"
|
||||
usage
|
||||
fi
|
||||
|
||||
OLD_IFS=${IFS}
|
||||
IFS=","
|
||||
read -ra Symbols <<< "${SymList}"
|
||||
IFS=${OLD_IFS}
|
||||
|
||||
echo "Date=${Date} Symbols=${Symbols[@]} OutputDir=${OutputDir}"
|
||||
echo Getting data from ${DataHost} ...
|
||||
|
||||
year=$(date -d ${Date} +"%Y")
|
||||
for sym in ${Symbols[@]}; do
|
||||
inst_id="STOCK-${sym}"
|
||||
capital=${sym:0:1}
|
||||
SourceDir="${SourceRootDir}/${year}/${capital}/${sym}"
|
||||
SourceHbarFile="${SourceDir}/${Date}.${sym}.alpaca_1m_bars.db.gz"
|
||||
SourceQatFile="${SourceDir}/${Date}.${sym}.alpaca_qat.db.gz"
|
||||
|
||||
for src_file in ${SourceHbarFile} ${SourceQatFile}; do
|
||||
Cmd="rsync -ahv"
|
||||
Cmd+=" ${SourceHost}:${src_file}"
|
||||
Cmd+=" $OutputDir/"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
done
|
||||
done
|
||||
|
||||
Cmd="(cd ${OutputDir} && gunzip *.db.gz)"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
|
||||
ResultDbFile="${OutputDir}/${Date}.alpaca_sim_md.db"
|
||||
echo "Creating Result Database File ${ResultDbFile}"
|
||||
sym=${Symbols[0]}
|
||||
for db_file in ${OutputDir}/${Date}.${sym}.alpaca_1m_bars.db ${OutputDir}/${Date}.${sym}.alpaca_qat.db ; do
|
||||
Cmd="sqlite3"
|
||||
Cmd+=" ${db_file} .schema"
|
||||
Cmd+=" | sqlite3 ${ResultDbFile}"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
done
|
||||
|
||||
set -f # not to expand *
|
||||
|
||||
for sym in ${Symbols[@]}; do
|
||||
src_hbar_db=${OutputDir}/${Date}.${sym}.alpaca_1m_bars.db
|
||||
src_qat_db=${OutputDir}/${Date}.${sym}.alpaca_qat.db
|
||||
for srcdb in ${src_hbar_db} ${src_qat_db} ; do
|
||||
|
||||
tables=$(sqlite3 ${srcdb} .tables)
|
||||
for table in $(sqlite3 ${srcdb} .tables) ; do
|
||||
echo "Loading from ${srcdb}.${table} ..."
|
||||
sqlite3 ${ResultDbFile} <<EOF
|
||||
ATTACH '${srcdb}' AS source_db;
|
||||
BEGIN;
|
||||
INSERT INTO ${table} SELECT * FROM source_db.${table};
|
||||
COMMIT;
|
||||
DETACH source_db;
|
||||
EOF
|
||||
done
|
||||
Cmd="rm ${srcdb}"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
done
|
||||
done
|
||||
|
||||
Cmd="gzip ${ResultDbFile}"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
|
||||
Cmd="rsync -ahvv ${ResultDbFile}.gz homestore.cvtt.vpn:/works/cvtt/md_archive/equity/alpaca_md/sim/"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
|
||||
Cmd="rsync -ahvv ${ResultDbFile}.gz cloud21.cvtt.vpn:/opt/store/cvtt/md_archive/equity/alpaca_md/sim/"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
|
||||
Cmd="rm ${ResultDbFile}.gz"
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
|
||||
echo Done $0 ${*}
|
||||
@@ -31,7 +31,7 @@ echo "Schemas=${Schemas}"
|
||||
Cmd=
|
||||
Cmd="${Python}"
|
||||
Cmd="${Cmd} ${RootDir}/cvttpy/research/utils/archive_ts_md.py"
|
||||
Cmd="${Cmd} --config=http://cloud16.cvtt.vpn:6789/apps/md_recorder"
|
||||
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}"
|
||||
|
||||
Executable
+79
@@ -0,0 +1,79 @@
|
||||
#!/bin/bash
|
||||
|
||||
# "cryptovaltrading.com": {
|
||||
# "cloud18": {
|
||||
# "users": ["oleg"],
|
||||
# "type": "cloud",
|
||||
# "ssh_port": 7822,
|
||||
# "to_check": "false"
|
||||
# "timeout_sec": 5
|
||||
# },
|
||||
|
||||
RootDir="${HOME}/prod"
|
||||
|
||||
AlertChannel=Alerts-CVTT
|
||||
Sender=${RootDir}/ops/utils/send_mmost.sh
|
||||
ConfigUrl=http://cloud23.cvtt.vpn:6789/admin/cvtt_hosts
|
||||
|
||||
HOSTS_CONFIG=$(curl -s ${ConfigUrl} | ${HOME}/bin/hjson -j)
|
||||
|
||||
get_domains() {
|
||||
echo ${HOSTS_CONFIG} | jq -r '. | keys[]'
|
||||
}
|
||||
get_user_hosts() {
|
||||
local User=${1}
|
||||
local Domain=${2}
|
||||
|
||||
jdcmd="jq -r --arg domain \"$Domain\""
|
||||
jdcmd="$jdcmd --arg usr \"$User\""
|
||||
jdcmd="$jdcmd '.[\$domain]"
|
||||
jdcmd="$jdcmd | to_entries[]"
|
||||
jdcmd="$jdcmd | select(.value.users[]"
|
||||
jdcmd="$jdcmd | contains(\$usr))"
|
||||
jdcmd="$jdcmd | .key'"
|
||||
echo ${HOSTS_CONFIG} | eval ${jdcmd} |sed "s/$/.$Domain/" # >&2
|
||||
}
|
||||
|
||||
function host_alert() {
|
||||
alert=${1}
|
||||
if [ "${alert}" != "" ]
|
||||
then
|
||||
echo -e "### :fire: HOST ALERT \n${alert}" | ${Sender} ${AlertChannel}
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
User=oleg
|
||||
Hosts=()
|
||||
DEFAULT_SSH_PORT=22
|
||||
DEFAULT_TIMEOUT=5
|
||||
DEFAULT_TO_CHECK="true"
|
||||
Domains=("${Domains[@]}" "$(get_domains)")
|
||||
|
||||
for Domain in ${Domains[@]} ; do
|
||||
Hosts=("${Hosts[@]}" "$(get_user_hosts ${User} ${Domain})")
|
||||
done
|
||||
|
||||
for Host in ${Hosts[@]} ; do
|
||||
host=$(echo $Host | cut -d'.' -f1)
|
||||
Domain=$(echo $Host | cut -d'.' -f2-)
|
||||
|
||||
|
||||
PortSSH=$(echo "$HOSTS_CONFIG" | jq -r --arg domain "$Domain" --arg host "$host" '.[$domain][$host].ssh_port // '"$DEFAULT_SSH_PORT"'')
|
||||
|
||||
Timeout=$(echo "$HOSTS_CONFIG" | jq -r --arg domain "$Domain" --arg host "$host" '.[$domain][$host].timeout_sec // '"$DEFAULT_TIMEOUT"'')
|
||||
|
||||
ToCheck=$(echo "$HOSTS_CONFIG" | jq -r --arg domain "$Domain" --arg host "$host" '.[$domain][$host].to_check // '"$DEFAULT_TO_CHECK"'')
|
||||
to_check="${ToCheck^^}"
|
||||
if [ "${to_check}" == "TRUE" -o "${to_check}" == "YES" -o "${to_check}" == "Y" -o "${to_check}" == "T" ] ; then
|
||||
echo "Checking host: $Host on port $PortSSH"
|
||||
else
|
||||
continue
|
||||
fi
|
||||
|
||||
# Use nc to check if the specified port is open
|
||||
if ! nc -z -w ${Timeout} "$Host" "$PortSSH"; then
|
||||
echo "Host $Host is not available on port $PortSSH"
|
||||
host_alert "Host $Host is not available on port $PortSSH"
|
||||
fi
|
||||
done
|
||||
Executable
+58
@@ -0,0 +1,58 @@
|
||||
#!/bin/bash
|
||||
|
||||
# "Jenkins" {
|
||||
# "to_check": "Yes",
|
||||
# "protocol": "http",
|
||||
# "host": "cvtt-build.cvtt.vpn",
|
||||
# "port": 8080
|
||||
# },
|
||||
|
||||
RootDir="${HOME}/prod"
|
||||
# RootDir=/home/oleg/develop/cvtt2 ###### D E B U G
|
||||
|
||||
AlertChannel=Alerts-CVTT
|
||||
Sender=${RootDir}/ops/utils/send_mmost.sh
|
||||
ConfigUrl=http://cloud23.cvtt.vpn:6789/admin/cvtt_services
|
||||
|
||||
SERVICES_CONFIG=$(curl -s ${ConfigUrl} | ${HOME}/bin/hjson -j)
|
||||
|
||||
echo $Sender
|
||||
echo $AlertChannel
|
||||
|
||||
|
||||
function service_alert() {
|
||||
alert="${1}"
|
||||
if [ "${alert}" != "" ]
|
||||
then
|
||||
#it may contain quotes
|
||||
alert=$(echo "${alert}" | sed 's/"/\\"/g')
|
||||
echo -e "### :boom: SERVICE ALERT\n${alert}" | ${Sender} ${AlertChannel}
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
User=oleg
|
||||
Hosts=()
|
||||
DEFAULT_TO_CHECK=Yes
|
||||
|
||||
mapfile -t SvcNames < <(echo ${SERVICES_CONFIG} | jq -r '. | keys[]')
|
||||
|
||||
DEFAULT_TO_CHECK=Yes
|
||||
for SvcName in "${SvcNames[@]}" ; do
|
||||
ToCheck=$(echo "$SERVICES_CONFIG" | jq -r --arg svcname "$SvcName" '.[$svcname].to_check // "Yes"')
|
||||
if [ "${ToCheck^^}" == "NO" ]; then
|
||||
continue
|
||||
fi
|
||||
Host=$(echo "$SERVICES_CONFIG" | jq -r --arg svcname "$SvcName" '.[$svcname].host ')
|
||||
Port=$(echo "$SERVICES_CONFIG" | jq -r --arg svcname "$SvcName" '.[$svcname].port ')
|
||||
echo "Checking \"$SvcName\" (${Host}:${Port})"
|
||||
|
||||
|
||||
# Use nc to check if the specified port is open
|
||||
if ! nc -z -w5 "$Host" "$Port"; then
|
||||
msg="Service \"${SvcName}\" (${Host}:${Port}) is not available"
|
||||
echo ${msg}
|
||||
service_alert "${msg}"
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -69,7 +69,9 @@ function storage_check() {
|
||||
Cmd="ssh -p ${port} $host"
|
||||
Cmd="${Cmd} eval \"df -hTl"
|
||||
Cmd="${Cmd} -x squashfs"
|
||||
Cmd="${Cmd} | grep -v tmpfs"
|
||||
Cmd="${Cmd} -x tmpfs"
|
||||
Cmd="${Cmd} -x vfat"
|
||||
Cmd="${Cmd} -x devtmpfs"
|
||||
Cmd="${Cmd} | grep -v Filesystem\""
|
||||
|
||||
IFS=$'\n' ; lines=$(eval ${Cmd})
|
||||
|
||||
@@ -4,7 +4,7 @@ Start=${1}
|
||||
NumJobs=${2}
|
||||
InstListFile=${3}
|
||||
|
||||
export CalendarURL=http://cloud16.cvtt.vpn:8000/api/v1/markets/hours?mic=XNYS
|
||||
export CalendarURL=http://cloud23.cvtt.vpn:8000/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://cloud16.cvtt.vpn:6789/apps/minimal_md
|
||||
export Config=http://cloud23.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
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
is_business_day() {
|
||||
dt=${1}
|
||||
|
||||
CalendarURL=http://cloud16.cvtt.vpn:8000/api/v1/markets/hours?mic=XNYS
|
||||
CalendarURL=http://cloud23.cvtt.vpn:8000/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
|
||||
|
||||
@@ -7,7 +7,6 @@ usage() {
|
||||
}
|
||||
|
||||
RootDir="${HOME}/prod"
|
||||
# RootDir=/home/oleg/develop/cvtt2 ###### D E B U G
|
||||
|
||||
export PYTHONPATH=${RootDir}
|
||||
|
||||
@@ -15,28 +14,33 @@ StatusChannel="MD-Status"
|
||||
Sender=${RootDir}/ops/utils/send_mmost.sh
|
||||
|
||||
# ----- For DEBUGGING
|
||||
# Sender=cat
|
||||
# StatusChannel=
|
||||
# RootDir=/home/oleg/develop/cvtt2 ###### D E B U G
|
||||
# Sender=cat #### D E B U G
|
||||
# StatusChannel= #### D E B U G
|
||||
|
||||
run_checklist() {
|
||||
|
||||
|
||||
yr=$(date -d 'yesterday' '+%Y')
|
||||
|
||||
CheckSymbols="A/AAPL N/NVDA M/META"
|
||||
declare -A Commands
|
||||
Commands["homestore"]="ssh cvtt@homestore.cvtt.vpn ls -l /works/cvtt/md_archive/equity/alpaca_md/A/AAPL/${yr} | tail -3"
|
||||
Commands["homestore"]+="; echo"
|
||||
Commands["homestore"]+="; ssh cvtt@homestore.cvtt.vpn ls -l /works/cvtt/md_archive/equity/alpaca_md/N/NVDA/${yr} | tail -3"
|
||||
Commands["homestore"]=""
|
||||
for sym in ${CheckSymbols}; do
|
||||
Commands["homestore"]+="ssh cvtt@homestore.cvtt.vpn ls -l /works/cvtt/md_archive/equity/alpaca_md/${yr}/${sym} | tail -3; "
|
||||
done
|
||||
Commands["homestore"]+="echo"
|
||||
|
||||
Commands["cloud21"]="ssh cvtt@cloud21.cvtt.vpn ls -l /opt/store/cvtt/md_archive/equity/alpaca_md/A/AAPL/${yr} | tail -3"
|
||||
Commands["cloud21"]+="; echo"
|
||||
Commands["cloud21"]+="; ssh cvtt@cloud21.cvtt.vpn ls -l /opt/store/cvtt/md_archive/equity/alpaca_md/N/NVDA/${yr} | tail -3"
|
||||
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; "
|
||||
done
|
||||
Commands["cloud21"]+="echo"
|
||||
|
||||
Commands["gpushnik"]="ssh oleg@gpushnik.cvtt.vpn 'ls -l /opt/jupyter_gpu/data/eqty_md | tail -10'"
|
||||
|
||||
for name in $(printf "%s\n" "${!Commands[@]}" | sort); do
|
||||
Cmd=${Commands[${name}]}
|
||||
echo "------- ${name}"
|
||||
Cmd=${Commands[${name}]}
|
||||
echo ${Cmd}
|
||||
eval ${Cmd}
|
||||
done
|
||||
|
||||
@@ -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://cloud16.cvtt.vpn:6789/apps/tests/listen_market_data"
|
||||
Cmd="${Cmd} --config=http://cloud23.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"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# ----- Settings
|
||||
LocalSoftwareDir=${HOME}/software/cvtt2
|
||||
|
||||
ProdDir=${HOME}/prod
|
||||
ProdDir=$(pwd)
|
||||
|
||||
ReleaseHosts=("cloud21.cvtt.vpn")
|
||||
ReleasePorts=("22")
|
||||
@@ -77,9 +77,9 @@ rsync_load_version
|
||||
Location="${LocalSoftwareDir}/${Project}/${Version}/${Project}"
|
||||
|
||||
Cmd="cd ${ProdDir}"
|
||||
Cmd="${Cmd} && rm -rf ${Project}"
|
||||
Cmd="${Cmd} && ln -snf ${Location} ${Project}"
|
||||
Cmd+=" && rm -rf ${Project}"
|
||||
Cmd+=" && ln -snf ${Location} ${Project}"
|
||||
|
||||
echo ${Cmd} && eval ${Cmd}
|
||||
|
||||
echo "Done: $0 $*"
|
||||
echo "Done: $0 ${*}"
|
||||
|
||||
Reference in New Issue
Block a user