javascript - Node.js API wrapper for altcoin exchange -
i'm trying make simple market maker bot , need use variables bid, ask , spread in other functions calculate kind of buy/sell orders create. how pass these variables along? how come i'm able subtract (ask - bid) , not add (bid + 0.001)
npm poloniex.js
function getspread() { poloniex.getticker(function(err, data){ if (err){ console.log('error', err); return; } var ask = data.btc_ltc.lowestask; var bid = data.btc_ltc.highestbid; var spread = ((ask - bid) / ask); console.log('ask:', ask,'bid:', bid,'spread:', spread); }); }
in order pass these variables separate function, may -
var calculateorder = function (bid, ask, spread) { // use variables } function getspread() { poloniex.getticker(function(err, data) { if (err){ console.log('error', err); return; } var ask = data.btc_ltc.lowestask; var bid = data.btc_ltc.highestbid; var spread = ((ask - bid) / ask); calculateorder(bid, ask, spread); }); }
you should convert lowestask , highestbid numbers before doing mathematical operations on them
var ask = number(data.btc_ltc.lowestask); var bid = number(data.btc_ltc.highestbid);
Comments
Post a Comment