Closed saeeds255 closed 6 years ago
Yes that code should cancel the order, the code you posted is Gekko code that should work for all exchanges. If you are experiencing errors it might be Okcoin specific code. Could you post Gekko output (with debug enabled) so we can see what part went wrong? Note that Gekko only checks the order after 1 minute of posting it.
I don't know how to debug. These lines of code doesn't run at all. Just after manager.prototype ... Can you tell me how to call the function without setTimeout? Please tell me the code without setTimeout and I will test again. Thanks
you can change the noteOrder function into:
Manager.prototype.noteOrder = function(err, order) {
this.order = order;
// if after 1 minute the order is still there
// we cancel and calculate & make a new one
this.checkOrder();
}
to run it directly. Note that running it directly almost always mean the order hasn't been completed fully yet (unless the market is extremely liquid).
With debug I mean, turn [on debug in your config]() and post the console output at the time of the trade.
Sorry for the late response ...
I edited the portfolioManager.js like bellow and ran the bot
Manager.prototype.noteOrder = function(err, order) {
this.order = order;
// if after 1 minute the order is still there
// we cancel and calculate & make a new one
this.checkOrder();
}
And here is the output with debug enabled in config
2016-08-26 10:01:02 (INFO): We have new trading advice!
2016-08-26 10:01:02 (INFO): Position: short
2016-08-26 10:01:02 (INFO): Market price: 3864.05
2016-08-26 10:01:02 (INFO): Based on market time: 2016-08-26 09:59:00
2016-08-26 10:01:02 (INFO): (PROFIT REPORT) original simulated balance: 3965.97000 CNY
2016-08-26 10:01:02 (INFO): (PROFIT REPORT) current simulated balance: 3717.91849 CNY
2016-08-26 10:01:02 (INFO): (PROFIT REPORT) simulated profit: -248.05151 CNY (-6.25450%)
2016-08-26 10:01:04 (INFO): wanted to buy BTC but the amount is too small (0.00020055600710280953) at okcoin
2016-08-26 10:01:04 (INFO): wanted to buy CNY but the amount is to small (0) at okcoin
2016-08-26 10:01:21 (DEBUG): Requested / trade data from OkCoin ...
2016-08-26 10:01:22 (DEBUG): Processing 60 new trades. From 2016-08-26 10:01:21 UTC to 2016-08-26 10:01:19 UTC. (a few seconds)
2016-08-26 10:01:41 (DEBUG): Requested / trade data from OkCoin ...
2016-08-26 10:01:42 (DEBUG): Processing 60 new trades. From 2016-08-26 10:01:41 UTC to 2016-08-26 10:01:40 UTC. (a few seconds)
2016-08-26 10:02:01 (DEBUG): Requested / trade data from OkCoin ...
2016-08-26 10:02:02 (DEBUG): Processing 60 new trades. From 2016-08-26 10:02:01 UTC to 2016-08-26 10:02:01 UTC. (a few seconds)
2016-08-26 10:02:02 (DEBUG): calculated DEMA properties for candle:
2016-08-26 10:02:02 (DEBUG): long ema: 3863.56257499
2016-08-26 10:02:02 (DEBUG): short ema: 3863.46813069
2016-08-26 10:02:02 (DEBUG): diff: -0.00244
2016-08-26 10:02:02 (DEBUG): DEMA age: 108 candles
2016-08-26 10:02:02 (DEBUG): we are currently not in an up or down trend @ 3863.50000000 (-0.00244)
As you can see we have
2016-08-26 10:01:04 (INFO): wanted to buy BTC but the amount is too small (0.00020055600710280953) at okcoin
2016-08-26 10:01:04 (INFO): wanted to buy CNY but the amount is to small (0) at okcoin
These are line 248 and 203 of portfolioManager.js because I have an open sell order that should be canceled, after that it started to fetch new data and just bypasses the canceling order lines.
I tried both setTimeout(this.checkOrder, util.minToMs(1));
and this.checkOrder();
but the results are same.
hey askmike why i cant cancel order in okcoin
the api key is upgraded , are you upgrade in your script
i didnt see any error , and didnt cancel the order , what do a to find the bug ?
Any updates relating to this issue?
@saeeds255 自己看,你想和提示 016-08-26 10:01:04 (INFO): wanted to buy BTC but the amount is too small (0.00020055600710280953) at okcoin 2016-08-26 10:01:04 (INFO): wanted to buy CNY but the amount is to small (0) at okcoin
是说你交易的量太小了,钱不够啊
log.info( 'Attempting to BUY', amount, this.asset, 'at', this.exchange.name ); this.exchange.buy(Math.trunc(amount*1000)/1000, price, this.noteOrder); };
@wupeng1211 That's because I have an open order that should be canceled by Gekko but it won't ! so it shows that I don't have enough money .
@askmike issue is open for longer then year, without any new mentions.
I checked portfolioManager.js and found this part of the code :
This should cancel the existing order, right ? But It doesn't cancel the order. I am using okcoin exchange. please check it and tell me what should I do for it ?
Maybe it's about setTimeout function or incorrect function calling.