garethdmm / gryphon

Powerful, proven, and extensible framework for building trading strategies at any frequency, with a focus on crypto currencies. Battle-tested with billions traded.
http://www.gryphonframework.org
Other
1.05k stars 151 forks source link

Dashboard #27

Open mattstone opened 5 years ago

mattstone commented 5 years ago

I've been able to play around with different strategies, but can't seem to get the dashboard to work.

I get this error.

(venv) zen:dashboards matt$ gryphon-dashboards

INFO:gryphon.dashboards.app:Could not find a gds credential, orderbook and other dashboards won't be operational WARNING:root:404 GET /webpack_hmr (::1) 3.00ms - FAST WARNING:root:404 GET /__webpack_hmr (::1) 1.21ms - FAST WARNING:root:404 GET /webpack_hmr (::1) 0.91ms - FAST

As I've downloaded from source, do I need to build the webpack version of the site?

Or any other pointers you can provide?

Thanks guys.

garethdmm commented 5 years ago

I don't know what webpack is, but it isn't part of Gryphon (a grep in the repo will say the same). As well, the GDS warning there is innocuous.

Where are you navigating to with your browser? With gryphon-dashboards running you should be able to navigate to localhost:8080 and see the login screen at least.

Also, the process just pauses after those lines you posted, right? It doesn't instant quit back to the terminal?

mattstone commented 5 years ago

ah.. thanks.

This page https://gryphon.readthedocs.io/en/latest/dashboards.html

Has this line.

Point your web browser at localhost:8000 and you should see this login screen:

I develop with Vue & React & had another browser window pointing at 8080 - hence the message I was getting.

garethdmm commented 5 years ago

Just to be clear it does work with localhost:8080?

I think changing the default port may have been a late change before release, I'll update the docs and mention this issue in the PR.

mattstone commented 5 years ago

Hi Gareth.

Yep it loads and I can login.

I've run the Simple Market Making Strategy for awhile, then attempted to select this from the Trading Menu. This is the error that occurs.

ERROR:tornado.application:Exception in exception handler Traceback (most recent call last): File "/Users/matt/projects/internetschminternet/gryphon/venv/lib/python2.7/site-packages/tornado/web.py", line 1597, in _execute self._handle_request_exception(e) File "/Users/matt/projects/internetschminternet/gryphon/venv/lib/python2.7/site-packages/tornado/web.py", line 1650, in _handle_request_exception self.send_error(500, exc_info=sys.exc_info()) File "/Users/matt/projects/internetschminternet/gryphon/gryphon-master/gryphon/dashboards/handlers/base.py", line 48, in send_error print str(vars(status_code)) TypeError: vars() argument must have dict attribute

I'll poke around in the source tonight and see if I can workout what is going on.

garethdmm commented 5 years ago

That does look like you're getting a 500, but the actual stack trace is being hidden because there's an error in the exception handler. Any chance you added a print statement in base.py at line 48?

print str(vars(status_code))
mattstone commented 5 years ago

Thanks Gareth.

This is actually the error before the above one - I'll add the print statement as you ask tonight.

INFO:gryphon.dashboards.app:Could not find a gds credential, orderbook and other dashboards won't be operational INFO:root:200 GET / (::1) 221.95ms - PRETTY SLOW /Users/matt/projects/internetschminternet/gryphon/venv/lib/python2.7/site-packages/sqlalchemy/sql/sqltypes.py:242: SAWarning: Unicode type received non-unicode bind param value 'SIMPLE_MM'. (this warning may be suppressed after 10 occurrences) (util.ellipses_string(value),)) ERROR:tornado.application:Uncaught exception GET /strategies/simple_mm (::1) HTTPServerRequest(protocol='http', host='localhost:8080', method='GET', uri='/strategies/simple_mm', version='HTTP/1.1', remote_ip='::1') Traceback (most recent call last): File "/Users/matt/projects/internetschminternet/gryphon/venv/lib/python2.7/site-packages/tornado/web.py", line 1590, in _execute result = method(*self.path_args, *self.path_kwargs) File "/Users/matt/projects/internetschminternet/gryphon/venv/lib/python2.7/site-packages/tornado/web.py", line 3006, in wrapper return method(self, args, kwargs) File "/Users/matt/projects/internetschminternet/gryphon/gryphon-master/gryphon/dashboards/handlers/strategies/strategy.py", line 63, in get self.render_template('strategy.html', args=template_args) File "/Users/matt/projects/internetschminternet/gryphon/gryphon-master/gryphon/dashboards/handlers/admin_base.py", line 109, in render_template return self.render(template, kwargs) File "/Users/matt/projects/internetschminternet/gryphon/venv/lib/python2.7/site-packages/tornado/web.py", line 766, in render html = self.render_string(template_name, kwargs) File "/Users/matt/projects/internetschminternet/gryphon/venv/lib/python2.7/site-packages/tornado/web.py", line 907, in render_string return t.generate(namespace) File "/Users/matt/projects/internetschminternet/gryphon/venv/lib/python2.7/site-packages/tornado/template.py", line 346, in generate return execute() File "templates/strategy_html.generated.py", line 107, in _tt_execute _tt_tmp = '%s %.2f' % (args['open_pl'].currency, args['open_pl'].amount) # templates/strategy.html:51 (via templates/base.html:207) AttributeError: 'NoneType' object has no attribute 'currency'

garethdmm commented 5 years ago

Hmm ok, let me take a closer look at this tomorrow morning.

garethdmm commented 5 years ago

After a quick refresher on this, this is a known issue with a simple fix I've had in a branch for about a month. The issue is that open_pl in the strategy handler isn't initialized with a default value, so if the strategy has no trading history (or, I think, only a single trade such that you can't calculate a realized p&l for it), the page will error.

I'll try to merge those changes this weekend, but in the meantime if you want to fix it in your version and create a patch back to the repo, that would be appreciated too!

garethdmm commented 5 years ago

@mattstone #38 is in progress and has multiple dashboard fixes including I believe the fix for your Nonetype issue. It'll be into master in the next day or two.

The specific fix is in this commit: https://github.com/garethdmm/gryphon/pull/38/commits/2fd690f83f0b25d6e8d5db613d89fe88139191a5

mattstone commented 5 years ago

Thanks for following this up.

Lz-Gustavo commented 4 years ago

Just faced this same issue today while trying to monitor some simple strategies on the dashboard. Managed to avoid it by adding a simple if statement on template/strategy.html line 51, as shown below. Then noticed #47 commit 2fd690f with a much better solution already implemented.

{% if args['open_pl'] %}
  <h3>{{ '%s %.2f' % (args['open_pl'].currency, args['open_pl'].amount) }}</h3>
{% end %}

So, if the branch is ok, could you please merge dashboard_overhaul when possible? Just merged locally without any conflict resolution.