From 88308ea13eaf0c70b2103b7eb40325bd06f71b38 Mon Sep 17 00:00:00 2001 From: Oleg Sheynin Date: Wed, 5 Jun 2024 16:55:53 -0400 Subject: [PATCH] progress --- scripts/crypto_hist_md/process_daily_md.sh | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 scripts/crypto_hist_md/process_daily_md.sh diff --git a/scripts/crypto_hist_md/process_daily_md.sh b/scripts/crypto_hist_md/process_daily_md.sh new file mode 100755 index 0000000..4732536 --- /dev/null +++ b/scripts/crypto_hist_md/process_daily_md.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +date=${1} +if [ "${date}" == "" ] ; then + date="yesterday" +fi + +SourceHost=cryptoval3.cvtt.vpn +SourceUser=cvtt +SourceRootDir=/localdisk/cvtt/archive/md_archive +SourceFile=$(date -d ${date} "+%Y%m%d.mktdata.db") +SourceFileZip="${SourceFile}.gz" +SourceFilePath=$(date -d ${date} "+${SourceRootDir}/%Y/%m/${SourceFileZip}") + +TargetDir=/tmp # URGENT change to /opt/jupyter_gpu/data +TargetFile=$(date -d ${date} "+%Y%m%d.mktdata.ohlcv.db") +TargetFilePath="${TargetDir}/${TargetFile}" + +echo ${SourceFile} +tmp_dir=$(mktemp -d) + +function cleanup { + cd ${HOME} + rm -rf ${tmp_dir} +} +trap cleanup EXIT + +function download_file { + + Cmd="rsync" + Cmd="${Cmd} -ahv" + if tty -s; then + Cmd="${Cmd} --progress=info2" + fi + Cmd="${Cmd} ${SourceUser}@${SourceHost}:${SourceFilePath} ${tmp_dir}/" + echo ${Cmd} + eval ${Cmd} + ls -lh ${tmp_dir} + Cmd="gunzip ${tmp_dir}/${SourceFileZip}" + echo ${Cmd} && eval ${Cmd} + ls -lh ${tmp_dir} + + rm -f ${TargetFilePath} + touch ${TargetFilePath} + + for table in bnbfut_ohlcv_1min bnbspot_ohlcv_1min coinbase_ohlcv_1min + do + Cmd="sqlite3 ${tmp_dir}/${SourceFile} \".dump ${table}\" | sqlite3 ${TargetFilePath}" + echo ${Cmd} + eval ${Cmd} + done + ls -lh ${TargetFilePath} + + +} +download_file