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

RSI always at 20 #151

Closed
FreshLondon opened this issue May 15, 2017 · 29 comments
Closed

RSI always at 20 #151

FreshLondon opened this issue May 15, 2017 · 29 comments
Labels

Comments

@FreshLondon
Copy link

FreshLondon commented May 15, 2017

Every time i run the bot my RSI is always 20 or near there!
Albeit I'm running a modded version of the poloniex bot, but havent changed anything RSI wise.
Could this be an issue with how its calculating it?

At poresent its not performing well at all as the RSI is stuck on a fixed amount.

Anyone else experiencing the same?

@FreshLondon
Copy link
Author

May i also ask, if i CTRL+C out of the current process and restart the bot - does this reset the RSI calc, or is the RSI calc stored and used again?

I restarted to get a fluctuating RSI between 48-53 but after stopping and starting the bot its quickly down back to 20.

Any help in understanding how this is worked out would be greatly appreciated.

@carlos8f
Copy link
Contributor

Hi,

The RSI in zenbot 3 uses the persistence of the run_state, so you can reset it either by dropping the run_state collection in mongo, or deleting just the record with the RSI's, or telling zenbot to create a new run_state with --rs some_new_run_state.

However, zenbot 4 will be dropping soon and it ditches RSI in favor of EMA, and also ditches the statically calculated map/reduce model and re-calculates indicators on the fly instead. So far it's much more agreeable to work with and I'd highly recommend waiting for it. It doesn't have Poloniex support yet, but I'm working on it.

@nedievas
Copy link
Contributor

Hi,
I'd like to help making support for Bitfinex. Where should I start, or is it too early for zenbot 4 to test?

@tuxitor
Copy link
Contributor

tuxitor commented May 16, 2017

Hello,
I already have done some programming on the Bitstamp APIfor zenbot 4, using GDAX as a template. However, I may need help with some functions as the Bitstamp API is quite different. The fact that Bitstamp doesn't supply much long term trade history may pose some challenges during development phase when the app needs a lot of stopping/starting.

@carlos8f: I don't feel well to make my own repository for Bitstamp, because I am an old man and not a node programmer meaning that I cannot make much of long term maintenance commitments, so please make the repository. I have the files. Maybe you could make a new discussion thread for work on APIs and/or a README documenting the API requirements?

@nedievas: Bitfinex would have been my next try. I am already using your Bitfinex implementation and have written the logic for Bitstamp using your work as a template.

Thanks

@carlos8f
Copy link
Contributor

carlos8f commented May 16, 2017

the 4.x branch is relatively stable right now, and writing support for an exchange would consist of copying extensions/gdax to extensions/{exchange}, re-implementing the functions in exchange.js, and ensuring the input/output of the functions remains consistent with the GDAX api. I need to document exactly what zenbot requires, but you could play around with it now if you like.

@EigilB I appreciate your offer, but I'm hesitant to support Bitstamp mostly because the fees are too steep. They don't offer a 0% fee for makers, all order types have a 0.25% fee which I believe would make 1-2 trades per day (as 4.x currently averages) unprofitable. I'm aiming for zenbot 4.x to exclusively use post-only orders, and not incur fees (or at least Bitfinex cuts the fee in half). Also exchanges that I'm comfortable maintaining will be in the zenbot repo, and others (such as that don't allow US citizens to make accounts) could be maintained in external repos.

Also as you mentioned there is the trade history problem. There are some 3rd party free api's that may fill the gap, such as cryptowat.ch. zenbot 4 currently processes raw trades into OHLC, but for markets that have a historical OHLC api and no historical trades, I could probably adapt the engine to use either.

@tuxitor
Copy link
Contributor

tuxitor commented May 16, 2017

the 4.x branch is relatively stable right now, and writing support for an exchange would consist of copying extensions/gdax to extensions/{exchange}, re-implementing the functions in exchange.js, and ensuring the input/output of the functions remains consistent with the GDAX api. I need to document exactly what zenbot requires, but you could play around with it now if you like.

That is exacly what I have done. Your API code is quite clear and slim, and most of the functions are straight forward to reimplement. The getTrades may need some more work, however.

I appreciate your offer, but I'm hesitant to support Bitstamp mostly because the fees are too steep. They don't offer a 0% fee for makers, all order types have a [0.25% fee]https://www.bitstamp.net/fee_schedule/) which I believe would make 1-2 trades per day (as 4.x currently averages) unprofitable. I'm aiming for zenbot 4.x to exclusively use post-only orders, and not incur fees (or at least Bitfinex cuts the fee in half. Also exchanges that I'm comfortable maintaining will be in the zenbot repo, and others (such as that don't allow US citizens to make accounts) could be maintained in external repos.

I am aware of the fee problem, but for people living in Europe, Bitstamp may be the easiest option. Money transfer is quick and easy using SEPA. I also made an account on GDAX, but unfortunately after depositing some coins there I discovered that GDAX don't allow people situated in Europe to trade USD. The only fiat option is EUR, and the volume on BTC-EUR market is very low, which resulted in withdrawal of my assets.

Also as you mentioned there is the trade history problem. There are some 3rd party free api's that may fill the gap, such as cryptowat.ch. zenbot 4 currently processes raw trades into OHLC, but for markets that have a historical OHLC api and no historical trades, I could probably adapt the engine to use either.

An option for me could be to have a daemon continuosly running in parallel just to collect trades from Bistamp into a db. Then zenbot could possibly look for trades in the db to fill the gap when starting after a longer stop. Bitfinex have the same history problem, BTW.

@carlos8f
Copy link
Contributor

An option for me could be to have a daemon continuosly running in parallel just to collect trades from Bistamp into a db.

currently in the 4.x branch you can do this by running another trade process with the --paper flag (the paper trades being ignored), I added realtime trade saving last night, which combined with the resuming backfiller that runs when the trade command starts, should fill the gap up to the present.

Bitfinex have the same history problem, BTW.

Yeah I may have to use cryptowat.ch API for that. Running trade currently requires about 2 days of trade data to warm up the EMA, and I think that should be fine with the rate-limit they use.

@urnotsam
Copy link

@carlos8f is the 4.x branch stable enough to start using (with caution of course)?

@nedievas
Copy link
Contributor

the 4.x branch is relatively stable right now, and writing support for an exchange would consist of copying extensions/gdax to extensions/{exchange}, re-implementing the functions in exchange.js, and ensuring the input/output of the functions remains consistent with the GDAX api. I need to document exactly what zenbot requires, but you could play around with it now if you like.

I tried to unsuccessfully test according to readme.md. Is there other way to make it run?

@urnotsam
Copy link

I will try when i get home @nedievas. Are you switching to the 4.x branch when you follow the steps in the README.

@nedievas
Copy link
Contributor

@urnotsam Yes. I use exactly 4.x branch.

[bfxbot@gene ~]$ cd zenbot-4.x/
[bfxbot@gene zenbot-4.x]$ ls
3x  boot.js  _codemap.js  commands  conf-sample.js  db  extensions  IDEA-watcher.md  index.js  lib  package.json  README.md  templates  zenbot.sh
[bfxbot@gene zenbot-4.x]$ npm install
zenbot4@4.0.0 /home/bfxbot/zenbot-4.x
├─┬ codemap@1.3.1
│ └─┬ debug@2.6.6
│   └── ms@0.7.3
├── colors@1.1.2
├─┬ commander@2.9.0
│ └── graceful-readlink@1.0.1
├─┬ glob@7.1.1
│ ├── fs.realpath@1.0.0
│ ├─┬ inflight@1.0.6
│ │ └── wrappy@1.0.2
│ ├── inherits@2.0.3
│ ├─┬ minimatch@3.0.4
│ │ └─┬ brace-expansion@1.1.7
│ │   ├── balanced-match@0.4.2
│ │   └── concat-map@0.0.1
│ ├── once@1.4.0
│ └── path-is-absolute@1.0.1
├── idgen@2.0.2
├── micro-request@666.0.10
├── minimist@1.2.0
├── moment@2.18.1
├─┬ mongodb@2.2.26
│ ├── es6-promise@3.2.1
│ ├─┬ mongodb-core@2.1.10
│ │ ├── bson@1.0.4
│ │ └─┬ require_optional@1.0.0
│ │   ├── resolve-from@2.0.0
│ │   └── semver@5.3.0
│ └─┬ readable-stream@2.2.7
│   ├── buffer-shims@1.0.0
│   ├── core-util-is@1.0.2
│   ├── isarray@1.0.0
│   ├── process-nextick-args@1.0.7
│   ├── string_decoder@1.0.0
│   └── util-deprecate@1.0.2
├── numbro@1.8.1  (git+https://github.com/carlos8f/numbro.git#e6e9a0d5f4c32939a7c19cf1546c7766b38cd31f)
├── run-parallel@1.1.6
├── run-series@1.1.4
├─┬ sosa_mongo@1.0.3
│ └── sosa@1.1.3
├── timebucket@0.4.0
└── zero-fill@2.2.3

npm WARN zenbot4@4.0.0 No repository field.
npm WARN zenbot4@4.0.0 No license field.
[bfxbot@gene zenbot-4.x]$ zenbot init
-bash: zenbot: command not found
[bfxbot@gene zenbot-4.x]$ ./zenbot.sh init
-bash: ./zenbot.sh: Permission denied
[bfxbot@gene zenbot-4.x]$ chmod 744 zenbot.sh
[bfxbot@gene zenbot-4.x]$ ./zenbot.sh init
module.js:471
    throw err;
    ^

Error: Cannot find module 'gdax'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/bfxbot/zenbot-4.x/extensions/gdax/exchange.js:1:74)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)

That's it. Step by step of readme.md.

@urnotsam
Copy link

It looks like you should make a new copy of sample-config.js and call it gdax.js and fill in the required parameters in there. Then also on line 24 of exchange.js you hsould replace 'YOUR-API-KEY' with the api key you just added to the new gdax.js.

I haven't tried this as im still at work, but reading through the code makes it seem like that is the problem. Let me know if it works.

@nedievas
Copy link
Contributor

nedievas commented May 16, 2017

Nope.
cp sample-config.js gdax.js does produce the same error.
I don't have GDAX account, so I'm not able to have API key. But I suppose it is not necessary to collect public data.

There should be a node_module like gdax. But it is not installed by default.

@urnotsam
Copy link

Hmm, okay. I will try to look into more later if no one has answered by then.

@tuxitor
Copy link
Contributor

tuxitor commented May 16, 2017

Remember to also do a 'npm install' in the 'extension/gdax' directory

@urnotsam
Copy link

Also the sample file is conf-sample.js. That was my bad so you should do cp conf-sample.js gdax.js and also do what @EigilB said.

@nedievas
Copy link
Contributor

I did this in the / directory:
[bfxbot@gene zenbot-4.x]$ npm install gdax
and it came out:

[bfxbot@gene zenbot-4.x]$ ./zenbot.sh init

  Usage: zenbot [options] [command]


  Commands:

    list-selectors                 list available selectors
    backfill [options] [selector]  download historical trades for analysis
    sim [options] [selector]       run a simulation on backfilled data
    trade [options] [selector]     run trading bot against live market data
    buy [options] [selector]       execute a buy order to the exchange
    sell [options] [selector]      execute a sell order to the exchange

  Options:

    -h, --help     output usage information
    -V, --version  output the version number

@nedievas
Copy link
Contributor

nedievas commented May 16, 2017

also did as @EigilB said. The same output from zenbot init. Readme.md is obsolete. You Must follow this output options.

@urnotsam
Copy link

@nedievas Great! now you can do some testing on backfill data and check how stable it is and its performance.

@tuxitor
Copy link
Contributor

tuxitor commented May 16, 2017

A trick to do test runs without the risk of losing money is to generate key/secret pair with only RO permissions

@nedievas
Copy link
Contributor

nedievas commented May 16, 2017

option 'list-selectors' not working. Backfill is good to go.

@nedievas
Copy link
Contributor

I will try to convert to Bitfinex when I finish to inspect all the working options on GDAX.

@deadchannelsky
Copy link

I've been trying to get 4.x to work on some level... However, after cloning and npm install in zenbot root and Gdax root. "./zenbot " only produces "list-Selectors", "backfill" and "sim".

list selectors does not work, it just lists the above options as if there is no parameter being passed.
Currently backfilling will report.

@nedievas
Copy link
Contributor

No sim after backfill:

......................
gdax.BTC-USD saved 14000 trades 0 days left

download complete!

[bfxbot@gene zenbot-4.x]$ ./zenbot.sh sim
{ strategy: 'trend_ema',
  sell_stop_pct: 0,
  buy_stop_pct: 0,
  profit_stop_enable_pct: 10,
  profit_stop_pct: 1,
  max_sell_loss_pct: 25,
  max_slippage_pct: 2,
  buy_pct: 99,
  sell_pct: 99,
  markup_pct: 0,
  currency_capital: 1000,
  asset_capital: 0,
  order_adjust_time: 30000,
  rsi_periods: 14,
  stats: false,
  selector: 'gdax.BTC-USD',
  mode: 'sim',
  period: '1h',
  min_periods: 36,
  trend_ema: 34,
  buy_rate: 0,
  sell_rate: 0,
  max_buy_duration: 1,
  max_sell_duration: 1 }
no trades found! try running `zenbot backfill gdax.BTC-USD` first

@carlos8f
Copy link
Contributor

@nedievas it's a bug, add --days=<days>

@nedievas
Copy link
Contributor

Cool! We have paper trading!

[bfxbot@gene zenbot-4.x]$ ./zenbot.sh trade --paper gdax.BTC-USD
fetching pre-roll data:

gdax.BTC-USD saved 100 trades 4 days left
............................................................................................................................................
skipping 2160 hrs of previously collected data
.
download complete!

               DATE            PRICE     DIFF            VOL         RSI                         ACTIONS                      BAL                PROFIT
2017-05-14 08:00:00      1789.73 USD                  232.22                      null
2017-05-14 09:00:00      1800.38 USD   +0.60%         138.26                      null
2017-05-14 10:00:00      1801.34 USD   +0.05%         115.34                      null
2017-05-14 11:00:00      1821.92 USD   +1.14%         169.36                      null
2017-05-14 12:00:00      1818.08 USD   -0.21%         146.85                      null
2017-05-14 13:00:00      1825.76 USD   +0.42%         139.36                      null
2017-05-14 14:00:00      1808.54 USD   -0.94%         187.13                      null
2017-05-14 15:00:00      1799.68 USD   -0.49%         227.83                      null
2017-05-14 16:00:00      1802.39 USD   +0.15%         205.39                      null
2017-05-14 17:00:00      1803.99 USD   +0.09%         233.63                      null
2017-05-14 18:00:00      1804.93 USD   +0.05%         208.43                      null
2017-05-14 19:00:00      1784.70 USD   -1.12%         237.20                      null
2017-05-14 20:00:00      1775.85 USD   -0.50%         422.10                      null
2017-05-14 21:00:00      1778.10 USD   +0.13%         220.65                      null
2017-05-14 22:00:00      1785.82 USD   +0.43%         187.29      ++              null
2017-05-14 23:00:00      1774.85 USD   -0.61%         236.62      +               null
2017-05-15 00:00:00      1798.87 USD   +1.35%         328.87      ++              null
2017-05-15 01:00:00      1798.99 USD   +0.01%         223.50      ++              null
2017-05-15 02:00:00      1798.82 USD   -0.01%         219.22      ++              null
2017-05-15 03:00:00      1799.99 USD   +0.07%         245.59      ++              null
2017-05-15 04:00:00      1799.61 USD   -0.02%         177.94      ++              null
2017-05-15 05:00:00      1793.91 USD   -0.32%         270.68      ++              null
2017-05-15 06:00:00      1786.00 USD   -0.44%         331.48      +               null
2017-05-15 07:00:00      1788.64 USD   +0.15%         324.07      +               null
2017-05-15 08:00:00      1767.20 USD   -1.20%         423.41    --                null
2017-05-15 09:00:00      1767.55 USD   +0.02%         300.81    --                null
2017-05-15 10:00:00      1775.94 USD   +0.47%         173.04     -                null
2017-05-15 11:00:00      1761.09 USD   -0.84%         115.32    --                null
2017-05-15 12:00:00      1736.00 USD   -1.42%         592.06   ---                null
2017-05-15 13:00:00      1747.00 USD   +0.63%         396.82    --                null
2017-05-15 14:00:00      1754.41 USD   +0.42%         313.05    --                null
2017-05-15 15:00:00      1764.62 USD   +0.58%         215.34     -                null
2017-05-15 16:00:00      1753.00 USD   -0.66%         212.37    --                null
2017-05-15 17:00:00      1750.00 USD   -0.17%         578.33    --                null
2017-05-15 18:00:00      1730.99 USD   -1.09%         481.04    --                null
2017-05-15 19:00:00      1728.29 USD   -0.16%         835.48   ---       -0.1744  sell
2017-05-15 20:00:00      1734.06 USD   +0.33%         653.46    --       -0.1461  null
2017-05-15 21:00:00      1731.00 USD   -0.18%         580.60    --       -0.1478  null
2017-05-15 22:00:00      1723.42 USD   -0.44%         574.94   ---       -0.1640  null
2017-05-15 23:00:00      1718.00 USD   -0.31%         539.17   ---       -0.1724  null
2017-05-16 00:00:00      1726.00 USD   +0.47%         373.04    --       -0.1370  null
2017-05-16 01:00:00      1743.99 USD   +1.04%         753.10     -       -0.0711  null
2017-05-16 02:00:00      1759.30 USD   +0.88%         437.90      +      -0.0175  null
2017-05-16 03:00:00      1747.81 USD   -0.65%         517.76     -       -0.0537  null
2017-05-16 04:00:00      1733.69 USD   -0.81%         656.33    --       -0.0964  null
2017-05-16 05:00:00      1737.33 USD   +0.21%         470.98    --       -0.0792  null
2017-05-16 06:00:00      1728.59 USD   -0.50%         334.91    --       -0.1031  null
2017-05-16 07:00:00      1709.76 USD   -1.09%        1303.52    --       -0.1585  null
2017-05-16 08:00:00      1722.01 USD   +0.72%         684.69    --       -0.1098  null
2017-05-16 09:00:00      1709.81 USD   -0.71%         412.28    --       -0.1434  null
2017-05-16 10:00:00      1719.88 USD   +0.59%         563.39    --       -0.1025  null
2017-05-16 11:00:00      1714.27 USD   -0.33%         228.70    --       -0.1151  null
2017-05-16 12:00:00      1727.00 USD   +0.74%         202.80     -       -0.0670  null
2017-05-16 13:00:00      1730.98 USD   +0.23%         404.41     -       -0.0502  null
2017-05-16 14:00:00      1741.51 USD   +0.61%         519.44      +      -0.0129  null
2017-05-16 15:00:00      1740.08 USD   -0.08%         258.19      +      -0.0168  null
2017-05-16 16:00:00      1749.98 USD   +0.57%         315.11      ++      0.0165   buy
2017-05-16 17:00:00      1752.74 USD   +0.16%         394.22      ++      0.0246  null
2017-05-16 18:00:00      1759.46 USD   +0.38%         590.41      ++      0.0452  null
2017-05-16 19:00:00      1767.99 USD   +0.48%         602.79      ++      0.0705  null
2017-05-16 20:00:00      1772.71 USD   +0.27%         404.24      ++      0.0819  null
2017-05-16 21:00:00      1774.97 USD   +0.13%         499.74      ++      0.0845  null
2017-05-16 22:00:00      1762.71 USD   -0.69%         417.84      ++      0.0396  null
2017-05-16 23:00:00      1768.18 USD   +0.31%         412.24      ++      0.0552  null
2017-05-17 00:00:00      1768.14 USD    0.00%         325.75      ++      0.0519  null
2017-05-17 01:00:00      1759.72 USD   -0.48%         500.20      +       0.0214  null
2017-05-17 02:00:00      1764.01 USD   +0.24%         404.00      ++      0.0342  null
2017-05-17 03:00:00      1777.02 USD   +0.74%         477.57      ++      0.0746  null
2017-05-17 04:00:00      1773.03 USD   -0.22%         530.75      ++      0.0573  null
2017-05-17 05:00:00      1757.15 USD   -0.90%         935.43      +       0.0023  null
2017-05-17 06:00:00      1777.93 USD   +1.18%        1461.44      ++      0.0698  null
2017-05-17 07:00:00      1809.04 USD   +1.75%        1030.35      +++     0.1669  null
---------------------------- STARTING PAPER TRADING ----------------------------
2017-05-17 07:19:39      1821.12 USD   +0.67%         147.71      +++     0.1963  null                          0.000000 BTC      1000.00 USD     0.00%   +0.00%

@nedievas
Copy link
Contributor

@carlos8f Thanks. Now I see how it is going.

{ days: 14,
  strategy: 'trend_ema',
  sell_stop_pct: 0,
  buy_stop_pct: 0,
  profit_stop_enable_pct: 10,
  profit_stop_pct: 1,
  max_sell_loss_pct: 25,
  max_slippage_pct: 2,
  buy_pct: 99,
  sell_pct: 99,
  markup_pct: 0,
  currency_capital: 1000,
  asset_capital: 0,
  order_adjust_time: 30000,
  rsi_periods: 14,
  end: 1494979200000,
  start: 1493769600000,
  stats: false,
  selector: 'gdax.BTC-USD',
  mode: 'sim',
  period: '1h',
  min_periods: 36,
  trend_ema: 34,
  buy_rate: 0,
  sell_rate: 0,
  max_buy_duration: 1,
  max_sell_duration: 1 }
end balance 1311.63 (31.16%)
buy hold 1208.95 (20.89%)
vs. buy hold 8.49%
35 trades over 15 days (avg 2.33 trades/day)
wrote sim_result.html

@stevepm
Copy link

stevepm commented May 19, 2017

@nedievas Have you seen the paper trader actually make any trades? I've had mine running for a few days and haven't seen it make any trades.

@DeviaVir
Copy link
Owner

DeviaVir commented Jun 3, 2017

Is this issue still valid, or can we close this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

8 participants