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

Web Usage #338

Closed
jhnferraris opened this issue Jun 23, 2016 · 25 comments
Closed

Web Usage #338

jhnferraris opened this issue Jun 23, 2016 · 25 comments

Comments

@jhnferraris
Copy link
Contributor

Any docs for running this in the web?

@askmike
Copy link
Owner

askmike commented Jun 23, 2016

You mean with a web interface? I'm running it in a cloud box right now (using SSH).

@jhnferraris
Copy link
Contributor Author

jhnferraris commented Jun 23, 2016

Hello Mike! I mean if I want to run the "web" component of this app locally? I saw there's a web/server.js in the directory.

@askmike
Copy link
Owner

askmike commented Jun 23, 2016

unfortunately it was never fully implemented, see #156.

It's very easy to add, but could you let me know:

What exactly would you use the webserver for? Just monitoring markets / trading advice is easy, but I imagine you actually want to configure / backtest.

@jhnferraris
Copy link
Contributor Author

jhnferraris commented Jun 23, 2016

For now I just want to move the logs from the console on markets/trading advice to a simple browser log. If it is easy, maybe you can guide us through it? I think no docs written for this?

@askmike
Copy link
Owner

askmike commented Jun 23, 2016

So if you very simply just want the same logs in your browser the easiest way would be something like this (works great on linux and os x, not 100% sure about windows):

In one terminal start gekko and pipe output to file

node gekko > log.txt

In another terminal / command prompt:

npm install -g http-server
http-server

Finally, in your browser go to: http://localhost:8080/log.txt. Note that you have to refresh every time you want to see new data.


The other way would be something that I tried in #156. It would be a simple plugin that starts a server and pushes new logdata over a websocket (not implemented but very simple).

@jhnferraris
Copy link
Contributor Author

Hello Mike,

Got the simple web logger to work. Refreshing it every time is a bit of a hassle.

I've read the discussions on #156 but I don't see any walkthrough? Can you take me through on setting up this plugin?

Much appreciated!

@jhnferraris
Copy link
Contributor Author

jhnferraris commented Jun 24, 2016

Hello Mike,

Got your web plugin to work but I've commented out some items. Can you please take a look at this,

jhnferraris@8513914

and check if the lines that I commented out are okay?

My next step would be to simulate a simple logger in the web browser in real-time. Hope you can guide me through this.

For starters, how do I handle the broadcastAdvice and show it in index.html?

Much appreciated!

@jhnferraris
Copy link
Contributor Author

Made another commit, I think I mixed up ws and http in one context. I guess they are different, yes? One is for the http server and the other I guess is for the web socket?

jhnferraris@af000eb

I'm testing this out if it will show up the broadcasted advice in the html.

Comments are highly appreciated.

Thanks!

@askmike
Copy link
Owner

askmike commented Jun 24, 2016

Hey John,

Made another commit, I think I mixed up ws and http in one context. I guess they are different, yes? One is for the http server and the other I guess is for the web socket?

Yes, the http server only serves the files for the frontend: event handling logic, the charting libraries and some html. While the ws context is used to broadcast all events (trade advice and market data) in semi realtime to the browser.

So I played around with the idea a few years ago, but never actually finished the plugin (it was working but functionality was very limited). A few things to note:

  • I am pretty sure Gekko changed so much that you cannot get it working without tweaking some stuff..
  • these lines at that time trading credentials were handled differently and not exposed directly. If you run the server on any network that you don't fully control and have real trading enabled: please also delete config.trader. Current Gekko does not deep copy the config so you should probably do that before the delete statement.
  • broadcastSmallCandle has been renamed to broadcastCandle. It also takes a second argument, a callback function to run when you are done processing (run it after the this.broadcast). If you don't do that Gekko will buffer market data and it will looks like everything froze.

After these changes you should have a server that is able to send data to the browser. However if you look at the index.html, you see that everything is commented out. Probably better to use this version. Note that the data format Gekko uses most likely changed..

@askmike
Copy link
Owner

askmike commented Jun 24, 2016

If you can't get it working I will try to hook it up ASAP. Unfortunately currently do not have the time to commit this.

@askmike
Copy link
Owner

askmike commented Jun 24, 2016

I'm assuming that ws is short for "web socket".

yes, sort of. Ws is short for the websocket server. See here

@jhnferraris
Copy link
Contributor Author

Hey Mike,

It seems that the css url in the index.html file can't be found. http://nvd3.org/src/nv.d3.css.  Is this a public url?

@askmike
Copy link
Owner

askmike commented Jun 24, 2016

It was 3 years ago.. You can try this one.

@askmike
Copy link
Owner

askmike commented Jun 24, 2016

@jhnferraris You can use my version, it is on the webserver branch:

https://github.com/askmike/gekko/tree/webserver

After you enable the plugin browse to http://localhost:8080. The result should look like this:

screen shot 2016-06-24 at 16 53 06

It updates in realtime when new advice and/or trade data comes in.


If you have any experience in webdevelopment, feel free to take it over from here and replace the raw logging with charts and/or an nice looking interface.

@jhnferraris
Copy link
Contributor Author

Hey Mike! Thanks a lot! Saw some stuff that I've missed when I tried experimenting on my end (ie. Sending the this.advice to the websocket instead of broadcasting it).

Can you send me a PR so I can merge your webserver branch to my repo?

@askmike
Copy link
Owner

askmike commented Jun 24, 2016

Done, I am closing this for now.

For future readers: the webserver branch has been merged into develop (and will soon be merged into stable).

@jhnferraris if you have more questions or issues, feel free to keep commenting here.

@askmike askmike closed this as completed Jun 24, 2016
@jhnferraris
Copy link
Contributor Author

Hello Mike,

I've been trying to deploy gekko in Heroku. However, I keep getting a crash state when running in production. Local deployment in heroku works fine though.

2016-06-27T02:52:46.365439+00:00 app[web.1]: 
2016-06-27T02:52:46.365443+00:00 app[web.1]: 
2016-06-27T02:52:46.365441+00:00 app[web.1]: Gekko version: v0.2.3
2016-06-27T02:52:46.365442+00:00 app[web.1]: Nodejs version: v5.11.1
2016-06-27T02:52:47.234284+00:00 heroku[web.1]: State changed from crashed to starting
2016-06-27T02:52:47.228584+00:00 heroku[web.1]: Process exited with status 0
2016-06-27T02:52:49.209522+00:00 heroku[web.1]: Starting process with command `node gekko.js`
2016-06-27T02:52:50.996500+00:00 app[web.1]: 
2016-06-27T02:52:50.996515+00:00 app[web.1]: 
2016-06-27T02:52:51.769011+00:00 heroku[web.1]: State changed from starting to crashed
2016-06-27T02:52:51.753364+00:00 heroku[web.1]: Process exited with status 0

My Procfile config is here:

web: node gekko.js

Am I missing something here? Are there any standing issues on deploying gekko in production?

Thanks!

@jhnferraris
Copy link
Contributor Author

I did missed something.

Solution when deploying to Heroku:

Remove config.js in .gitignore and push it to heroku master

@listenlight
Copy link

I got the following with a similar procfile as @jhnferraris.

2016-09-21T14:42:08.168821+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2016-09-21T14:42:08.168906+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-09-21T14:42:08.391899+00:00 heroku[web.1]: Process exited with status 137
2016-09-21T14:42:08.420465+00:00 heroku[web.1]: State changed from starting to crashed

@askmike
Copy link
Owner

askmike commented Sep 21, 2016

@jhnferraris @tidelake The current stable Gekko requires node 6 or higher!

@listenlight
Copy link

@askmike My node version is 6.6 iirc.

@listenlight
Copy link

I changed to my desired config file and pushed to heroku. The bot only runs for a minute before I get that message. I really appreciate your help.

@albertolive
Copy link

You have to change from web to worker, adding a file named Procfile in your root folder and adding this line of code:

worker: node gekko

Then, you have to got to Resources of your heroku project and activate it and deactivate web.

screen shot 2017-03-04 at 12 08 05

@askmike
Copy link
Owner

askmike commented Mar 4, 2017

note that I am working on a web UI for gekko, details can be found here: #489.

@askmike
Copy link
Owner

askmike commented Oct 12, 2017 via email

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

No branches or pull requests

4 participants