Compare commits

...

79 Commits

Author SHA1 Message Date
oleg b24a1217e8 fix 2024-07-29 20:30:37 -04:00
oleg 362a2bf61d progress 2024-07-29 20:28:30 -04:00
oleg e0a0d6d9d6 monor fix 2024-07-28 19:43:49 -04:00
oleg 20a375cd55 progress 2024-07-28 19:40:22 -04:00
oleg 35466a1932 fix 2024-07-28 13:50:41 -04:00
oleg 26afead109 fix 2024-07-27 21:54:47 -04:00
oleg 32935143da progress 2024-07-27 18:31:37 -04:00
oleg 4e2df290db version 2024-07-27 18:22:34 -04:00
oleg d0ee8fea09 progress 2024-07-27 18:20:56 -04:00
oleg cd4663d775 fix 2024-07-26 13:46:15 -04:00
oleg b353572ea6 progress 2024-07-25 12:42:43 -04:00
oleg fa6dd0fa95 fix 2024-07-25 10:22:51 -04:00
oleg ce68165eef fix 2024-07-24 19:57:30 -04:00
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
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
oleg f9ac5503eb progress 2024-04-25 15:37:53 -04:00
oleg 5cc53f8cd8 progress 2024-04-24 18:10:34 -04:00
oleg fce17db6ec progress 2024-04-10 12:48:20 -04:00
oleg ed43a900a2 progress 2024-04-09 09:41:37 -04:00
oleg 9de86bf3e3 progress 2024-03-28 09:53:52 -04:00
oleg 4873af1673 fix 2024-03-26 12:07:54 -04:00
oleg c2dae20d7b improvements to alpaca md 2024-03-26 11:30:41 -04:00
oleg 8607db6506 fix 2024-03-25 20:42:35 -04:00
oleg 465d4c746e progress 2024-03-25 18:04:49 -04:00
oleg 70c7769fd6 fix and progress 2024-03-24 16:40:20 -04:00
oleg 2416ca4b0d progress 2024-03-24 16:16:10 -04:00
oleg 41d18e0e7f removed config 2024-03-06 18:18:14 -05:00
oleg e93e1f676f progress 2024-03-02 22:02:09 -05:00
oleg 46eead797f progress 2024-03-02 21:47:22 -05:00
oleg a6a37edec3 progress 2024-03-02 14:43:48 -05:00
oleg 0908f5f10f fix 2024-03-02 14:27:11 -05:00
oleg ad4f8e1328 version 2024-03-02 14:26:47 -05:00
oleg f14a5c1637 progress 2024-03-02 14:25:39 -05:00
oleg 0afb8e2db4 progress 2024-03-02 13:33:28 -05:00
oleg d93b46ef48 fix 2024-02-28 21:13:38 -05:00
oleg 7f449ce08c Merge branch 'master' of cloud21.cvtt.vpn:/opt/store/git/ops 2024-02-28 19:20:16 -05:00
oleg ec4b1623f8 progress: send_mattermost channels with space 2024-02-28 19:19:16 -05:00
oleg 69a3cd2ecb progress 2024-02-25 21:30:59 -05:00
oleg d7cf5fd7eb progress 2024-02-11 17:12:42 -05:00
oleg a58f15d9d9 version 2024-02-10 21:29:49 -05:00
oleg 81a1db39e3 fix move_archives 2024-02-10 21:29:19 -05:00
oleg bcc5b0562c getting rid of Servarica 2024-02-03 21:21:18 -05:00
34 changed files with 1042 additions and 221 deletions
-47
View File
@@ -1,47 +0,0 @@
[supervisord]
environment=PYTHONPATH="/home/cvtt/prod"
autostart=true
autorestart=unexpected
startretries=3
logfile=/home/cvtt/prod/logs/supervisord.log
[supervisorctl]
[inet_http_server]
port = 127.0.0.1:9001
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[program:bnbfut_rec_cv1]
directory=/home/cvtt/prod
command=/home/cvtt/.pyenv/python3.10-venv/bin/python3 -u /home/cvtt/prod/cvttpy/apps/md/md_recorder.py
--config=http://cloud16.cvtt.vpn:6789/apps/md_recorder
--active_exchanges=BNBFUT
--instruments=PERP-BTC-USDT,PERP-ETH-USDT
--db_credentials_key=TSDB_MD_CV1
--admin_port=7226
--log_level=INFO
--log_file=/home/cvtt/prod/logs/%%T.MD_REC.BNBFUT.CV1.log
autostart=true
autorestart=true
startretries=1
startsecs=3
user=cvtt
[program:coinbase_rec_cv1]
directory=/home/cvtt/prod
command=/home/cvtt/.pyenv/python3.10-venv/bin/python3 -u /home/cvtt/prod/cvttpy/apps/md/md_recorder.py
--config=http://cloud16.cvtt.vpn:6789/apps/md_recorder
--active_exchanges=COINBASE_AT
--instruments=PAIR-BTC-USD,PAIR-ETH-USD,PAIR-LTC-USD,PAIR-XRP-USD
--db_credentials_key=TSDB_MD_CV1
--admin_port=7224
--log_level=INFO
--log_file=/home/cvtt/prod/logs/%%T.MD_REC.COINBASE.CV1.log
autostart=true
autorestart=true
startretries=1
startsecs=3
user=cvtt
-28
View File
@@ -1,28 +0,0 @@
[supervisord]
environment=PYTHONPATH="/home/cvtt/prod"
autostart=true
autorestart=unexpected
startretries=3
logfile=/home/cvtt/prod/logs/supervisord.log
[supervisorctl]
[inet_http_server]
port = 127.0.0.1:9001
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[program:config_service]
directory=/home/cvtt/prod
command=/home/cvtt/.pyenv/python3.10-venv/bin/python3.10
-u /home/cvtt/prod/cvttpy/apps/utils/config_server.py
--port=6789
--root=/home/cvtt/prod/config_service/data
--log_file=/home/cvtt/prod/logs/%%T.CONFIG_SERVICE.log
autostart=true
autorestart=true
startretries=1
startsecs=3
user=cvtt
-99
View File
@@ -1,99 +0,0 @@
[supervisord]
environment=PYTHONPATH="/home/cvtt/prod"
autostart=true
autorestart=unexpected
startretries=3
logfile=/home/cvtt/prod/logs/supervisord.log
[supervisorctl]
[inet_http_server]
port = 127.0.0.1:9001
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
# [program:executor]
# directory=/home/cvtt/prod
# command=/home/cvtt/.pyenv/python3.10-venv/bin/python3
# -u /home/cvtt/prod/cvttpy/apps/executor_app.py
# --config=http://cloud16.cvtt.vpn:6789/apps/cvtt
# --active_exchanges=COINBASE_AT
# --admin_port=7220
# --log_level=INFO
# --log_file=/home/cvtt/prod/logs/%%T.EXECUTOR_APP.log
# autostart=true
# autorestart=true
# startretries=1
# startsecs=3
# user=cvtt
#[group:bnbspot_mdrec]
#programs=
# bnbspot_rec_cloud17,
# bnbspot_rec_cv1
[program:bnbfut_rec_cld19]
directory=/home/cvtt/prod
command=/home/cvtt/.pyenv/python3.10-venv/bin/python3 -u /home/cvtt/prod/cvttpy/apps/md/md_recorder.py
--config=http://cloud16.cvtt.vpn:6789/apps/md_recorder
--active_exchanges=BNBFUT
--instruments=PERP-BTC-USDT,PERP-ETH-USDT
--db_credentials_key=TSDB_MD_CLD19
--admin_port=7201
--log_level=INFO
--log_file=/home/cvtt/prod/logs/%%T.MD_REC.BNBFUT.CLD19.log
autostart=true
autorestart=true
startretries=1
startsecs=3
user=cvtt
[program:coinbase_rec_cld19]
directory=/home/cvtt/prod
command=/home/cvtt/.pyenv/python3.10-venv/bin/python3 -u /home/cvtt/prod/cvttpy/apps/md/md_recorder.py
--config=http://cloud16.cvtt.vpn:6789/apps/md_recorder
--active_exchanges=COINBASE_AT
--instruments=PAIR-BTC-USD,PAIR-ETH-USD,PAIR-LTC-USD,PAIR-XRP-USD
--db_credentials_key=TSDB_MD_CLD19
--admin_port=7202
--log_level=INFO
--log_file=/home/cvtt/prod/logs/%%T.MD_REC.COINBASE.CLD19.log
autostart=true
autorestart=true
startretries=1
startsecs=3
user=cvtt
[program:bnbspot_rec_cld19]
directory=/home/cvtt/prod
command=/home/cvtt/.pyenv/python3.10-venv/bin/python3 -u /home/cvtt/prod/cvttpy/apps/md/md_recorder.py
--config=http://cloud16.cvtt.vpn:6789/apps/md_recorder
--active_exchanges=BNBSPOT
--instruments=PAIR-BTC-USDT,PAIR-ETH-USDT,PAIR-LTC-USDT,PAIR-XRP-USDT,PAIR-USDT-USD
--db_credentials_key=TSDB_MD_CLD19
--admin_port=7203
--log_level=INFO
--log_file=/home/cvtt/prod/logs/%%T.MD_REC.BNBSPOT.CLD19.log
autostart=true
autorestart=true
startretries=1
startsecs=3
user=cvtt
[program:bnbspot_rec_cvttdata]
directory=/home/cvtt/prod
command=/home/cvtt/.pyenv/python3.10-venv/bin/python3 -u /home/cvtt/prod/cvttpy/apps/md/md_recorder.py
--config=http://cloud16.cvtt.vpn:6789/apps/md_recorder
--active_exchanges=BNBSPOT
--instruments=PAIR-BTC-USDT,PAIR-ETH-USDT,PAIR-LTC-USDT,PAIR-XRP-USDT,PAIR-USDT-USD
--db_credentials_key=TSDB_MD_CVTTDATA
--admin_port=7222
--log_level=INFO
--log_file=/home/cvtt/prod/logs/%%T.MD_REC.BNBSPOT.CVTTDATA.log
autostart=true
autorestart=true
startretries=1
startsecs=3
user=cvtt
+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_______
+124
View File
@@ -0,0 +1,124 @@
#!/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
}
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
if [ -z ${date_to_load} ] ; then
echo "Yesterday data has priority. Running historical container will be stopped"
Cmd="docker stop ${ContainerName}"
echo ${Cmd} && eval ${Cmd}
Cmd="docker kill ${ContainerName}"
echo ${Cmd} && eval ${Cmd}
Cmd="docker rm -f ${ContainerName}"
echo ${Cmd} && eval ${Cmd}
Cmd="docker ps"
echo ${Cmd} && eval ${Cmd}
if is_container_running "$ContainerName"; then
echo "Container ${ContainerName} is still running."
exit 3
fi
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
fi
if [ -n "${date_to_load}" ]; then
date_to_load=$(get_prev_business_day ${date_to_load})
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
+14
View File
@@ -0,0 +1,14 @@
#!/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}
+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
+40
View File
@@ -0,0 +1,40 @@
#!/bin/bash
ValidJobs=('BNBFUT_CLD21' 'BNBSPOT_CLD21' 'COINBASE_CLD21' 'BNBFUT_CVTTDATA' 'BNBSPOT_CVTTDATA' 'COINBASE_CVTTDATA')
# runs on host to start container
usage() {
echo "Usage: $0 <job_name; one of (${ValidJobs[@]})>"
exit 1
}
is_valid() {
local job=$1
for valid_job in "${ValidJobs[@]}";
do
# echo "job=$job valid_job=$valid_job"
if [[ "${job}" == "${valid_job}" ]]; then
return 0
fi
done
return 1
}
job=${1}
if ! is_valid "${job}"; then
usage
fi
Cmd="docker run"
Cmd="${Cmd} -d"
Cmd="${Cmd} --rm"
Cmd="${Cmd} --network=host"
Cmd="${Cmd} --pull=always"
Cmd="${Cmd} --name=md_recorder.${job}"
Cmd="${Cmd} -v /home/cvtt/prod/data:/app/data"
Cmd="${Cmd} -v /home/cvtt/prod/logs:/logs"
Cmd="${Cmd} cloud21.cvtt.vpn:5500/md_recorder:latest"
Cmd="${Cmd} ${job}"
echo ${Cmd}
eval ${Cmd}
+44
View File
@@ -0,0 +1,44 @@
#!/bin/bash
usage() {
echo "Usage: $0 <instance (CLD21,CVTTDATA)> [<admin_port (def. 7225)>]"
exit 1
}
ValidInstances=('CLD21' 'CVTTDATA')
is_valid() {
local inst=$1
for valid_inst in "${ValidInstances[@]}";
do
if [[ "$inst" == "$valid_inst" ]]; then
return 0
fi
done
return 1
}
Instance=${1}
if ! is_valid "${Instance}"; then
usage
fi
AdminPort=7225
if [ "${2}" != "" ]; then
AdminPort=${2}
fi
Cmd="docker run"
Cmd="${Cmd} -d"
Cmd="${Cmd} --rm"
Cmd="${Cmd} --network=host"
Cmd="${Cmd} --pull=always"
Cmd="${Cmd} --name=md_recorder_monitor.${job}"
Cmd="${Cmd} -p ${AdminPort}:${AdminPort}"
Cmd="${Cmd} -v /home/cvtt/prod/logs:/logs"
Cmd="${Cmd} cloud21.cvtt.vpn:5500/md_recorder:latest"
Cmd="${Cmd} ${Instance} ${AdminPort}"
echo ${Cmd}
eval ${Cmd}
+14
View File
@@ -0,0 +1,14 @@
#!/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}
+12
View File
@@ -0,0 +1,12 @@
#!/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}
+1 -1
View File
@@ -1 +1 @@
0.5.2 1.2.1
+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
+28
View File
@@ -0,0 +1,28 @@
#!/bin/bash
CredsFile=${1}
CredKey=${2}
if [ "${CredsFile}" == "" ] ; then
CredsFile="${HOME}/.creds"
fi
if [ "${CredKey}" == "" ] ; then
CredKey="ALPACA_SANDBOX"
fi
key=$(jq -r ".[\"${CredKey}\"] | .api_key" ${CredsFile})
secret=$(jq -r ".[\"${CredKey}\"] | .secret_key" ${CredsFile})
Cmd="curl -s --request GET --url 'https://paper-api.alpaca.markets/v2/assets?status=active'"
Cmd="${Cmd} --header 'APCA-API-KEY-ID: ${key}'"
Cmd="${Cmd} --header 'APCA-API-SECRET-KEY: ${secret}'"
Cmd="${Cmd} --header 'accept: application/json'"
eval ${Cmd}
# split string into array
Instruments=()
for Inst in $(eval ${Cmd})
do
Instruments+=("$Inst")
done
+114
View File
@@ -0,0 +1,114 @@
#!/bin/bash
Start=${1}
NumJobs=${2}
InstListFile=${3}
export CalendarURL=http://cloud16.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
if [ "${Start}" == "" ] ; then
Start=$(date -d "yesterday" "+%Y-%m-%d")
fi
if ! is_business_day ${Start}; then
echo "${Start} is not business day in US"
exit
fi
End=$(date -d "${Start} + 1 day" "+%Y-%m-%d")
# Exclude today
if [ "${End}" == $(date '+%Y-%m-%d') ] ; then
End=$(date -d 'yesterday' ''+%Y-%m-%d'')
fi
if [ "${NumJobs}" == "" ] ; then
NumJobs=30
fi
echo "Start=${Start} End=${End} NumJobs=${NumJobs}"
# export PyScript=/home/cvtt/prod/cvttpy/exchanges/alpaca/hist_mkt_data.py
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/prod/archive/md_archive/equity/alpaca_md # Local
export LogDir=/home/cvtt/prod/logs/alpaca_md
mkdir -p ${LogDir}
run_proc() {
Inst=${1}
Start=${2}
End=${3}
echo "Running for $Inst"
Cmd="${Python} ${PyScript}"
Cmd="${Cmd} --config=${Config}"
Cmd="${Cmd} --output_dir=${OutputDir}/${Start:0:4}"
Cmd="${Cmd} --instruments=ALPACA:${Inst}"
Cmd="${Cmd} --start=${Start}"
if [ "${End}" != "" ]; then
Cmd="${Cmd} --end=${End}"
fi
Cmd="${Cmd} --log_file=${LogDir}/${Inst}.log"
Cmd="${Cmd} --log_level=WARNING"
echo ${Cmd}
eval ${Cmd}
}
export -f run_proc
if [ "$InstListFile" == "" ]; then
key=$(jq -r '.["ALPACA_SANDBOX"] | .api_key' ~/.creds)
secret=$(jq -r '.["ALPACA_SANDBOX"] | .secret_key' ~/.creds)
Cmd="curl -s --request GET --url 'https://paper-api.alpaca.markets/v2/assets?status=active'"
Cmd="${Cmd} --header 'APCA-API-KEY-ID: ${key}'"
Cmd="${Cmd} --header 'APCA-API-SECRET-KEY: ${secret}'"
Cmd="${Cmd} --header 'accept: application/json'"
Cmd="${Cmd} | jq '.[] | select(.class == \"us_equity\" and .exchange != \"OTC\") | .symbol'"
Cmd="${Cmd} | sed 's/\"//g'"
Cmd="${Cmd} | sed 's/^/STOCK-/'"
else
Cmd="cat ${InstListFile}"
fi
# split string into array
Instruments=()
for Inst in $(eval ${Cmd})
do
Instruments+=("$Inst")
done
slice_size=500 # 10K symbols parallel cannot handle
for ((ii=0; ii <${#Instruments[@]}; ii+=slice_size)); do
InstSlice=("${Instruments[@]:ii:slice_size}")
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
+18
View File
@@ -0,0 +1,18 @@
#!/bin/bash
export PYTHONPATH=${HOME}/prod
Python=${HOME}/.pyenv/python3.10-venv/bin/python3
Script=${HOME}/prod/cvttpy/exchanges/alpaca/hist_md/rl_calc_loader.py
DbFile=${HOME}/prod/data/rel_liquidity.db
Config=http://cloud23.cvtt.vpn:6789/apps/minimal_md_eqt
Cmd="${Python}"
Cmd="${Cmd} ${Script}"
Cmd="${Cmd} --config=${Config}"
Cmd="${Cmd} --db_file=${DbFile}"
echo ${Cmd}
eval ${Cmd}
echo Done ${0} ${*}
+50
View File
@@ -0,0 +1,50 @@
#!/bin/bash
is_business_day() {
dt=${1}
CalendarURL=http://cloud16.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
else
return 1
fi
}
export -f is_business_day
# Dates are in descending order
FinishedDateFile=${HOME}/prod/run/alpaca_md_last_date
Script=${HOME}/prod/run/alpaca_md.sh
last_date=$(cat ${FinishedDateFile})
if [ "${last_date}" == "" ]; then
echo "process is currently on"
exit
fi
while true; do
new_date=$(date -d "${last_date} - 1 day" "+%Y-%m-%d")
if is_business_day ${new_date}; then
break
else
last_date=${new_date}
fi
done
echo Collecting data for ${new_date}
Cmd="${Script} ${new_date}"
echo "${0} Starting at $(date)"
echo > ${FinishedDateFile}
echo ${Cmd} && eval ${Cmd}
echo $new_date > ${FinishedDateFile}
echo "${0} Done at $(date)"
+5 -5
View File
@@ -4,14 +4,14 @@ Python=/home/cvtt/.pyenv/python3.10-venv/bin/python3.10
RootDir=/home/cvtt/prod RootDir=/home/cvtt/prod
export PYTHONPATH=${RootDir} export PYTHONPATH=${RootDir}
host=$(hostname) host=${1}
if [ "${host}" == "cvttdata" ] if [ "${host}" == "cvttdata" ]
then then
ArchiveRootDir=/home/cvtt/prod/archive/md_archive ArchiveRootDir=/home/cvtt/prod/archive/md_archive/crypto/cvttdata
CredKey=TSDB_MD_CVTTDATA_RO CredKey=TSDB_MD_CVTTDATA_RO
elif [ "${host}" == "cloud21.cryptovaltrading.com" ] elif [ "${host}" == "cloud21" ]
then then
ArchiveRootDir=/opt/store/cvtt/archive/md_archive ArchiveRootDir=/home/cvtt/prod/archive/md_archive/crypto/cloud21
CredKey=TSDB_MD_CLD21_RO CredKey=TSDB_MD_CLD21_RO
else else
echo "Unknown host ${host}. ${0} Aborted." echo "Unknown host ${host}. ${0} Aborted."
@@ -21,7 +21,7 @@ fi
mkdir -p ${ArchiveRootDir} mkdir -p ${ArchiveRootDir}
yesterday=$(date -d "yesterday" +%Y%m%d) yesterday=$(date -d "yesterday" +%Y%m%d)
Schemas=${1} Schemas=${2}
if [ "${Schemas}" == "" ] if [ "${Schemas}" == "" ]
then then
Schemas="coinbase,bnbspot,bnbfut" Schemas="coinbase,bnbspot,bnbfut"
+181
View File
@@ -0,0 +1,181 @@
#!/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
dist_root=/home/cvttdist/software/cvtt2
dist_user=cvttdist
dist_host="cloud21.cvtt.vpn"
dist_ssh_port="22"
dist_locations="cloud21.cvtt.vpn:22 homestore.cvtt.vpn:22"
# ---------------- Settings
# ---------------- cmdline
prj=
brnch=master
interactive=N
usage() {
echo "Usage: $0 -p <project> [-b <branch (master)> -i (interactive)"
exit 1
}
while getopts ":p:b:i" opt; do
case ${opt} in
p )
prj=$OPTARG
;;
b )
brnch=$OPTARG
;;
i )
interactive=Y
;;
\? )
echo "Invalid option: -$OPTARG" >&2
usage
;;
: )
echo "Option -$OPTARG requires an argument." >&2
usage
;;
esac
done
# ---------------- cmdline
function confirm {
if [ "${interactive}" == "Y" ]; then
echo "--------------------------------"
echo -n "Press <Enter> to continue" && read
fi
}
if [ "${interactive}" == "Y" ]; then
echo -n "Enter project [${prj}]: "
read project
if [ "${project}" == "" ]
then
project=${prj}
fi
else
project=${prj}
fi
repo=${git_repo_arr[${project}]}
if [ -z ${repo} ]; then
echo "ERROR: Project repository for ${project} not found"
exit -1
fi
echo "Project repo: ${repo}"
if [ "${interactive}" == "Y" ]; then
echo -n "Enter branch to build release from [${brnch}]: "
read branch
if [ "${branch}" == "" ]
then
branch=${brnch}
fi
else
branch=${brnch}
fi
tmp_dir=$(mktemp -d)
function cleanup {
cd ${HOME}
rm -rf ${tmp_dir}
}
trap cleanup EXIT
prj_dir="${tmp_dir}/${prj}"
cmd_arr=()
Cmd="git clone ${repo} ${prj_dir}"
cmd_arr+=("${Cmd}")
Cmd="cd ${prj_dir}"
cmd_arr+=("${Cmd}")
if [ "${interactive}" == "Y" ]; then
echo "------------------------------------"
echo "The following commands will execute:"
echo "------------------------------------"
for cmd in "${cmd_arr[@]}"
do
echo ${cmd}
done
fi
confirm
for cmd in "${cmd_arr[@]}"
do
echo ${cmd} && eval ${cmd}
done
Cmd="git checkout ${branch}"
echo ${Cmd} && eval ${Cmd}
if [ "${?}" != "0" ]; then
echo "ERROR: Branch ${branch} is not found"
cd ${HOME} && rm -rf ${tmp_dir}
exit -1
fi
release_version=$(cat release_version.txt)
echo "--------------------------------"
echo "Release version: ${release_version}"
confirm
version_tag="v${release_version}"
version_comment="${version_tag}_${project}_${branch}_$(date +%Y%m%d)"
cmd_arr=()
Cmd="git tag -a ${version_tag} -m ${version_comment}"
cmd_arr+=("${Cmd}")
Cmd="git push origin --tags"
cmd_arr+=("${Cmd}")
Cmd="rm -rf .git"
cmd_arr+=("${Cmd}")
dist_path="${dist_root}/${project}/${release_version}"
for dist_loc in ${dist_locations}; do
dhp=(${dist_loc//:/ })
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_arr+=("${Cmd}")
done
if [ "${interactive}" == "Y" ]; then
echo "------------------------------------"
echo "The following commands will execute:"
echo "------------------------------------"
for cmd in "${cmd_arr[@]}"
do
echo ${cmd}
done
fi
confirm
for cmd in "${cmd_arr[@]}"
do
pwd && echo ${cmd} && eval ${cmd}
done
echo "$0 Done ${project} ${release_version}"
+14
View File
@@ -0,0 +1,14 @@
#!/bin/bash
export PYTHONPATH=/home/cvtt/prod
Cmd="/home/cvtt/.pyenv/python3.10-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} --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"
Cmd="${Cmd} --log_file=/home/cvtt/prod/logs/%%T.EXCHANGE_TRADING_STATS.log"
echo ${Cmd}
eval ${Cmd}
+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
+40 -13
View File
@@ -15,31 +15,45 @@ Sender=${RootDir}/ops/utils/send_mmost.sh
Hosts= Hosts=
Hosts="${Hosts} cloud11.cvtt.vpn" Hosts="${Hosts} cloud11.cvtt.vpn"
Hosts="${Hosts} cloud14.cvtt.vpn"
Hosts="${Hosts} cloud15.cvtt.vpn" Hosts="${Hosts} cloud15.cvtt.vpn"
Hosts="${Hosts} cloud16.cvtt.vpn" Hosts="${Hosts} cloud16.cvtt.vpn"
Hosts="${Hosts} cloud17.cvtt.vpn" Hosts="${Hosts} cloud17.cvtt.vpn"
Hosts="${Hosts} cloud19.cvtt.vpn" Hosts="${Hosts} cloud21.cvtt.vpn"
Hosts="${Hosts} cloudstore.cvtt.vpn" Hosts="${Hosts} cloud22.cryptovaltrading.com"
Hosts="${Hosts} cvttdata.cvtt.vpn" Hosts="${Hosts} cvttdata.cvtt.vpn"
Hosts="${Hosts} cryptoval1.cvtt.vpn"
Hosts="${Hosts} cryptoval2.cvtt.vpn" Hosts="${Hosts} cryptoval2.cvtt.vpn"
Hosts="${Hosts} cryptoval3.cvtt.vpn" Hosts="${Hosts} cryptoval3.cvtt.vpn"
Hosts="${Hosts} homestore.cvtt.vpn" Hosts="${Hosts} homestore.cvtt.vpn"
Hosts="${Hosts} nsbackup.cvtt.vpn" Hosts="${Hosts} nsbackup.sheynin.home"
Hosts="${Hosts} dtvmhost.cvtt.vpn" Hosts="${Hosts} dtvmhost.cvtt.vpn"
Hosts="${Hosts} ops-server.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() { function space_alert() {
ALERT_USAGE=75% ALERT_USAGE=75%
for ln in "${Measurements[@]}" for metric in "${Metrics[@]}"
do do
IFS=$' '; args=($ln); unset IFS IFS=$' '; args=($metric); unset IFS
host=${args[0]} host=${args[0]}
fs=${args[1]} fs=${args[1]}
space_used=${args[2]} space_used=${args[2]}
if [ ${space_used%?} -ge ${ALERT_USAGE%?} ]; then if [ ${space_used%?} -ge ${ALERT_USAGE%?} ]; then
echo ":red_circle: Filesystem **${host}:${fs}** is using **${space_used}** :red_circle:" echo ":red_circle: Filesystem **${host}:${fs}** is using **${space_used}** :red_circle:"
fi fi
@@ -50,9 +64,15 @@ function storage_check() {
result_lines=() result_lines=()
declare -a SingleMeas
for host in ${Hosts} for host in ${Hosts}
do do
Cmd="ssh $host" if [[ "${host}" == *"cryptovaltrading.com" ]]; then
port=7822
else
port=22
fi
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} | grep -v tmpfs"
@@ -63,7 +83,12 @@ function storage_check() {
do do
IFS=$' '; args=($ln); unset IFS IFS=$' '; args=($ln); unset IFS
res="${args[5]}| **${host}** | ***${args[6]}*** | *${args[5]}* |" res="${args[5]}| **${host}** | ***${args[6]}*** | *${args[5]}* |"
result_lines+=("$res") result_lines+=("$res")
fs=${args[6]}
used=${args[5]}
Metrics+=("$host $fs $used")
done done
unset IFS unset IFS
done done
@@ -74,7 +99,11 @@ function storage_check() {
} }
tmpfile=$(mktemp) tmpfile=$(mktemp)
TempFiles="${TempFiles} ${tmpfile}"
tmpfile2=$(mktemp) tmpfile2=$(mktemp)
TempFiles="${TempFiles} ${tmpfile2}"
storage_check > ${tmpfile2} storage_check > ${tmpfile2}
echo "## :card_file_box: STORAGE HEALTH CHECK" >> ${tmpfile} echo "## :card_file_box: STORAGE HEALTH CHECK" >> ${tmpfile}
@@ -83,17 +112,15 @@ echo "| host | filesystem | usage |" >> ${tmpfile}
echo "| --- | --- | --- |" >> ${tmpfile} echo "| --- | --- | --- |" >> ${tmpfile}
cat ${tmpfile2} | sort -h -r | awk -F'%' '{printf "%s%%%s\n",$2,$3}' >> ${tmpfile} cat ${tmpfile2} | sort -h -r | awk -F'%' '{printf "%s%%%s\n",$2,$3}' >> ${tmpfile}
cat ${tmpfile} | ${Sender} ${StatusChannel} cat ${tmpfile} | ${Sender} ${StatusChannel}
rm ${tmpfile} ${tmpfile2}
Measurements=()
tmpfile=$(mktemp) tmpfile=$(mktemp)
TempFiles="${TempFiles} ${tmpfile}"
space_alert > ${tmpfile} space_alert > ${tmpfile}
cat ${tmpfile}
if [ -s ${tmpfile} ] if [ -s ${tmpfile} ]
then then
(echo "### :card_file_box: STORAGE ALERTS" && cat ${tmpfile}) | ${Sender} ${AlertChannel} (echo "### :card_file_box: STORAGE ALERTS" && cat ${tmpfile}) | ${Sender} ${AlertChannel}
else else
echo File ${tmpfile} is empty echo "No Storage Alerts"
fi 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}
@@ -1,32 +1,34 @@
#!/bin/bash #!/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() { function usage() {
echo "Usage: ${0} <version>" echo "Usage: ${0} <project> <version>"
exit 1 exit 1
} }
Version=${1} Project=${1}
Version=${2}
if [ "${Version}" == "" ] if [ "${Project}" == "" ]
then then
usage usage
fi fi
Project=ops if [ "${Version}" == "" ]
# ----- Settings then
LocalSoftwareDir=/opt/software/cvtt2 Version=latest
fi
ProdDir=${HOME}/prod
Location="${LocalSoftwareDir}/${Project}/${Version}/${Project}"
ReleaseHosts=("cryptovaltrading.com" "cryptoval1.sheynin.home" "cloudstore.cvtt.vpn")
ReleasePorts=("1588" "22" "22")
ReleaseUsers=("cryptova" "cvtt" "cvtt")
ReleaseDir=("/home/cryptova/opt/software/cvtt2" "/opt/software/cvtt2" "/opt/software/cvtt2")
# ----- Settings
function rsync_load_version() { function rsync_load_version() {
for idx in "${!ReleaseHosts[@]}" for idx in "${!ReleaseHosts[@]}"
@@ -36,6 +38,11 @@ function rsync_load_version() {
user=${ReleaseUsers[${idx}]} user=${ReleaseUsers[${idx}]}
rel_dir=${ReleaseDir[${idx}]} rel_dir=${ReleaseDir[${idx}]}
if [ "${Version}" == "latest" ]; then
echo "Checking for latest version of ${Project} on ${user}@${host}:${rel_dir}"
Version=$(ssh -q -p ${port} ${user}@${host} "ls -tr ${rel_dir}/${Project} | tail -1" )
echo "Latest version is ${Version}"
fi
echo "Checking ${user}@${host} for ${rel_dir}/${Project}/${Version} ..." echo "Checking ${user}@${host} for ${rel_dir}/${Project}/${Version} ..."
if ssh -q -p ${port} ${user}@${host} "test -d ${rel_dir}/${Project}/${Version}" if ssh -q -p ${port} ${user}@${host} "test -d ${rel_dir}/${Project}/${Version}"
then then
@@ -61,18 +68,18 @@ function rsync_load_version() {
fi fi
} }
mkdir -p ${LocalSoftwareDir}
mkdir -p ${ProdDir}
# exists and not empty # exists and not empty
if [[ ! -d "${Location}" ]] ; then rsync_load_version
rsync_load_version
fi Location="${LocalSoftwareDir}/${Project}/${Version}/${Project}"
Cmd="cd ${ProdDir}" Cmd="cd ${ProdDir}"
Cmd="${Cmd} && rm -rf ${Project}" Cmd="${Cmd} && rm -rf ${Project}"
Cmd="${Cmd} && ln -snf ${Location} ${Project}" Cmd="${Cmd} && ln -snf ${Location} ${Project}"
echo ${Cmd} echo ${Cmd} && eval ${Cmd}
eval ${Cmd}
echo "Done: $0 $*" echo "Done: $0 $*"
+1 -1
View File
@@ -26,7 +26,7 @@ Oldest=$(date -d "${DateCriteria}" '+%Y-%m-%d')
echo "Looking for log files older than ${DateCriteria} in ${LogDir}" echo "Looking for log files older than ${DateCriteria} in ${LogDir}"
LogArchiveDir=/home/cvtt/prod/archive/logs LogArchiveDir=${HOME}/prod/archive/logs
mkdir -p ${LogArchiveDir} mkdir -p ${LogArchiveDir}
echo "find ${LogDir}/ '(' -name '*.log' -o -name '*.log.*' ')' -type f -not -newermt ${Oldest})" echo "find ${LogDir}/ '(' -name '*.log' -o -name '*.log.*' ')' -type f -not -newermt ${Oldest})"
+4 -3
View File
@@ -30,7 +30,8 @@ fi
DateCriteria="${Days} days ago" DateCriteria="${Days} days ago"
TargeHost=cloudstore.cvtt.vpn TargetHost=cloud21.cvtt.vpn
TargetRootDir=/opt/store/cvtt/archive
Oldest=$(date -d "${DateCriteria}" '+%Y-%m-%d') Oldest=$(date -d "${DateCriteria}" '+%Y-%m-%d')
Now=$(date '+%Y%m%d_%H%M%S') Now=$(date '+%Y%m%d_%H%M%S')
@@ -53,7 +54,7 @@ if [ "$files" == "" ]
then then
echo "No files found older than ${Oldest} in ${ArchiveDir}" echo "No files found older than ${Oldest} in ${ArchiveDir}"
else else
Target="${TargetHost}:/home/cvtt/Archive/${FromHost}/" Target="${TargetHost}:${TargetRootDir}/${FromHost}/"
echo "Moving files to ${Target}:" echo "Moving files to ${Target}:"
echo ----------------- echo -----------------
for f in ${files} for f in ${files}
@@ -66,7 +67,7 @@ else
Cmd="${Cmd} $files" Cmd="${Cmd} $files"
Cmd="${Cmd} ${Target}" Cmd="${Cmd} ${Target}"
echo ${Cmd} echo ${Cmd}
# exit # exit
eval ${Cmd} eval ${Cmd}
fi fi
echo Done ${0} ${*} echo Done ${0} ${*}
+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
+4
View File
@@ -11,6 +11,10 @@ url=$(jq -r '.MATTERMOST.url' ${HOME}/.creds)
team=$(jq -r '.MATTERMOST.team' ${HOME}/.creds) team=$(jq -r '.MATTERMOST.team' ${HOME}/.creds)
bearer=$(jq -r '.MATTERMOST.bearer' ${HOME}/.creds) bearer=$(jq -r '.MATTERMOST.bearer' ${HOME}/.creds)
#lowercase channel
channel_name=$(echo "${channel_name}" | awk '{print tolower($0)}')
# space to '-'
channel_name=${channel_name//" "/"-"}
get_channel_url="${url}/api/v4/teams/name/${team}/channels/name/${channel_name}" get_channel_url="${url}/api/v4/teams/name/${team}/channels/name/${channel_name}"
+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