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

Strategies: TA (ema+macd) and Trust/Distrust #285

Merged
merged 2 commits into from
Jul 28, 2017
Merged

Strategies: TA (ema+macd) and Trust/Distrust #285

merged 2 commits into from
Jul 28, 2017

Conversation

DeviaVir
Copy link
Owner

@DeviaVir DeviaVir commented Jun 14, 2017

This TA is a copy of the work @Fjuxx has been doing, since it's a separate strategy, I don't think there's a harm in including it already.

The trust/distrust can be described as follows:

the idea is that you trust the coin to keep growing, but that you distrust it when it comes to peaks. simply put: you tell it what the min sell percentage is (what percentage the current price should be above the starting, or buy-in, price), you tell it at what percentage below the highest point you wish to sell it at, and you tell it at what percentage above the deepest point you wish to buy at. All reset after an action.

Trust/Distrust is best used with (expected) growing altcoins. Trust/Distrust is nice if you don't want the bot to ever make a negative trade (although you can configure the sell_threshold_max which is the percentage below at which the bot will panic sell)

Here are some results from trust/distrust:

$ ./zenbot.sh sim poloniex.DGB-BTC --strategy=trust_distrust --sell_threshold=3 --sell_min=2 --buy_threshold=2 --period=28m --sell_threshold_max=0 --poll_trades=5000 --order_adjust_time=5000 --greed=350 --currency_capital=1400 --asset_capital=0 --days=30

end balance: 7263.64799015 (418.83%)
buy hold: 3870.28985507 (176.45%)
vs. buy hold: 87.68%

vs a not super fast growing market (these params should be further tuned):

$ ./zenbot.sh sim gdax.ETH-EUR --strategy=trust_distrust --sell_threshold=3 --sell_min=2 --buy_threshold=1 --period=28m --sell_threshold_max=10 --poll_trades=5000 --order_adjust_time=5000 --currency_capital=1400 --asset_capital=0 --days=14

end balance: 2005.97032216 (43.28%)
buy hold: 2120.40945035 (51.46%)
vs. buy hold: -5.40%

another not fast growing market:

$ ./zenbot.sh sim gdax.BTC-EUR --strategy=trust_distrust --sell_threshold=3 --sell_min=2 --buy_threshold=1 --period=28m --sell_threshold_max=10 --poll_trades=5000 --order_adjust_time=5000 --currency_capital=1400 --asset_capital=0 --days=14

end balance: 1563.41699875 (11.67%)
buy hold: 1640.53128599 (17.18%)
vs. buy hold: -4.70%

(trend_ema balance for the above market: end balance: 1358.10164583 (-2.99%))

@Fjuxx
Copy link
Contributor

Fjuxx commented Jun 14, 2017

Please note that the TA is still WIP, i'm planning to work on it a bit further at the end of this week.

as you can see, with the MACD it processes ALL data to TAlib. with the EMA only the last x periods are fed.

As well i found that at leased for MACD the data seems to be 1 period off and i dont know why yet. this needs more testing.
(it could be that the difference is coming from the fact that the bot is calculating it realtime and the internet graphs are calculating it backwards.

@DeviaVir
Copy link
Owner Author

@Fjuxx noted! This is why I added them as separate ta_ strategies, so we are not overwriting anything while this is WIP.

@Fjuxx
Copy link
Contributor

Fjuxx commented Jun 14, 2017

Perfect, when i start again i will work from this branch (or if it is merged from master ofc)

Repository owner deleted a comment from RyanF109 Jun 14, 2017
Repository owner deleted a comment from RyanF109 Jun 14, 2017
@@ -32,6 +32,7 @@
"semver": "^5.3.0",
"sosa_mongo": "^1.0.3",
"timebucket": "^0.4.0",
"talib": "^1.0.3",
Copy link

@simonwestyn simonwestyn Jun 15, 2017

Choose a reason for hiding this comment

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

FYI, Talib doesnt work on Windows:
npm ERR! notsup Unsupported platform for talib@1.0.3: wanted {"os":"darwin,linux","arch":"any"} (current: {"os":"win32","arch":"x64"})

Copy link
Owner Author

Choose a reason for hiding this comment

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

Although, yes, that sucks, TA-Lib has many indicators and many financial functions that might be of use. This could be a case where I'd say that we drop Windows support.

Choose a reason for hiding this comment

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

Just wanted to let you know. But I agree, VM on windows is easy

@arpheno
Copy link

arpheno commented Jun 16, 2017

I'm noticing major slowdown in performance for the two ta_ strategies. Are you observing the same behaviour?

description: 'Sell when price higher than $sell_min% and highest point - $sell_threshold% is reached. Buy when lowest price point + $buy_threshold% reached.',

getOptions: function () {
this.option('period', 'period length', String, '30m')
Copy link

Choose a reason for hiding this comment

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

You're missing a min_periods value here, which causes a NaN when trying to calculate the number of days to backfill here.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I feel like this min_periods shouldn't be part of the strategy, as it's needed in trade.js... but I added it, as I see that all other strategies, except for SAR, have also added it (but don't actually do anything with it).

Good catch!

@nao0811ta
Copy link

I have same problem.so reset to previous commit.
Signal is to null.

@DeviaVir
Copy link
Owner Author

DeviaVir commented Jun 18, 2017

@arpheno yes, those are definitely WIP at this time. This is also the reason that they've gotten their own strategy name instead of replacing the current ema and macd.

@DeviaVir
Copy link
Owner Author

@nao0811ta I'm not sure what you're referring to, what signal is to null?

node-gyp and node v8.x are not friends, stick to boron for now

Rename talib's MACD (#2)

* Rename talib's MACD so it doesn't overlap with original macd
if (s.trust_distrust_lowest > s.period.high) {
s.trust_distrust_lowest = s.period.high
}
},
Copy link
Owner Author

@DeviaVir DeviaVir Jun 20, 2017

Choose a reason for hiding this comment

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

note to self: might want to consider calculating EMA/MACD (both?) to check if we are in an up or down trend, and advise buy/sell accordingly.

currently we sell when we drop a certain percentage under the top, but if EMA/MACD says we are in an upward trend, it doesn't make sense to sell.
currently we buy when we grow a certain percentage above the deepest point, but if EMA/MACD says we are in a downward trend, it doesn't make sense to buy.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @DeviaVir, did you manage to implement this idea of yours?

@nibzo1
Copy link

nibzo1 commented Jul 3, 2017

@DeviaVir whats the status of this PR, seems like a good strategy for taking Max profit.

@DeviaVir
Copy link
Owner Author

DeviaVir commented Jul 3, 2017

@nibzo1 could definitely still use some more eyes, tweaks and other things. It also breaks the Windows version (by trying to install ta-lib) so I'm not merging unless I have contributor agreement at those pros and cons.

@nibzo1
Copy link

nibzo1 commented Jul 3, 2017

Ok sure thing I might bull changes and give it a test run, I'm not a windows user so I wont be able to assist there.

I can definitely do some sim's and even some live testing against the Kraken exchange and report back any odd behavior.

@bchadek
Copy link

bchadek commented Jul 13, 2017

I think the two ta_ strategies are so slow because the arrays used in the corresponding lib files grow rather large. Perhaps making the s.marketData just what is needed (close), instead of a multidimensional array, then slicing the last n that are needed into a new working array var will help

@@ -0,0 +1,136 @@
var z = require('zero-fill')

Choose a reason for hiding this comment

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

Could you comment what exactly this strategy does at the top? What you wrote in the description of this pr would be really awesome.

@DeviaVir
Copy link
Owner Author

My biggest mental blocker for this was Windows support. Which it looks like we have already broken, so I'm inclined to just merge this now and allow others to play with this in master.

@DeviaVir DeviaVir merged commit 255a057 into DeviaVir:master Jul 28, 2017
@DeviaVir DeviaVir deleted the deviavir/strategies branch July 28, 2017 10:20
christian452 pushed a commit to christian452/zenbot that referenced this pull request Aug 4, 2017
…os8f-master

* 'master' of https://github.com/carlos8f/zenbot:
  Improve command help for train command (DeviaVir#436)
  Support for missing win/loss and error rate from output (DeviaVir#426)
  Fix docker builds for forex.analytics (DeviaVir#424)
  Minor fixes for Quadriga trading API (DeviaVir#421)
  xmpp for trading alarms (DeviaVir#333)
  Strategies: TA (ema+macd) and Trust/Distrust (DeviaVir#285)
  Fixed docker build (DeviaVir#349)
  updated c.default_selector to c.selector in README.md (DeviaVir#418)
  added check for message before doing anything with it (DeviaVir#412)
  FIX: Properly check for unknown indicators in forex_analytics (DeviaVir#408)
  Added support for the BTCe exchange (DeviaVir#388)
  Add strategy: forex.analytics, an genetic optimization algorithm for TA-lib stats (DeviaVir#389)

# Conflicts:
#	.gitignore
#	commands/sim.js
#	extensions/exchanges/bittrex/exchange.js
#	extensions/exchanges/quadriga/exchange.js
#	lib/engine.js
#	scripts/auto_backtester/backtester.js
supersabbath pushed a commit to supersabbath/zenbot that referenced this pull request Oct 2, 2017
node-gyp and node v8.x are not friends, stick to boron for now

Rename talib's MACD (DeviaVir#2)

* Rename talib's MACD so it doesn't overlap with original macd
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants