dexbot 1.6.16 → 1.6.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +58 -0
- package/analysis/README.md +10 -9
- package/analysis/ama_fitting/README.md +2 -2
- package/analysis/bot_fitting/README.md +3 -3
- package/analysis/tradingview/README.md +2 -2
- package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +1 -1
- package/claw/package.json +1 -1
- package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
- package/claw/runtimes/openclaw-plugin/package.json +1 -1
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js +5 -3
- package/dist/analysis/analyze_args.d.ts +2 -1
- package/dist/analysis/fills_source.d.ts +1 -8
- package/dist/analysis/fills_source.js +1 -1
- package/dist/analysis/grid_correction_check.d.ts +9 -6
- package/dist/analysis/grid_correction_check.js +56 -64
- package/dist/analysis/math_utils.d.ts +1 -1
- package/dist/analysis/trade_profitability.d.ts +1 -1
- package/dist/analysis/tradingview/grid_reset_sim.js +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +7 -7
- package/dist/analysis/trend_detection/backtest_ama_slope_huber.js +1 -1
- package/dist/analysis/trend_detection/huber_scale_variants.d.ts +4 -3
- package/dist/market_adapter/cli_args.d.ts +6 -1
- package/dist/market_adapter/cli_args.js +16 -2
- package/dist/market_adapter/core/kibana_candles.d.ts +5 -1
- package/dist/market_adapter/core/kibana_candles.js +3 -1
- package/dist/market_adapter/core/strategies/regime_gate.d.ts +7 -1
- package/dist/market_adapter/core/strategies/regime_gate.js +3 -1
- package/dist/market_adapter/inputs/cex_candle_parsing.d.ts +7 -2
- package/dist/market_adapter/inputs/cex_candle_parsing.js +3 -1
- package/dist/market_adapter/inputs/fetch_book_data.d.ts +7 -1
- package/dist/market_adapter/inputs/fetch_book_data.js +3 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +2 -11
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts +26 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js +62 -52
- package/dist/market_adapter/inputs/kibana_feed_source.d.ts +14 -2
- package/dist/market_adapter/inputs/kibana_feed_source.js +14 -1
- package/dist/market_adapter/inputs/window_cache.d.ts +14 -3
- package/dist/market_adapter/inputs/window_cache.js +14 -1
- package/dist/market_adapter/lp_chart_runner.d.ts +12 -9
- package/dist/market_adapter/lp_chart_runner.js +3 -1
- package/dist/market_adapter/lp_chart_strategy_loader.d.ts +5 -1
- package/dist/market_adapter/lp_chart_strategy_loader.js +3 -1
- package/dist/market_adapter/market_adapter.d.ts +10 -2
- package/dist/market_adapter/market_adapter.js +10 -11
- package/dist/market_adapter/utils/chain.d.ts +2 -3
- package/dist/market_adapter/utils/file_json_cache.d.ts +5 -1
- package/dist/market_adapter/utils/file_json_cache.js +3 -1
- package/dist/market_adapter/utils/file_lock.js +1 -1
- package/dist/market_adapter/utils/native_history.d.ts +7 -3
- package/dist/market_adapter/utils/native_history.js +3 -1
- package/dist/market_adapter/utils/pair_orientation.d.ts +2 -2
- package/dist/modules/account_bots.d.ts +3 -0
- package/dist/modules/bots_file_lock.d.ts +2 -2
- package/dist/modules/bots_file_lock.js +2 -2
- package/dist/modules/chain_keys.d.ts +1 -1
- package/dist/modules/constants.d.ts +6 -0
- package/dist/modules/constants.js +37 -6
- package/dist/modules/credit_pricing.d.ts +20 -1
- package/dist/modules/credit_pricing.js +23 -1
- package/dist/modules/credit_runtime.js +33 -16
- package/dist/modules/dexbot_class.d.ts +11 -1
- package/dist/modules/dexbot_class.js +15 -2
- package/dist/modules/dexbot_cow_runtime.d.ts +90 -38
- package/dist/modules/dexbot_cow_runtime.js +507 -108
- package/dist/modules/dexbot_credential_client.d.ts +5 -0
- package/dist/modules/dexbot_maintenance_runtime.js +117 -12
- package/dist/modules/dexbot_startup_runtime.js +7 -1
- package/dist/modules/graceful_shutdown.d.ts +2 -2
- package/dist/modules/graceful_shutdown.js +2 -2
- package/dist/modules/launcher/credential_daemon.d.ts +14 -2
- package/dist/modules/launcher/credential_daemon.js +60 -26
- package/dist/modules/launcher/runtime_mode.d.ts +4 -3
- package/dist/modules/node_manager.d.ts +1 -1
- package/dist/modules/node_manager.js +1 -1
- package/dist/modules/order/accounting.js +2 -1
- package/dist/modules/order/export.d.ts +2 -2
- package/dist/modules/order/export.js +2 -2
- package/dist/modules/order/grid.d.ts +26 -14
- package/dist/modules/order/grid.js +416 -73
- package/dist/modules/order/grid_reconcile.js +5 -1
- package/dist/modules/order/grid_reconcile_internal.js +2 -1
- package/dist/modules/order/index.d.ts +22 -1
- package/dist/modules/order/manager.d.ts +40 -7
- package/dist/modules/order/manager.js +149 -23
- package/dist/modules/order/strategy.d.ts +5 -0
- package/dist/modules/order/strategy.js +44 -3
- package/dist/modules/order/sync_engine.d.ts +12 -1
- package/dist/modules/order/sync_engine.js +135 -20
- package/dist/modules/order/utils/math.d.ts +49 -10
- package/dist/modules/order/utils/math.js +71 -14
- package/dist/modules/order/utils/order.d.ts +65 -11
- package/dist/modules/order/utils/order.js +198 -28
- package/dist/modules/order/utils/system.d.ts +112 -2
- package/dist/modules/order/utils/system.js +338 -12
- package/dist/modules/order/utils/validate.d.ts +4 -1
- package/dist/modules/order/utils/validate.js +9 -2
- package/dist/modules/storage/index.d.ts +3 -2
- package/dist/modules/storage/index.js +3 -2
- package/dist/modules/types.d.ts +44 -2
- package/dist/scripts/analyze-credit.js +64 -23
- package/dist/scripts/bts_distribution.d.ts +66 -0
- package/dist/scripts/bts_distribution.js +2102 -0
- package/dist/scripts/token_distribution.d.ts +45 -0
- package/dist/scripts/token_distribution.js +1870 -0
- package/dist/unlock.js +42 -24
- package/docs/COPY_ON_WRITE_MASTER_PLAN.md +1 -1
- package/docs/COW_INVARIANTS.md +24 -8
- package/docs/DEXBOT_COMPARISON.md +5 -5
- package/docs/EVOLUTION.md +10 -8
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +13 -11
- package/docs/GRID_PRICE_INVARIANT.md +29 -3
- package/docs/GRID_RECALCULATION.md +3 -3
- package/docs/GRID_RECONCILE.md +5 -5
- package/docs/LIFECYCLE.md +11 -11
- package/docs/LOGGING.md +22 -0
- package/docs/MPA_CREDIT_USAGE.md +3 -2
- package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +236 -32
- package/docs/README.md +1 -1
- package/docs/architecture.md +205 -6
- package/docs/developer_guide.md +12 -0
- package/market_adapter/README.md +11 -6
- package/modules/README.md +18 -14
- package/package.json +6 -3
- package/scripts/README.md +85 -148
|
@@ -41,6 +41,7 @@ import { shardStemFromName } from '../utils/month_shards.js';
|
|
|
41
41
|
import * as bitsharesClient from '../../modules/bitshares_client.js';
|
|
42
42
|
import { getErrorMessage, resolveSeamMs } from '../../modules/utils/errors.js';
|
|
43
43
|
import { isSameBotName } from '../../modules/utils/sanitize_key.js';
|
|
44
|
+
import { walkCliArgs } from '../cli_args.js';
|
|
44
45
|
import { pathToFileURL } from 'node:url';
|
|
45
46
|
const storage = getStorage();
|
|
46
47
|
const { readJSON } = storage;
|
|
@@ -56,8 +57,44 @@ const FETCH_MAX_ATTEMPTS = MARKET_ADAPTER.RUNTIME_DEFAULTS.sourceRetries;
|
|
|
56
57
|
const FETCH_RETRY_BACKOFF_BASE_MS = MARKET_ADAPTER.LP_FETCH_RETRY_BACKOFF_BASE_MS;
|
|
57
58
|
const BOTS_JSON = PATHS.PROFILES.BOTS_JSON;
|
|
58
59
|
// ─── CLI ──────────────────────────────────────────────────────────────────────
|
|
60
|
+
function printHelp() {
|
|
61
|
+
console.log(`Usage:
|
|
62
|
+
node dist/market_adapter/inputs/fetch_lp_data.js [options]
|
|
63
|
+
|
|
64
|
+
Options:
|
|
65
|
+
--bot <name> Read pool/assets/interval from profiles/bots.json
|
|
66
|
+
--pool <id> Liquidity pool id (1.19.N or N)
|
|
67
|
+
--interval <label> Candle interval (1m|5m|15m|30m|1h|2h|4h|6h|12h|1d|1w or seconds)
|
|
68
|
+
--lookback <hours> Trailing window in hours (accepts a trailing \`h\`)
|
|
69
|
+
--start <date> Absolute ISO start time (pairs with --end)
|
|
70
|
+
--end <date> Absolute ISO end time (pairs with --start)
|
|
71
|
+
--chunkMonths <n> Fetch window size in months (default ${DEFAULT_CONFIG.chunkMonths})
|
|
72
|
+
--precA <n> Override asset A precision
|
|
73
|
+
--precB <n> Override asset B precision
|
|
74
|
+
--apiKey <key> Kibana API key, when the endpoint requires auth
|
|
75
|
+
--out <file> Explicit output path
|
|
76
|
+
--help, -h Show this help
|
|
77
|
+
|
|
78
|
+
Flags accept \`--flag value\` or \`--flag=value\`; use the second form when the
|
|
79
|
+
value itself starts with \`--\`.
|
|
80
|
+
`);
|
|
81
|
+
}
|
|
82
|
+
/** Parse an integer option, rejecting non-numeric or out-of-range input. */
|
|
83
|
+
function parseIntOption(flag, raw, min) {
|
|
84
|
+
const value = raw.trim() === '' ? Number.NaN : Number(raw);
|
|
85
|
+
if (!Number.isInteger(value) || value < min) {
|
|
86
|
+
throw new Error(`${flag}: invalid value "${raw}" (expected an integer >= ${min})`);
|
|
87
|
+
}
|
|
88
|
+
return value;
|
|
89
|
+
}
|
|
90
|
+
/** Reject an empty string option (a blank path or API key is never intended). */
|
|
91
|
+
function requireNonEmpty(flag, raw) {
|
|
92
|
+
if (raw.trim() === '') {
|
|
93
|
+
throw new Error(`${flag}: expected a non-empty value`);
|
|
94
|
+
}
|
|
95
|
+
return raw;
|
|
96
|
+
}
|
|
59
97
|
function parseArgs() {
|
|
60
|
-
const args = process.argv.slice(2);
|
|
61
98
|
const config = { ...DEFAULT_CONFIG };
|
|
62
99
|
let poolId = null; // null = auto-discover from bots.json
|
|
63
100
|
let botName = null;
|
|
@@ -71,19 +108,15 @@ function parseArgs() {
|
|
|
71
108
|
'1h': 3600, '2h': 7200, '4h': 14400, '6h': 21600, '12h': 43200,
|
|
72
109
|
'1d': 86400, '1w': 604800, '7d': 604800,
|
|
73
110
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
poolId = val;
|
|
84
|
-
i++;
|
|
85
|
-
break;
|
|
86
|
-
case '--interval': {
|
|
111
|
+
walkCliArgs(process.argv.slice(2), {
|
|
112
|
+
onHelp: () => {
|
|
113
|
+
printHelp();
|
|
114
|
+
process.exit(0);
|
|
115
|
+
},
|
|
116
|
+
value: {
|
|
117
|
+
'--bot': (val) => { botName = val; },
|
|
118
|
+
'--pool': (val) => { poolId = val; },
|
|
119
|
+
'--interval': (val) => {
|
|
87
120
|
let seconds = intervalMap[val];
|
|
88
121
|
if (seconds == null)
|
|
89
122
|
seconds = parseInt(val, 10);
|
|
@@ -91,48 +124,23 @@ function parseArgs() {
|
|
|
91
124
|
throw new Error(`--interval: unsupported value "${val}" (use ${Object.keys(intervalMap).join(', ')} or seconds)`);
|
|
92
125
|
}
|
|
93
126
|
config.intervalSeconds = seconds;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
case '--lookback': {
|
|
127
|
+
},
|
|
128
|
+
'--lookback': (val) => {
|
|
98
129
|
const hours = parseInt(String(val).replace('h', ''), 10);
|
|
99
130
|
if (!Number.isFinite(hours) || hours <= 0) {
|
|
100
131
|
throw new Error(`--lookback: invalid value "${val}" (expected hours, e.g. 48 or 48h)`);
|
|
101
132
|
}
|
|
102
133
|
config.lookbackHours = hours;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
break;
|
|
114
|
-
case '--precB':
|
|
115
|
-
precB = parseInt(val, 10);
|
|
116
|
-
i++;
|
|
117
|
-
break;
|
|
118
|
-
case '--apiKey':
|
|
119
|
-
config.apiKey = val;
|
|
120
|
-
i++;
|
|
121
|
-
break;
|
|
122
|
-
case '--start':
|
|
123
|
-
config.timeRange = { ...(config.timeRange || {}), gte: val };
|
|
124
|
-
i++;
|
|
125
|
-
break;
|
|
126
|
-
case '--end':
|
|
127
|
-
config.timeRange = { ...(config.timeRange || {}), lte: val };
|
|
128
|
-
i++;
|
|
129
|
-
break;
|
|
130
|
-
case '--out':
|
|
131
|
-
config.outPath = val;
|
|
132
|
-
i++;
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
134
|
+
},
|
|
135
|
+
'--chunkMonths': (val) => { config.chunkMonths = parseIntOption('--chunkMonths', val, 1); },
|
|
136
|
+
'--precA': (val) => { precA = parseIntOption('--precA', val, 0); },
|
|
137
|
+
'--precB': (val) => { precB = parseIntOption('--precB', val, 0); },
|
|
138
|
+
'--apiKey': (val) => { config.apiKey = requireNonEmpty('--apiKey', val); },
|
|
139
|
+
'--start': (val) => { config.timeRange = { ...(config.timeRange || {}), gte: val }; },
|
|
140
|
+
'--end': (val) => { config.timeRange = { ...(config.timeRange || {}), lte: val }; },
|
|
141
|
+
'--out': (val) => { config.outPath = requireNonEmpty('--out', val); },
|
|
142
|
+
},
|
|
143
|
+
});
|
|
136
144
|
return { poolId, botName, precA, precB, config };
|
|
137
145
|
}
|
|
138
146
|
// ─── Output path ──────────────────────────────────────────────────────────────
|
|
@@ -642,5 +650,7 @@ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
|
|
|
642
650
|
process.exit(1);
|
|
643
651
|
});
|
|
644
652
|
}
|
|
645
|
-
export {
|
|
653
|
+
export { fetchCandlesSequentially, outputPath };
|
|
654
|
+
/** Internal seams exercised directly by tests. */
|
|
655
|
+
export const __test = { applyPrecisionOverrides, parseBotsConfig, selectBot, loadCachedFetchContext, parseArgs };
|
|
646
656
|
//# sourceMappingURL=fetch_lp_data.js.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
declare const OP_TYPE_FEED = 19;
|
|
2
1
|
interface AssetRef {
|
|
3
2
|
id?: string;
|
|
4
3
|
precision?: number;
|
|
@@ -135,5 +134,18 @@ declare function fetchFeedCandlesSequentially(feedCtx: FeedContext, assetA: Asse
|
|
|
135
134
|
};
|
|
136
135
|
outPath?: string;
|
|
137
136
|
}): Promise<number[][]>;
|
|
138
|
-
export {
|
|
137
|
+
export { fetchFeedCandlesSequentially };
|
|
138
|
+
/** Internal seams exercised directly by tests. */
|
|
139
|
+
export declare const __test: {
|
|
140
|
+
OP_TYPE_FEED: number;
|
|
141
|
+
backingPerMpa: typeof backingPerMpa;
|
|
142
|
+
hitToFeedPrice: typeof hitToFeedPrice;
|
|
143
|
+
buildFeedDocumentQuery: typeof buildFeedDocumentQuery;
|
|
144
|
+
crossPointsToRatios: typeof crossPointsToRatios;
|
|
145
|
+
bucketPricesToCandles: typeof bucketPricesToCandles;
|
|
146
|
+
invertCandles: typeof invertCandles;
|
|
147
|
+
getFeedCandlesForMpa: typeof getFeedCandlesForMpa;
|
|
148
|
+
getFeedCandlesForPair: typeof getFeedCandlesForPair;
|
|
149
|
+
getFeedCandlesForMpaCross: typeof getFeedCandlesForMpaCross;
|
|
150
|
+
};
|
|
139
151
|
//# sourceMappingURL=kibana_feed_source.d.ts.map
|
|
@@ -584,5 +584,18 @@ async function fetchFeedCandlesSequentially(feedCtx, assetA, assetB, opts = {})
|
|
|
584
584
|
});
|
|
585
585
|
return flipped ? invertCandles(merged) : merged;
|
|
586
586
|
}
|
|
587
|
-
export {
|
|
587
|
+
export { fetchFeedCandlesSequentially };
|
|
588
|
+
/** Internal seams exercised directly by tests. */
|
|
589
|
+
export const __test = {
|
|
590
|
+
OP_TYPE_FEED,
|
|
591
|
+
backingPerMpa,
|
|
592
|
+
hitToFeedPrice,
|
|
593
|
+
buildFeedDocumentQuery,
|
|
594
|
+
crossPointsToRatios,
|
|
595
|
+
bucketPricesToCandles,
|
|
596
|
+
invertCandles,
|
|
597
|
+
getFeedCandlesForMpa,
|
|
598
|
+
getFeedCandlesForPair,
|
|
599
|
+
getFeedCandlesForMpaCross,
|
|
600
|
+
};
|
|
588
601
|
//# sourceMappingURL=kibana_feed_source.js.map
|
|
@@ -87,9 +87,7 @@ interface RunCachedWindowsOptions {
|
|
|
87
87
|
lte: string;
|
|
88
88
|
}) => void;
|
|
89
89
|
}
|
|
90
|
-
declare const TAIL_REFRESH_HOURS = 48;
|
|
91
90
|
declare const TAIL_SETTLE_LAG_MS: number;
|
|
92
|
-
declare const GAP_SETTLE_HORIZON_MS: number;
|
|
93
91
|
declare const MAX_COVERAGE_SPANS = 64;
|
|
94
92
|
declare function readCacheChunk(chunkFile: string, requestKey: unknown, isMatch: (meta: unknown, requestKey: unknown) => boolean): CacheChunk | null;
|
|
95
93
|
declare function loadBucketCache(outPath: string, requestKey: unknown, isMatch: (meta: unknown, requestKey: unknown) => boolean, range?: {
|
|
@@ -174,6 +172,19 @@ declare function formatWindowLine(unit: string, index: number, total: number, gt
|
|
|
174
172
|
* touch nothing on disk.
|
|
175
173
|
*/
|
|
176
174
|
declare function runCachedWindows(opts: RunCachedWindowsOptions): Promise<Candle[]>;
|
|
177
|
-
export {
|
|
175
|
+
export { TAIL_SETTLE_LAG_MS, MAX_COVERAGE_SPANS, shardKeyForTimestamp, shardBoundsForKey, shardKeysForRange, shardPathFor, unionQueriedRanges, compactCoverage, rangesCoveredBy, coverageSatisfied, verifiedAt, timestampMs, allQueriedRanges, buildFetchWindowsFromRange, formatWindowLine, runCachedWindows, };
|
|
176
|
+
/** Internal seams exercised directly by tests. */
|
|
177
|
+
export declare const __test: {
|
|
178
|
+
TAIL_REFRESH_HOURS: number;
|
|
179
|
+
GAP_SETTLE_HORIZON_MS: number;
|
|
180
|
+
readCacheChunk: typeof readCacheChunk;
|
|
181
|
+
loadBucketCache: typeof loadBucketCache;
|
|
182
|
+
settleCoverage: typeof settleCoverage;
|
|
183
|
+
findMissingBucketRanges: typeof findMissingBucketRanges;
|
|
184
|
+
mergeGapRanges: typeof mergeGapRanges;
|
|
185
|
+
pruneImmutableGaps: typeof pruneImmutableGaps;
|
|
186
|
+
persistCacheChunk: typeof persistCacheChunk;
|
|
187
|
+
planWindowReuse: typeof planWindowReuse;
|
|
188
|
+
};
|
|
178
189
|
export type { QueriedRange } from '../utils/month_shards.js';
|
|
179
190
|
//# sourceMappingURL=window_cache.d.ts.map
|
|
@@ -822,5 +822,18 @@ async function runCachedWindows(opts) {
|
|
|
822
822
|
}
|
|
823
823
|
return merged;
|
|
824
824
|
}
|
|
825
|
-
export {
|
|
825
|
+
export { TAIL_SETTLE_LAG_MS, MAX_COVERAGE_SPANS, shardKeyForTimestamp, shardBoundsForKey, shardKeysForRange, shardPathFor, unionQueriedRanges, compactCoverage, rangesCoveredBy, coverageSatisfied, verifiedAt, timestampMs, allQueriedRanges, buildFetchWindowsFromRange, formatWindowLine, runCachedWindows, };
|
|
826
|
+
/** Internal seams exercised directly by tests. */
|
|
827
|
+
export const __test = {
|
|
828
|
+
TAIL_REFRESH_HOURS,
|
|
829
|
+
GAP_SETTLE_HORIZON_MS,
|
|
830
|
+
readCacheChunk,
|
|
831
|
+
loadBucketCache,
|
|
832
|
+
settleCoverage,
|
|
833
|
+
findMissingBucketRanges,
|
|
834
|
+
mergeGapRanges,
|
|
835
|
+
pruneImmutableGaps,
|
|
836
|
+
persistCacheChunk,
|
|
837
|
+
planWindowReuse,
|
|
838
|
+
};
|
|
826
839
|
//# sourceMappingURL=window_cache.js.map
|
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import { findLatestLpData } from './utils/data_discovery.js';
|
|
2
|
-
declare const DEFAULT_COMPARISON_STRATEGIES: {
|
|
3
|
-
name: string;
|
|
4
|
-
erPeriod: number;
|
|
5
|
-
fastPeriod: number;
|
|
6
|
-
slowPeriod: number;
|
|
7
|
-
color: string;
|
|
8
|
-
dash: string;
|
|
9
|
-
}[];
|
|
10
2
|
type NormalizedLpCandle = [number, number, number, number, number, number];
|
|
11
3
|
interface LpCandleObject {
|
|
12
4
|
timestamp: number;
|
|
@@ -117,5 +109,16 @@ declare function generateLpChartBundle(options?: BundleChartOptions): {
|
|
|
117
109
|
marketChart: ReturnType<typeof generateMarketLpChart>;
|
|
118
110
|
comparisonChart: ReturnType<typeof generateComparisonLpChart>;
|
|
119
111
|
};
|
|
120
|
-
export {
|
|
112
|
+
export { calculateMetrics, defaultMarketChartPath, findLatestLpData, generateComparisonLpChart, generateLpChartBundle, generateMarketLpChart, loadLpDataFile, parseLpChartCliArgs };
|
|
113
|
+
/** Internal seams exercised directly by tests. */
|
|
114
|
+
export declare const __test: {
|
|
115
|
+
DEFAULT_COMPARISON_STRATEGIES: {
|
|
116
|
+
name: string;
|
|
117
|
+
erPeriod: number;
|
|
118
|
+
fastPeriod: number;
|
|
119
|
+
slowPeriod: number;
|
|
120
|
+
color: string;
|
|
121
|
+
dash: string;
|
|
122
|
+
}[];
|
|
123
|
+
};
|
|
121
124
|
//# sourceMappingURL=lp_chart_runner.d.ts.map
|
|
@@ -323,5 +323,7 @@ function generateLpChartBundle(options = {}) {
|
|
|
323
323
|
comparisonChart,
|
|
324
324
|
};
|
|
325
325
|
}
|
|
326
|
-
export {
|
|
326
|
+
export { calculateMetrics, defaultMarketChartPath, findLatestLpData, generateComparisonLpChart, generateLpChartBundle, generateMarketLpChart, loadLpDataFile, parseLpChartCliArgs };
|
|
327
|
+
/** Internal seams exercised directly by tests. */
|
|
328
|
+
export const __test = { DEFAULT_COMPARISON_STRATEGIES };
|
|
327
329
|
//# sourceMappingURL=lp_chart_runner.js.map
|
|
@@ -40,5 +40,9 @@ declare function loadStrategiesForLpChart({ dataFile, meta, profilesFile, extraS
|
|
|
40
40
|
profilesFile?: string | null;
|
|
41
41
|
extraSearchDirs?: string[];
|
|
42
42
|
}): AmaStrategy[] | null;
|
|
43
|
-
export { loadStrategiesForLpChart
|
|
43
|
+
export { loadStrategiesForLpChart };
|
|
44
|
+
/** Internal seams exercised directly by tests. */
|
|
45
|
+
export declare const __test: {
|
|
46
|
+
loadStrategiesFromProfiles: typeof loadStrategiesFromProfiles;
|
|
47
|
+
};
|
|
44
48
|
//# sourceMappingURL=lp_chart_strategy_loader.d.ts.map
|
|
@@ -163,5 +163,7 @@ function loadStrategiesForLpChart({ dataFile, meta, profilesFile, extraSearchDir
|
|
|
163
163
|
}
|
|
164
164
|
return loadStrategiesFromProfiles(profilesFile, meta);
|
|
165
165
|
}
|
|
166
|
-
export { loadStrategiesForLpChart
|
|
166
|
+
export { loadStrategiesForLpChart };
|
|
167
|
+
/** Internal seams exercised directly by tests. */
|
|
168
|
+
export const __test = { loadStrategiesFromProfiles };
|
|
167
169
|
//# sourceMappingURL=lp_chart_strategy_loader.js.map
|
|
@@ -271,7 +271,7 @@ declare function buildAmaRecord(botAma: unknown, amaPrice: number): {
|
|
|
271
271
|
}[];
|
|
272
272
|
declare function fetchNativeMarketHistorySince(assetA: unknown, assetB: unknown, sinceMs: number, untilMs: number, intervalSeconds: number, options?: {
|
|
273
273
|
fillCandleGaps?: (...args: unknown[]) => unknown;
|
|
274
|
-
}): Promise<
|
|
274
|
+
}): Promise<[number, number, number, number, number, number][]>;
|
|
275
275
|
declare function writeGridResetTrigger(bot: Record<string, unknown>, payload: Record<string, unknown>): string;
|
|
276
276
|
/**
|
|
277
277
|
* Atomically write the dynamic grid snapshot for a bot to profiles/orders/<botKey>.dynamicgrid.json.
|
|
@@ -324,5 +324,13 @@ declare function runOnceForAma(overrides?: object): Promise<{
|
|
|
324
324
|
updatedAt: string;
|
|
325
325
|
}>;
|
|
326
326
|
declare function main(): Promise<0 | 1>;
|
|
327
|
-
export { main, runOnceForAma, DEFAULT_AMA, DEFAULTS, calculateBotThreshold, buildAmaRecord, computeCandleStaleness, normalizeMarketSource, sleepUntilAlignedBoundary, computeStartupDelayMs, evaluateStartupSleep, resolveAmaForBot,
|
|
327
|
+
export { main, runOnceForAma, DEFAULT_AMA, DEFAULTS, calculateBotThreshold, buildAmaRecord, computeCandleStaleness, normalizeMarketSource, sleepUntilAlignedBoundary, computeStartupDelayMs, evaluateStartupSleep, resolveAmaForBot, applyRuntimeDefaultsFromGeneralSettings, resolveBotCfg, usesAmaGridPrice, isBotWhitelisted, isBotDynamicWeightWhitelisted, isBotAsymmetricBoundsWhitelisted, writeCenterSnapshot, writeBotDynamicGrid, writeGridResetTrigger, normalizeNativeMarketHistoryCandles, fetchNativeMarketHistorySince, loadMarketAdapterSettings, findPairForBot };
|
|
328
|
+
/** Internal seams exercised directly by tests. */
|
|
329
|
+
export declare const __test: {
|
|
330
|
+
resolveDeltaThresholdPercentFromGeneralSettings: typeof resolveDeltaThresholdPercentFromGeneralSettings;
|
|
331
|
+
resolveAmaSlopeDeltaThresholdPercentFromGeneralSettings: typeof resolveAmaSlopeDeltaThresholdPercentFromGeneralSettings;
|
|
332
|
+
_resetCycleCache: typeof _resetCycleCache;
|
|
333
|
+
mergeGridResetMetadataFromDynamicGrid: typeof mergeGridResetMetadataFromDynamicGrid;
|
|
334
|
+
_setBitsharesClientForTests: typeof setBitsharesClientForTests;
|
|
335
|
+
};
|
|
328
336
|
//# sourceMappingURL=market_adapter.d.ts.map
|
|
@@ -1037,16 +1037,7 @@ async function fetchNativeMarketHistorySince(assetA, assetB, sinceMs, untilMs, i
|
|
|
1037
1037
|
}
|
|
1038
1038
|
const startDate = new Date(Number.isFinite(sinceMs) ? sinceMs : Date.now());
|
|
1039
1039
|
const stopDate = new Date(Number.isFinite(untilMs) ? untilMs : Date.now());
|
|
1040
|
-
|
|
1041
|
-
if (typeof BitShares.history?.getMarketHistory === 'function') {
|
|
1042
|
-
history = await BitShares.history.getMarketHistory(b.id, a.id, intervalSeconds, startDate.toISOString().slice(0, -5), stopDate.toISOString().slice(0, -5));
|
|
1043
|
-
}
|
|
1044
|
-
else if (typeof BitShares.tradeHistory === 'function') {
|
|
1045
|
-
history = await BitShares.tradeHistory(b.symbol || b.id, a.symbol || a.id, startDate, stopDate, intervalSeconds);
|
|
1046
|
-
}
|
|
1047
|
-
else {
|
|
1048
|
-
throw new Error('native market history source unavailable');
|
|
1049
|
-
}
|
|
1040
|
+
const history = await BitShares.history.getMarketHistory(b.id, a.id, intervalSeconds, startDate.toISOString().slice(0, -5), stopDate.toISOString().slice(0, -5));
|
|
1050
1041
|
let candles = normalizeNativeMarketHistoryCandles(history, a, b);
|
|
1051
1042
|
if (candles.length > 0 && typeof options.fillCandleGaps === 'function') {
|
|
1052
1043
|
candles = options.fillCandleGaps(candles, intervalSeconds);
|
|
@@ -1588,5 +1579,13 @@ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
|
|
|
1588
1579
|
process.exit(1);
|
|
1589
1580
|
});
|
|
1590
1581
|
}
|
|
1591
|
-
export { main, runOnceForAma, DEFAULT_AMA, DEFAULTS, calculateBotThreshold, buildAmaRecord, computeCandleStaleness, normalizeMarketSource, sleepUntilAlignedBoundary, computeStartupDelayMs, evaluateStartupSleep, resolveAmaForBot,
|
|
1582
|
+
export { main, runOnceForAma, DEFAULT_AMA, DEFAULTS, calculateBotThreshold, buildAmaRecord, computeCandleStaleness, normalizeMarketSource, sleepUntilAlignedBoundary, computeStartupDelayMs, evaluateStartupSleep, resolveAmaForBot, applyRuntimeDefaultsFromGeneralSettings, resolveBotCfg, usesAmaGridPrice, isBotWhitelisted, isBotDynamicWeightWhitelisted, isBotAsymmetricBoundsWhitelisted, writeCenterSnapshot, writeBotDynamicGrid, writeGridResetTrigger, normalizeNativeMarketHistoryCandles, fetchNativeMarketHistorySince, loadMarketAdapterSettings, findPairForBot };
|
|
1583
|
+
/** Internal seams exercised directly by tests. */
|
|
1584
|
+
export const __test = {
|
|
1585
|
+
resolveDeltaThresholdPercentFromGeneralSettings,
|
|
1586
|
+
resolveAmaSlopeDeltaThresholdPercentFromGeneralSettings,
|
|
1587
|
+
_resetCycleCache,
|
|
1588
|
+
mergeGridResetMetadataFromDynamicGrid,
|
|
1589
|
+
_setBitsharesClientForTests: setBitsharesClientForTests,
|
|
1590
|
+
};
|
|
1592
1591
|
//# sourceMappingURL=market_adapter.js.map
|
|
@@ -9,7 +9,6 @@ interface RpcClient {
|
|
|
9
9
|
BitShares: {
|
|
10
10
|
db: RpcProxy;
|
|
11
11
|
history: RpcProxy;
|
|
12
|
-
tradeHistory?: (...args: unknown[]) => Promise<unknown>;
|
|
13
12
|
[method: string]: unknown;
|
|
14
13
|
};
|
|
15
14
|
}
|
|
@@ -20,7 +19,7 @@ interface BitsharesClient extends RpcClient {
|
|
|
20
19
|
[key: string]: unknown;
|
|
21
20
|
}
|
|
22
21
|
/** Resolved asset identity used by the pool/context helpers. */
|
|
23
|
-
|
|
22
|
+
interface ResolvedAsset {
|
|
24
23
|
id: string;
|
|
25
24
|
precision: number;
|
|
26
25
|
symbol: string;
|
|
@@ -44,7 +43,7 @@ declare function normalizeMarketSource(raw: unknown): 'pool' | 'book' | null;
|
|
|
44
43
|
declare function hasNumericStartPrice(raw: unknown): boolean;
|
|
45
44
|
declare function resolveMarketSourceForBot(bot: unknown): 'pool' | 'book' | null;
|
|
46
45
|
declare function normalizePoolId(id: unknown): string | null;
|
|
47
|
-
|
|
46
|
+
interface ResolvedBotContext {
|
|
48
47
|
assetA: ResolvedAsset;
|
|
49
48
|
assetB: ResolvedAsset;
|
|
50
49
|
poolId: string | null;
|
|
@@ -25,5 +25,9 @@ declare function readCachedJson<T>(filePath: string, loader: () => T): T;
|
|
|
25
25
|
declare function noteJsonWritten(filePath: string, value: unknown): void;
|
|
26
26
|
/** Drop every cached entry (config reload, tests, explicit cache busting). */
|
|
27
27
|
declare function clearJsonCache(): void;
|
|
28
|
-
export { readCachedJson, noteJsonWritten
|
|
28
|
+
export { readCachedJson, noteJsonWritten };
|
|
29
|
+
/** Internal seams exercised directly by tests. */
|
|
30
|
+
export declare const __test: {
|
|
31
|
+
clearJsonCache: typeof clearJsonCache;
|
|
32
|
+
};
|
|
29
33
|
//# sourceMappingURL=file_json_cache.d.ts.map
|
|
@@ -102,5 +102,7 @@ function noteJsonWritten(filePath, value) {
|
|
|
102
102
|
function clearJsonCache() {
|
|
103
103
|
_cache.clear();
|
|
104
104
|
}
|
|
105
|
-
export { readCachedJson, noteJsonWritten
|
|
105
|
+
export { readCachedJson, noteJsonWritten };
|
|
106
|
+
/** Internal seams exercised directly by tests. */
|
|
107
|
+
export const __test = { clearJsonCache };
|
|
106
108
|
//# sourceMappingURL=file_json_cache.js.map
|
|
@@ -84,7 +84,7 @@ function _resolveLockPayload(lockPath, opts, timeoutMs) {
|
|
|
84
84
|
const buildPayloadFn = opts.buildPayload;
|
|
85
85
|
const buildPayload = typeof buildPayloadFn === 'function'
|
|
86
86
|
? () => ({ ...buildPayloadFn(), ownerId })
|
|
87
|
-
: () => ({ pid:
|
|
87
|
+
: () => ({ pid: runtime.pid, at: Date.now(), ownerId });
|
|
88
88
|
const alreadyRunningMsg = opts.alreadyRunningMsg;
|
|
89
89
|
const resolveRunningMsg = typeof alreadyRunningMsg === 'function'
|
|
90
90
|
? alreadyRunningMsg
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/** Asset identity/precision needed to convert chain amounts. */
|
|
2
|
-
|
|
2
|
+
interface NativeHistoryAssetMeta {
|
|
3
3
|
id?: unknown;
|
|
4
4
|
precision?: number;
|
|
5
5
|
}
|
|
6
6
|
/** Normalized OHLCV candle: [tsMs, open, high, low, close, volume]. */
|
|
7
|
-
|
|
7
|
+
type NativeHistoryCandle = [number, number, number, number, number, number];
|
|
8
8
|
/**
|
|
9
9
|
* Native BitShares market history parsing utilities.
|
|
10
10
|
*
|
|
@@ -14,5 +14,9 @@ export type NativeHistoryCandle = [number, number, number, number, number, numbe
|
|
|
14
14
|
*/
|
|
15
15
|
declare function parseNativeMarketHistoryTimestamp(entry: unknown): number | null;
|
|
16
16
|
declare function normalizeNativeMarketHistoryCandles(history: unknown, assetA: NativeHistoryAssetMeta, assetB: NativeHistoryAssetMeta): NativeHistoryCandle[];
|
|
17
|
-
export {
|
|
17
|
+
export { normalizeNativeMarketHistoryCandles };
|
|
18
|
+
/** Internal seams exercised directly by tests. */
|
|
19
|
+
export declare const __test: {
|
|
20
|
+
parseNativeMarketHistoryTimestamp: typeof parseNativeMarketHistoryTimestamp;
|
|
21
|
+
};
|
|
18
22
|
//# sourceMappingURL=native_history.d.ts.map
|
|
@@ -153,5 +153,7 @@ function normalizeNativeMarketHistoryCandles(history, assetA, assetB) {
|
|
|
153
153
|
}
|
|
154
154
|
return candles.sort((a, b) => a[0] - b[0]);
|
|
155
155
|
}
|
|
156
|
-
export {
|
|
156
|
+
export { normalizeNativeMarketHistoryCandles };
|
|
157
|
+
/** Internal seams exercised directly by tests. */
|
|
158
|
+
export const __test = { parseNativeMarketHistoryTimestamp };
|
|
157
159
|
//# sourceMappingURL=native_history.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
interface OrientableAsset {
|
|
2
2
|
id?: string | null;
|
|
3
3
|
precision?: unknown;
|
|
4
4
|
symbol?: string | null;
|
|
5
5
|
}
|
|
6
6
|
/** The asset legs stored on every shard meta and cache request key. */
|
|
7
|
-
|
|
7
|
+
interface AssetPairLike {
|
|
8
8
|
assetA?: {
|
|
9
9
|
id?: string | null;
|
|
10
10
|
precision?: unknown;
|
|
@@ -157,6 +157,9 @@ declare function loadGeneralSettings(): {
|
|
|
157
157
|
FILL_TOTALS_RETRY_MAX_MS: number;
|
|
158
158
|
SPREAD_STALE_WARN_MS: number;
|
|
159
159
|
SPREAD_STALE_ESCALATE_MS: number;
|
|
160
|
+
SPREAD_STALE_IN_TOLERANCE_RESET_MS: number;
|
|
161
|
+
SPREAD_STALE_FUND_ESCALATE_MS: number;
|
|
162
|
+
SPREAD_STALE_GEOMETRY_ESCALATE_MS: number;
|
|
160
163
|
SPREAD_CORRECTION_MAX_ATTEMPTS: number;
|
|
161
164
|
SPREAD_STALE_TRANSIENT_GRACE: number;
|
|
162
165
|
SPREAD_CORRECTION_SYNC_FRESH_MS: number;
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
*
|
|
34
34
|
* ===============================================================================
|
|
35
35
|
*
|
|
36
|
-
* USAGE:
|
|
37
|
-
*
|
|
36
|
+
* USAGE (from the repo root):
|
|
37
|
+
* import { readBotsFileWithLock, writeBotsFileWithLock, readBotsFileSync } from './modules/bots_file_lock.js';
|
|
38
38
|
* const { config } = await readBotsFileWithLock('./profiles/bots.json', JSON.parse);
|
|
39
39
|
* await writeBotsFileWithLock('./profiles/bots.json', updatedConfig);
|
|
40
40
|
*
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
*
|
|
34
34
|
* ===============================================================================
|
|
35
35
|
*
|
|
36
|
-
* USAGE:
|
|
37
|
-
*
|
|
36
|
+
* USAGE (from the repo root):
|
|
37
|
+
* import { readBotsFileWithLock, writeBotsFileWithLock, readBotsFileSync } from './modules/bots_file_lock.js';
|
|
38
38
|
* const { config } = await readBotsFileWithLock('./profiles/bots.json', JSON.parse);
|
|
39
39
|
* await writeBotsFileWithLock('./profiles/bots.json', updatedConfig);
|
|
40
40
|
*
|
|
@@ -202,7 +202,7 @@ declare class MasterPasswordError extends Error {
|
|
|
202
202
|
* @returns {boolean} True if the error indicates authentication could not complete
|
|
203
203
|
*/
|
|
204
204
|
declare function isMasterPasswordFailure(err: unknown): boolean;
|
|
205
|
-
type VaultSecret = {
|
|
205
|
+
export type VaultSecret = {
|
|
206
206
|
kind: string;
|
|
207
207
|
version: number;
|
|
208
208
|
vaultKeyHex: string;
|
|
@@ -230,6 +230,9 @@ declare let TIMING: {
|
|
|
230
230
|
FILL_TOTALS_RETRY_MAX_MS: number;
|
|
231
231
|
SPREAD_STALE_WARN_MS: number;
|
|
232
232
|
SPREAD_STALE_ESCALATE_MS: number;
|
|
233
|
+
SPREAD_STALE_IN_TOLERANCE_RESET_MS: number;
|
|
234
|
+
SPREAD_STALE_FUND_ESCALATE_MS: number;
|
|
235
|
+
SPREAD_STALE_GEOMETRY_ESCALATE_MS: number;
|
|
233
236
|
SPREAD_CORRECTION_MAX_ATTEMPTS: number;
|
|
234
237
|
SPREAD_STALE_TRANSIENT_GRACE: number;
|
|
235
238
|
SPREAD_CORRECTION_SYNC_FRESH_MS: number;
|
|
@@ -773,6 +776,9 @@ declare function buildDefaultGeneralSettings(): {
|
|
|
773
776
|
FILL_TOTALS_RETRY_MAX_MS: number;
|
|
774
777
|
SPREAD_STALE_WARN_MS: number;
|
|
775
778
|
SPREAD_STALE_ESCALATE_MS: number;
|
|
779
|
+
SPREAD_STALE_IN_TOLERANCE_RESET_MS: number;
|
|
780
|
+
SPREAD_STALE_FUND_ESCALATE_MS: number;
|
|
781
|
+
SPREAD_STALE_GEOMETRY_ESCALATE_MS: number;
|
|
776
782
|
SPREAD_CORRECTION_MAX_ATTEMPTS: number;
|
|
777
783
|
SPREAD_STALE_TRANSIENT_GRACE: number;
|
|
778
784
|
SPREAD_CORRECTION_SYNC_FRESH_MS: number;
|
|
@@ -335,6 +335,31 @@ let TIMING = {
|
|
|
335
335
|
// by moving the boundary). Time-based so it holds for any tick cadence.
|
|
336
336
|
SPREAD_STALE_WARN_MS: 10 * 60 * 1000, // 10 minutes
|
|
337
337
|
SPREAD_STALE_ESCALATE_MS: 30 * 60 * 1000, // 30 minutes
|
|
338
|
+
// SPREAD_STALE_IN_TOLERANCE_RESET_MS: how long the spread must stay
|
|
339
|
+
// continuously within tolerance before the persistence clock is cleared.
|
|
340
|
+
// A single in-tolerance reading between refusals must NOT clear it: the
|
|
341
|
+
// measured spread oscillates around the threshold, and resetting on each
|
|
342
|
+
// good glance let a live bot sit out of tolerance for 84 minutes while
|
|
343
|
+
// every individual cycle looked recoverable. A placed correction always
|
|
344
|
+
// clears the clock immediately.
|
|
345
|
+
SPREAD_STALE_IN_TOLERANCE_RESET_MS: 10 * 60 * 1000, // 10 minutes
|
|
346
|
+
// SPREAD_STALE_FUND_ESCALATE_MS: escalated window used when the correction
|
|
347
|
+
// reports a RAIL-OVERSUBSCRIBED fund stall (virtual reservation > chain
|
|
348
|
+
// free on the corrected side, e.g. free 454560 vs virtual 456046). That is
|
|
349
|
+
// not "wait for a fill" — the rail itself must be re-sized from chain
|
|
350
|
+
// truth, which the structural re-center does. A shorter window keeps the
|
|
351
|
+
// side dead for minutes instead of the 84 minutes observed live.
|
|
352
|
+
SPREAD_STALE_FUND_ESCALATE_MS: 5 * 60 * 1000, // 5 minutes
|
|
353
|
+
// SPREAD_STALE_GEOMETRY_ESCALATE_MS: escalated window used when the
|
|
354
|
+
// correction reports the geometry bind 'last-fill-blocked' — every
|
|
355
|
+
// tightening slot on the corrected side sits at/through the last fill, i.e.
|
|
356
|
+
// the window itself is behind the last fill (boundary/crawl lag). No
|
|
357
|
+
// amount of waiting fixes that; a re-center does, because it re-derives the
|
|
358
|
+
// center AROUND that same pivot. Waiting the structural 30 minutes just
|
|
359
|
+
// leaves the side unquoted. Capped at ONE re-center per pivot value
|
|
360
|
+
// (`_lastGeometryResyncPivotKey`): the pivot does not move with the grid, so
|
|
361
|
+
// a second attempt re-derives the identical veto.
|
|
362
|
+
SPREAD_STALE_GEOMETRY_ESCALATE_MS: 10 * 60 * 1000, // 10 minutes
|
|
338
363
|
// SPREAD_CORRECTION_MAX_ATTEMPTS: bounded attempts for one spread-correction
|
|
339
364
|
// cycle (initial broadcast + fresh-master re-plan retries). Kept next to the
|
|
340
365
|
// other SPREAD_* tunables so the retry budget is centralized; a value < 1
|
|
@@ -1162,7 +1187,7 @@ let MARKET_ADAPTER = {
|
|
|
1162
1187
|
// Lower values make the AMA channel reach maximum influence more easily.
|
|
1163
1188
|
// Higher values require a stronger price move before AMA reaches full effect.
|
|
1164
1189
|
// nob: amaS% (AMA Max Slope %)
|
|
1165
|
-
DYNAMIC_WEIGHT_AMA_MAX_SLOPE_PCT: 0.
|
|
1190
|
+
DYNAMIC_WEIGHT_AMA_MAX_SLOPE_PCT: 0.1,
|
|
1166
1191
|
// DYNAMIC_WEIGHT_KALMAN_MAX_SLOPE_PCT: Trend size that counts as "full strength" for
|
|
1167
1192
|
// the Kalman composite branch. Kept separate from the AMA slope knob so the two
|
|
1168
1193
|
// channels can saturate independently.
|
|
@@ -1383,9 +1408,15 @@ let MARKET_ADAPTER = {
|
|
|
1383
1408
|
// DEFAULT_AMA_KEY: Built-in default profile for `gridPrice: "ama"` when no
|
|
1384
1409
|
// pair-specific market_profiles entry exists.
|
|
1385
1410
|
DEFAULT_AMA_KEY: 'AMA3',
|
|
1386
|
-
// AMAS: Built-in AMA presets
|
|
1387
|
-
// Fitted with per-AMA λ weights (0.0031 / 0.0025 / 0.00185 / 0.0013) on 1h candles
|
|
1411
|
+
// AMAS: Built-in AMA presets. AMA1 is the fitted winner (λ=0.0031) on 1h candles
|
|
1388
1412
|
// (2023-07 → 2026-07, SMA-warmup-aligned optimizer, ER=781 fixed, Fast=5.2 fixed).
|
|
1413
|
+
// AMA2–AMA4 are spaced from AMA1 on an exact −9%-per-step effective-smoothing
|
|
1414
|
+
// ladder evaluated at AMA_CONVERGENCE_ER_AVG (0.151):
|
|
1415
|
+
// smooth = (ER·(fastSC−slowSC) + slowSC)², fastSC = 2/(fastPeriod+1),
|
|
1416
|
+
// slowSC = 2/(slowPeriod+1).
|
|
1417
|
+
// Unrounded targets are 62.10 / 71.48 / 83.46 / 99.27; the values below are
|
|
1418
|
+
// rounded to one decimal (the optimizer's 0.1 quantum). Re-derive if
|
|
1419
|
+
// fastPeriod or AMA_CONVERGENCE_ER_AVG changes.
|
|
1389
1420
|
// These serve as stable defaults for the market adapter and can be overridden by
|
|
1390
1421
|
// pair-specific profiles in profiles/market_profiles.json.
|
|
1391
1422
|
AMAS: {
|
|
@@ -1399,19 +1430,19 @@ let MARKET_ADAPTER = {
|
|
|
1399
1430
|
name: 'AMA2',
|
|
1400
1431
|
erPeriod: 781,
|
|
1401
1432
|
fastPeriod: 5.2,
|
|
1402
|
-
slowPeriod:
|
|
1433
|
+
slowPeriod: 71.5,
|
|
1403
1434
|
},
|
|
1404
1435
|
AMA3: {
|
|
1405
1436
|
name: 'AMA3',
|
|
1406
1437
|
erPeriod: 781,
|
|
1407
1438
|
fastPeriod: 5.2,
|
|
1408
|
-
slowPeriod: 83.
|
|
1439
|
+
slowPeriod: 83.5,
|
|
1409
1440
|
},
|
|
1410
1441
|
AMA4: {
|
|
1411
1442
|
name: 'AMA4',
|
|
1412
1443
|
erPeriod: 781,
|
|
1413
1444
|
fastPeriod: 5.2,
|
|
1414
|
-
slowPeriod:
|
|
1445
|
+
slowPeriod: 99.3,
|
|
1415
1446
|
},
|
|
1416
1447
|
},
|
|
1417
1448
|
// AMA_CONVERGENCE_ER_AVG: Typical market Efficiency Ratio used to estimate
|