Compare commits

..

18 Commits

Author SHA1 Message Date
oleg 1387893a14 fix 2024-10-31 15:39:33 -04:00
oleg 87e1a0610b progress: host checks 2024-10-31 15:17:21 -04:00
oleg 6a6046050c fix 2024-10-31 12:04:08 -04:00
oleg 0e23024aab using new(rust) alpaca market data structure for hbar 2024-10-31 11:51:42 -04:00
oleg d32bf31f4a fix 2024-10-30 15:34:19 -04:00
oleg 65c87f97e6 fix 2024-10-30 15:29:10 -04:00
oleg ae79f940fb update for storage check 2024-10-30 15:21:38 -04:00
oleg 80ae780f02 fix 2024-10-29 19:51:24 -04:00
oleg 5318b16b7f alpaca hbar load 2024-10-29 19:44:41 -04:00
oleg 03c341cefb fix2 2024-10-29 19:07:30 -04:00
oleg db7ea93c6b fix 2024-10-29 18:38:21 -04:00
oleg d7c1a3c456 load alpaca QAT 2024-10-29 18:25:17 -04:00
oleg 5bf2d043a2 minor 2024-10-04 11:34:26 -04:00
oleg 72d5a849be 2024-09-23 08:04:54 -04:00
oleg 6125b10935 minor 2024-09-23 04:13:31 -04:00
oleg c637faf4bf cleaned out several docker scripts. added checklist sources 2024-09-11 11:37:51 -04:00
oleg a8f3b5c495 beginning to move docker to prod repos 2024-09-10 16:57:26 -04:00
oleg 26d0b1a4e0 config (for all trading images) is made more flexible, docker compose initial 2024-09-09 20:44:49 -04:00
24 changed files with 355 additions and 614 deletions
File diff suppressed because one or more lines are too long
-14
View File
@@ -1,14 +0,0 @@
#!/bin/bash
Cmd="docker run"
Cmd="${Cmd} -d"
Cmd="${Cmd} --rm"
Cmd="${Cmd} --pull=always"
Cmd="${Cmd} --name=cvtt_config_service"
Cmd="${Cmd} -p 6789:6789"
Cmd="${Cmd} -v /home/cvtt/prod/config_service/data:/app/data"
Cmd="${Cmd} -v /home/cvtt/prod/logs:/logs"
Cmd="${Cmd} cloud21.cvtt.vpn:5500/config_service:latest"
echo ${Cmd}
eval ${Cmd}
+3 -2
View File
@@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
date_to_load=${1} date_to_load=${1} # YYYY-MM-DD
DockerRegistry=cloud21.cvtt.vpn:5500 DockerRegistry=cloud21.cvtt.vpn:5500
DockerImage=${DockerRegistry}/alpaca_md_day #:latest DockerImage=${DockerRegistry}/alpaca_md_day #:latest
@@ -46,7 +46,7 @@ get_prev_business_day() {
export -f get_prev_business_day export -f get_prev_business_day
if [ -z ${date_to_load} ] ; then if [ -z ${date_to_load} ] ; then
echo "Yesterday data has priority. Running historical container will be stopped" echo "Date is not specified. Yesterday data has priority. Running historical container will be stopped"
Cmd="docker stop ${ContainerName}" Cmd="docker stop ${ContainerName}"
echo ${Cmd} && eval ${Cmd} echo ${Cmd} && eval ${Cmd}
Cmd="docker kill ${ContainerName}" Cmd="docker kill ${ContainerName}"
@@ -62,6 +62,7 @@ if [ -z ${date_to_load} ] ; then
exit 3 exit 3
fi fi
else else
date_to_load=$(date -d ${date_to_load} '+%Y-%m-%d') #expected format
echo "Historical run ${date_to_load}" echo "Historical run ${date_to_load}"
if is_container_running "$ContainerName"; then if is_container_running "$ContainerName"; then
echo "Container ${ContainerName} is already running." echo "Container ${ContainerName} is already running."
+105
View File
@@ -0,0 +1,105 @@
#!/bin/bash
usage() {
echo "Usage: $0 -N <num_symbols> [-L <LogDir>] [-d <YYYYMMDD Date>]"
exit 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
}
export CalendarURL=http://cloud23.cvtt.vpn:8000/api/v1/markets/hours?mic=XNYS
is_business_day() {
dt=${1}
open_time=$(curl -s "${CalendarURL}&start=${dt}&end=${dt}" | jq '.[] | .open_time')
if [ -n "${open_time}" ]; then
return 0
else
return 1
fi
}
export -f is_business_day
get_prev_business_day() {
Start=${1}
while true; do
if is_business_day ${Start}; then
break
fi
echo "${Start} is not business day in US" >&2
Start=$(date -d "${Start} - 1 day" "+%Y-%m-%d")
done
echo ${Start}
}
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
# ----- Settings
while getopts ":d:N:L:" opt; do
case ${opt} in
d )
date_to_load=$OPTARG
;;
N )
NumSymbols=$OPTARG
;;
L )
LogDir=$OPTARG
;;
\? )
echo "Invalid option: -$OPTARG" >&2
usage
;;
: )
echo "Option -$OPTARG requires an argument." >&2
usage
;;
esac
done
if is_container_running "$ContainerName"; then
echo "Container ${ContainerName} is already running."
exit 3
fi
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'))
echo "Historical Data for ${date_to_load}"
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} ${DockerImage}"
Cmd="${Cmd} -d ${date_to_load}"
if [ -n "${NumSymbols}" ]; then
Cmd="${Cmd} -N ${NumSymbols}"
fi
echo $Cmd
eval $Cmd
if [ "$?" != "0" ] ; then
exit 1 # if killed we do not save last day
fi
+108
View File
@@ -0,0 +1,108 @@
#!/bin/bash
usage() {
echo "Usage: $0 -S <symbols> [-L <LogDir>] [-d <YYYYMMDD Date>]"
exit 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
}
export CalendarURL=http://cloud23.cvtt.vpn:8000/api/v1/markets/hours?mic=XNYS
is_business_day() {
dt=${1}
open_time=$(curl -s "${CalendarURL}&start=${dt}&end=${dt}" | jq '.[] | .open_time')
if [ -n "${open_time}" ]; then
return 0
else
return 1
fi
}
export -f is_business_day
get_prev_business_day() {
Start=${1}
while true; do
if is_business_day ${Start}; then
break
fi
echo "${Start} is not business day in US" >&2
Start=$(date -d "${Start} - 1 day" "+%Y-%m-%d")
done
echo ${Start}
}
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
# ----- Settings
while getopts ":d:S:L:" opt; do
case ${opt} in
d )
date_to_load=$OPTARG
;;
S )
Symbols=$OPTARG
;;
L )
LogDir=$OPTARG
;;
\? )
echo "Invalid option: -$OPTARG" >&2
usage
;;
: )
echo "Option -$OPTARG requires an argument." >&2
usage
;;
esac
done
if [ -z ${Symbols} ] ; then
echo "symbols are not specified"
usage
fi
if is_container_running "$ContainerName"; then
echo "Container ${ContainerName} is already running."
exit 3
fi
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'))
echo "Historical Data for ${date_to_load}"
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} ${DockerImage}"
Cmd="${Cmd} -d ${date_to_load}"
Cmd="${Cmd} -S ${Symbols}"
echo $Cmd
eval $Cmd
if [ "$?" != "0" ] ; then
exit 1 # if killed we do not save last day
fi
@@ -1,2 +0,0 @@
ROOT_DIR=/home/cvtt/prod
ADMIN_PORT=7220
@@ -1,20 +0,0 @@
version: '3.8'
#==================================================
# Relies on the file `.env` content for varables:
# ROOT_DIR
# JUPYTER_PORT
#==================================================
services:
md_portal:
image: cloud21.cvtt.vpn:5500/md_portal:latest
network_mode: host
container_name: md_portal
restart: unless-stopped
environment:
- JUPYTER_ENABLE_LAB=yes
volumes:
- ${ROOT_DIR}/logs:/logs
ports:
- "${ADMIN_PORT}:${ADMIN_PORT}"
shm_size: "8gb"
@@ -1,73 +0,0 @@
#!/bin/bash
usage() {
echo -n "Usage: ${0}"
echo -n " [-C <config (dflt: apps/cvtt_eqt_alpaca)>]"
echo -n " [-c <config_server (dflt: cloud23.cvtt.vpn:6789)>]"
echo -n " [-e <active_exchanges (ALPACA_SNBOX)>]"
echo -n " [-a <admin_port (7220)>]"
echo -n " [-n <portal_name (MD_PORTAL_ALPACA)>]"
echo
exit 1
}
args=${*}
Config=apps/cvtt_eqt_alpaca
ConfigServer=cloud23.cvtt.vpn:6789
ActiveExchanges=ALPACA_SNDBX
PortalName=MD_PORTAL_ALPACA_SNDBX
AdminPort=7220
while getopts ":C:c:e:a:n:" opt; do
case ${opt} in
C )
Config=$OPTARG
;;
c )
ConfigServer=$OPTARG
;;
e )
ActiveExchanges=$OPTARG
;;
a )
AdminPort=$OPTARG
;;
n )
PortalName=$OPTARG
;;
\? )
echo "Invalid option: -$OPTARG" >&2
usage
;;
: )
echo "Option -$OPTARG requires an argument." >&2
usage
;;
esac
done
echo "Config=${Config}"
echo "ConfigServer=${ConfigServer}"
echo "ActiveExchanges=${ActiveExchanges}"
echo "PortalName=${PortalName}"
echo "AdminPort=${AdminPort}"
ImageName=md_portal
DockerRegistry=cloud21.cvtt.vpn:5500
DockerImage=${DockerRegistry}/${ImageName}
Cmd="docker run"
Cmd="${Cmd} --detach"
Cmd="${Cmd} --restart=unless-stopped"
Cmd="${Cmd} --pull=always"
Cmd="${Cmd} --network=host"
Cmd="${Cmd} --name=${ImageName}.${PortalName}"
Cmd="${Cmd} --volume /home/cvtt/prod/logs:/logs"
Cmd="${Cmd} ${DockerImage}"
Cmd="${Cmd} ${args}"
echo $Cmd
eval $Cmd
@@ -1,14 +0,0 @@
#!/bin/bash
Cmd="docker run"
Cmd="${Cmd} -d"
#Cmd="${Cmd} --rm"
Cmd="${Cmd} --pull=always"
Cmd="${Cmd} --name=relative_liquidity_svc"
Cmd="${Cmd} -p 5678:5678"
Cmd="${Cmd} -v /home/cvtt/prod/data:/app/data"
Cmd="${Cmd} -v /home/cvtt/prod/logs:/logs"
Cmd="${Cmd} cloud21.cvtt.vpn:5500/relative_liquidity:latest"
echo ${Cmd}
eval ${Cmd}
@@ -1,12 +0,0 @@
#!/bin/bash
#Cmd="docker pull apptasticsoftware/trading-calendar:latest"
#echo ${Cmd} && eval ${Cmd}
Cmd="docker run"
Cmd="${Cmd} -d"
Cmd="${Cmd} --rm"
Cmd="${Cmd} --pull=always"
Cmd="${Cmd} --name trading-calendar"
Cmd="${Cmd} -p 8000:80 apptasticsoftware/trading-calendar"
echo ${Cmd} && eval ${Cmd}
-5
View File
@@ -1,5 +0,0 @@
BOOK=ALPACA-TEST-BOOK-01
CONFIG=http://cloud23.cvtt.vpn:6789/apps/cvtt_eqt_alpaca
ACTIVE_EXCHANGES=ALPACA_SNDBX-MDPORTAL
#
ADMIN_PORT_EXECUTOR=7222
-27
View File
@@ -1,27 +0,0 @@
version: "3.8"
#==================================================
# Relies on the file `.env` content for varables:
# BOOK
# CONFIG
# ACTIVE_EXCHANGES
# ADMIN_PORT_EXECUTOR
# Start with the command:
# docker compose up -d --pull
#==================================================
services:
redis:
image: redis/redis-stack:latest
container_name: redis-stack
ports:
- "6379:6379"
executor:
image: cloud21.cvtt.vpn:5500/executor:latest
container_name: executor.${BOOK}
network_mode: "host"
restart: unless-stopped
depends_on:
- redis
volumes:
- /opt/shared:/shared
command: ["-c", "${CONFIG}", "-e", "${ACTIVE_EXCHANGES}", "-a", "${ADMIN_PORT_EXECUTOR}"]
shm_size: "8gb"
@@ -1,61 +0,0 @@
#!/bin/bash
usage() {
echo -n "Usage: $0"
echo -n " [-c <config (dflt: http://cloud23.cvtt.vpn:6789/apps/cvtt_eqt_alpaca)>]"
echo -n " [-e <active_exchanges (ALPACA_SNDBX-MDPORTAL)>]"
echo -n " [-a <admin_port (7222)>"]
echo
exit 1
}
args=${*}
Config=http://cloud23.cvtt.vpn:6789/apps/cvtt_eqt_alpaca
ActiveExchanges=ALPACA_SNDBX-MDPORTAL
AdminPort=7222
Book=""
while getopts ":c:e:a:" opt; do
case ${opt} in
c )
Config=$OPTARG
;;
e )
ActiveExchanges=$OPTARG
;;
a )
AdminPort=$OPTARG
;;
\? )
echo "Invalid option: -$OPTARG" >&2
usage
;;
: )
echo "Option -$OPTARG requires an argument." >&2
usage
;;
esac
done
echo "Config=${Config}"
echo "ActiveExchanges=${ActiveExchanges}"
echo "AdminPort=${AdminPort}"
ImageName=executor
DockerRegistry=cloud21.cvtt.vpn:5500
DockerImage=${DockerRegistry}/${ImageName}
Cmd="docker run"
Cmd="${Cmd} --detach"
Cmd="${Cmd} --restart=unless-stopped"
Cmd="${Cmd} --pull=always"
Cmd="${Cmd} --network=host"
Cmd="${Cmd} --name=${ImageName}"
Cmd="${Cmd} --volume /home/cvtt/prod/logs:/logs"
Cmd="${Cmd} ${DockerImage}"
Cmd="${Cmd} ${args}"
echo $Cmd
eval $Cmd
@@ -1,86 +0,0 @@
#!/bin/bash
usage() {
echo -n "Usage: $0"
echo -n " -b <book>"
echo -n " -S <strategy> (dflt: TRDALGO_001)"
echo -n " [-c <config_server (dflt: cloud23.cvtt.vpn:6789)>]"
echo -n " [-e <active_exchanges (ALPACA_SNDBX-MDPORTAL)>]"
echo -n " [-a <admin_port (7224)>"]
echo
exit 1
}
args=${*}
ConfigServer=cloud23.cvtt.vpn:6789
ActiveExchanges=ALPACA_SNDBX-MDPORTAL
AdminPort=7224
Strategy=DAILY_STOCK_001
Book=""
while getopts ":b:c:e:a:S:" opt; do
case ${opt} in
c )
ConfigServer=$OPTARG
;;
e )
ActiveExchanges=$OPTARG
;;
a )
AdminPort=$OPTARG
;;
b )
Book=$OPTARG
;;
S )
Strategy=$OPTARG
;;
\? )
echo "Invalid option: -$OPTARG" >&2
usage
;;
: )
echo "Option -$OPTARG requires an argument." >&2
usage
;;
esac
done
if [ "${Book}" == "" ]; then
echo "Book is missing"
usage
fi
echo "ConfigServer=${ConfigServer}"
echo "ActiveExchanges=${ActiveExchanges}"
echo "Book=${Book}"
echo "Strategy=${Strategy}"
echo "AdminPort=${AdminPort}"
if [ "${Book}" == "" ]; then
echo "Book is missing"
usage
fi
ImageName=quant
DockerRegistry=cloud21.cvtt.vpn:5500
DockerImage=${DockerRegistry}/${ImageName}
Cmd="docker run"
Cmd="${Cmd} --detach"
Cmd="${Cmd} --restart=unless-stopped"
Cmd="${Cmd} --pull=always"
Cmd="${Cmd} --network=host"
Cmd="${Cmd} --name=${ImageName}.${Book}"
Cmd="${Cmd} --volume /home/cvtt/prod/logs:/logs"
Cmd="${Cmd} ${DockerImage}"
Cmd="${Cmd} ${args}"
echo $Cmd
eval $Cmd
@@ -1,74 +0,0 @@
#!/bin/bash
usage() {
echo -n "Usage: $0"
echo -n " -b <book>"
echo -n " [-c <config_server (dflt: cloud23.cvtt.vpn:6789)>]"
echo -n " [-e <active_exchanges (ALPACA_SNDBX-MDPORTAL)>]"
echo -n " [-a <admin_port (7223)>"]
echo
exit 1
}
args=${*}
ConfigServer=cloud23.cvtt.vpn:6789
ActiveExchanges=ALPACA_SNDBX-MDPORTAL
AdminPort=7223
Book=""
while getopts ":b:c:e:a:" opt; do
case ${opt} in
c )
ConfigServer=$OPTARG
;;
e )
ActiveExchanges=$OPTARG
;;
a )
AdminPort=$OPTARG
;;
b )
Book=$OPTARG
;;
\? )
echo "Invalid option: -$OPTARG" >&2
usage
;;
: )
echo "Option -$OPTARG requires an argument." >&2
usage
;;
esac
done
echo "ConfigServer=${ConfigServer}"
echo "ActiveExchanges=${ActiveExchanges}"
echo "Book=${Book}"
echo "AdminPort=${AdminPort}"
if [ "${Book}" == "" ]; then
echo "Book is missing"
usage
fi
ImageName=risk_mgr
DockerRegistry=cloud21.cvtt.vpn:5500
DockerImage=${DockerRegistry}/${ImageName}
Cmd="docker run"
Cmd="${Cmd} --detach"
Cmd="${Cmd} --restart=unless-stopped"
Cmd="${Cmd} --pull=always"
Cmd="${Cmd} --network=host"
Cmd="${Cmd} --name=${ImageName}.${Book}"
Cmd="${Cmd} --volume /home/cvtt/prod/logs:/logs"
Cmd="${Cmd} ${DockerImage}"
Cmd="${Cmd} ${args}"
echo $Cmd
eval $Cmd
@@ -1,87 +0,0 @@
#!/bin/bash
usage() {
echo -n "Usage: $0"
echo -n " -b <book>"
echo -n " -A <algo> (dflt: TRDALGO_001)"
echo -n " [-c <config_server (dflt: cloud23.cvtt.vpn:6789)>]"
echo -n " [-e <active_exchanges (ALPACA_SNDBX-MDPORTAL)>]"
echo -n " [-a <admin_port (7223)>"]
echo
exit 1
}
args=${*}
# ConfigServer=cloud16.cvtt.vpn
ConfigServer=cloud23.cvtt.vpn:6789
ActiveExchanges=ALPACA_SNDBX-MDPORTAL
AdminPort=7226
Algo=TRDALGO_001
Book=""
while getopts ":b:c:e:a:" opt; do
case ${opt} in
c )
ConfigServer=$OPTARG
;;
e )
ActiveExchanges=$OPTARG
;;
a )
AdminPort=$OPTARG
;;
b )
Book=$OPTARG
;;
A )
Algo=$OPTARG
;;
\? )
echo "Invalid option: -$OPTARG" >&2
usage
;;
: )
echo "Option -$OPTARG requires an argument." >&2
usage
;;
esac
done
if [ "${Book}" == "" ]; then
echo "Book is missing"
usage
fi
echo "ConfigServer=${ConfigServer}"
echo "ActiveExchanges=${ActiveExchanges}"
echo "Book=${Book}"
echo "Algo=${Algo}"
echo "AdminPort=${AdminPort}"
if [ "${Book}" == "" ]; then
echo "Book is missing"
usage
fi
ImageName=trader
DockerRegistry=cloud21.cvtt.vpn:5500
DockerImage=${DockerRegistry}/${ImageName}
Cmd="docker run"
Cmd="${Cmd} --detach"
Cmd="${Cmd} --restart=unless-stopped"
Cmd="${Cmd} --pull=always"
Cmd="${Cmd} --network=host"
Cmd="${Cmd} --name=${ImageName}.${Book}"
Cmd="${Cmd} --volume /home/cvtt/prod/logs:/logs"
Cmd="${Cmd} ${DockerImage}"
Cmd="${Cmd} ${args}"
echo $Cmd
eval $Cmd
@@ -1,81 +0,0 @@
#!/bin/bash
usage() {
echo -n "Usage: $0"
echo -n " -b <book>"
echo -n " [-C <config (dflt: apps/cvtt_eqt_alpaca)>]"
echo -n " [-c <config_server (dflt: cloud23.cvtt.vpn:6789)>]"
echo -n " [-e <active_exchanges (ALPACA_SNDBX-MDPORTAL)>]"
echo -n " [-a <admin_port (7223)>"]
echo
exit 1
}
args=${*}
# ConfigServer=cloud16.cvtt.vpn
ConfigServer=cloud23.cvtt.vpn:6789
ActiveExchanges=ALPACA_SNDBX-MDPORTAL
AdminPort=7225
Book=""
Config=apps/cvtt_eqt_alpaca
while getopts ":C:b:c:e:a:" opt; do
case ${opt} in
c )
ConfigServer=$OPTARG
;;
e )
ActiveExchanges=$OPTARG
;;
a )
AdminPort=$OPTARG
;;
b )
Book=$OPTARG
;;
\? )
echo "Invalid option: -$OPTARG" >&2
usage
;;
: )
echo "Option -$OPTARG requires an argument." >&2
usage
;;
esac
done
if [ "${Book}" == "" ]; then
echo "Book is missing"
usage
fi
echo "Config=${Config}"
echo "ConfigServer=${ConfigServer}"
echo "ActiveExchanges=${ActiveExchanges}"
echo "Book=${Book}"
echo "AdminPort=${AdminPort}"
if [ "${Book}" == "" ]; then
echo "Book is missing"
usage
fi
ImageName=trading_recorder
DockerRegistry=cloud21.cvtt.vpn:5500
DockerImage=${DockerRegistry}/${ImageName}
Cmd="docker run"
Cmd="${Cmd} --detach"
Cmd="${Cmd} --restart=unless-stopped"
Cmd="${Cmd} --pull=always"
Cmd="${Cmd} --network=host"
Cmd="${Cmd} --name=${ImageName}.${Book}"
Cmd="${Cmd} --volume /home/cvtt/prod/logs:/logs"
Cmd="${Cmd} ${DockerImage}"
Cmd="${Cmd} ${args}"
echo $Cmd
eval $Cmd
+1 -1
View File
@@ -1 +1 @@
1.6.6,config (for executor) is made more flexible, docker compose initial 1.7.6.fx1,host avalability check
+33
View File
@@ -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
+2 -5
View File
@@ -167,10 +167,10 @@ EOF
echo "Loading files" echo "Loading files"
for stock in "${Stocks[@]}"; do for stock in "${Stocks[@]}"; do
StockLetter="${stock:0:1}" 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" 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} echo ${SourceFilePath}
download_file ${SourceFilePath} download_file ${SourceFilePath}
@@ -180,6 +180,3 @@ if [ -f ${TargetFilePath} ]; then
chmod 600 chmod 600
ls -lh ${TargetFilePath} ls -lh ${TargetFilePath}
fi fi
# mkdir -p /tmp/aaa
# cp -r ${tmp_dir}/* /tmp/aaa/
+97
View File
@@ -0,0 +1,97 @@
#!/bin/bash
# "cryptovaltrading.com": {
# "cloud18": {
# "users": ["oleg"],
# "type": "cloud",
# "ssh_port": 7822,
# # "to_check": "No"
# },
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_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
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-)
# echo "Host=$Host host=$host Domain=$Domain"
# Get SSH port for the host, or use default if not specified
ToCheck=$(echo "$HOSTS_CONFIG" | jq -r --arg domain "$Domain" --arg host "$host" '.[$domain][$host].to_check // "Yes"')
if [ "${ToCheck}" == "No" ]; then
continue
fi
PortSSH=$(echo "$HOSTS_CONFIG" | jq -r --arg domain "$Domain" --arg host "$host" '.[$domain][$host].ssh_port // '"$DEFAULT_SSH_PORT"'')
echo "Checking host: $Host on port $PortSSH"
# Use nc to check if the specified port is open
if ! nc -z -w5 "$Host" "$PortSSH"; then
echo "Host $Host is not available on port $PortSSH"
host_alert "Host $Host is not available on port $PortSSH"
fi
done
# for Domain in $DOMAINS; do
# echo "Processing domain: $Domain"
# for host in $HOSTS; do
# # Construct the fully qualified hostname
# FQHN="${host}.${Domain}"
# # Get SSH port for the host, or use default if not specified
# SSH_PORT=$(echo "$JSON_CONFIG" | jq -r --arg domain "$Domain" --arg host "$host" '.[$domain][$host].ssh_port // '"$DEFAULT_SSH_PORT"'')
# echo "Checking host: $FQHN on port $SSH_PORT"
# # Use nc to check if the specified port is open
# if nc -z -w5 "$FQHN" "$SSH_PORT"; then
# echo "Host $FQHN is available on port $SSH_PORT"
# else
# echo "Host $FQHN is not available on port $SSH_PORT"
# fi
# echo "----------------------------------------"
# done
+3 -1
View File
@@ -69,7 +69,9 @@ function storage_check() {
Cmd="ssh -p ${port} $host" Cmd="ssh -p ${port} $host"
Cmd="${Cmd} eval \"df -hTl" Cmd="${Cmd} eval \"df -hTl"
Cmd="${Cmd} -x squashfs" 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\"" Cmd="${Cmd} | grep -v Filesystem\""
IFS=$'\n' ; lines=$(eval ${Cmd}) IFS=$'\n' ; lines=$(eval ${Cmd})
@@ -47,7 +47,7 @@ function cleanup {
} }
trap cleanup EXIT trap cleanup EXIT
echo "## :hearts: CRYPTO MD HEALTH CHECK" >> ${tmpfile} echo "## :hearts: CRYPTO MD HEALTH CHECK (cvtt-md.cvtt.vpn)" >> ${tmpfile}
echo '```' >> ${tmpfile} echo '```' >> ${tmpfile}
run_checklist >> ${tmpfile} run_checklist >> ${tmpfile}
echo '```' >> ${tmpfile} echo '```' >> ${tmpfile}
+1 -16
View File
@@ -51,25 +51,10 @@ function cleanup {
} }
trap cleanup EXIT trap cleanup EXIT
echo "## :fire: EQUITY MD HEALTH CHECK" >> ${tmpfile} echo "## :fire: EQUITY MD HEALTH CHECK (cryptoval4)" >> ${tmpfile}
echo '```' | tee -a ${tmpfile} echo '```' | tee -a ${tmpfile}
run_checklist | tee -a ${tmpfile} run_checklist | tee -a ${tmpfile}
echo '```' | tee -a ${tmpfile} echo '```' | tee -a ${tmpfile}
echo "Sending result to ${Sender} ${StatusChannel}" echo "Sending result to ${Sender} ${StatusChannel}"
cat ${tmpfile} | ${Sender} ${StatusChannel} cat ${tmpfile} | ${Sender} ${StatusChannel}
exit
# homestore
echo homestore
ssh cvtt@homestore.cvtt.vpn ls -l /works/cvtt/md_archive/equity/alpaca_md/A/AAPL/${yr} | tail -3
echo
ssh cvtt@homestore.cvtt.vpn ls -l /works/cvtt/md_archive/equity/alpaca_md/N/NVDA/${yr} | tail -3
echo cloud21
ssh cvtt@cloud21.cvtt.vpn ls -l /opt/store/cvtt/md_archive/equity/alpaca_md/A/AAPL/${yr} | tail -3
echo
ssh cvtt@cloud21.cvtt.vpn ls -l /opt/store/cvtt/md_archive/equity/alpaca_md/N/NVDA/${yr} | tail -3
echo "------ gpushnik"
ssh oleg@gpushnik.cvtt.vpn 'ls -l /opt/jupyter_gpu/data/eqty_md | tail -10'