Skip to content

Commit

Permalink
fix and merge zb createOrder from ccxt#1300 ccxt#1717
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed Feb 27, 2018
1 parent b7073ce commit fd1e489
Showing 1 changed file with 15 additions and 38 deletions.
53 changes: 15 additions & 38 deletions js/zb.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,36 +341,13 @@ module.exports = class zb extends Exchange {

async createOrder (symbol, type, side, amount, price = undefined, params = {}) {
await this.loadMarkets ();
// let order = {
// 'price': price.toString (),
// 'amount': amount.toString (),
// 'tradeType': (side === 'buy') ? '1' : '0',
// 'currency': this.marketId (symbol),
// };
// order = this.extend (order, params);
// let response = await this.privateGetOrder (order);
//---------------------------------------------------------------------
// old code
let paramString = '&price=' + price.toString ();
paramString += '&amount=' + amount.toString ();
let tradeType = (side === 'buy') ? '1' : '0';
paramString += '&tradeType=' + tradeType;
paramString += '&currency=' + this.marketId (symbol);
let response = await this.privatePostOrder (paramString);
// end of old code
//---------------------------------------------------------------------
//---------------------------------------------------------------------
// new code
let order = {
'price': price.toString (),
'amount': amount.toString (),
'tradeType': (side == 'buy') ? '1' : '0',
'price': price.toString (), // TODO: this is a problem
'amount': amount.toString (), // TODO: this is a problem
'tradeType': (side === 'buy') ? '1' : '0',
'currency': this.marketId (symbol),
};
order = this.extend (order, params);
let response = await this.privatePostOrder (order);
// end of new code
//---------------------------------------------------------------------
let response = await this.privateGetOrder (this.extend (order, params));
return {
'info': response,
'id': response['id'],
Expand Down Expand Up @@ -565,17 +542,17 @@ module.exports = class zb extends Exchange {

async request (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
let response = await this.fetch2 (path, api, method, params, headers, body);
// if (api === 'private') {
// if ('code' in response) {
// let code = response['code'];
// if (this.errors[code]) {
// response['message'] = this.errors[code];
// }
// if (code !== 1000) {
// throw new ExchangeError (this.id + ' ' + this.json (response));
// }
// }
// }
if (api === 'private') {
if ('code' in response) {
let code = response['code'];
if (this.errors[code]) {
response['message'] = this.errors[code];
}
if (code !== 1000) {
throw new ExchangeError (this.id + ' ' + this.json (response));
}
}
}
//---------------------------------------------------------------------
// old code
if (api === 'private')
Expand Down

0 comments on commit fd1e489

Please sign in to comment.