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

Bittrex: a few fixes #269

Merged
merged 1 commit into from
Jun 12, 2017
Merged
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
5 changes: 5 additions & 0 deletions commands/buy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = function container (get, set, clear) {
.allowUnknownOption()
.description('execute a buy order to the exchange')
.option('--pct <pct>', 'buy with this % of currency balance', Number, c.buy_pct)
.option('--order_type <type>', 'order type to use (maker/taker)', /^(maker|taker)$/i, c.order_type)
.option('--size <size>', 'buy specific size of currency')
.option('--markup_pct <pct>', '% to mark up ask price', Number, c.markup_pct)
.option('--order_adjust_time <ms>', 'adjust bid on this interval to keep order competitive', Number, c.order_adjust_time)
Expand All @@ -27,6 +28,10 @@ module.exports = function container (get, set, clear) {
so.debug = cmd.debug
so.buy_pct = cmd.pct
so.selector = get('lib.normalize-selector')(selector || c.selector)
var order_types = ['maker', 'taker']
if (!so.order_type in order_types || !so.order_type) {
so.order_type = 'maker'
}
so.mode = 'live'
so.strategy = c.strategy
so.stats = true
Expand Down
5 changes: 5 additions & 0 deletions commands/sell.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = function container (get, set, clear) {
.allowUnknownOption()
.description('execute a sell order to the exchange')
.option('--pct <pct>', 'sell with this % of currency balance', Number, c.sell_pct)
.option('--order_type <type>', 'order type to use (maker/taker)', /^(maker|taker)$/i, c.order_type)
.option('--size <size>', 'sell specific size of currency')
.option('--markup_pct <pct>', '% to mark up ask price', Number, c.markup_pct)
.option('--order_adjust_time <ms>', 'adjust ask on this interval to keep order competitive', Number, c.order_adjust_time)
Expand All @@ -27,6 +28,10 @@ module.exports = function container (get, set, clear) {
so.debug = cmd.debug
so.sell_pct = cmd.pct
so.selector = get('lib.normalize-selector')(selector || c.selector)
var order_types = ['maker', 'taker']
if (!so.order_type in order_types || !so.order_type) {
so.order_type = 'maker'
}
so.mode = 'live'
so.strategy = c.strategy
so.stats = true
Expand Down
2 changes: 1 addition & 1 deletion commands/trade.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ module.exports = function container (get, set, clear) {
var engine = get('lib.engine')(s)

var order_types = ['maker', 'taker']
if (!so.order_type in order_types) {
if (!so.order_type in order_types || !so.order_type) {
so.order_type = 'maker'
}

Expand Down
35 changes: 25 additions & 10 deletions extensions/exchanges/bittrex/exchange.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ module.exports = function container(get, set, clear) {

bittrex_authed.options({
'apikey' : c.bittrex.key.trim(),
'apisecret' : c.bittrex.secret.trim()
'apisecret' : c.bittrex.secret.trim(),
'stream': false,
'cleartext': false,
'verbose': false
})

function joinProduct(product_id) {
Expand Down Expand Up @@ -116,13 +119,25 @@ module.exports = function container(get, set, clear) {
}
Object.keys(data.result).forEach(function (i) {
var _balance = data.result[i]
if (_balance['Currency'] === opts.currency.toUpperCase()) {
balance.currency = n(_balance.Available).format('0.00000000'),
balance.currency_hold = 0
}
if (_balance['Currency'] === opts.asset.toUpperCase()) {
balance.asset = n(_balance.Available).format('0.00000000'),
balance.asset_hold = 0
// yes, currency and asset are turned around on purpose, their API is weird
if(opts.last_signal === 'buy') {
if (_balance['Currency'] === opts.currency.toUpperCase()) {
balance.currency = n(_balance.Available).format('0.00000000'),
balance.currency_hold = 0
}
if (_balance['Currency'] === opts.asset.toUpperCase()) {
balance.asset = n(_balance.Available).format('0.00000000'),
balance.asset_hold = 0
}
} else {
if (_balance['Currency'] === opts.currency.toUpperCase()) {
balance.asset = n(_balance.Available).format('0.00000000'),
balance.asset_hold = 0
}
if (_balance['Currency'] === opts.asset.toUpperCase()) {
balance.currency = n(_balance.Available).format('0.00000000'),
balance.currency_hold = 0
}
Copy link
Owner Author

Choose a reason for hiding this comment

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

this is the real "fix": their API expects it turned around for sell

}
})
cb(null, balance)
Expand Down Expand Up @@ -183,8 +198,8 @@ module.exports = function container(get, set, clear) {
rate: opts.price
}

if(!'order_type' in opts) {
opts.order_type = 'limit'
if(!'order_type' in opts || !opts.order_type) {
opts.order_type = 'maker'
}

var fn = function(data) {
Expand Down
Loading