#!/bin/bash # SQLite DDL for simulation # ========================= # -- md_quotes # -- md_1min_bars usage() { echo -n "Usage: $0" echo -n " -d YYYMMDD Date>" echo -n " [-O ]" echo -n " [-S ]" echo -n " [-D (cloud21)]" echo exit 1 } # --------------------- Settings SourceHost=cloud21 SourceRootDir=/opt/store/cvtt/md_archive/crypto DbSource=cloud21 # --------------------- Settings while getopts ":d:O:S:D:" opt; do case ${opt} in d ) Date=$OPTARG ;; O ) OutputDir=$OPTARG ;; S ) SourceHost=$OPTARG ;; D ) DbSource=$OPTARG ;; \? ) echo "Invalid option: -$OPTARG" >&2 usage ;; : ) echo "Option -$OPTARG requires an argument." >&2 usage ;; esac done if [ -z ${Date} ] ; then echo "date is not specified" usage fi if [ -z ${OutputDir} ] ; then OutputDir=. fi SourceHost+=".cvtt.vpn" mkdir -p ${OutputDir} # --- Binance Instruments=( PAIR-ADA-USDT ) Instruments+=( PAIR-BCH-USDT ) Instruments+=( PAIR-BTC-USDT ) Instruments+=( PAIR-DOT-USDT ) Instruments+=( PAIR-ETH-USDT ) Instruments+=( PAIR-LTC-USDT ) Instruments+=( PAIR-SOL-USDT ) Instruments+=( PAIR-USDC-USDT ) Instruments+=( PAIR-XRP-USDT ) # --- Coinbase Instruments+=( PAIR-ADA-USD ) Instruments+=( PAIR-BCH-USD ) Instruments+=( PAIR-BTC-USD ) Instruments+=( PAIR-DOT-USD ) Instruments+=( PAIR-ETH-USD ) Instruments+=( PAIR-LTC-USD ) Instruments+=( PAIR-SOL-USD ) Instruments+=( PAIR-XRP-USD ) echo "Date=${Date} Instruments=${Instruments[@]} OutputDir=${OutputDir}" echo Getting data from ${DataHost} ... year=$(date -d ${Date} +"%Y") month=$(date -d ${Date} +"%m") SourceDir="${SourceRootDir}/${DbSource}/${year}/${month}" SourceFile="${SourceDir}/${Date}.mktdata.db.gz" Cmd="rsync -ahv" Cmd+=" ${SourceHost}:${SourceFile}" Cmd+=" $OutputDir/" echo ${Cmd} eval ${Cmd} Cmd="(cd ${OutputDir} && gunzip *.db.gz)" echo ${Cmd} eval ${Cmd} SourceDbFile="${OutputDir}/${Date}.mktdata.db" ResultDbFile="${OutputDir}/${Date}.crypto_sim_md.db" echo "Creating Result Database File ${ResultDbFile}" echo "Creating table md_trades ..." sqlite3 ${ResultDbFile} <