Compare commits

..

15 Commits

Author SHA1 Message Date
oleg 3932cbde37 fix 2024-07-24 13:53:26 -04:00
oleg 9e90186432 progress 2024-07-24 13:30:17 -04:00
oleg bbfd200ec4 fix 2024-07-23 16:49:48 -04:00
oleg 489016782c progress 2024-07-23 14:48:59 -04:00
oleg b698b847a5 progress 2024-07-23 13:57:47 -04:00
oleg 65f55528ef fix version 2024-07-22 17:53:00 -04:00
oleg 13ff201999 progress 2024-07-22 17:49:34 -04:00
oleg 1bc2a367ec fix version 2024-07-22 13:18:14 -04:00
oleg 416fdaffed fix 2024-07-22 13:17:38 -04:00
oleg b08ffbb73b progress 2024-07-22 13:00:00 -04:00
oleg 85534b130a progress 2024-07-19 11:09:34 -04:00
oleg f391593857 progress 2024-07-19 11:04:30 -04:00
oleg 108ae35a06 progress 2024-07-19 10:45:46 -04:00
oleg 2416a5a77e progress 2024-07-19 10:37:45 -04:00
oleg 0b9feb8610 progress 2024-07-19 10:25:26 -04:00
8 changed files with 225 additions and 8 deletions
+4 -6
View File
@@ -30,13 +30,11 @@ C R Y P T O M A R K E T D A T A
==========
Storage
==========
| created by crontabs:
| cvttdata:
| /home/cvtt/prod/utils/sync_crypto_archives.sh
| TBD prune files older than 7 days
| created by crontab cvttdata:
| /home/cvtt/prod/utils/sync_market_data.sh (ops/utls)
| stored in:
| homestore:/works/cvtt/md_archive/crypto/ (cvttdata and cloud21)
| cloud21:/opt/store/cvtt/md_archive/crypto/ (cvttdata and cloud21)
| homestore:/works/cvtt/md_archive/equity/alpaca_md
| cloud21:/opt/store/cvtt/md_archive/equity/alpaca_md
|
v
==========
+1 -1
View File
@@ -19,7 +19,7 @@ E Q U I T Y M A R K E T D A T A
| created by crontab on cvttdata:
| /home/cvtt/prod/run/alpaca_md.sh
| stored in:
| cvttdata:/home/cvtt/prod/archive/md_archive/equity/alpaca_md (TBD)
| cvttdata:/home/cvtt/prod/archive/md_archive/equity/alpaca_md
|
v
==========
+1 -1
View File
@@ -1 +1 @@
0.9.3
1.0.7
+42
View File
@@ -0,0 +1,42 @@
#!/bin/bash
pushd () {
command pushd "$@" > /dev/null
}
popd () {
command popd "$@" > /dev/null
}
SourceRoot=/works/cvtt/md_archive/equity/alpaca_md.2
TargetRoot=/works/cvtt/md_archive/equity/alpaca_md.NEW
mkdir -p ${TargetDir}
unalias ls
cd ${SourceRoot}
for year in $(ls -d 2*)
do
echo $year
pushd $year
for letter in $(ls -d ?)
do
pushd ${letter}
echo "${year}/${letter}"
for symbol in $(ls -d ${letter}*)
do
pushd $symbol
echo "${year}/${letter}/${symbol}/* --> ${letter}/${symbol}/${year}/"
mkdir -p ${TargetRoot}/${letter}/${symbol}/${year}
mv ${SourceRoot}/${year}/${letter}/${symbol}/* ${TargetRoot}/${letter}/${symbol}/${year}/
popd
done
popd
done
popd
done
+81
View File
@@ -0,0 +1,81 @@
#!/bin/bash
date_to_load=${1}
DockerRegistry=cloud21.cvtt.vpn:5500
DockerImage=${DockerRegistry}/alpaca_md_day #:latest
LastDayFile=/home/cvtt/prod/logs/last_alpaca_hist_day
ContainerName=alpaca_md_day
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
}
if [ -z ${date_to_load} ] ; then
echo "Yesterday data has priority. Running historical container will be killed"
docker kill ${ContainerName}
else
echo "Historical run ${date_to_load}"
if is_container_running "$ContainerName"; then
echo "Container ${ContainerName} is already running."
exit 3
fi
if [ "${date_to_load}" == "next" ] ; then
if [ ! -e ${LastDayFile} ]; then
echo "File ${LastDayFile} does not exist. Will try to use prev file."
if [ ! -e ${LastDayFile}.prev ]; then
echo "File ${LastDayFile}.prev does not exist. Aborted."
exit 2
fi
mv ${LastDayFile}.prev ${LastDayFile}
fi
last_date=$(cat ${LastDayFile} | xargs)
if [ -z "${last_date}" ] ; then
echo "File ${LastDayFile} returned an empty last day. Will try to use prev file."
if [ ! -e ${LastDayFile}.prev ]; then
echo "File ${LastDayFile}.prev does not exist. Aborted."
exit 2
fi
mv ${LastDayFile}.prev ${LastDayFile}
last_date=$(cat ${LastDayFile} | xargs)
if [ -z "${last_date}" ] ; then
echo "Unable to obtain last_date. Aborted"
exit 3
fi
echo "No last date_to_load in ${LastDayFile}"
exit 1
fi
mv ${LastDayFile} ${LastDayFile}.prev
date_to_load=$(date -d "${last_date} - 1 day" "+%Y-%m-%d")
fi
echo "Historical Data for ${date_to_load}"
fi
Cmd="docker run"
Cmd="${Cmd} --pull=always"
Cmd="${Cmd} --network=host"
Cmd="${Cmd} --name=${ContainerName}"
Cmd="${Cmd} --rm"
Cmd="${Cmd} ${DockerImage}"
Cmd="${Cmd} ${date_to_load}"
echo $Cmd
eval $Cmd
if [ "$?" != "0" ] ; then
exit 1 # if killed we do not save last day
fi
# truncate to avoid false positive
date_to_load=$(echo "${date_to_load} | xargs")
if [ -n "${date_to_load}" ]; then
echo "Saving date_to_load to ${LastDayFile}"
echo ${date_to_load} > ${LastDayFile}
fi
+24
View File
@@ -0,0 +1,24 @@
#!/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} ${DockerImage}"
Cmd="${Cmd} -h ${host}"
Cmd="${Cmd} -d ${date}"
Cmd="${Cmd} -s coinbase,bnbspot,bnbfut"
echo $Cmd
eval $Cmd
+58
View File
@@ -0,0 +1,58 @@
#!/bin/bash
Src=${1}
Days=${2}
if [ -z "$Days" ] || [ -z "$Src" ]; then
echo "Usage: $0 <source_dir> <num_days>"
exit 1
fi
# Add / if Src does not have it (symlinks)
if [ "${Src: -1}" != "/" ]; then
Src="${Src}/"
fi
declare -A Settings=()
Settings[Src]=${Src}
Settings[PruneDate]=$(date -d "${Days} days ago" '+%Y-%m-%d')
src=${Settings[Src]}
prune_date=${Settings[PruneDate]}
echo "Finding files older than ${prune_date} in ${Src} ..."
Cmd="find ${src} -type f ! -newermt \"${prune_date}\""
echo ${Cmd}
files=($(eval ${Cmd}))
total_files=${#files[*]}
if [[ ${total_files} == 0 ]]
then
echo "No files found to be pruned. Bye..."
exit 0
fi
echo Before Pruning....
duf ${src}
echo "The following files will be removed:"
echo "===================================="
for f in $files ; do ls -l $f; done
echo "===================================="
echo "Total files to be pruned: ${total_files}"
echo "Removing files..."
Cmd="${Cmd} -print -delete"
echo ${Cmd}
eval ${Cmd}
echo "Removing empty directories..."
Cmd="find ${src} -type d -empty -print -delete"
echo ${Cmd}
eval ${Cmd}
echo After Pruning....
duf ${src}
echo $0 Done
+14
View File
@@ -0,0 +1,14 @@
#!/bin/bash
Source=/home/cvtt/prod/archive/md_archive/
Targets=
Targets="${Targets} oleg@homestore.cvtt.vpn:/works/cvtt/md_archive/"
Targets="${Targets} cvtt@cloud21.cvtt.vpn:/opt/store/cvtt/md_archive/"
for tgt in ${Targets}
do
Cmd="/usr/bin/rsync -ahv ${Source} ${tgt}"
echo $Cmd
eval $Cmd
done