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

GDAX: cancel_after #596

Merged
merged 5 commits into from
Oct 13, 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
2 changes: 2 additions & 0 deletions conf-sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ c.rsi_periods = 14
c.balance_snapshot_period = '15m'
// avg. amount of slippage to apply to sim trades
c.avg_slippage_pct = 0.045
// time to leave an order open, default to 1 day (this feature is not supported on all exchanges, currently: GDAX)
c.cancel_after = 'day'

// Notifiers:
c.notifiers = {}
Expand Down
3 changes: 2 additions & 1 deletion extensions/exchanges/btce/exchange.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// Warning - Some of the functions need testing
// by someone in posession of a BTCe account
// In particular this is the case for
// In particular this is the case for
// the buy, sell, cancelOrderand getOrderfunctions
//
var BTCE = require('btce')
Expand Down Expand Up @@ -166,6 +166,7 @@ module.exports = function container (get, set, clear) {
}
*/
delete opts.order_type
delete opts.cancel_after
client.trade({'pair': pair, 'type': type, 'rate': opts.price, 'amount': opts.size }, function(err, body) {
body = statusErr(err, body)
// Fix me - Check return codes from API
Expand Down
10 changes: 9 additions & 1 deletion extensions/exchanges/gdax/exchange.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,12 @@ module.exports = function container (get, set, clear) {
if (opts.order_type === 'taker') {
delete opts.price
delete opts.post_only
delete opts.cancel_after
opts.type = 'market'
}
else {
opts.time_in_force = 'GTT'
}
delete opts.order_type
client.buy(opts, function (err, resp, body) {
if (body && body.message === 'Insufficient funds') {
Expand All @@ -164,8 +168,12 @@ module.exports = function container (get, set, clear) {
if (opts.order_type === 'taker') {
delete opts.price
delete opts.post_only
delete opts.cancel_after
opts.type = 'market'
}
else {
opts.time_in_force = 'GTT'
}
delete opts.order_type
client.sell(opts, function (err, resp, body) {
if (body && body.message === 'Insufficient funds') {
Expand Down Expand Up @@ -204,4 +212,4 @@ module.exports = function container (get, set, clear) {
}
}
return exchange
}
}
3 changes: 2 additions & 1 deletion lib/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,8 @@ module.exports = function container (get, set, clear) {
size: s.buy_order.orig_size,
fee: fee,
price: price,
order_type: so.order_type
order_type: so.order_type,
cancel_after: so.cancel_after
}
s.my_trades.push(my_trade)
if (so.stats) {
Expand Down