質問編集履歴
2
ソースコード、実行したコマンドの一部修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -60,6 +60,8 @@
|
|
60
60
|
### 該当のソースコード
|
61
61
|
|
62
62
|
```ここに言語名を入力
|
63
|
+
// GitHub https://github.com/askmike/gekko より抜粋
|
64
|
+
|
63
65
|
/**********************gekko.js****************************/
|
64
66
|
|
65
67
|
console.log(`
|
@@ -302,8 +304,8 @@
|
|
302
304
|
■コマンドプロンプトより下記コマンドを実行
|
303
305
|
$ node gekko ui -c sample-config.js
|
304
306
|
$ node gekko ui --config sample-config.js
|
305
|
-
$ node gekko ui -c C:\Users\
|
307
|
+
$ node gekko ui -c C:\Users\***\Downloads\gekko-develop\sample-config.js
|
306
|
-
$ node gekko ui --config C:\Users\
|
308
|
+
$ node gekko ui --config C:\Users\***\Downloads\gekko-develop\sample-config.js
|
307
309
|
|
308
310
|
### 補足情報(FW/ツールのバージョンなど)
|
309
311
|
|
1
ソースコード追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -60,10 +60,244 @@
|
|
60
60
|
### 該当のソースコード
|
61
61
|
|
62
62
|
```ここに言語名を入力
|
63
|
+
/**********************gekko.js****************************/
|
64
|
+
|
65
|
+
console.log(`
|
66
|
+
______ ________ __ __ __ __ ______
|
67
|
+
/ \\ / |/ | / |/ | / | / \\
|
68
|
+
/$$$$$$ |$$$$$$$$/ $$ | /$$/ $$ | /$$/ /$$$$$$ |
|
69
|
+
$$ | _$$/ $$ |__ $$ |/$$/ $$ |/$$/ $$ | $$ |
|
70
|
+
$$ |/ |$$ | $$ $$< $$ $$< $$ | $$ |
|
71
|
+
$$ |$$$$ |$$$$$/ $$$$$ \\ $$$$$ \\ $$ | $$ |
|
72
|
+
$$ \\__$$ |$$ |_____ $$ |$$ \\ $$ |$$ \\ $$ \\__$$ |
|
73
|
+
$$ $$/ $$ |$$ | $$ |$$ | $$ |$$ $$/
|
74
|
+
$$$$$$/ $$$$$$$$/ $$/ $$/ $$/ $$/ $$$$$$/
|
75
|
+
`);
|
76
|
+
|
77
|
+
const util = require(__dirname + '/core/util');
|
78
|
+
|
79
|
+
console.log('\tGekko v' + util.getVersion());
|
80
|
+
console.log('\tI\'m gonna make you rich, Bud Fox.', '\n\n');
|
81
|
+
|
82
|
+
const dirs = util.dirs();
|
83
|
+
|
84
|
+
if(util.launchUI()) {
|
85
|
+
return require(util.dirs().web + 'server');
|
86
|
+
}
|
87
|
+
|
88
|
+
const pipeline = require(dirs.core + 'pipeline');
|
89
|
+
const config = util.getConfig();
|
90
|
+
const mode = util.gekkoMode();
|
91
|
+
|
92
|
+
if(
|
93
|
+
config.trader &&
|
94
|
+
config.trader.enabled &&
|
95
|
+
!config['I understand that Gekko only automates MY OWN trading strategies']
|
96
|
+
)
|
97
|
+
util.die('Do you understand what Gekko will do with your money? Read this first:\n\nhttps://github.com/askmike/gekko/issues/201');
|
98
|
+
|
99
|
+
// > Ever wonder why fund managers can't beat the S&P 500?
|
100
|
+
// > 'Cause they're sheep, and sheep get slaughtered.
|
63
|
-
|
101
|
+
pipeline({
|
102
|
+
config: config,
|
64
|
-
|
103
|
+
mode: mode
|
104
|
+
});
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
/**********************gekko.js****************************/
|
109
|
+
|
110
|
+
var moment = require('moment');
|
111
|
+
var _ = require('lodash');
|
112
|
+
var path = require('path');
|
113
|
+
var fs = require('fs');
|
114
|
+
var semver = require('semver');
|
115
|
+
var program = require('commander');
|
116
|
+
|
117
|
+
var startTime = moment();
|
118
|
+
|
119
|
+
var _config = false;
|
120
|
+
var _package = false;
|
121
|
+
var _nodeVersion = false;
|
122
|
+
var _gekkoMode = false;
|
123
|
+
var _gekkoEnv = false;
|
124
|
+
|
125
|
+
var _args = false;
|
126
|
+
|
127
|
+
// helper functions
|
128
|
+
var util = {
|
129
|
+
getConfig: function() {
|
130
|
+
// cache
|
131
|
+
if(_config)
|
132
|
+
return _config;
|
133
|
+
|
134
|
+
if(!program.config)
|
135
|
+
util.die('Please specify a config file.', true);
|
136
|
+
|
137
|
+
if(!fs.existsSync(util.dirs().gekko + program.config))
|
138
|
+
util.die('Cannot find the specified config file.', true);
|
139
|
+
|
140
|
+
_config = require(util.dirs().gekko + program.config);
|
141
|
+
return _config;
|
142
|
+
},
|
143
|
+
// overwrite the whole config
|
144
|
+
setConfig: function(config) {
|
145
|
+
_config = config;
|
146
|
+
},
|
147
|
+
setConfigProperty: function(parent, key, value) {
|
148
|
+
if(parent)
|
149
|
+
_config[parent][key] = value;
|
150
|
+
else
|
151
|
+
_config[key] = value;
|
152
|
+
},
|
153
|
+
getVersion: function() {
|
154
|
+
return util.getPackage().version;
|
155
|
+
},
|
156
|
+
getPackage: function() {
|
157
|
+
if(_package)
|
158
|
+
return _package;
|
159
|
+
|
160
|
+
|
161
|
+
_package = JSON.parse( fs.readFileSync(__dirname + '/../package.json', 'utf8') );
|
162
|
+
return _package;
|
163
|
+
},
|
164
|
+
getRequiredNodeVersion: function() {
|
165
|
+
return util.getPackage().engines.node;
|
166
|
+
},
|
167
|
+
recentNode: function() {
|
168
|
+
var required = util.getRequiredNodeVersion();
|
169
|
+
return semver.satisfies(process.version, required);
|
170
|
+
},
|
171
|
+
// check if two moments are corresponding
|
172
|
+
// to the same time
|
173
|
+
equals: function(a, b) {
|
174
|
+
return !(a < b || a > b)
|
175
|
+
},
|
176
|
+
minToMs: function(min) {
|
177
|
+
return min * 60 * 1000;
|
178
|
+
},
|
179
|
+
defer: function(fn) {
|
180
|
+
return function(args) {
|
181
|
+
var args = _.toArray(arguments);
|
182
|
+
return _.defer(function() { fn.apply(this, args) });
|
183
|
+
}
|
184
|
+
},
|
185
|
+
logVersion: function() {
|
186
|
+
return `Gekko version: v${util.getVersion()}`
|
187
|
+
+ `\nNodejs version: ${process.version}`;
|
188
|
+
},
|
189
|
+
die: function(m, soft) {
|
190
|
+
|
191
|
+
if(_gekkoEnv === 'child-process') {
|
192
|
+
return process.send({type: 'error', error: '\n ERROR: ' + m + '\n'});
|
193
|
+
}
|
194
|
+
|
195
|
+
var log = console.log.bind(console);
|
196
|
+
|
197
|
+
if(m) {
|
198
|
+
if(soft) {
|
199
|
+
log('\n ERROR: ' + m + '\n\n');
|
200
|
+
} else {
|
201
|
+
log(`\nGekko encountered an error and can\'t continue`);
|
202
|
+
log('\nError:\n');
|
203
|
+
log(m, '\n\n');
|
204
|
+
log('\nMeta debug info:\n');
|
205
|
+
log(util.logVersion());
|
206
|
+
log('');
|
207
|
+
}
|
208
|
+
}
|
209
|
+
process.exit(1);
|
210
|
+
},
|
211
|
+
dirs: function() {
|
212
|
+
var ROOT = __dirname + '/../';
|
213
|
+
|
214
|
+
return {
|
215
|
+
gekko: ROOT,
|
216
|
+
core: ROOT + 'core/',
|
217
|
+
markets: ROOT + 'core/markets/',
|
218
|
+
exchanges: ROOT + 'exchange/wrappers/',
|
219
|
+
plugins: ROOT + 'plugins/',
|
220
|
+
methods: ROOT + 'strategies/',
|
221
|
+
indicators: ROOT + 'strategies/indicators/',
|
222
|
+
budfox: ROOT + 'core/budfox/',
|
223
|
+
importers: ROOT + 'importers/exchanges/',
|
224
|
+
tools: ROOT + 'core/tools/',
|
225
|
+
workers: ROOT + 'core/workers/',
|
226
|
+
web: ROOT + 'web/',
|
227
|
+
config: ROOT + 'config/',
|
228
|
+
broker: ROOT + 'exchange/'
|
229
|
+
}
|
230
|
+
},
|
231
|
+
inherit: function(dest, source) {
|
232
|
+
require('util').inherits(
|
233
|
+
dest,
|
234
|
+
source
|
235
|
+
);
|
236
|
+
},
|
237
|
+
makeEventEmitter: function(dest) {
|
238
|
+
util.inherit(dest, require('events').EventEmitter);
|
239
|
+
},
|
240
|
+
setGekkoMode: function(mode) {
|
241
|
+
_gekkoMode = mode;
|
242
|
+
},
|
243
|
+
gekkoMode: function() {
|
244
|
+
if(_gekkoMode)
|
245
|
+
return _gekkoMode;
|
246
|
+
|
247
|
+
if(program['import'])
|
248
|
+
return 'importer';
|
249
|
+
else if(program.backtest)
|
250
|
+
return 'backtest';
|
251
|
+
else
|
252
|
+
return 'realtime';
|
253
|
+
},
|
254
|
+
gekkoModes: function() {
|
255
|
+
return [
|
256
|
+
'importer',
|
257
|
+
'backtest',
|
258
|
+
'realtime'
|
259
|
+
]
|
260
|
+
},
|
261
|
+
setGekkoEnv: function(env) {
|
262
|
+
_gekkoEnv = env;
|
263
|
+
},
|
264
|
+
gekkoEnv: function() {
|
265
|
+
return _gekkoEnv || 'standalone';
|
266
|
+
},
|
267
|
+
launchUI: function() {
|
268
|
+
if(program['ui'])
|
269
|
+
return true;
|
270
|
+
else
|
271
|
+
return false;
|
272
|
+
},
|
273
|
+
getStartTime: function() {
|
274
|
+
return startTime;
|
275
|
+
},
|
276
|
+
}
|
277
|
+
|
278
|
+
// NOTE: those options are only used
|
279
|
+
// in stand alone mode
|
280
|
+
program
|
281
|
+
.version(util.logVersion())
|
282
|
+
.option('-c, --config <file>', 'Config file')
|
283
|
+
.option('-b, --backtest', 'backtesting mode')
|
284
|
+
.option('-i, --import', 'importer mode')
|
285
|
+
.option('--ui', 'launch a web UI')
|
286
|
+
.parse(process.argv);
|
287
|
+
|
288
|
+
// make sure the current node version is recent enough
|
289
|
+
if(!util.recentNode())
|
290
|
+
util.die([
|
291
|
+
'Your local version of Node.js is too old. ',
|
292
|
+
'You have ',
|
293
|
+
process.version,
|
294
|
+
' and you need atleast ',
|
295
|
+
util.getRequiredNodeVersion()
|
296
|
+
].join(''), true);
|
297
|
+
|
298
|
+
module.exports = util
|
299
|
+
|
65
300
|
```
|
66
|
-
|
67
301
|
### 試したこと
|
68
302
|
■コマンドプロンプトより下記コマンドを実行
|
69
303
|
$ node gekko ui -c sample-config.js
|