This commit is contained in:
Oleg Sheynin 2024-08-14 20:08:12 -04:00
parent 087e536bdf
commit ef7f33f960
2 changed files with 44 additions and 21 deletions

View File

@ -1 +1 @@
1.4.6,removing containers for crypto_md_day 1.4.7,adding eqty data to research

View File

@ -1,7 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
usage() { usage() {
echo "Usage: $0 [-h <host (homestore*/cloud21)>] [-d <YYYYMMDD> (yesterday*)] [-s <stocks comma separated>" echo -n "Usage: $0"
echo -n " [-h <host (homestore*/cloud21)>]"
echo -n " [-d <YYYYMMDD> (yesterday*)]"
echo -n " [-s <stocks comma separated>"
echo -n " [-t <target directory>"
echo
exit 1 exit 1
} }
if [[ "$(uname)" == "Darwin" ]]; then if [[ "$(uname)" == "Darwin" ]]; then
@ -11,6 +16,18 @@ else
date='date' date='date'
fi fi
# ------------------ Settings
md_date=""
host=homestore
stocks=COIN,GBTC,SQ
TargetDir="/opt/jupyter_gpu/data/eqty_md"
mkdir -p ${TargetDir}
Table=md_1min_bars
# ------------------ Settings
is_valid() { is_valid() {
local inst=$1 local inst=$1
@ -26,11 +43,8 @@ is_valid() {
return 1 return 1
} }
md_date=""
host=homestore
stocks=COIN,GBTC,SQ
while getopts ":h:d:s:" opt; do while getopts ":h:d:s:t:u" opt; do
case ${opt} in case ${opt} in
d ) d )
md_date=$OPTARG md_date=$OPTARG
@ -41,6 +55,12 @@ while getopts ":h:d:s:" opt; do
s ) s )
stocks=$OPTARG stocks=$OPTARG
;; ;;
t )
TargetDir=$OPTARG
;;
u )
usage
;;
\? ) \? )
echo "Invalid option: -$OPTARG" >&2 echo "Invalid option: -$OPTARG" >&2
usage usage
@ -64,6 +84,13 @@ if ! is_valid "${host}" "${valid_hosts[@]}" ; then
usage usage
fi fi
TargetFile=$(${date} -d ${md_date} "+%Y%m%d.eqty.mktdata.ohlcv.db")
TargetFilePath="${TargetDir}/${TargetFile}"
mv ${TargetFilePath} "${TargetFilePath}.saved.$(${date} '+%Y%m%d_%H%M%S')"
touch ${TargetFilePath}
# ---- temp dir # ---- temp dir
echo ${SourceFile} echo ${SourceFile}
tmp_dir=$(mktemp -d) tmp_dir=$(mktemp -d)
@ -113,25 +140,21 @@ function download_file {
Cmd="gunzip ${tmp_dir}/${SourceFileZip}" Cmd="gunzip ${tmp_dir}/${SourceFileZip}"
echo ${Cmd} && eval ${Cmd} echo ${Cmd} && eval ${Cmd}
ls -lh ${tmp_dir} DbFile=${tmp_dir}/${SourceFile}
Cmd="sqlite3 ${tmp_dir}/${SourceFile} \".dump ${table}\" | sqlite3 ${TargetFilePath}" # --- T E M P - for files older than 20240813
sqlite3 ${DbFile} <<EOF
DROP INDEX md_1min_bars_idx;
CREATE UNIQUE INDEX IF NOT EXISTS md_1min_bars_idx on md_1min_bars(tstamp, exchange_id, instrument_id);
EOF
# --- T E M P
Cmd="sqlite3 ${DbFile} \".dump ${table}\" | sqlite3 ${TargetFilePath}"
echo ${Cmd} echo ${Cmd}
eval ${Cmd} eval ${Cmd}
} }
# TargetDir="/opt/jupyter_gpu/data/eqty_md"
TargetDir="/tmp/aaa"
mkdir -p ${TargetDir}
TargetFile=$(${date} -d ${md_date} "+%Y%m%d.eqty.mktdata.ohlcv.db")
TargetFilePath="${TargetDir}/${TargetFile}"
rm -f ${TargetFilePath}
touch ${TargetFilePath}
Table=md_1min_bars
echo "Loading files" echo "Loading files"
for stock in "${Stocks[@]}"; do for stock in "${Stocks[@]}"; do
StockLetter="${stock:0:1}" StockLetter="${stock:0:1}"