This repository was archived by the owner on Feb 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2k
Rest API Support for zenbot #797
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
dbcac99
Added Binance to Zenbot
abduegal b1a8f92
small change in the engine to make binance cancel order work
abduegal 2d6c3b6
removed the node-binance-api
abduegal e708d11
Merge remote-tracking branch 'upstream/master'
abduegal d676eae
fixed feedback for pull request.
abduegal aad87cf
Added API support to zenbot
abduegal d5527ab
Merge branch 'master' of https://github.com/carlos8f/zenbot
abduegal f4e0433
Added output handler in the lib
abduegal 82409f3
Fixed feedback added readme
abduegal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| module.exports = { | ||
| _ns: 'zenbot', | ||
|
|
||
| 'output.api': require('./api') | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
|
|
||
|
|
||
| module.exports = function container (get) { | ||
| let c = get('conf') | ||
| let express = require('express') | ||
| let app = express() | ||
| let random_port = require('random-port') | ||
|
|
||
| let run = function(reporter, tradeObject) { | ||
| if (!reporter.port || reporter.port === 0) { | ||
| random_port({from: 20000}, function(port) { | ||
| startServer(port, tradeObject) | ||
| }) | ||
| } else { | ||
| startServer(reporter.port, tradeObject) | ||
| } | ||
| } | ||
|
|
||
| let startServer = function(port, tradeObject) { | ||
| tradeObject.port = port | ||
|
|
||
| app.get('/trades', function (req, res) { | ||
| res.send(tradeObject) | ||
| }) | ||
|
|
||
| app.listen(port) | ||
| tradeObject.url = require('ip').address() + ':' + port + '/trades' | ||
| console.log('api running on ' + tradeObject.url) | ||
| } | ||
|
|
||
| return { | ||
| run: run | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| module.exports = function container (get) { | ||
| var c = get('conf') | ||
|
|
||
| var initializeOutput = function(tradeObject) { | ||
| for (var output in c.output) { | ||
| if (c.output[output].on) { | ||
| if (c.debug) { | ||
| console.log(`initializing output ${output}`) | ||
| } | ||
| get(`output.${output}`).run(c.output[output], tradeObject) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return { | ||
| initializeOutput: initializeOutput | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try/catch if the port doesn't work, and we try a different one automatically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay I will do that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the random_port function already searches for a free port, so I dont think this is neccesary anymore. The function also tests explicitly if the port is available through a try / catch mechanism
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sweet! Thanks for digging that up.