Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions bitstamp-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ Bitstamp = function(client_id, api_key, api_secret) {
params: ['key', 'signature', 'nonce', 'id']
},
orderbuy: {
endpoint: '/api/buy/',
endpoint: '/api/v2/buy/',
method: 'POST',
params: ['key', 'signature', 'nonce', 'price', 'amount']
},
ordersell: {
endpoint: '/api/sell/',
endpoint: '/api/v2/sell/',
method: 'POST',
params: ['key', 'signature', 'nonce', 'price', 'amount']
},
Expand Down Expand Up @@ -121,6 +121,7 @@ Bitstamp.prototype.submitRequest = function(bitstampmethod, params, callback) {
params.nonce = unix_timestamp_ms;
}

console.log(params);
for (var param in params) {
if (typeof params[param] === 'undefined') {
delete params[param];
Expand All @@ -129,12 +130,20 @@ Bitstamp.prototype.submitRequest = function(bitstampmethod, params, callback) {
}
}

var currency_pair = '';
if(params.currency_pair != undefined){
alert('fsdf');
currency_pair = params.currency_pair + '/';
delete params.currency_pair;
}

console.log('Submitting request');


var that = this;
this.requestFunction({
type: bitstampmethod.method,
url: this.host + bitstampmethod.endpoint,
url: this.host + bitstampmethod.endpoint + currency_pair,
data: params,
success: function(data, textStatus, jqXHR){that.parseResponse(data, callback);},
error: function(jqXHR, textStatus, errorThrown){that.handleError(textStatus, errorThrown, callback);},
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
$('#usertransactions').click( function(){getUserTransactions();} );
$('#openorders').click( function(){getOpenOrders();} );
$('#cancelorder').click( function(){cancelOrder(1);} );
$('#orderbuy').click( function(){orderBuy(1, 1);} );
$('#orderbuy').click( function(){orderBuy('btcusd', 0.01, 12000.01);} );
$('#ordersell').click( function(){orderSell(1, 1);} );

$('#withdrawalrequests').click( function(){withdrawalRequest();} );
Expand Down
8 changes: 4 additions & 4 deletions tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ function cancelOrder(orderid) {
displayInputParams(params);
}

function orderBuy(amount, price) {
function orderBuy(currency_pair, amount, price) {
$('#response').val('');
params = bitstamp.submitRequest(bitstamp.methods.orderbuy, debugResponse, {amount: amount, price: price});
params = bitstamp.submitRequest(bitstamp.methods.orderbuy, {currency_pair: currency_pair, amount: amount, price: price});
displayInputParams(params);
}

function orderSell(amount, price) {
function orderSell(currency_pair, amount, price) {
$('#response').val('');
params = bitstamp.submitRequest(bitstamp.methods.ordersell, debugResponse, {amount:amount, price: price});
params = bitstamp.submitRequest(bitstamp.methods.ordersell, {currency_pair, amount:amount, price: price});
displayInputParams(params);
}

Expand Down