Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Commit

Permalink
Allow to specify market for orders call, refs #4
Browse files Browse the repository at this point in the history
  • Loading branch information
Genar Trias Ortiz committed Dec 5, 2017
1 parent 93a1c95 commit 9ab57d9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
9 changes: 6 additions & 3 deletions server/exchanges/bittrex.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import bittrex from 'node-bittrex-api'
import debug from 'debug'

module.exports = class BittrexExchange {
constructor (bitrexOpts) {
Expand All @@ -17,8 +16,12 @@ module.exports = class BittrexExchange {
})
}

getOrders (cb) {
bittrex.getorderhistory({}, function (data, err) {
getOrders (market, cb) {
const options = {}
if (market) {
options.market = market
}
bittrex.getorderhistory(options, function (data, err) {
if (err) {
cb(err)
}
Expand Down
7 changes: 5 additions & 2 deletions server/models/order.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import BittrexExchange from '../exchanges/bittrex'

module.exports = function (Order) {
Order.getOrders = (cb) => {
Order.getOrders = (market, cb) => {
const bitrexOpts = Order.app.get('bittrex')
const exchange = new BittrexExchange(bitrexOpts)

exchange.getOrders((err, data) => {
exchange.getOrders(market, (err, data) => {
if (err) {
cb(err)
}
Expand All @@ -15,6 +15,9 @@ module.exports = function (Order) {
}

Order.remoteMethod('getOrders', {
accepts: [
{arg: 'market', type: 'string'}
],
http: { verb: 'get', path: '/' },
returns: {type: 'array', root: true}
})
Expand Down

0 comments on commit 9ab57d9

Please sign in to comment.