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

Error Apparently due to XMPP being enabled. #459

Closed
dmzpkts opened this issue Aug 8, 2017 · 13 comments
Closed

Error Apparently due to XMPP being enabled. #459

dmzpkts opened this issue Aug 8, 2017 · 13 comments
Labels

Comments

@dmzpkts
Copy link

dmzpkts commented Aug 8, 2017

I have managed to get zenbot to do everything but trade.

Upon attempting to trade I get this, right after the candlesticks.

(Edit: the reason the other commands were working was because I was using a conf file that did not have xmpp enabled, for testing, the only difference between the conf file I was using, and the live trading conf file was xmpp, and exchange keys.)

---------------------------- STARTING LIVE TRADING ----------------------------
/root/zenbot/node_modules/sosa_mongo/mongo_backend.js:33
      var tmp_obj = JSON.parse(JSON.stringify(obj))
                                    ^

TypeError: Converting circular structure to JSON
    at JSON.stringify (<anonymous>)
    at Object.save (/root/zenbot/node_modules/sosa_mongo/mongo_backend.js:33:37)
    at withHooks (/root/zenbot/node_modules/sosa/api.js:68:15)
    at Object.save (/root/zenbot/node_modules/sosa/api.js:65:12)
    at /root/zenbot/commands/trade.js:255:24
    at /root/zenbot/lib/engine.js:191:14
    at /root/zenbot/extensions/exchanges/poloniex/exchange.js:118:9
    at Request._callback (/root/zenbot/node_modules/poloniex.js/lib/poloniex.js:79:7)
    at Request.self.callback (/root/zenbot/node_modules/poloniex.js/node_modules/request/request.js:122:22)
    at emitTwo (events.js:125:13)
    at Request.emit (events.js:213:7)
    at Request.<anonymous> (/root/zenbot/node_modules/poloniex.js/node_modules/request/request.js:888:14)
    at emitOne (events.js:120:20)
    at Request.emit (events.js:210:7)
    at IncomingMessage.<anonymous> (/root/zenbot/node_modules/poloniex.js/node_modules/request/request.js:839:12)
    at emitNone (events.js:110:20)
    at IncomingMessage.emit (events.js:207:7)
    at endReadableNT (_stream_readable.js:1045:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
@DeviaVir
Copy link
Owner

DeviaVir commented Aug 9, 2017

What is the command you are trying to run?

@dmzpkts
Copy link
Author

dmzpkts commented Aug 10, 2017

All of the following commands produce the same error

zenbot trade --conf ./livepnex-conf.js --period 1h poloniex.GNT-BTC

zenbot trade --conf ./livepnex-conf.js --period 1h

zenbot trade --conf ./livepnex-conf.js

@dmzpkts
Copy link
Author

dmzpkts commented Aug 10, 2017

Warning: this is an ugly hack and I dont recommend this as a likely fix until a dev says something, but..

I was able to get trading to work by adding the circular-json library with npm:

npm install --save circular-json

then in zenbot/node_modules/sosa_mongo/mongo_backend.js

adding this to line number 2 of mongo_backend.js
const JSON = require('circular-json');

I know this is probably not the best practice.

@dmzpkts
Copy link
Author

dmzpkts commented Aug 10, 2017

I noticed some new output above the trading line. Maybe this will help diagnose something, it appears to not be saving the session from what I can tell. Any of the values below with *'s have been removed for my own privacy.

---------------------------- STARTING LIVE TRADING ----------------------------

2017-08-10 01:46:43 - error saving session
{ Error: cyclic dependency detected
at serializeObject (/home/bot/zenbot/node_modules/bson/lib/bson/parser/serializer.js:296:33)
at serializeInto (/home/bot/zenbot/node_modules/bson/lib/bson/parser/serializer.js:776:17)
at serializeObject (/home/bot/zenbot/node_modules/bson/lib/bson/parser/serializer.js:308:18)
at serializeInto (/home/bot/zenbot/node_modules/bson/lib/bson/parser/serializer.js:776:17)
at serializeObject (/home/bot/zenbot/node_modules/bson/lib/bson/parser/serializer.js:308:18)
at serializeInto (/home/bot/zenbot/node_modules/bson/lib/bson/parser/serializer.js:776:17)
at serializeObject (/home/bot/zenbot/node_modules/bson/lib/bson/parser/serializer.js:308:18)
at serializeInto (/home/bot/zenbot/node_modules/bson/lib/bson/parser/serializer.js:776:17)
at serializeObject (/home/bot/zenbot/node_modules/bson/lib/bson/parser/serializer.js:308:18)
at serializeInto (/home/bot/zenbot/node_modules/bson/lib/bson/parser/serializer.js:776:17)
at serializeObject (/home/bot/zenbot/node_modules/bson/lib/bson/parser/serializer.js:308:18)
at serializeInto (/home/bot/zenbot/node_modules/bson/lib/bson/parser/serializer.js:776:17)
at serializeObject (/home/bot/zenbot/node_modules/bson/lib/bson/parser/serializer.js:308:18)
at serializeInto (/home/bot/zenbot/node_modules/bson/lib/bson/parser/serializer.js:776:17)
at serializeObject (/home/bot/zenbot/node_modules/bson/lib/bson/parser/serializer.js:308:18)
at serializeInto (/home/bot/zenbot/node_modules/bson/lib/bson/parser/serializer.js:776:17)
at serializeObject (/home/bot/zenbot/node_modules/bson/lib/bson/parser/serializer.js:308:18)
at serializeInto (/home/bot/zenbot/node_modules/bson/lib/bson/parser/serializer.js:776:17)
at serializeObject (/home/bot/zenbot/node_modules/bson/lib/bson/parser/serializer.js:308:18)
at serializeInto (/home/bot/zenbot/node_modules/bson/lib/bson/parser/serializer.js:776:17)
at serializeObject (/home/bot/zenbot/node_modules/bson/lib/bson/parser/serializer.js:308:18)
at serializeInto (/home/bot/zenbot/node_modules/bson/lib/bson/parser/serializer.js:618:17)
saved: false,
obj:
{ id: '80b1284c',
selector: '',
started: 1502329601444,
mode: 'live',
options:
{ conf: './conf.js',
period: '1h',
indicators: '
',
strategy: 'trend_ema',
sell_stop_pct: 0,
buy_stop_pct: 0,
profit_stop_enable_pct: 0,
profit_stop_pct: 1,
max_slippage_pct: 5,
buy_pct: 99,
sell_pct: 99,
order_adjust_time: 5000,
max_sell_loss_pct: 20,
order_poll_time: 5000,
markup_pct: 0,
order_type: 'maker',
poll_trades: 30000,
currency_capital: 1000,
asset_capital: 0,
rsi_periods: 14,
avg_slippage_pct: 0.045,
debug: undefined,
stats: true,
mode: 'live',
mongo: [Object],
selector: '',
gdax: [Object],
poloniex: [Object],
kraken: [Object],
bittrex: [Object],
bitfinex: [Object],
bitstamp: [Object],
quadriga: [Object],
btce: [Object],
gemini: [Object],
wait_for_settlement: 5000,
days: 14,
symmetrical: false,
balance_snapshot_period: '15m',
xmppon: 1,
xmpp: [Object],
xmppto: '
',
min_periods: 52,
trend_ema: 26,
neutral_rate: 'auto',
oversold_rsi_periods: 14,
oversold_rsi: 10 },
updated: 1502329603166,
balance:
{ id: '-15m1669255',
selector: '
',
time: 1502329500000,
currency: '0.00000000',
asset: '*',
price: 0.00009001,
start_capital: *,
start_price: 0.0000902,
consolidated: 0.0432082964753541,
profit: -0.0021064301552106463,
buy_hold: 0.0432082964753541,
buy_hold_profit: -0.0021064301552106463,
vs_buy_hold: 0 },
start_capital: *,
start_price: 0.0000902,
num_trades: 0,
orig_capital: *,
orig_price: 0.0000902,
price: 0.00009001 } }

And then after this it begins live trading.

@dmzpkts
Copy link
Author

dmzpkts commented Aug 10, 2017

After disabling xmpp, the error when starting trading went away.

Edit: I Would like to be able to use XMPP for trading notification, so do you want me to open a new report? or can we turn this from a question into a bug?

@dmzpkts dmzpkts changed the title Error when live trading. Error Apparently due to XMPP being enabled. Aug 10, 2017
@dmzpkts
Copy link
Author

dmzpkts commented Aug 10, 2017

I have narrowed it down to enabling xmpp.

When I enable xmpp. I get errors on just about every command about circular structure errors.

When I disable xmpp. it works fine.

I'd like to use xmpp.

(Edit: it is worth noting, that with my hack allowing the circular structure to be flattened so it didnt puke on the trade command, the bot did sign on to xmpp, I am not 100% certain a trade occured during the time it was enabled, but I did see the account log on, I just never received any messages)

@dmzpkts
Copy link
Author

dmzpkts commented Aug 10, 2017

It would seem to me that the xmpp object isnt being handled correctly (because it possibly contains a circular reference?) when it comes to the conf object for saving. Im not 100% sure as js is not one of the languages I frequently use.

@tuxitor
Copy link
Contributor

tuxitor commented Aug 10, 2017

@dmzpkts
If you would like to get xmpp messages, you could look at this fork:
https://github.com/tuxitor/zenbot
With the zentalk branch you will get XMPP messages from several subscribed events. You can also turn debug on/off an set some variables during a zenbot run and a lot more. More information here:
https://github.com/tuxitor/zenbot/blob/zentalk/docs/Zentalk.md Work in progress.
You can easily find me on the discord zenbot channel as tuxador. https://discord.gg/NKnu8N

@piedrogenius
Copy link
Contributor

Did you do an: npm install simple-xmpp

I forgot to include this dependance in package.json

@cpjolicoeur
Copy link
Contributor

cpjolicoeur commented Feb 7, 2018

I get this same issue, but unrelated to XMPP. I don't have XMPP enabled, but see this circular issue with the GDAX exchange in the trade file.

/home/cpjolicoeur/zenbot/node_modules/sosa_mongo/mongo_backend.js:33
      var tmp_obj = JSON.parse(JSON.stringify(obj))
                                    ^

TypeError: Converting circular structure to JSON
    at JSON.stringify (<anonymous>)
    at Object.save (/home/cpjolicoeur/zenbot/node_modules/sosa_mongo/mongo_backend.js:33:37)
    at withHooks (/home/cpjolicoeur/zenbot/node_modules/sosa/api.js:68:15)
    at Object.save (/home/cpjolicoeur/zenbot/node_modules/sosa/api.js:65:12)
    at /home/cpjolicoeur/zenbot/commands/trade.js:586:22
    at /home/cpjolicoeur/zenbot/lib/engine.js:220:9
    at Object.getQuote (/home/cpjolicoeur/zenbot/extensions/exchanges/gdax/exchange.js:270:11)
    at /home/cpjolicoeur/zenbot/lib/engine.js:209:18
    at /home/cpjolicoeur/zenbot/extensions/exchanges/gdax/exchange.js:261:9
    at Request._callback (/home/cpjolicoeur/zenbot/node_modules/gdax/lib/clients/public.js:64:9)

So I don't think this is XMPP related.

Every session save fails from this point forward. I can dump the log output like @dmzpkts did if anyone wants to see it. I'm not fully sure how this will affect the bot going forward as it doesn't appear to be saving historical data to my DB so back analytics probably won't survive a restart?

My thought is maybe I have corrupted data in Mongo?

I think I may git bisect back out to an earlier checkout and see if the problem persists.

@cpjolicoeur
Copy link
Contributor

As a follow-up, I was previously on commit 2bda376 and did a full git pull of unstable today to get the latest and started having this issue. After a server update, the 2bda376 commit was throwing allocation errors for me, so I attempted to just grab the latest code and that is when I started running into this issue.

So I rolled back to 2bda376, blew away node_modules, re-installed and ran zenbot again. I no longer get the circular JSON errors, but I still am back to my original issue with stack allocation errors.

That, I believe is related to the upgrade of other server software are my machine and potentially unrelated to zenbot. These errrors are:

terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
./zenbot.sh: line 2: 15364 Aborted                 env node zenbot.js $@

@gtfoomwgtr
Copy link

I'm having the exact same thing as cpjolicoeur and I believe it's also due to a recent update. I have another zenbot that is working fine (no circular structure errors) and the only difference is that it was built two days ago. How do I roll back the version so I can get this working - thanks.

@Netzarim
Copy link

Netzarim commented Feb 8, 2018

I was running normally too - until today... same errors as above...

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

7 participants