forked from debut-js/Strategies
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meta.ts
76 lines (63 loc) · 2.52 KB
/
meta.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { geneticShutdownPlugin } from '@debut/plugin-genetic-shutdown';
import { reportPlugin } from '@debut/plugin-report';
import { debugPlugin } from '@debut/plugin-debug';
import { createSessionValidator } from '@debut/plugin-session';
import { CCIDynamic, CCIDynamicBotOptions } from './bot';
import { GeneticSchema, DebutMeta, BaseTransport, WorkingEnv } from '@debut/types';
const parameters: GeneticSchema<CCIDynamicBotOptions> = {
stopTakeRatio: { min: 1, max: 4 },
atrPeriod: { min: 8, max: 40, int: true },
atrMultiplier: { min: 0.5, max: 10 },
cciPeriod: { min: 8, max: 40, int: true },
levelPeriod: { min: 4, max: 50, int: true },
levelSampleType: { min: 1, max: 4, int: true },
levelRedunant: { min: 0.25, max: 0.99 },
levelSampleCount: { min: 1, max: 4, int: true },
levelMultiplier: { min: 1, max: 2.5 },
cciAtr: { bool: true },
closeAtZero: { bool: true },
orderCandlesLimit: { min: 10, max: 100, int: true },
zeroClose: { bool: true },
signalFilter: { bool: true },
takeProfit: { min: 1, max: 10 },
stopLoss: { min: 1, max: 10 },
reduceWhen: { min: 1, max: 5 },
reduceSize: { min: 0.2, max: 0.9 },
trailing: { min: 0, max: 3, int: true },
};
const meta: DebutMeta = {
parameters,
score(bot: CCIDynamic) {
const report = bot.plugins.stats.report();
return report.balance - (report.maxBalance * report.potentialDD) / 100;
},
stats(bot: CCIDynamic) {
return bot.plugins.stats.report();
},
async create(transport: BaseTransport, cfg: CCIDynamicBotOptions, env: WorkingEnv) {
const bot = new CCIDynamic(transport, cfg);
// Специфичные плагины окружения
if (env === WorkingEnv.genetic) {
bot.registerPlugins([geneticShutdownPlugin(cfg.interval)]);
} else if (env === WorkingEnv.tester) {
bot.registerPlugins([reportPlugin(false)]);
bot.plugins.report.addIndicators(bot.getIndicators());
} else if (env === WorkingEnv.production) {
bot.registerPlugins([debugPlugin()]);
}
return bot;
},
ticksFilter(cfg: CCIDynamicBotOptions) {
if (!cfg.from && !cfg.to) {
return () => true;
}
const tickValidator = createSessionValidator(cfg.from, cfg.to, cfg.noTimeSwitching);
return (tick) => {
return tickValidator(tick.time).inSession;
};
},
validate(cfg: CCIDynamicBotOptions) {
return cfg;
},
};
export default meta;