This repository has been archived on 2025-10-29. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
gekko/web/routes/startGekko.js
T
2021-06-06 20:25:14 +02:00

39 lines
835 B
JavaScript

const _ = require('lodash');
const cache = require('../state/cache');
const Logger = require('../state/logger');
const apiKeyManager= cache.get('apiKeyManager');
const gekkoManager = cache.get('gekkos');
const base = require('./baseConfig');
// starts an import
// requires a post body with a config object
module.exports = function *() {
const mode = this.request.body.mode;
let config = {};
_.merge(config, base, this.request.body);
// Attach API keys
if(config.trader && config.trader.enabled && !config.trader.key) {
const keys = apiKeyManager._getApiKeyPair(config.watch.exchange);
if(!keys) {
this.body = 'No API keys found for this exchange.';
return;
}
_.merge(
config.trader,
keys
);
}
const state = gekkoManager.add({config, mode});
this.body = state;
}