This repository has been 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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added Binance to Zenbot * small change in the engine to make binance cancel order work * removed the node-binance-api * fixed feedback for pull request. * Added API support to zenbot * Added output handler in the lib * Fixed feedback added readme
- Loading branch information
Showing
8 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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
4aadfd1
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.
When I put c.output.api.port (not 0) into config zenbot crashes at startup. port=0 works ok. It seems that REST API uses 2 ports. Could you give a correct example of api config ? Thanks