Skip to content

Commit

Permalink
buy GHS constantly until price peak, but still have the option for a …
Browse files Browse the repository at this point in the history
…panic sell

so long as the price is increasing by "fast enough" (value for "fast enoguh" is still part of config.EMA) assume that the price IS NOT about to crash.

since the price is still on the way up, it's best to keep buying GHS (this code is meant to be most optimal on cex.io) because there will be a mining income on any newly acquired GHS

once the price starts to level off (up trend rate drops below buyTreshold) this new code will simply hold the GHS which will continue to mine

The code for "sellTreshold" is unmodified, so it is up to the end-user to decide how severe of a market signal for "price crash" should be used to trigger the panic sell.
  • Loading branch information
kuzetsa committed Dec 5, 2013
1 parent 72ab99f commit 916aab0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions methods/exponential-moving-averages.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,15 @@ TradingMethod.prototype.advice = function() {
if(diff > settings.buyTreshold) {
log.debug('we are currently in uptrend (' + diff + ')');

if(this.currentTrend !== 'up') {
this.currentTrend = 'up';
this.emit('advice', 'BUY', price, message);
} else
this.emit('advice', 'HOLD', price, message);
// *** buyTreshold is now honored unconditionally ***
this.emit('advice', 'BUY', price, message);

// *** this commented out code only buys during start of an up trend ***
// if(this.currentTrend !== 'up') {
// this.currentTrend = 'up';
// this.emit('advice', 'BUY', price, message);
// } else
// this.emit('advice', 'HOLD', price, message);

} else if(diff < settings.sellTreshold) {
log.debug('we are currently in a downtrend', message);
Expand Down

4 comments on commit 916aab0

@kuzetsa
Copy link
Owner Author

@kuzetsa kuzetsa commented on 916aab0 Dec 6, 2013

Choose a reason for hiding this comment

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

This commit need removed from the "refresh-balance" branch, fixing now.

Edited to add:

Fixed.

this commit is no longer part of the "refresh-balance" branch

@kuzetsa
Copy link
Owner Author

@kuzetsa kuzetsa commented on 916aab0 Dec 6, 2013

Choose a reason for hiding this comment

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

Someone put in a line comment about this commit and I accidentally mis-clicked and deleted it & forgot to note who wrote what...

To answer your question:

It doesn't seem to matter with the way I have my own gekko bot configured. The way I'm using gekko doesn't EVER need to know what the previous trend was, because my local configuration only checks if it's on an uptrend or not. If it's on an uptrend, buy. There's no "sell" condition at all on mine because I'm running in "buy and hold" mode.

If you have an opinion about a more elegant way to handle this behavior and/or maybe a patch to do things the way you want I'll gladly create a new branch and make the settings configurable. This particular commit was just related to some of my own code I was using in a test. (the test was successful, and bot behaved as I had intended)

P.S. next time please also include your questions or commentary somewhere in the commit comment section as well, as this makes it easier to reply.

@toomyem
Copy link

@toomyem toomyem commented on 916aab0 Dec 6, 2013

Choose a reason for hiding this comment

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

It was me, who made this line comment. I understand your point but I just wanted to express my concerns about broken logic after the change. Either way this is your code and should suit your needs :)

@kuzetsa
Copy link
Owner Author

@kuzetsa kuzetsa commented on 916aab0 Dec 8, 2013

Choose a reason for hiding this comment

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

@toomyem Yep, I quite agree with the way you worded that. I don't know what the usage case is for most of the userbase (including your own needs)

Based on my own testing and use pattern, the logic was broken BEFORE I made this change...

...this change to the logic / code only applies to users with similar usage cases to my own...

To qualify my statement, this code is for users who would prefer a "buy and hold" strategy, and this patch causes gekko to only take a break from buying when there is an obvious down-trend indicating that a better price is soon approaching in the near future, and the end result is a new behavior where gekko temporarily delays the purchase of new GHS (on cex.io, or other exchanges which might sell securities and commodities which yield income)

Not everyone wants their portfolio managed the same way, so there is no "one size fits all" algorithm for trend-handling logic :)

Like I mentioned, the logic for this code is still linked to whatever the user configures for their EMA thresholds.

This patch behaves exactly how I want (the logic is LESS broken, but only for people who prefer buy and hold style like the one I personally use)

Thanks @toomyem, I appreciate your returning to write a new response after I accidentally deleted your line comment.

Please sign in to comment.