Compare commits

...

16 Commits

Author SHA1 Message Date
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
7 changed files with 185 additions and 31 deletions
+1 -1
View File
@@ -1 +1 @@
0.6.4
0.7.6
+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
+46 -27
View File
@@ -1,6 +1,11 @@
#!/bin/bash
CalendarURL=http://cloud16.cvtt.vpn:8000/api/v1/markets/hours?mic=XNYS
Start=${1}
NumJobs=${2}
InstListFile=${3}
export CalendarURL=http://cloud16.cvtt.vpn:8000/api/v1/markets/hours?mic=XNYS
is_business_day() {
dt=${1}
@@ -14,13 +19,9 @@ is_business_day() {
}
export -f is_business_day
Start=${1}
End=${2}
NumJobs=${3}
if [ "${Start}" == "" ] ; then
echo "Usage: ${0} <start_date> [<end_date>] [<num_jobs> (25)]]"
exit
Start=$(date -d "yesterday" "+%Y-%m-%d")
fi
if ! is_business_day ${Start}; then
@@ -28,23 +29,37 @@ if ! is_business_day ${Start}; then
exit
fi
if [ "${End}" == "" ] ; then
End=$(date -d "${Start} + 1 day" "+%Y-%m-%d")
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=25
NumJobs=30
fi
echo "Start=${Start} End=${End} NumJobs=${NumJobs}"
# export PyScript=/home/cvtt/prod/cvttpy/exchanges/alpaca/hist_mkt_data.py
Python=/home/cvtt/.pyenv/python3.10-venv/bin/python3
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/host_drive/alpaca_md # Local
export LogDir=/home/cvtt/prod/logs/alpaca_md
OutputDir=/home/cvtt/alpaca_md
Config=http://cloud16.cvtt.vpn:6789/apps/minimal_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
mkdir -p ${LogDir}
run_proc() {
Inst=${1}
@@ -52,33 +67,37 @@ run_proc() {
End=${3}
echo "Running for $Inst"
Cmd="${Python} ${PyScript}"
Cmd="${Cmd} --config=${Config}"
Cmd="${Cmd} --output_dir=${OutputDir}"
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=./logs/${Start}.${Inst}.log"
Cmd="${Cmd} --log_file=${LogDir}/${Inst}.log"
Cmd="${Cmd} --log_level=WARNING"
echo ${Cmd}
eval ${Cmd}
}
export PYTHONPATH=/home/cvtt/prod
export -f run_proc
key=$(jq -r '.["ALPACA_SANDBOX"] | .api_key' ~/.creds)
secret=$(jq -r '.["ALPACA_SANDBOX"] | .secret_key' ~/.creds)
if [ "$InstListFile" == "" ]; then
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-/'"
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=()
@@ -87,7 +106,7 @@ do
Instruments+=("$Inst")
done
slice_size=100 # 10K symbols parallel cannot handle
slice_size=500 # 10K symbols parallel cannot handle
for ((ii=0; ii <${#Instruments[@]}; ii+=slice_size)); do
InstSlice=("${Instruments[@]:ii:slice_size}")
+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)"
+2 -2
View File
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# ---------------- Settings
declare -A git_repo_arr
@@ -152,4 +152,4 @@ done
cd ${HOME}
rm -rf ${tmp_dir}
echo $0 Done
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
+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}"
LogArchiveDir=/home/cvtt/prod/archive/logs
LogArchiveDir=${HOME}/prod/archive/logs
mkdir -p ${LogArchiveDir}
echo "find ${LogDir}/ '(' -name '*.log' -o -name '*.log.*' ')' -type f -not -newermt ${Oldest})"