Created
May 10, 2018 20:29
-
-
Save leovarmak/0b96e0e3e0de01656284d5d3164f43b2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var unirest = require('unirest'); | |
var prompt = require('prompt'); | |
var typeOf = require('typeof'); | |
const crypto = require('crypto') | |
const request = require('request') | |
var sleep = require('sleep'); | |
function main() { | |
// prompt.get(['x'], function (err, result) { | |
// var x = parseInt(result.x); | |
var timeStamp = Math.floor(Date.now()); | |
console.log(timeStamp); | |
var counter = 1; | |
// while (counter <= 60) { | |
// FILL YOUR KEYS HERE | |
key = ""; | |
secret = ""; | |
function sell(){ | |
body = { | |
"side" : "sell", | |
"order_type" : "market_order", | |
"market" : "XRPBTC", | |
"total_quantity" : 5, | |
"timestamp": timeStamp | |
} | |
const payload = new Buffer(JSON.stringify(body)).toString(); | |
const signature = crypto | |
.createHmac('sha256', secret) | |
.update(payload) | |
.digest('hex') | |
const options = { | |
url: "https://api.coindcx.com/exchange/v1/orders/create", | |
headers: { | |
'X-AUTH-APIKEY': key, | |
'X-AUTH-SIGNATURE': signature | |
}, | |
json: true, | |
body: body | |
} | |
request.post(options,function(error, response, body) { | |
console.log('body:', body); | |
}) | |
} | |
function buy(){ | |
body2 = { | |
"side" : "buy", | |
"order_type" : "market_order", | |
"market" : "XRPBTC", | |
"total_quantity" : 5, | |
"timestamp": timeStamp | |
} | |
const payload2 = new Buffer(JSON.stringify(body2)).toString(); | |
const signature2 = crypto | |
.createHmac('sha256', secret) | |
.update(payload2) | |
.digest('hex') | |
const options2 = { | |
url: "https://api.coindcx.com/exchange/v1/orders/create", | |
headers: { | |
'X-AUTH-APIKEY': key, | |
'X-AUTH-SIGNATURE': signature2 | |
}, | |
json: true, | |
body: body2 | |
} | |
request.post(options2,function(error, response, body) { | |
console.log('body:', body); | |
}) | |
} | |
buy(); | |
sell(); | |
} | |
main(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment