Compare commits

...

25 Commits

Author SHA1 Message Date
oleg 0b9feb8610 progress 2024-07-19 10:25:26 -04:00
oleg 51e059a72b fix 2024-07-19 09:47:18 -04:00
oleg 9a59b00998 progress 2024-07-18 16:45:52 -04:00
oleg 78de26d154 progress 2024-07-18 12:08:35 -04:00
oleg 8eb52d718f progress 2024-07-17 10:47:52 -04:00
oleg a0cf2531e6 progress 2024-07-17 09:14:22 -04:00
oleg ada2a74eb6 fix 2024-07-16 15:11:14 -04:00
oleg 7dec83b190 fix 2024-07-16 14:51:21 -04:00
oleg 2b2056171e progress 2024-07-16 14:37:46 -04:00
oleg 913d971663 progress 2024-07-16 12:11:37 -04:00
oleg 0f6d7874de progress 2024-06-13 19:40:49 -04:00
oleg 769d8116d5 fix 2024-06-13 18:17:13 -04:00
oleg a7ad7f45f5 fix 2024-06-13 18:13:27 -04:00
oleg 0e6190f999 progress 2024-06-13 18:11:54 -04:00
oleg 180e3f89cf fix 2024-06-13 18:03:43 -04:00
oleg 80bbf47755 progress 2024-06-13 18:00:09 -04:00
oleg e295aa8dff progress 2024-06-13 17:27:16 -04:00
oleg 60d2327b7e progress 2024-06-06 20:07:49 -04:00
oleg a0b41cad8e progress 2024-06-06 19:55:04 -04:00
oleg b62981a338 version 2024-06-06 19:45:56 -04:00
oleg 553748fdcd progress 2024-06-05 17:47:51 -04:00
oleg 5956d9d200 Merge branch 'master' of ssh://homestore.cvtt.vpn:/opt/git/cvtt2/ops 2024-06-05 16:57:00 -04:00
oleg 88308ea13e progress 2024-06-05 16:55:53 -04:00
oleg 74783ab064 progress 2024-05-18 14:49:59 -04:00
oleg c1a4e7b292 fix 2024-05-02 16:10:43 -04:00
11 changed files with 246 additions and 41 deletions
+42
View File
@@ -0,0 +1,42 @@
-------------------------------------
C R Y P T O M A R K E T D A T A
-------------------------------------
============
Exchanges
============
| Coinbase
| Binance Spot
| Binance Futures
|
v
============
Databases
============
| TimescaleDB: cloud21
| TimescaleDB: cvttdata
v
================
Daily Archive
================
| created by crontabs:
| cvttdata:
| (1) /home/cvtt/prod/utils/archive_yesterday_md.sh cloud21
| (2) /home/cvtt/prod/utils/archive_yesterday_md.sh cvttdata
| stored in:
| cvttdata:/home/cvtt/prod/archive/md_archive/crypto/cloud21 (1)
| cvttdata:/home/cvtt/prod/archive/md_archive/crypto/cvttdata (2)
|
v
==========
Storage
==========
| created by crontab cvttdata:
| /home/cvtt/prod/utils/sync_market_data.sh (ops/utls)
| stored in:
| homestore:/works/cvtt/md_archive/equity/alpaca_md
| cloud21:/opt/store/cvtt/md_archive/equity/alpaca_md
|
v
==========
Usage
==========
+33
View File
@@ -0,0 +1,33 @@
-------------------------------------
E Q U I T Y M A R K E T D A T A
-------------------------------------
=====================
Exchanges (Sources)
=====================
| Alpaca
|
|
| TBD ============
| TBD Databases
| TBD ============
| TBD | TimescaleDB: cloud21
| TBD | TimescaleDB: cvttdata
v TBD v
================
Daily Archive
================
| created by crontab on cvttdata:
| /home/cvtt/prod/run/alpaca_md.sh
| stored in:
| cvttdata:/home/cvtt/prod/archive/md_archive/equity/alpaca_md
|
v
==========
Storage
==========
| created by crontab cvttdata:
| /home/cvtt/prod/utils/sync_market_data.sh
| stored in:
| homestore:/works/cvtt/md_archive/equity/alpaca_md
| cloud21:/opt/store/cvtt/md_archive/equity/alpaca_md
____V_______
+1 -1
View File
@@ -1 +1 @@
0.7.5
0.9.4
+10 -10
View File
@@ -48,16 +48,9 @@ export PYTHONPATH=/home/cvtt/prod
export Python=/home/cvtt/.pyenv/python3.10-venv/bin/python3
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/host_drive/alpaca_md # Local
export LogDir=/home/cvtt/prod/logs/alpaca_md
# ----- T E M P
# export PYTHONPATH=/home/oleg/develop/cvtt2
# export Python=/home/oleg/.pyenv/python3.10-venv/bin/python3
# export Config=http://cloud16.cvtt.vpn:6789/apps/minimal_md
# export PyScript=/home/oleg/develop/cvtt2/cvttpy/exchanges/alpaca/hist_md/hist_md_bars.py
# export OutputDir=/home/oleg/develop/cvtt2/tmp # Local
# export LogDir=/home/oleg/develop/cvtt2/tmp
export OutputDir=/home/cvtt/prod/archive/md_archive/equity/alpaca_md # Local
export LogDir=/home/cvtt/prod/logs/alpaca_md
mkdir -p ${LogDir}
@@ -110,5 +103,12 @@ slice_size=500 # 10K symbols parallel cannot handle
for ((ii=0; ii <${#Instruments[@]}; ii+=slice_size)); do
InstSlice=("${Instruments[@]:ii:slice_size}")
echo parallel -j ${NumJobs} run_proc {} ${Start} ${End} ::: "${InstSlice[@]}"
parallel -j ${NumJobs} run_proc {} ${Start} ${End} ::: "${InstSlice[@]}"
done
echo "Compressing"
for file in $(find ${OutputDir} -type f -name '*db' -print )
do
echo "Compressing ${file}"
gzip ${file}
done
+5 -5
View File
@@ -4,14 +4,14 @@ Python=/home/cvtt/.pyenv/python3.10-venv/bin/python3.10
RootDir=/home/cvtt/prod
export PYTHONPATH=${RootDir}
host=$(hostname)
host=${1}
if [ "${host}" == "cvttdata" ]
then
ArchiveRootDir=/home/cvtt/prod/archive/md_archive
ArchiveRootDir=/home/cvtt/prod/archive/md_archive/crypto/cvttdata
CredKey=TSDB_MD_CVTTDATA_RO
elif [ "${host}" == "cloud21.cryptovaltrading.com" ]
elif [ "${host}" == "cloud21" ]
then
ArchiveRootDir=/opt/store/cvtt/archive/md_archive
ArchiveRootDir=/home/cvtt/prod/archive/md_archive/crypto/cloud21
CredKey=TSDB_MD_CLD21_RO
else
echo "Unknown host ${host}. ${0} Aborted."
@@ -21,7 +21,7 @@ fi
mkdir -p ${ArchiveRootDir}
yesterday=$(date -d "yesterday" +%Y%m%d)
Schemas=${1}
Schemas=${2}
if [ "${Schemas}" == "" ]
then
Schemas="coinbase,bnbspot,bnbfut"
+9 -4
View File
@@ -1,10 +1,11 @@
#!/bin/bash
#!/usr/bin/env bash
# ---------------- 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
default_project=cvttpy
default_branch=master
@@ -63,6 +64,13 @@ else
fi
tmp_dir=$(mktemp -d)
function cleanup {
cd ${HOME}
rm -rf ${tmp_dir}
}
trap cleanup EXIT
prj_dir="${tmp_dir}/${prj}"
cmd_arr=()
@@ -149,7 +157,4 @@ do
pwd && echo ${cmd} && eval ${cmd}
done
cd ${HOME}
rm -rf ${tmp_dir}
echo "$0 Done ${project} ${release_version}"
+57
View File
@@ -0,0 +1,57 @@
#!/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="/opt/jupyter_gpu/data/crypto_md"
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
chmod 600 ${TargetFilePath}
ls -lh ${TargetFilePath}
}
download_file
+29 -10
View File
@@ -15,7 +15,6 @@ Sender=${RootDir}/ops/utils/send_mmost.sh
Hosts=
Hosts="${Hosts} cloud11.cvtt.vpn"
Hosts="${Hosts} cloud14.cvtt.vpn"
Hosts="${Hosts} cloud15.cvtt.vpn"
Hosts="${Hosts} cloud16.cvtt.vpn"
Hosts="${Hosts} cloud17.cvtt.vpn"
@@ -23,26 +22,38 @@ Hosts="${Hosts} cloud21.cvtt.vpn"
Hosts="${Hosts} cloud22.cryptovaltrading.com"
Hosts="${Hosts} cvttdata.cvtt.vpn"
Hosts="${Hosts} cryptoval1.cvtt.vpn"
Hosts="${Hosts} cryptoval2.cvtt.vpn"
Hosts="${Hosts} cryptoval3.cvtt.vpn"
Hosts="${Hosts} homestore.cvtt.vpn"
Hosts="${Hosts} nsbackup.cvtt.vpn"
Hosts="${Hosts} nsbackup.sheynin.home"
Hosts="${Hosts} dtvmhost.cvtt.vpn"
Hosts="${Hosts} ops-server.cvtt.vpn"
Hosts="${Hosts} cvtt-prod-01.cvtt.vpn"
Hosts="${Hosts} cvtt-prod-02.cvtt.vpn"
Hosts="${Hosts} cvtt-prod-03.cvtt.vpn"
Metrics=()
TempFiles=
function cleanup {
echo Cleaing up temporary files: ${TempFiles}
if [ "" != "${TempFiles}" ]; then
rm -f ${TempFiles}
fi
}
trap cleanup EXIT
function space_alert() {
ALERT_USAGE=75%
for ln in "${Measurements[@]}"
for metric in "${Metrics[@]}"
do
IFS=$' '; args=($ln); unset IFS
IFS=$' '; args=($metric); unset IFS
host=${args[0]}
fs=${args[1]}
space_used=${args[2]}
if [ ${space_used%?} -ge ${ALERT_USAGE%?} ]; then
echo ":red_circle: Filesystem **${host}:${fs}** is using **${space_used}** :red_circle:"
fi
@@ -53,6 +64,7 @@ function storage_check() {
result_lines=()
declare -a SingleMeas
for host in ${Hosts}
do
if [[ "${host}" == *"cryptovaltrading.com" ]]; then
@@ -71,7 +83,12 @@ function storage_check() {
do
IFS=$' '; args=($ln); unset IFS
res="${args[5]}| **${host}** | ***${args[6]}*** | *${args[5]}* |"
result_lines+=("$res")
fs=${args[6]}
used=${args[5]}
Metrics+=("$host $fs $used")
done
unset IFS
done
@@ -82,7 +99,11 @@ function storage_check() {
}
tmpfile=$(mktemp)
TempFiles="${TempFiles} ${tmpfile}"
tmpfile2=$(mktemp)
TempFiles="${TempFiles} ${tmpfile2}"
storage_check > ${tmpfile2}
echo "## :card_file_box: STORAGE HEALTH CHECK" >> ${tmpfile}
@@ -91,17 +112,15 @@ echo "| host | filesystem | usage |" >> ${tmpfile}
echo "| --- | --- | --- |" >> ${tmpfile}
cat ${tmpfile2} | sort -h -r | awk -F'%' '{printf "%s%%%s\n",$2,$3}' >> ${tmpfile}
cat ${tmpfile} | ${Sender} ${StatusChannel}
rm ${tmpfile} ${tmpfile2}
Measurements=()
tmpfile=$(mktemp)
TempFiles="${TempFiles} ${tmpfile}"
space_alert > ${tmpfile}
cat ${tmpfile}
if [ -s ${tmpfile} ]
then
(echo "### :card_file_box: STORAGE ALERTS" && cat ${tmpfile}) | ${Sender} ${AlertChannel}
else
echo File ${tmpfile} is empty
echo "No Storage Alerts"
fi
rm ${tmpfile}
+33
View File
@@ -0,0 +1,33 @@
#!/bin/bash
# Collect all "A" files
letter=${1}
if [ "${letter}" == "" ]; then
echo "Usage $0 <letter>"
exit 1
fi
# copy text data to local location
rsync -ahv /home/cvtt/host_drive/eqt_hist_md/txt/${letter} /home/cvtt/tmp/txt/
# create db files
PYTHONPATH=/home/cvtt/prod /home/cvtt/.pyenv/python3.10-venv/bin/python3 /home/cvtt/prod/cvttpy/trading/mkt_data/ad_hoc/eqt_md_to_db.py /home/cvtt/tmp/txt/${letter} /home/cvtt/tmp/db
if [ "$?" != "0" ] ; then
exit
fi
# Move all files to host drive
# a) create file list
(cd /home/cvtt/tmp/db/ && find . -name '*db' -print | grep "/${letter}/") > /home/cvtt/tmp/tran_db/${letter}_files
echo ${letter} is done
exit
# b) rsync files to host drive
rsync -ahv --remove-source-files --files-from=/home/cvtt/tmp/tran_db/${letter}_files /home/cvtt/tmp/db/ cvtt@my-vm-host:/localdisk/cvtt/eqt_hist_md/db/
# Clean directories
( cd /home/cvtt/tmp/db && (for d in $(find . -name $letter -type d -print); do echo $d ; done) | grep -v /$letter/$letter | xargs rm -rf) && rm -rf /home/cvtt/tmp/txt/${letter}
+13 -11
View File
@@ -1,5 +1,17 @@
#!/bin/bash
# ----- Settings
LocalSoftwareDir=${HOME}/software/cvtt2
ProdDir=${HOME}/prod
ReleaseHosts=("cloud21.cvtt.vpn")
ReleasePorts=("22")
ReleaseUsers=("cvttdist")
ReleaseDir=("/home/cvttdist/software/cvtt2")
# ----- Settings
function usage() {
echo "Usage: ${0} <project> <version>"
exit 1
@@ -18,17 +30,6 @@ then
Version=latest
fi
# ----- Settings
LocalSoftwareDir=${HOME}/software/cvtt2
ProdDir=${HOME}/prod
ReleaseHosts=("cloud21.cvtt.vpn")
ReleasePorts=("22")
ReleaseUsers=("cvttdist")
ReleaseDir=("/home/cvttdist/software/cvtt2")
# ----- Settings
function rsync_load_version() {
for idx in "${!ReleaseHosts[@]}"
do
@@ -68,6 +69,7 @@ function rsync_load_version() {
}
mkdir -p ${LocalSoftwareDir}
mkdir -p ${ProdDir}
# exists and not empty
rsync_load_version
+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