Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
router.get("/testbuy", function(req, res, next){
// bittrex.sendCustomRequest("https://bittrex.com/api/v1.1/account/getbalance?apikey="+ secrets.bittrex.API_KEY +"¤cy=sc", function(data, err) {
// res.json(data);
// });
bittrex.getbalance({currency: "BTC"}, function(data, err){
res.json(data);
})
})
console.log("buy worked")
var buyString = `{market: ${marketName}, buy: true, sell: false, quantity: ${calculatedBuy.quantity}, rate: ${calculatedBuy.rate}}`;
fs.appendFile('logs/orders.txt', buyString, function (err) {
if (err) throw err;
console.log('Saved!');
});
});
}
}
});
} else {
notBuyable();
}
})
} else if (winner.action && winner.action === "SELL" && winner.symbol){
bittrex.getbalance({currency: winner.symbol}, function(data, err){
console.log("GOT BALANCE", data)
var marketName = "btc-" + winner.symbol.toLowerCase();
bittrex.getmarketsummary({market: marketName}, function(marketData,err){
if (marketData && marketData.result){
console.log("md", marketData, marketData.result)
var calculatedSell = calculateSell(marketData.result, winner.symbol, marketName, data);
if (calculatedSell.quantity && calculatedSell.rate){
console.log("EXECUTING SELL", {market: marketName, quantity: calculatedSell.quantity, rate: calculatedSell.rate})
bittrex.selllimit({market: marketName, quantity: calculatedSell.quantity, rate: calculatedSell.rate}, function(data, err){
console.log("sell worked")
var sellString = `{market: ${marketName}, sell: true, buy: false, quantity: ${calculatedSell.quantity}, rate: ${calculatedSell.rate}}`;
fs.appendFile('logs/orders.txt', sellString, function (err) {
if (err) throw err;
console.log('Saved!');
const arbitrageTrade = (coinStruct) => {
bittrex.getbalance({ currency : 'BTC' }, function( data, err ) {
if (err) {
}
console.log( data );
});
};