Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

Quadriga CX now supports LTC trading, adding to products #392

Merged
merged 12 commits into from
Jul 20, 2017
59 changes: 34 additions & 25 deletions extensions/exchanges/quadriga/exchange.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ module.exports = function container(get, set, clear) {
trade_id: trade.tid,
time: moment.unix(trade.date).valueOf(),
size: Number(trade.amount),
price: trade.price,
price: Number(trade.price),
side: trade.side
}
})
Expand All @@ -104,11 +104,11 @@ module.exports = function container(get, set, clear) {
currency: 0
}

balance.currency = wallet[currency + '_balance'];
balance.asset = wallet[asset + '_balance'];
balance.currency = Number(wallet[currency + '_balance']);
balance.asset = Number(wallet[asset + '_balance']);

balance.currency_hold = wallet[currency + '_reserved']
balance.asset_hold = wallet[asset + '_reserved']
balance.currency_hold = Number(wallet[currency + '_reserved'])
balance.asset_hold = Number(wallet[asset + '_reserved'])
cb(null, balance)
})
},
Expand All @@ -126,8 +126,8 @@ module.exports = function container(get, set, clear) {
if (quote.error) return retry('getQuote', func_args, quote.error)

var r = {
bid: quote.bid,
ask: quote.ask
bid: Number(quote.bid),
ask: Number(quote.ask)
}

cb(null, r)
Expand Down Expand Up @@ -163,15 +163,18 @@ module.exports = function container(get, set, clear) {
var order = {
id: null,
status: 'open',
price: opts.price,
size: opts.size,
price: Number(opts.price),
size: Number(opts.size),
created_at: new Date().getTime(),
filled_size: '0',
filled_size: 0,
ordertype: opts.order_type
}

if (err) return cb(err)
if (body.error) return cb(body.error.message)
if (body.error) {
//console.log(`API Error: ${body.error.message}`);
return cb(body.error)
}

if (opts.order_type === 'taker') {
order.status = 'done'
Expand All @@ -182,15 +185,15 @@ module.exports = function container(get, set, clear) {
var price_total = 0.0
var order_count = body.orders_matched.length
for (var idx = 0; idx < order_count; idx++) {
asset_total = asset_total + body.orders_matched[idx].amount
price_total = price_total + (body.orders_matched[idx].amount * body.orders_matched[idx].price)
asset_total = asset_total + Number(body.orders_matched[idx].amount)
price_total = price_total + (Number(body.orders_matched[idx].amount) * Number(body.orders_matched[idx].price))
}

order.price = price_total / asset_total
order.size = asset_total
} else {
order.price = body.price
order.size = body.amount
order.price = Number(body.price)
order.size = Number(body.amount)
}
}

Expand All @@ -215,15 +218,18 @@ module.exports = function container(get, set, clear) {
var order = {
id: null,
status: 'open',
price: opts.price,
size: opts.size,
price: Number(opts.price),
size: Number(opts.size),
created_at: new Date().getTime(),
filled_size: '0',
filled_size: 0,
ordertype: opts.order_type
}

if (err) return cb(err)
if (body.error) return cb(body.error.message)
if (body.error) {
//console.log(`API Error: ${body.error.message}`);
return cb(body.error)
}

if (opts.order_type === 'taker') {
order.status = 'done'
Expand All @@ -234,15 +240,15 @@ module.exports = function container(get, set, clear) {
var price_total = 0.0
var order_count = body.orders_matched.length
for (var idx = 0; idx < order_count; idx++) {
asset_total = asset_total + body.orders_matched[idx].amount
price_total = price_total + (body.orders_matched[idx].amount * body.orders_matched[idx].price)
asset_total = asset_total + Number(body.orders_matched[idx].amount)
price_total = price_total + (Number(body.orders_matched[idx].amount) * body.orders_matched[idx].price)
}

order.price = price_total / asset_total
order.size = asset_total
} else {
order.price = body.price
order.size = body.amount
order.price = Number(body.price)
order.size = Number(body.amount)
}
}

Expand All @@ -261,12 +267,15 @@ module.exports = function container(get, set, clear) {
var client = authedClient()
client.api('lookup_order', params, function(err, body) {
if (err) return cb(err)
if (body.error) return cb(body.error.message)
if (body.error) {
//console.log(`API Error: ${body.error.message}`);
return cb(body.error)
}

if (body.status === 2) {
order.status = 'done'
order.done_at = new Date().getTime()
order.filled_size = body.amount
order.filled_size = Number(body.amount)
return cb(null, order)
}
cb(null, order)
Expand Down
12 changes: 10 additions & 2 deletions extensions/exchanges/quadriga/products.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[
{
[{
"id": "BTCUSD",
"asset": "BTC",
"currency": "USD",
Expand Down Expand Up @@ -34,5 +33,14 @@
"max_size": "1000000",
"increment": "0.00001",
"label": "ETH/BTC"
},
{
"id": "LTCCAD",
"asset": "LTC",
"currency": "CAD",
"min_size": "0.00001",
"max_size": "10000",
"increment": "0.00001",
"label": "LTC/CAD"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it really just LTC/CAD? No other pairs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. QCX only does CAD currency and no other crypto-to-crypto trading other than ETH-BTC for the moment. But they are fiarly new, so that may change with time.

}
]