dexbot 1.6.12 → 1.6.14
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 +65 -1
- package/README.md +2 -2
- package/analysis/README.md +9 -11
- package/analysis/ama_fitting/README.md +5 -3
- package/claw/README.md +1 -0
- package/claw/docs/AI_BOT_LIBRARY_API.md +3 -1
- package/claw/docs/DEXBOT2_TUNING_CHEAT_SHEET.md +4 -4
- package/claw/modules/claw_bridge.ts +0 -3
- package/claw/modules/claw_catalog.ts +8 -4
- package/claw/modules/claw_skill_md.ts +1 -0
- package/claw/modules/dexbot_profiles.ts +59 -15
- package/claw/modules/types.ts +2 -1
- package/claw/package.json +3 -3
- package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
- package/claw/runtimes/openclaw-plugin/package.json +1 -1
- package/claw/skills/margin-trading/SKILL.md +1 -1
- package/claw/skills/margin-trading/references/position-management.md +1 -1
- package/claw/tsconfig.json +2 -2
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js +1 -14
- package/dist/analysis/ama_fitting/fetch_lp_candles.js +51 -41
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts +1 -24
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js +36 -18
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js +18 -66
- package/dist/analysis/analyze_args.d.ts +12 -0
- package/dist/analysis/analyze_args.js +20 -0
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts +1 -16
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js +20 -101
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js +26 -92
- package/dist/analysis/bot_fitting/backtest_lookback_drawdown.js +19 -34
- package/dist/analysis/bot_fitting/shared_utils.d.ts +71 -3
- package/dist/analysis/bot_fitting/shared_utils.js +124 -8
- package/dist/analysis/chart_ui.d.ts +30 -1
- package/dist/analysis/chart_ui.js +37 -1
- package/dist/analysis/fills_cache.d.ts +3 -23
- package/dist/analysis/fills_cache.js +3 -84
- package/dist/analysis/fills_source.d.ts +31 -1
- package/dist/analysis/fills_source.js +69 -1
- package/dist/analysis/grid_correction_check.d.ts +1 -23
- package/dist/analysis/grid_correction_check.js +15 -58
- package/dist/analysis/math_utils.d.ts +85 -1
- package/dist/analysis/math_utils.js +116 -1
- package/dist/analysis/price_sources.d.ts +22 -1
- package/dist/analysis/price_sources.js +23 -0
- package/dist/analysis/resolve_source.js +31 -10
- package/dist/analysis/trade_profitability.d.ts +6 -0
- package/dist/analysis/trade_profitability.js +23 -97
- package/dist/analysis/tradingview/analyze_tradingview.d.ts +1 -17
- package/dist/analysis/tradingview/analyze_tradingview.js +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +27 -40
- package/dist/analysis/trend_detection/backtest_ama_slope_huber.d.ts +1 -101
- package/dist/analysis/trend_detection/backtest_ama_slope_huber.js +22 -80
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +11 -37
- package/dist/analysis/trend_detection/volatility_chart_generator.js +9 -10
- package/dist/analysis/worker_pool.d.ts +38 -0
- package/dist/analysis/worker_pool.js +67 -0
- package/dist/dexbot.js +67 -48
- package/dist/market_adapter/ama_signal_runner.js +21 -54
- package/dist/market_adapter/candle_utils.d.ts +7 -1
- package/dist/market_adapter/candle_utils.js +11 -1
- package/dist/market_adapter/cli_args.d.ts +22 -0
- package/dist/market_adapter/cli_args.js +30 -0
- package/dist/market_adapter/core/config_normalizers.js +11 -6
- package/dist/market_adapter/core/kibana_candles.d.ts +3 -1
- package/dist/market_adapter/core/kibana_candles.js +3 -2
- package/dist/market_adapter/core/market_adapter_service.d.ts +85 -85
- package/dist/market_adapter/core/market_adapter_service.js +93 -158
- package/dist/market_adapter/core/signals/hurst_analyzer.d.ts +1 -6
- package/dist/market_adapter/core/signals/hurst_analyzer.js +1 -1
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.d.ts +1 -11
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js +1 -1
- package/dist/market_adapter/inputs/fetch_book_data.js +0 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +63 -107
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts +8 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js +25 -7
- package/dist/market_adapter/inputs/kibana_feed_source.js +4 -26
- package/dist/market_adapter/inputs/window_cache.d.ts +4 -72
- package/dist/market_adapter/inputs/window_cache.js +52 -177
- package/dist/market_adapter/interval_utils.d.ts +11 -1
- package/dist/market_adapter/interval_utils.js +16 -1
- package/dist/market_adapter/lp_chart_runner.d.ts +3 -0
- package/dist/market_adapter/lp_chart_runner.js +37 -19
- package/dist/market_adapter/market_adapter.js +27 -72
- package/dist/market_adapter/utils/data_discovery.d.ts +45 -1
- package/dist/market_adapter/utils/data_discovery.js +220 -27
- package/dist/market_adapter/utils/month_shards.d.ts +84 -0
- package/dist/market_adapter/utils/month_shards.js +237 -0
- package/dist/modules/account_bots.d.ts +8 -6
- package/dist/modules/account_bots.js +112 -131
- package/dist/modules/account_orders.d.ts +49 -4
- package/dist/modules/account_orders.js +114 -49
- package/dist/modules/bitshares-native/chain_client.d.ts +1 -1
- package/dist/modules/bitshares-native/chain_client.js +14 -13
- package/dist/modules/bitshares-native/crypto/ecc_core.d.ts +1 -2
- package/dist/modules/bitshares-native/crypto/ecc_core.js +1 -1
- package/dist/modules/bitshares-native/resolvers.js +22 -25
- package/dist/modules/bitshares-native/serial/chain_constants.d.ts +1 -2
- package/dist/modules/bitshares-native/serial/chain_constants.js +1 -2
- package/dist/modules/bitshares-native/serial/types.js +22 -50
- package/dist/modules/bitshares-native/signing_client.d.ts +1 -1
- package/dist/modules/bot_defaults.d.ts +18 -3
- package/dist/modules/bot_defaults.js +34 -8
- package/dist/modules/bot_settings.d.ts +5 -1
- package/dist/modules/bot_settings.js +55 -21
- package/dist/modules/broadcast_failure.d.ts +2 -1
- package/dist/modules/chain_orders.d.ts +1 -1
- package/dist/modules/chain_orders.js +51 -96
- package/dist/modules/cli_start_onboarding.d.ts +2 -1
- package/dist/modules/config.js +6 -1
- package/dist/modules/constants.d.ts +14 -6
- package/dist/modules/constants.js +32 -6
- package/dist/modules/cr_planner.d.ts +1 -1
- package/dist/modules/cr_planner.js +1 -5
- package/dist/modules/credit_pricing.d.ts +2 -1
- package/dist/modules/credit_pricing.js +36 -40
- package/dist/modules/credit_runtime.d.ts +7 -0
- package/dist/modules/credit_runtime.js +45 -73
- package/dist/modules/daemon_node_health.d.ts +4 -3
- package/dist/modules/dexbot_class.d.ts +33 -17
- package/dist/modules/dexbot_class.js +113 -61
- package/dist/modules/dexbot_cow_runtime.d.ts +62 -181
- package/dist/modules/dexbot_cow_runtime.js +380 -69
- package/dist/modules/dexbot_credential_client.d.ts +1 -23
- package/dist/modules/dexbot_credential_client.js +2 -3
- package/dist/modules/dexbot_fill_runtime.d.ts +2 -3
- package/dist/modules/dexbot_fill_runtime.js +17 -7
- package/dist/modules/dexbot_maintenance_runtime.d.ts +36 -81
- package/dist/modules/dexbot_maintenance_runtime.js +137 -133
- package/dist/modules/dexbot_startup_runtime.d.ts +0 -1
- package/dist/modules/dexbot_startup_runtime.js +25 -14
- package/dist/modules/dexbot_state_recovery.js +16 -0
- package/dist/modules/general_settings.d.ts +1 -1
- package/dist/modules/graceful_shutdown.js +17 -11
- package/dist/modules/key_store.d.ts +0 -5
- package/dist/modules/key_store.js +1 -2
- package/dist/modules/lazy_shim.d.ts +11 -0
- package/dist/modules/lazy_shim.js +16 -0
- package/dist/modules/node_connect_policy.d.ts +3 -2
- package/dist/modules/node_failure_ledger.d.ts +6 -5
- package/dist/modules/order/accounting.js +11 -11
- package/dist/modules/order/export.js +2 -2
- package/dist/modules/order/format.d.ts +26 -3
- package/dist/modules/order/format.js +33 -3
- package/dist/modules/order/genesis_policy.d.ts +4 -4
- package/dist/modules/order/genesis_policy.js +6 -3
- package/dist/modules/order/grid.d.ts +26 -12
- package/dist/modules/order/grid.js +468 -80
- package/dist/modules/order/grid_reconcile.d.ts +1 -1
- package/dist/modules/order/grid_reconcile.js +5 -5
- package/dist/modules/order/grid_reconcile_internal.js +48 -40
- package/dist/modules/order/index.d.ts +35 -8
- package/dist/modules/order/logger.d.ts +1 -8
- package/dist/modules/order/logger.js +2 -11
- package/dist/modules/order/manager.d.ts +18 -15
- package/dist/modules/order/manager.js +91 -74
- package/dist/modules/order/strategy.d.ts +2 -2
- package/dist/modules/order/strategy.js +51 -21
- package/dist/modules/order/sync_engine.js +4 -0
- package/dist/modules/order/utils/math.d.ts +3 -3
- package/dist/modules/order/utils/math.js +38 -27
- package/dist/modules/order/utils/order.d.ts +58 -58
- package/dist/modules/order/utils/order.js +158 -137
- package/dist/modules/order/utils/system.d.ts +202 -35
- package/dist/modules/order/utils/system.js +409 -31
- package/dist/modules/order/utils/validate.js +28 -6
- package/dist/modules/order/utils/withPoolRef.d.ts +2 -1
- package/dist/modules/paths.js +32 -34
- package/dist/modules/runtime_settings.d.ts +3 -5
- package/dist/modules/runtime_settings.js +3 -3
- package/dist/modules/settings_merge.d.ts +2 -2
- package/dist/modules/socket_json_client.d.ts +2 -1
- package/dist/modules/types.d.ts +89 -30
- package/dist/modules/utils/errors.js +1 -3
- package/dist/modules/version_notice.d.ts +11 -10
- package/dist/pm2.d.ts +0 -1
- package/dist/pm2.js +56 -35
- package/dist/scripts/analyze-git.js +2 -15
- package/dist/scripts/analyze-orders.d.ts +1 -1
- package/dist/scripts/analyze-orders.js +4 -4
- package/dist/scripts/chart_command.js +2 -2
- package/dist/scripts/check_any.d.ts +4 -0
- package/dist/scripts/check_any.js +53 -21
- package/dist/scripts/diagnose-pool-history.js +1 -6
- package/dist/scripts/divergence-calc.js +6 -6
- package/dist/scripts/run-tests.js +0 -1
- package/dist/scripts/sync-version.js +0 -10
- package/dist/scripts/validate_bots.d.ts +1 -1
- package/dist/scripts/validate_bots.js +3 -3
- package/dist/unlock.js +7 -2
- package/docs/BITSHARES_ONBOARDING.md +8 -12
- package/docs/COPY_ON_WRITE_MASTER_PLAN.md +2 -3
- package/docs/COW_INVARIANTS.md +6 -6
- package/docs/DEXBOT_COMPARISON.md +7 -7
- package/docs/EVOLUTION.md +10 -8
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +8 -6
- package/docs/GRID_PRICE_INVARIANT.md +3 -3
- package/docs/GRID_RECALCULATION.md +4 -1
- package/docs/GRID_RECONCILE.md +4 -4
- package/docs/LIFECYCLE.md +11 -11
- package/docs/LOGGING.md +14 -0
- package/docs/MPA_CREDIT_USAGE.md +1 -1
- package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +12 -4
- package/docs/README.md +3 -3
- package/docs/WORKFLOW.md +1 -0
- package/docs/architecture.md +25 -16
- package/docs/developer_guide.md +7 -2
- package/market_adapter/README.md +6 -4
- package/package.json +6 -9
- package/scripts/README.md +43 -38
- package/tests/README.md +26 -11
- package/dist/scripts/diagnose-kibana-candles.d.ts +0 -3
- package/dist/scripts/diagnose-kibana-candles.js +0 -82
- package/scripts/git-viewer.sh +0 -489
- package/scripts/postinstall.js +0 -16
|
@@ -886,16 +886,14 @@ class MarketAdapterService {
|
|
|
886
886
|
const outputThreshold = minOutputThreshold;
|
|
887
887
|
// Per-bar directional offset series — canonical implementation shared
|
|
888
888
|
// with the research chart and test harness (see dynamic_weight_series.ts).
|
|
889
|
-
|
|
889
|
+
// The base inputs are identical for the real series and the AMA-only
|
|
890
|
+
// diagnostic; only the Kalman inputs and clip threshold differ.
|
|
891
|
+
const seriesBaseInputs = {
|
|
890
892
|
amaValues,
|
|
891
|
-
kalmanVelocityPct: kalmanSmoothedVelocityPct,
|
|
892
|
-
kalmanDisplacementPct: kalmanHistory.map((kr) => kr.displacementRawPct),
|
|
893
|
-
kalmanIsReady: kalmanHistory.map((kr) => kr.isReady),
|
|
894
893
|
regimeMultipliers,
|
|
895
894
|
lookbackBars,
|
|
896
895
|
amaErPeriod: botAma.erPeriod,
|
|
897
896
|
amaClipThreshold,
|
|
898
|
-
kalClipThreshold,
|
|
899
897
|
neutralZonePct: nz,
|
|
900
898
|
amaMaxSlopePct: amaMaxS,
|
|
901
899
|
kalmanMaxSlopePct: kalMaxS,
|
|
@@ -907,6 +905,13 @@ class MarketAdapterService {
|
|
|
907
905
|
minOutputThreshold,
|
|
908
906
|
signalConfirmBars,
|
|
909
907
|
clampFinalOutput: true,
|
|
908
|
+
};
|
|
909
|
+
const seriesResult = computeDynamicWeightSeries({
|
|
910
|
+
...seriesBaseInputs,
|
|
911
|
+
kalmanVelocityPct: kalmanSmoothedVelocityPct,
|
|
912
|
+
kalmanDisplacementPct: kalmanHistory.map((kr) => kr.displacementRawPct),
|
|
913
|
+
kalmanIsReady: kalmanHistory.map((kr) => kr.isReady),
|
|
914
|
+
kalClipThreshold,
|
|
910
915
|
});
|
|
911
916
|
const { combinedOffSeries, gatedOffSeries, echoedOffSeries, echoedGatedOffSeries, } = seriesResult;
|
|
912
917
|
const rawFinalOff = combinedOffSeries[combinedOffSeries.length - 1] ?? 0;
|
|
@@ -920,55 +925,44 @@ class MarketAdapterService {
|
|
|
920
925
|
// alpha*(offset/norm)*gain*regime recomputation diverged from
|
|
921
926
|
// finalOffset whenever gating or signal confirmation was active.)
|
|
922
927
|
const amaOnlySeriesResult = computeDynamicWeightSeries({
|
|
923
|
-
|
|
928
|
+
...seriesBaseInputs,
|
|
924
929
|
kalmanVelocityPct: kalmanSmoothedVelocityPct.map(() => null),
|
|
925
930
|
kalmanDisplacementPct: kalmanHistory.map(() => null),
|
|
926
931
|
kalmanIsReady: kalmanHistory.map(() => false),
|
|
927
|
-
regimeMultipliers,
|
|
928
|
-
lookbackBars,
|
|
929
|
-
amaErPeriod: botAma.erPeriod,
|
|
930
|
-
amaClipThreshold,
|
|
931
932
|
kalClipThreshold: Infinity,
|
|
932
|
-
neutralZonePct: nz,
|
|
933
|
-
amaMaxSlopePct: amaMaxS,
|
|
934
|
-
kalmanMaxSlopePct: kalMaxS,
|
|
935
|
-
offsetClamp,
|
|
936
|
-
dispScaleMinPct,
|
|
937
|
-
alpha,
|
|
938
|
-
dw,
|
|
939
|
-
gain,
|
|
940
|
-
minOutputThreshold,
|
|
941
|
-
signalConfirmBars,
|
|
942
|
-
clampFinalOutput: true,
|
|
943
933
|
});
|
|
944
934
|
const amaSlopeGated = slopeResult.isReady
|
|
945
935
|
? (useAmaBlend
|
|
946
936
|
? (amaOnlySeriesResult.echoedOffSeries[amaOnlySeriesResult.echoedOffSeries.length - 1] ?? 0)
|
|
947
937
|
: 0)
|
|
948
938
|
: 0;
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
rawSlopeOffset: slopeResult.rawSlopeOffset,
|
|
955
|
-
amaSlopeGated,
|
|
956
|
-
regimeMultiplier,
|
|
957
|
-
symmetricDelta: slopeResult.symmetricDelta,
|
|
958
|
-
weightVariance,
|
|
959
|
-
isReady: slopeResult.isReady,
|
|
960
|
-
kalmanReady: kalmanResult?.isReady ?? false,
|
|
939
|
+
// Shared report fragments so the diagnostic `amaSlope` snapshot, the
|
|
940
|
+
// persisted `weights.meta` and `dynamicWeightsPayload` cannot drift
|
|
941
|
+
// apart. Kept as separate pieces so each object keeps its original
|
|
942
|
+
// key order.
|
|
943
|
+
const blendReport = {
|
|
961
944
|
alpha,
|
|
962
945
|
dw,
|
|
963
946
|
gain,
|
|
964
|
-
atrPeriod
|
|
947
|
+
atrPeriod,
|
|
965
948
|
maxSlopeOffset: mo,
|
|
949
|
+
};
|
|
950
|
+
const slopeConfigReport = {
|
|
966
951
|
amaSlope: {
|
|
967
952
|
maxSlopePct: amaMaxS,
|
|
968
953
|
},
|
|
969
954
|
kalmanSlope: {
|
|
970
955
|
maxSlopePct: kalMaxS,
|
|
971
956
|
},
|
|
957
|
+
};
|
|
958
|
+
const volatilityReport = {
|
|
959
|
+
clipPercentile,
|
|
960
|
+
neutralZonePct: nz,
|
|
961
|
+
volatilityThreshold,
|
|
962
|
+
volatilityExponent,
|
|
963
|
+
volatilityScaleX,
|
|
964
|
+
};
|
|
965
|
+
const kalmanReport = {
|
|
972
966
|
maxVolatilityOffset: volatilityClamp,
|
|
973
967
|
kalmanSmoothPct,
|
|
974
968
|
kalmanDispScaleMult,
|
|
@@ -976,6 +970,22 @@ class MarketAdapterService {
|
|
|
976
970
|
kalmanSmoothSpanPct,
|
|
977
971
|
signalConfirmBars,
|
|
978
972
|
};
|
|
973
|
+
const amaSlope = {
|
|
974
|
+
trend: slopeResult.trend,
|
|
975
|
+
confidence: slopeResult.confidence,
|
|
976
|
+
slopePct: slopeResult.slopePct,
|
|
977
|
+
slopeOffset: slopeResult.slopeOffset,
|
|
978
|
+
rawSlopeOffset: slopeResult.rawSlopeOffset,
|
|
979
|
+
amaSlopeGated,
|
|
980
|
+
regimeMultiplier,
|
|
981
|
+
symmetricDelta: slopeResult.symmetricDelta,
|
|
982
|
+
weightVariance,
|
|
983
|
+
isReady: slopeResult.isReady,
|
|
984
|
+
kalmanReady: kalmanResult?.isReady ?? false,
|
|
985
|
+
...blendReport,
|
|
986
|
+
...slopeConfigReport,
|
|
987
|
+
...kalmanReport,
|
|
988
|
+
};
|
|
979
989
|
const staticSell = bot.weightDistribution?.sell ?? 0;
|
|
980
990
|
const staticBuy = bot.weightDistribution?.buy ?? 0;
|
|
981
991
|
const MIN_W = MARKET_ADAPTER.DYNAMIC_WEIGHT_MIN_WEIGHT;
|
|
@@ -1007,34 +1017,16 @@ class MarketAdapterService {
|
|
|
1007
1017
|
regimeSensitivity,
|
|
1008
1018
|
absoluteThreshold,
|
|
1009
1019
|
volatilityPenalty: volPenalty,
|
|
1010
|
-
|
|
1011
|
-
dw,
|
|
1012
|
-
gain,
|
|
1013
|
-
atrPeriod: atrPeriod,
|
|
1014
|
-
maxSlopeOffset: mo,
|
|
1020
|
+
...blendReport,
|
|
1015
1021
|
maxAsymmetryFactor: (cfg.asymmetricBounds?.maxAsymmetryFactor != null)
|
|
1016
1022
|
? cfg.asymmetricBounds.maxAsymmetryFactor
|
|
1017
1023
|
: null,
|
|
1018
1024
|
minScaleSlots: (cfg.asymmetricBounds?.minScaleSlots != null)
|
|
1019
1025
|
? cfg.asymmetricBounds.minScaleSlots
|
|
1020
1026
|
: null,
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
volatilityExponent,
|
|
1025
|
-
volatilityScaleX,
|
|
1026
|
-
amaSlope: {
|
|
1027
|
-
maxSlopePct: amaMaxS,
|
|
1028
|
-
},
|
|
1029
|
-
kalmanSlope: {
|
|
1030
|
-
maxSlopePct: kalMaxS,
|
|
1031
|
-
},
|
|
1032
|
-
maxVolatilityOffset: volatilityClamp,
|
|
1033
|
-
kalmanSmoothPct,
|
|
1034
|
-
kalmanDispScaleMult,
|
|
1035
|
-
kalmanDispThresholdMult,
|
|
1036
|
-
kalmanSmoothSpanPct,
|
|
1037
|
-
signalConfirmBars,
|
|
1027
|
+
...volatilityReport,
|
|
1028
|
+
...slopeConfigReport,
|
|
1029
|
+
...kalmanReport,
|
|
1038
1030
|
amaChannelContribution: amaSlopeGated,
|
|
1039
1031
|
rawFinalOffset: rawFinalOff,
|
|
1040
1032
|
trendOffset: trendOff,
|
|
@@ -1054,28 +1046,10 @@ class MarketAdapterService {
|
|
|
1054
1046
|
amaSlopeGated,
|
|
1055
1047
|
volatilityPenalty: volPenalty,
|
|
1056
1048
|
finalOffset: finalOff,
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
maxSlopeOffset: mo,
|
|
1062
|
-
amaSlope: {
|
|
1063
|
-
maxSlopePct: amaMaxS,
|
|
1064
|
-
},
|
|
1065
|
-
kalmanSlope: {
|
|
1066
|
-
maxSlopePct: kalMaxS,
|
|
1067
|
-
},
|
|
1068
|
-
clipPercentile,
|
|
1069
|
-
neutralZonePct: nz,
|
|
1070
|
-
volatilityThreshold,
|
|
1071
|
-
volatilityExponent,
|
|
1072
|
-
volatilityScaleX,
|
|
1073
|
-
maxVolatilityOffset: volatilityClamp,
|
|
1074
|
-
kalmanSmoothPct,
|
|
1075
|
-
kalmanDispScaleMult,
|
|
1076
|
-
kalmanDispThresholdMult,
|
|
1077
|
-
kalmanSmoothSpanPct,
|
|
1078
|
-
signalConfirmBars,
|
|
1049
|
+
...blendReport,
|
|
1050
|
+
...slopeConfigReport,
|
|
1051
|
+
...volatilityReport,
|
|
1052
|
+
...kalmanReport,
|
|
1079
1053
|
rawFinalOffset: rawFinalOff,
|
|
1080
1054
|
maxAsymmetryFactor: (cfg.asymmetricBounds?.maxAsymmetryFactor != null)
|
|
1081
1055
|
? cfg.asymmetricBounds.maxAsymmetryFactor
|
|
@@ -1471,6 +1445,21 @@ class MarketAdapterService {
|
|
|
1471
1445
|
nativePagesFetched = null;
|
|
1472
1446
|
const bucketMs = Number(Number(cfg.intervalSeconds)) * 1000;
|
|
1473
1447
|
const nowMs = this.getNowMs();
|
|
1448
|
+
// Native order-book history fetch shared by the bootstrap
|
|
1449
|
+
// fallback and the incremental path. Returns [] on failure
|
|
1450
|
+
// (after the same warn the inline blocks used to emit).
|
|
1451
|
+
const fetchNativeHistory = async (startMs, failureLabel) => {
|
|
1452
|
+
try {
|
|
1453
|
+
if (typeof deps.fetchNativeMarketHistorySince === 'function') {
|
|
1454
|
+
return await deps.withRetries(() => deps.fetchNativeMarketHistorySince(ctx.assetA, ctx.assetB, startMs, nowMs, Number(cfg.intervalSeconds), { fillCandleGaps: deps.fillCandleGaps }), cfg.sourceRetries, cfg.retryDelayMs, failureLabel);
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
catch (_) {
|
|
1458
|
+
if (typeof deps.logger?.warn === 'function')
|
|
1459
|
+
deps.logger.warn(`[market_adapter] ${ctx.botKey}: ${failureLabel}`);
|
|
1460
|
+
}
|
|
1461
|
+
return [];
|
|
1462
|
+
};
|
|
1474
1463
|
if (needBootstrap) {
|
|
1475
1464
|
// Bootstrap: Kibana first (deep history), native as fallback
|
|
1476
1465
|
const kibanaLookbackHours = this.bootstrapKibanaLookbackHours(cfg, rawKeepCount);
|
|
@@ -1495,16 +1484,7 @@ class MarketAdapterService {
|
|
|
1495
1484
|
// Fall back to native
|
|
1496
1485
|
const nativeLookbackHours = Math.max(Number(cfg.bootstrapLookbackHours) || 0, Number(Number(cfg.nativeBackfillHours)) || 0, (analysisKeepCount * Math.max(Number(Number(cfg.intervalSeconds)) || 3600, 3600)) / 3600);
|
|
1497
1486
|
const nativeStartMs = Math.max(0, nowMs - (nativeLookbackHours * 3600 * 1000));
|
|
1498
|
-
|
|
1499
|
-
try {
|
|
1500
|
-
if (typeof deps.fetchNativeMarketHistorySince === 'function') {
|
|
1501
|
-
nativeCandles = await deps.withRetries(() => deps.fetchNativeMarketHistorySince(ctx.assetA, ctx.assetB, nativeStartMs, nowMs, Number(cfg.intervalSeconds), { fillCandleGaps: deps.fillCandleGaps }), cfg.sourceRetries, cfg.retryDelayMs, 'native market history bootstrap failed');
|
|
1502
|
-
}
|
|
1503
|
-
}
|
|
1504
|
-
catch (_) {
|
|
1505
|
-
if (typeof deps.logger?.warn === 'function')
|
|
1506
|
-
deps.logger.warn(`[market_adapter] ${ctx.botKey}: native market history bootstrap failed`);
|
|
1507
|
-
}
|
|
1487
|
+
const nativeCandles = await fetchNativeHistory(nativeStartMs, 'native market history bootstrap failed');
|
|
1508
1488
|
if (Array.isArray(nativeCandles) && nativeCandles.length > 0) {
|
|
1509
1489
|
nextCandles = nativeCandles;
|
|
1510
1490
|
sourceLabel = 'native-book-bootstrap';
|
|
@@ -1518,16 +1498,7 @@ class MarketAdapterService {
|
|
|
1518
1498
|
// Incremental: native fetch
|
|
1519
1499
|
const lastTs = nextCandles[nextCandles.length - 1]?.[0] || 0;
|
|
1520
1500
|
const nativeStartMs = Math.max(0, lastTs - bucketMs);
|
|
1521
|
-
|
|
1522
|
-
try {
|
|
1523
|
-
if (typeof deps.fetchNativeMarketHistorySince === 'function') {
|
|
1524
|
-
nativeCandles = await deps.withRetries(() => deps.fetchNativeMarketHistorySince(ctx.assetA, ctx.assetB, nativeStartMs, nowMs, Number(cfg.intervalSeconds), { fillCandleGaps: deps.fillCandleGaps }), cfg.sourceRetries, cfg.retryDelayMs, 'native market history fetch failed');
|
|
1525
|
-
}
|
|
1526
|
-
}
|
|
1527
|
-
catch (_) {
|
|
1528
|
-
if (typeof deps.logger?.warn === 'function')
|
|
1529
|
-
deps.logger.warn(`[market_adapter] ${ctx.botKey}: native market history fetch failed`);
|
|
1530
|
-
}
|
|
1501
|
+
const nativeCandles = await fetchNativeHistory(nativeStartMs, 'native market history fetch failed');
|
|
1531
1502
|
if (Array.isArray(nativeCandles) && nativeCandles.length > 0) {
|
|
1532
1503
|
nextCandles = deps.mergeCandles(nextCandles, nativeCandles);
|
|
1533
1504
|
sourceLabel = 'native-book-history';
|
|
@@ -1960,6 +1931,26 @@ class MarketAdapterService {
|
|
|
1960
1931
|
? previousClosedCandleTs
|
|
1961
1932
|
: null;
|
|
1962
1933
|
hasNewClosedCandle = lastClosedCandleTs !== null && lastClosedCandleTs > previousClosedCandleTs;
|
|
1934
|
+
// Fields shared by the persisted bot state and the cycle result.
|
|
1935
|
+
// Built on demand so `consumedClosedCandleTs` is read after the
|
|
1936
|
+
// retry-baseline adjustment below, rather than frozen early.
|
|
1937
|
+
const buildCandleCycleFields = () => ({
|
|
1938
|
+
candleCount: nextCandles.length,
|
|
1939
|
+
analysisCandleCount: closedCandles.length,
|
|
1940
|
+
rawKeepCount,
|
|
1941
|
+
analysisKeepCount,
|
|
1942
|
+
amaWarmupBars,
|
|
1943
|
+
kibanaGapRepairCount,
|
|
1944
|
+
kibanaBackfillCount,
|
|
1945
|
+
unresolvedGapCount,
|
|
1946
|
+
nativeRecentTradeSequences,
|
|
1947
|
+
nativeLastTradeTs,
|
|
1948
|
+
nativeOverlapCount,
|
|
1949
|
+
nativePagesFetched,
|
|
1950
|
+
lastCandleTs: rawLastCandleTs,
|
|
1951
|
+
rawLastCandleTs,
|
|
1952
|
+
lastClosedCandleTs: consumedClosedCandleTs,
|
|
1953
|
+
});
|
|
1963
1954
|
const candlePayload = {
|
|
1964
1955
|
meta: {
|
|
1965
1956
|
updatedAt: nowIso,
|
|
@@ -2009,21 +2000,7 @@ class MarketAdapterService {
|
|
|
2009
2000
|
poolId: ctx.poolId,
|
|
2010
2001
|
marketSource,
|
|
2011
2002
|
candleFile: deps.path.relative(deps.root, filePath),
|
|
2012
|
-
|
|
2013
|
-
analysisCandleCount: closedCandles.length,
|
|
2014
|
-
rawKeepCount,
|
|
2015
|
-
analysisKeepCount,
|
|
2016
|
-
amaWarmupBars,
|
|
2017
|
-
kibanaGapRepairCount,
|
|
2018
|
-
kibanaBackfillCount,
|
|
2019
|
-
unresolvedGapCount,
|
|
2020
|
-
nativeRecentTradeSequences,
|
|
2021
|
-
nativeLastTradeTs,
|
|
2022
|
-
nativeOverlapCount,
|
|
2023
|
-
nativePagesFetched,
|
|
2024
|
-
lastCandleTs: rawLastCandleTs,
|
|
2025
|
-
rawLastCandleTs,
|
|
2026
|
-
lastClosedCandleTs: consumedClosedCandleTs,
|
|
2003
|
+
...buildCandleCycleFields(),
|
|
2027
2004
|
lastCycleSource: sourceLabel,
|
|
2028
2005
|
lastCycleAt: nowIso,
|
|
2029
2006
|
staleData,
|
|
@@ -2035,27 +2012,13 @@ class MarketAdapterService {
|
|
|
2035
2012
|
dryRunMessages,
|
|
2036
2013
|
source: sourceLabel,
|
|
2037
2014
|
marketSource,
|
|
2038
|
-
|
|
2039
|
-
analysisCandleCount: closedCandles.length,
|
|
2040
|
-
rawKeepCount,
|
|
2041
|
-
analysisKeepCount,
|
|
2042
|
-
amaWarmupBars,
|
|
2043
|
-
kibanaGapRepairCount,
|
|
2044
|
-
kibanaBackfillCount,
|
|
2045
|
-
unresolvedGapCount,
|
|
2046
|
-
nativeRecentTradeSequences,
|
|
2047
|
-
nativeLastTradeTs,
|
|
2048
|
-
nativeOverlapCount,
|
|
2049
|
-
nativePagesFetched,
|
|
2015
|
+
...buildCandleCycleFields(),
|
|
2050
2016
|
thresholdPercent: botThreshold,
|
|
2051
2017
|
staleData,
|
|
2052
2018
|
staleAgeHours,
|
|
2053
2019
|
triggerSuppressedReason,
|
|
2054
2020
|
poolId: ctx.poolId,
|
|
2055
2021
|
candleFile: deps.path.relative(deps.root, filePath),
|
|
2056
|
-
lastCandleTs: rawLastCandleTs,
|
|
2057
|
-
rawLastCandleTs,
|
|
2058
|
-
lastClosedCandleTs: consumedClosedCandleTs,
|
|
2059
2022
|
amaConfig: {
|
|
2060
2023
|
erPeriod: botAma.erPeriod,
|
|
2061
2024
|
fastPeriod: botAma.fastPeriod,
|
|
@@ -2484,21 +2447,7 @@ class MarketAdapterService {
|
|
|
2484
2447
|
poolId: ctx.poolId,
|
|
2485
2448
|
marketSource,
|
|
2486
2449
|
candleFile: deps.path.relative(deps.root, filePath),
|
|
2487
|
-
|
|
2488
|
-
analysisCandleCount: analysisCandles.length,
|
|
2489
|
-
rawKeepCount,
|
|
2490
|
-
analysisKeepCount,
|
|
2491
|
-
amaWarmupBars,
|
|
2492
|
-
kibanaGapRepairCount,
|
|
2493
|
-
kibanaBackfillCount,
|
|
2494
|
-
unresolvedGapCount,
|
|
2495
|
-
nativeRecentTradeSequences,
|
|
2496
|
-
nativeLastTradeTs,
|
|
2497
|
-
nativeOverlapCount,
|
|
2498
|
-
nativePagesFetched,
|
|
2499
|
-
lastCandleTs: rawLastCandleTs,
|
|
2500
|
-
rawLastCandleTs,
|
|
2501
|
-
lastClosedCandleTs: consumedClosedCandleTs,
|
|
2450
|
+
...buildCandleCycleFields(),
|
|
2502
2451
|
lastAmaPrice: amaPrice,
|
|
2503
2452
|
amaCenterPrice: Number(botState.amaCenterPrice || 0) > 0
|
|
2504
2453
|
? Number(botState.amaCenterPrice)
|
|
@@ -2553,18 +2502,7 @@ class MarketAdapterService {
|
|
|
2553
2502
|
source: sourceLabel,
|
|
2554
2503
|
marketSource,
|
|
2555
2504
|
intervalSeconds: Number(cfg.intervalSeconds),
|
|
2556
|
-
|
|
2557
|
-
analysisCandleCount: analysisCandles.length,
|
|
2558
|
-
rawKeepCount,
|
|
2559
|
-
analysisKeepCount,
|
|
2560
|
-
amaWarmupBars,
|
|
2561
|
-
kibanaGapRepairCount,
|
|
2562
|
-
kibanaBackfillCount,
|
|
2563
|
-
unresolvedGapCount,
|
|
2564
|
-
nativeRecentTradeSequences,
|
|
2565
|
-
nativeLastTradeTs,
|
|
2566
|
-
nativeOverlapCount,
|
|
2567
|
-
nativePagesFetched,
|
|
2505
|
+
...buildCandleCycleFields(),
|
|
2568
2506
|
amaPrice,
|
|
2569
2507
|
previousCenterPrice,
|
|
2570
2508
|
deltaPercent,
|
|
@@ -2592,9 +2530,6 @@ class MarketAdapterService {
|
|
|
2592
2530
|
hasExplicitBaseWeights,
|
|
2593
2531
|
poolId: ctx.poolId,
|
|
2594
2532
|
candleFile: deps.path.relative(deps.root, filePath),
|
|
2595
|
-
lastCandleTs: rawLastCandleTs,
|
|
2596
|
-
rawLastCandleTs,
|
|
2597
|
-
lastClosedCandleTs: consumedClosedCandleTs,
|
|
2598
2533
|
lastClosedCandleClose: Number(latestClosedCandle?.[4]),
|
|
2599
2534
|
centerPrice,
|
|
2600
2535
|
amaConfig: {
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compute R/S (rescaled range) over `returns[from..to)` (to exclusive).
|
|
3
|
-
* Taking a range instead of a slice keeps the caller's buffer reusable.
|
|
4
|
-
*/
|
|
5
|
-
declare function computeRS(returns: ArrayLike<number>, from: number, to: number): number;
|
|
6
1
|
/**
|
|
7
2
|
* Shared Hurst zone classification used by both HurstAnalyzer.getAnalysis()
|
|
8
3
|
* and the regime gate, so the zone boundaries live in exactly one place.
|
|
@@ -53,5 +48,5 @@ declare class HurstAnalyzer {
|
|
|
53
48
|
updateCount: number;
|
|
54
49
|
};
|
|
55
50
|
}
|
|
56
|
-
export { HurstAnalyzer, classifyHurst
|
|
51
|
+
export { HurstAnalyzer, classifyHurst };
|
|
57
52
|
//# sourceMappingURL=hurst_analyzer.d.ts.map
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Ordinal pattern key for the m values starting at `prices[start]`, stepping by
|
|
3
|
-
* `delay`. Returns the permutation of source indices (sorted by value, ties
|
|
4
|
-
* broken by source index) encoded as a factorial-number-system integer, so the
|
|
5
|
-
* key is a small int (m! - 1 <= 5039 for m = 7) instead of a string.
|
|
6
|
-
*
|
|
7
|
-
* Sorting uses a preallocated scratch pair and insertion sort (m <= 7), so the
|
|
8
|
-
* hot path allocates nothing.
|
|
9
|
-
*/
|
|
10
|
-
declare function ordinalPatternKey(prices: Float64Array, start: number, m: number, delay: number): number;
|
|
11
1
|
interface PermutationEntropyAnalysis {
|
|
12
2
|
isReady: boolean;
|
|
13
3
|
entropy: number;
|
|
@@ -56,5 +46,5 @@ declare class PermutationEntropyAnalyzer {
|
|
|
56
46
|
update(price: number): PermutationEntropyAnalysis;
|
|
57
47
|
getAnalysis(): PermutationEntropyAnalysis;
|
|
58
48
|
}
|
|
59
|
-
export { PermutationEntropyAnalyzer
|
|
49
|
+
export { PermutationEntropyAnalyzer };
|
|
60
50
|
//# sourceMappingURL=permutation_entropy_analyzer.d.ts.map
|
|
@@ -127,7 +127,6 @@ async function fetchMarketCandlesSequentially(assetA, assetB, opts = {}) {
|
|
|
127
127
|
assetA: requestKey.assetA,
|
|
128
128
|
assetB: requestKey.assetB,
|
|
129
129
|
intervalSeconds,
|
|
130
|
-
chunkIndex: window.index,
|
|
131
130
|
timeRange: { gte: window.gte, lte: window.lte },
|
|
132
131
|
format: '[timestamp_ms, open, high, low, close, volume_A]',
|
|
133
132
|
}),
|
|
@@ -21,7 +21,7 @@ const { getAmaWarmupBars } = require('../core/strategies/ama');
|
|
|
21
21
|
const { getErrorMessage } = require('../../modules/utils/errors');
|
|
22
22
|
const { isSameBotName } = require('../../modules/utils/sanitize_key');
|
|
23
23
|
const { candleFileForBot } = require('../../analysis/bot_key_utils');
|
|
24
|
-
const { DEFAULTS: MARKET_ADAPTER_DEFAULTS, resolveAmaForBot, resolveBotCfg, } = require('../market_adapter
|
|
24
|
+
const { DEFAULTS: MARKET_ADAPTER_DEFAULTS, resolveAmaForBot, resolveBotCfg, } = require('../market_adapter');
|
|
25
25
|
const DEFAULT_INTERVAL = '1h';
|
|
26
26
|
const DEFAULT_LIMIT = 1000;
|
|
27
27
|
const DEFAULT_BASE = 'XRP';
|
|
@@ -237,6 +237,61 @@ function extractMarketsFromList(list, mapper) {
|
|
|
237
237
|
const rows = asArray(list);
|
|
238
238
|
return rows.map(mapper).filter((row) => Boolean(row && row.id && row.base && row.quote));
|
|
239
239
|
}
|
|
240
|
+
// Interval → venue-specific unit tables. Most CEX APIs share one of a few
|
|
241
|
+
// shapes; keep one table per shape and compose where a venue overrides a
|
|
242
|
+
// single unit (Kraken day/week, MEXC's case-sensitive `1W`).
|
|
243
|
+
const INTERVAL_MINUTES = {
|
|
244
|
+
'1m': '1',
|
|
245
|
+
'5m': '5',
|
|
246
|
+
'15m': '15',
|
|
247
|
+
'30m': '30',
|
|
248
|
+
'1h': '60',
|
|
249
|
+
'4h': '240',
|
|
250
|
+
'6h': '360',
|
|
251
|
+
'12h': '720',
|
|
252
|
+
'1d': 'D',
|
|
253
|
+
'1w': 'W',
|
|
254
|
+
};
|
|
255
|
+
const INTERVAL_KRAKEN = {
|
|
256
|
+
...INTERVAL_MINUTES,
|
|
257
|
+
'1d': '1440',
|
|
258
|
+
'1w': '10080',
|
|
259
|
+
};
|
|
260
|
+
const INTERVAL_DURATION = {
|
|
261
|
+
'1m': '1min',
|
|
262
|
+
'5m': '5min',
|
|
263
|
+
'15m': '15min',
|
|
264
|
+
'30m': '30min',
|
|
265
|
+
'1h': '1hour',
|
|
266
|
+
'4h': '4hour',
|
|
267
|
+
'6h': '6hour',
|
|
268
|
+
'12h': '12hour',
|
|
269
|
+
'1d': '1day',
|
|
270
|
+
'1w': '1week',
|
|
271
|
+
};
|
|
272
|
+
const INTERVAL_HTX = {
|
|
273
|
+
...INTERVAL_DURATION,
|
|
274
|
+
'1h': '60min',
|
|
275
|
+
};
|
|
276
|
+
const INTERVAL_BITGET = {
|
|
277
|
+
'1m': '1m',
|
|
278
|
+
'5m': '5m',
|
|
279
|
+
'15m': '15m',
|
|
280
|
+
'30m': '30m',
|
|
281
|
+
'1h': '1h',
|
|
282
|
+
'4h': '4h',
|
|
283
|
+
'6h': '6h',
|
|
284
|
+
'12h': '12h',
|
|
285
|
+
'1d': '1d',
|
|
286
|
+
'1w': '1w',
|
|
287
|
+
};
|
|
288
|
+
const INTERVAL_MEXC = {
|
|
289
|
+
...INTERVAL_BITGET,
|
|
290
|
+
'1h': '60m',
|
|
291
|
+
// MEXC interval enums are case-sensitive
|
|
292
|
+
'1w': '1W',
|
|
293
|
+
};
|
|
294
|
+
const intervalFormatter = (map) => (interval) => map[lower(interval)] || interval;
|
|
240
295
|
const EXCHANGES = {
|
|
241
296
|
binance: {
|
|
242
297
|
name: 'Binance',
|
|
@@ -261,21 +316,7 @@ const EXCHANGES = {
|
|
|
261
316
|
},
|
|
262
317
|
bybit: {
|
|
263
318
|
name: 'Bybit',
|
|
264
|
-
formatInterval: (
|
|
265
|
-
const map = {
|
|
266
|
-
'1m': '1',
|
|
267
|
-
'5m': '5',
|
|
268
|
-
'15m': '15',
|
|
269
|
-
'30m': '30',
|
|
270
|
-
'1h': '60',
|
|
271
|
-
'4h': '240',
|
|
272
|
-
'6h': '360',
|
|
273
|
-
'12h': '720',
|
|
274
|
-
'1d': 'D',
|
|
275
|
-
'1w': 'W',
|
|
276
|
-
};
|
|
277
|
-
return map[lower(interval)] || interval;
|
|
278
|
-
},
|
|
319
|
+
formatInterval: intervalFormatter(INTERVAL_MINUTES),
|
|
279
320
|
marketsUrl: 'https://api.bybit.com/v5/market/instruments-info?category=spot&limit=1000',
|
|
280
321
|
candlesUrl: ({ id, interval, limit, sinceMs, untilMs }) => {
|
|
281
322
|
const url = new URL('https://api.bybit.com/v5/market/kline');
|
|
@@ -318,21 +359,7 @@ const EXCHANGES = {
|
|
|
318
359
|
},
|
|
319
360
|
bitget: {
|
|
320
361
|
name: 'Bitget',
|
|
321
|
-
formatInterval: (
|
|
322
|
-
const map = {
|
|
323
|
-
'1m': '1m',
|
|
324
|
-
'5m': '5m',
|
|
325
|
-
'15m': '15m',
|
|
326
|
-
'30m': '30m',
|
|
327
|
-
'1h': '1h',
|
|
328
|
-
'4h': '4h',
|
|
329
|
-
'6h': '6h',
|
|
330
|
-
'12h': '12h',
|
|
331
|
-
'1d': '1d',
|
|
332
|
-
'1w': '1w',
|
|
333
|
-
};
|
|
334
|
-
return map[lower(interval)] || interval;
|
|
335
|
-
},
|
|
362
|
+
formatInterval: intervalFormatter(INTERVAL_BITGET),
|
|
336
363
|
marketsUrl: 'https://api.bitget.com/api/v2/spot/public/symbols',
|
|
337
364
|
candlesUrl: ({ id, interval, limit, sinceMs, untilMs }) => {
|
|
338
365
|
const url = new URL('https://api.bitget.com/api/v2/spot/market/candles');
|
|
@@ -353,21 +380,7 @@ const EXCHANGES = {
|
|
|
353
380
|
},
|
|
354
381
|
kucoin: {
|
|
355
382
|
name: 'KuCoin',
|
|
356
|
-
formatInterval: (
|
|
357
|
-
const map = {
|
|
358
|
-
'1m': '1min',
|
|
359
|
-
'5m': '5min',
|
|
360
|
-
'15m': '15min',
|
|
361
|
-
'30m': '30min',
|
|
362
|
-
'1h': '1hour',
|
|
363
|
-
'4h': '4hour',
|
|
364
|
-
'6h': '6hour',
|
|
365
|
-
'12h': '12hour',
|
|
366
|
-
'1d': '1day',
|
|
367
|
-
'1w': '1week',
|
|
368
|
-
};
|
|
369
|
-
return map[lower(interval)] || interval;
|
|
370
|
-
},
|
|
383
|
+
formatInterval: intervalFormatter(INTERVAL_DURATION),
|
|
371
384
|
marketsUrl: 'https://api.kucoin.com/api/v2/symbols',
|
|
372
385
|
candlesUrl: ({ id, interval, sinceMs, untilMs }) => {
|
|
373
386
|
const url = new URL('https://api.kucoin.com/api/v1/market/candles');
|
|
@@ -387,21 +400,7 @@ const EXCHANGES = {
|
|
|
387
400
|
},
|
|
388
401
|
htx: {
|
|
389
402
|
name: 'HTX',
|
|
390
|
-
formatInterval: (
|
|
391
|
-
const map = {
|
|
392
|
-
'1m': '1min',
|
|
393
|
-
'5m': '5min',
|
|
394
|
-
'15m': '15min',
|
|
395
|
-
'30m': '30min',
|
|
396
|
-
'1h': '60min',
|
|
397
|
-
'4h': '4hour',
|
|
398
|
-
'6h': '6hour',
|
|
399
|
-
'12h': '12hour',
|
|
400
|
-
'1d': '1day',
|
|
401
|
-
'1w': '1week',
|
|
402
|
-
};
|
|
403
|
-
return map[lower(interval)] || interval;
|
|
404
|
-
},
|
|
403
|
+
formatInterval: intervalFormatter(INTERVAL_HTX),
|
|
405
404
|
marketsUrl: 'https://api.htx.com/v1/common/symbols',
|
|
406
405
|
candlesUrl: ({ id, interval, limit, sinceMs, untilMs }) => {
|
|
407
406
|
// Official Huobi/HTX spot historical kline endpoint is /market/history/kline
|
|
@@ -433,21 +432,7 @@ const EXCHANGES = {
|
|
|
433
432
|
},
|
|
434
433
|
kraken: {
|
|
435
434
|
name: 'Kraken',
|
|
436
|
-
formatInterval: (
|
|
437
|
-
const map = {
|
|
438
|
-
'1m': '1',
|
|
439
|
-
'5m': '5',
|
|
440
|
-
'15m': '15',
|
|
441
|
-
'30m': '30',
|
|
442
|
-
'1h': '60',
|
|
443
|
-
'4h': '240',
|
|
444
|
-
'6h': '360',
|
|
445
|
-
'12h': '720',
|
|
446
|
-
'1d': '1440',
|
|
447
|
-
'1w': '10080',
|
|
448
|
-
};
|
|
449
|
-
return map[lower(interval)] || interval;
|
|
450
|
-
},
|
|
435
|
+
formatInterval: intervalFormatter(INTERVAL_KRAKEN),
|
|
451
436
|
marketsUrl: 'https://api.kraken.com/0/public/AssetPairs',
|
|
452
437
|
candlesUrl: ({ id, interval, intervalSeconds, limit, sinceMs }) => {
|
|
453
438
|
const url = new URL('https://api.kraken.com/0/public/OHLC');
|
|
@@ -481,21 +466,7 @@ const EXCHANGES = {
|
|
|
481
466
|
name: 'OKX',
|
|
482
467
|
// /api/v5/market/candles caps limit at CEX_PAGE_LIMIT_CAPS.okx per request
|
|
483
468
|
maxLimit: MARKET_ADAPTER.CEX_PAGE_LIMIT_CAPS.okx,
|
|
484
|
-
formatInterval: (
|
|
485
|
-
const map = {
|
|
486
|
-
'1m': '1',
|
|
487
|
-
'5m': '5',
|
|
488
|
-
'15m': '15',
|
|
489
|
-
'30m': '30',
|
|
490
|
-
'1h': '60',
|
|
491
|
-
'4h': '240',
|
|
492
|
-
'6h': '360',
|
|
493
|
-
'12h': '720',
|
|
494
|
-
'1d': 'D',
|
|
495
|
-
'1w': 'W',
|
|
496
|
-
};
|
|
497
|
-
return map[lower(interval)] || interval;
|
|
498
|
-
},
|
|
469
|
+
formatInterval: intervalFormatter(INTERVAL_MINUTES),
|
|
499
470
|
marketsUrl: 'https://www.okx.com/api/v5/public/instruments?instType=SPOT',
|
|
500
471
|
candlesUrl: ({ id, interval, limit, sinceMs, untilMs }) => {
|
|
501
472
|
const url = new URL('https://www.okx.com/api/v5/market/candles');
|
|
@@ -518,22 +489,7 @@ const EXCHANGES = {
|
|
|
518
489
|
name: 'MEXC',
|
|
519
490
|
// /api/v3/klines caps limit at CEX_PAGE_LIMIT_CAPS.mexc per request
|
|
520
491
|
maxLimit: MARKET_ADAPTER.CEX_PAGE_LIMIT_CAPS.mexc,
|
|
521
|
-
formatInterval: (
|
|
522
|
-
const map = {
|
|
523
|
-
'1m': '1m',
|
|
524
|
-
'5m': '5m',
|
|
525
|
-
'15m': '15m',
|
|
526
|
-
'30m': '30m',
|
|
527
|
-
'1h': '60m',
|
|
528
|
-
'4h': '4h',
|
|
529
|
-
'6h': '6h',
|
|
530
|
-
'12h': '12h',
|
|
531
|
-
'1d': '1d',
|
|
532
|
-
// MEXC interval enums are case-sensitive
|
|
533
|
-
'1w': '1W',
|
|
534
|
-
};
|
|
535
|
-
return map[lower(interval)] || interval;
|
|
536
|
-
},
|
|
492
|
+
formatInterval: intervalFormatter(INTERVAL_MEXC),
|
|
537
493
|
marketsUrl: 'https://api.mexc.com/api/v3/exchangeInfo',
|
|
538
494
|
candlesUrl: ({ id, interval, limit, sinceMs, untilMs }) => {
|
|
539
495
|
const url = new URL('https://api.mexc.com/api/v3/klines');
|