You are viewing a single comment's thread from:

RE: [USEFUL] Cryptocurrency exchange arbitrage script source code [BASH]

in #linux7 years ago

Whoa, cool script! And very well/cleanly written.

Why did you use hard coded file names instead of something like WFILE=$(mktemp)
YFILE=$(mktemp)
etc?

A small note for Ubuntu users, you'll also need the html2text and jq packages installed.

Sort:  

Thank you very much for your comment :) I'm afraid I don't know how to work with mktemp files in the bash. I will definitely look this topic & learn it for my future use, thanks @not-a-bird !

NP.

Essentially, you just invoke mktemp and it creates a file and returns that file's name. So you can use it anywhere you'd use a hard-coded file name.

So by doing WFILE=$(mktemp) you get something like /tmp/tmp.CqOZSJZb5y in your WFILE variable. So where you deal with wfile it would look something like this:

WFILE=$(mktemp)
curl -f -s https://wex.nz/api/3/ticker/"${tickerswex[i]}" > "${WFILE}"
w=$(cat "${WFILE}" | jq '.'"${tickerswex[i]}"'.sell')
wv=$(cat "${WFILE}" | jq '.'"${tickerswex[i]}"'.vol')
rm "${WFILE}"

You could do it for wfile, yfile, efile...

Sorry if I over-explained that.