You are viewing a single comment's thread from:

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

in #linux9 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.

Coin Marketplace

STEEM 0.04
TRX 0.32
JST 0.098
BTC 64085.58
ETH 1844.13
USDT 1.00
SBD 0.38