Skip to content

Instantly share code, notes, and snippets.

@fatherofluqmaan
Last active August 12, 2021 23:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fatherofluqmaan/0d46dcb8621523e0b471f2a170c827c0 to your computer and use it in GitHub Desktop.
Save fatherofluqmaan/0d46dcb8621523e0b471f2a170c827c0 to your computer and use it in GitHub Desktop.
A Bash script to run a single pair and save the outputs in to files, one with the raw run info, another with just the datetime, pair, and granularity, and another with an additional suffix of your choice added. A single simulation can be ran using just the pycrypto bot, however, other than the log, there wasn't a clean output that could be viewe…
#!/usr/bin/env bash
rm -f short-simbot-run.txt
echo "[+] enter the following:"
echo "Coinbase pair that you want to run (format ETH-EUR, QNT-USD, LINK-GBP)"
read -r pre
echo "Granularity (86400,21600,3600,900)"
read -r grn
echo "Simulation Start Date and End Date (format 2021-01-01)"
echo "Start Date: " & read -r simst
echo "End Date: " & read -r simen
echo "Output suffix name (e.g. su15, AP, run1, shorter is better)"
read -r nme
echo "The following will be applied to the sim run:"
echo -e "Market Pair: $pre\nGranularity: $grn\nStart Date: $simst\nEnd Date: $simen\nOutput suffix: $nme"
sleep 3
dte=$(date +"%Y-%m-%d %T")
dt=$(date +"%Y-%m-%d")
mkdir -p raw-sim-outputs
mkdir -p sim-run-outputs
mkdir -p sim-result-outputs
echo "[+] Current config set"
echo -e "\n"
cat config.json | grep -B30 '.telegram' | awk -F'\"telegram' '{print $1}'
sleep 2
echo "[+] Running simulation, pair(s) running: $pre"
echo "Command executing: python3 pycryptobot.py --sim fast-sample --exchange coinbasepro --simstartdate $simst --simenddate $simen --granularity $grn --market $pre --disabletelegram"
python3 pycryptobot.py --sim fast-sample --exchange coinbasepro --simstartdate "$simst" --simenddate "$simen" --granularity "$grn" --market "$pre" --disabletelegram 2> "./sim-run-outputs/simbot-run-$nme.txt"
cat "./sim-run-outputs/simbot-run-$nme.txt" | grep "Margin.*" | sed -e "s@^@$dte-gran\:$grn-$pre @" >> "./sim-result-outputs/simbot-results-$nme.txt"
cat "./sim-run-outputs/simbot-run-$nme.txt" > "./raw-sim-outputs/$pre-$dt-$nme.txt"
rst=$(cat "./sim-result-outputs/simbot-results-$nme.txt")
echo "[+] Results: $rst"
sort "./sim-result-outputs/simbot-results-$nme.txt" > "sim-results-$dt-$nme.txt"
sleep 3
echo -e "Simulation for $pre complete\Results: $rst\nDate Range: $simst to $simen complete\nfiles now available with suffix $nme" | notify
@loomsen
Copy link

loomsen commented Aug 6, 2021

#L42
sed -e "/Margin.*/s@^@$dte-gran\:$grn-$pre @" simbot-run-"$nme".txt >> simbot-results-"$nme".txt

@fatherofluqmaan
Copy link
Author

#L42
sed -e "/Margin.*/s@^@$dte-gran\:$grn-$pre @" simbot-run-"$nme".txt >> simbot-results-"$nme".txt

This seems to cause the entire output to be posted to the new file for some reason

@loomsen
Copy link

loomsen commented Aug 6, 2021

Oops

sed -ne "/Margin.*/s@^@$dte-gran\:$grn-$pre @p" simbot-run-"$nme".txt >> simbot-results-"$nme".txt

That should do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment