dexbot 1.1.10
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/LICENSE +21 -0
- package/README.md +287 -0
- package/claw/README.md +513 -0
- package/claw/scripts/memu_runner.py +385 -0
- package/claw/skills/bitshares-guide/SKILL.md +14 -0
- package/claw/skills/bitshares-guide/references/example-skill-shells.md +18 -0
- package/claw/skills/bitshares-guide/references/presentation-patterns.md +19 -0
- package/claw/skills/bitshares-guide/references/scope-guardrails.md +9 -0
- package/claw/skills/launcher-ops/SKILL.md +18 -0
- package/claw/skills/launcher-ops/references/launcher-workflow.md +23 -0
- package/claw/skills/margin-trading/SKILL.md +23 -0
- package/claw/skills/margin-trading/references/honest-asset-list.md +74 -0
- package/claw/skills/margin-trading/references/honest-assets.md +44 -0
- package/claw/skills/margin-trading/references/position-management.md +203 -0
- package/claw/skills/margin-trading/references/trading-concepts.md +80 -0
- package/claw/skills/memu-memory/SKILL.md +218 -0
- package/claw/skills/shared/references/js-automation-overview.md +24 -0
- package/claw/skills/shared/references/safety-and-staleness.md +11 -0
- package/claw/skills/shared/references/skill-boundaries.md +17 -0
- package/claw/skills/trend-detection/SKILL.md +33 -0
- package/claw/skills/trend-detection/agents/openai.yaml +3 -0
- package/claw/skills/trend-detection/references/service.md +45 -0
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.d.ts +3 -0
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.d.ts.map +1 -0
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.js +149 -0
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.js.map +1 -0
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.d.ts +3 -0
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.d.ts.map +1 -0
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js +387 -0
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js.map +1 -0
- package/dist/analysis/ama_fitting/calibrate_convergence_er.d.ts +3 -0
- package/dist/analysis/ama_fitting/calibrate_convergence_er.d.ts.map +1 -0
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js +200 -0
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js.map +1 -0
- package/dist/analysis/ama_fitting/fetch_lp_candles.d.ts +3 -0
- package/dist/analysis/ama_fitting/fetch_lp_candles.d.ts.map +1 -0
- package/dist/analysis/ama_fitting/fetch_lp_candles.js +212 -0
- package/dist/analysis/ama_fitting/fetch_lp_candles.js.map +1 -0
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts +31 -0
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts.map +1 -0
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js +249 -0
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js.map +1 -0
- package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts +2 -0
- package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts.map +1 -0
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js +782 -0
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js.map +1 -0
- package/dist/analysis/analyze_derivatives.d.ts +95 -0
- package/dist/analysis/analyze_derivatives.d.ts.map +1 -0
- package/dist/analysis/analyze_derivatives.js +295 -0
- package/dist/analysis/analyze_derivatives.js.map +1 -0
- package/dist/analysis/analyze_dynamic_weight.d.ts +14 -0
- package/dist/analysis/analyze_dynamic_weight.d.ts.map +1 -0
- package/dist/analysis/analyze_dynamic_weight.js +208 -0
- package/dist/analysis/analyze_dynamic_weight.js.map +1 -0
- package/dist/analysis/analyze_kalman.d.ts +13 -0
- package/dist/analysis/analyze_kalman.d.ts.map +1 -0
- package/dist/analysis/analyze_kalman.js +123 -0
- package/dist/analysis/analyze_kalman.js.map +1 -0
- package/dist/analysis/analyze_regime.d.ts +20 -0
- package/dist/analysis/analyze_regime.d.ts.map +1 -0
- package/dist/analysis/analyze_regime.js +139 -0
- package/dist/analysis/analyze_regime.js.map +1 -0
- package/dist/analysis/analyze_regime_windows.d.ts +19 -0
- package/dist/analysis/analyze_regime_windows.d.ts.map +1 -0
- package/dist/analysis/analyze_regime_windows.js +413 -0
- package/dist/analysis/analyze_regime_windows.js.map +1 -0
- package/dist/analysis/analyze_risk_profile.d.ts +3 -0
- package/dist/analysis/analyze_risk_profile.d.ts.map +1 -0
- package/dist/analysis/analyze_risk_profile.js +159 -0
- package/dist/analysis/analyze_risk_profile.js.map +1 -0
- package/dist/analysis/analyze_trade_heatmap.d.ts +3 -0
- package/dist/analysis/analyze_trade_heatmap.d.ts.map +1 -0
- package/dist/analysis/analyze_trade_heatmap.js +367 -0
- package/dist/analysis/analyze_trade_heatmap.js.map +1 -0
- package/dist/analysis/analyze_volatility.d.ts +22 -0
- package/dist/analysis/analyze_volatility.d.ts.map +1 -0
- package/dist/analysis/analyze_volatility.js +172 -0
- package/dist/analysis/analyze_volatility.js.map +1 -0
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts +99 -0
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts.map +1 -0
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js +804 -0
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js.map +1 -0
- package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts +2 -0
- package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts.map +1 -0
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js +347 -0
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js.map +1 -0
- package/dist/analysis/bot_fitting/shared_utils.d.ts +15 -0
- package/dist/analysis/bot_fitting/shared_utils.d.ts.map +1 -0
- package/dist/analysis/bot_fitting/shared_utils.js +48 -0
- package/dist/analysis/bot_fitting/shared_utils.js.map +1 -0
- package/dist/analysis/bot_key_utils.d.ts +16 -0
- package/dist/analysis/bot_key_utils.d.ts.map +1 -0
- package/dist/analysis/bot_key_utils.js +61 -0
- package/dist/analysis/bot_key_utils.js.map +1 -0
- package/dist/analysis/bot_usage/discover_bot_accounts.d.ts +3 -0
- package/dist/analysis/bot_usage/discover_bot_accounts.d.ts.map +1 -0
- package/dist/analysis/bot_usage/discover_bot_accounts.js +498 -0
- package/dist/analysis/bot_usage/discover_bot_accounts.js.map +1 -0
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts +546 -0
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +1 -0
- package/dist/analysis/bot_usage/kibana_bot_queries.js +427 -0
- package/dist/analysis/bot_usage/kibana_bot_queries.js.map +1 -0
- package/dist/analysis/chart_utils.d.ts +13 -0
- package/dist/analysis/chart_utils.d.ts.map +1 -0
- package/dist/analysis/chart_utils.js +142 -0
- package/dist/analysis/chart_utils.js.map +1 -0
- package/dist/analysis/derivative_chart_generator.d.ts +18 -0
- package/dist/analysis/derivative_chart_generator.d.ts.map +1 -0
- package/dist/analysis/derivative_chart_generator.js +896 -0
- package/dist/analysis/derivative_chart_generator.js.map +1 -0
- package/dist/analysis/math_utils.d.ts +35 -0
- package/dist/analysis/math_utils.d.ts.map +1 -0
- package/dist/analysis/math_utils.js +121 -0
- package/dist/analysis/math_utils.js.map +1 -0
- package/dist/analysis/price_sources.d.ts +34 -0
- package/dist/analysis/price_sources.d.ts.map +1 -0
- package/dist/analysis/price_sources.js +103 -0
- package/dist/analysis/price_sources.js.map +1 -0
- package/dist/analysis/trade_profitability.d.ts +115 -0
- package/dist/analysis/trade_profitability.d.ts.map +1 -0
- package/dist/analysis/trade_profitability.js +1247 -0
- package/dist/analysis/trade_profitability.js.map +1 -0
- package/dist/analysis/tradingview/analyze_tradingview.d.ts +38 -0
- package/dist/analysis/tradingview/analyze_tradingview.d.ts.map +1 -0
- package/dist/analysis/tradingview/analyze_tradingview.js +212 -0
- package/dist/analysis/tradingview/analyze_tradingview.js.map +1 -0
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts +9 -0
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts.map +1 -0
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +1717 -0
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js.map +1 -0
- package/dist/analysis/trend_detection/derivative_analyzer.d.ts +250 -0
- package/dist/analysis/trend_detection/derivative_analyzer.d.ts.map +1 -0
- package/dist/analysis/trend_detection/derivative_analyzer.js +903 -0
- package/dist/analysis/trend_detection/derivative_analyzer.js.map +1 -0
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts +6 -0
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts.map +1 -0
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +1449 -0
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js.map +1 -0
- package/dist/analysis/trend_detection/hurst_analyzer.d.ts +42 -0
- package/dist/analysis/trend_detection/hurst_analyzer.d.ts.map +1 -0
- package/dist/analysis/trend_detection/hurst_analyzer.js +159 -0
- package/dist/analysis/trend_detection/hurst_analyzer.js.map +1 -0
- package/dist/analysis/trend_detection/kalman_chart_generator.d.ts +6 -0
- package/dist/analysis/trend_detection/kalman_chart_generator.d.ts.map +1 -0
- package/dist/analysis/trend_detection/kalman_chart_generator.js +408 -0
- package/dist/analysis/trend_detection/kalman_chart_generator.js.map +1 -0
- package/dist/analysis/trend_detection/kalman_trend_analyzer.d.ts +103 -0
- package/dist/analysis/trend_detection/kalman_trend_analyzer.d.ts.map +1 -0
- package/dist/analysis/trend_detection/kalman_trend_analyzer.js +229 -0
- package/dist/analysis/trend_detection/kalman_trend_analyzer.js.map +1 -0
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.d.ts +34 -0
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.d.ts.map +1 -0
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.js +89 -0
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.js.map +1 -0
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.d.ts +39 -0
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.d.ts.map +1 -0
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.js +132 -0
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.js.map +1 -0
- package/dist/analysis/trend_detection/regime_chart_generator.d.ts +6 -0
- package/dist/analysis/trend_detection/regime_chart_generator.d.ts.map +1 -0
- package/dist/analysis/trend_detection/regime_chart_generator.js +345 -0
- package/dist/analysis/trend_detection/regime_chart_generator.js.map +1 -0
- package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts +2 -0
- package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts.map +1 -0
- package/dist/analysis/trend_detection/tests/test_kalman_trend.js +130 -0
- package/dist/analysis/trend_detection/tests/test_kalman_trend.js.map +1 -0
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts +2 -0
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts.map +1 -0
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js +38 -0
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js.map +1 -0
- package/dist/analysis/trend_detection/volatility_chart_generator.d.ts +6 -0
- package/dist/analysis/trend_detection/volatility_chart_generator.d.ts.map +1 -0
- package/dist/analysis/trend_detection/volatility_chart_generator.js +732 -0
- package/dist/analysis/trend_detection/volatility_chart_generator.js.map +1 -0
- package/dist/bot.d.ts +49 -0
- package/dist/bot.d.ts.map +1 -0
- package/dist/bot.js +221 -0
- package/dist/bot.js.map +1 -0
- package/dist/credential-daemon.d.ts +64 -0
- package/dist/credential-daemon.d.ts.map +1 -0
- package/dist/credential-daemon.js +987 -0
- package/dist/credential-daemon.js.map +1 -0
- package/dist/dexbot.d.ts +87 -0
- package/dist/dexbot.d.ts.map +1 -0
- package/dist/dexbot.js +1222 -0
- package/dist/dexbot.js.map +1 -0
- package/dist/market_adapter/ama_signal_runner.d.ts +3 -0
- package/dist/market_adapter/ama_signal_runner.d.ts.map +1 -0
- package/dist/market_adapter/ama_signal_runner.js +175 -0
- package/dist/market_adapter/ama_signal_runner.js.map +1 -0
- package/dist/market_adapter/candle_utils.d.ts +57 -0
- package/dist/market_adapter/candle_utils.d.ts.map +1 -0
- package/dist/market_adapter/candle_utils.js +252 -0
- package/dist/market_adapter/candle_utils.js.map +1 -0
- package/dist/market_adapter/core/asymmetric_bounds.d.ts +20 -0
- package/dist/market_adapter/core/asymmetric_bounds.d.ts.map +1 -0
- package/dist/market_adapter/core/asymmetric_bounds.js +88 -0
- package/dist/market_adapter/core/asymmetric_bounds.js.map +1 -0
- package/dist/market_adapter/core/config_normalizers.d.ts +10 -0
- package/dist/market_adapter/core/config_normalizers.d.ts.map +1 -0
- package/dist/market_adapter/core/config_normalizers.js +24 -0
- package/dist/market_adapter/core/config_normalizers.js.map +1 -0
- package/dist/market_adapter/core/kibana_candles.d.ts +74 -0
- package/dist/market_adapter/core/kibana_candles.d.ts.map +1 -0
- package/dist/market_adapter/core/kibana_candles.js +249 -0
- package/dist/market_adapter/core/kibana_candles.js.map +1 -0
- package/dist/market_adapter/core/kibana_client.d.ts +27 -0
- package/dist/market_adapter/core/kibana_client.d.ts.map +1 -0
- package/dist/market_adapter/core/kibana_client.js +120 -0
- package/dist/market_adapter/core/kibana_client.js.map +1 -0
- package/dist/market_adapter/core/kibana_market_candles.d.ts +143 -0
- package/dist/market_adapter/core/kibana_market_candles.d.ts.map +1 -0
- package/dist/market_adapter/core/kibana_market_candles.js +170 -0
- package/dist/market_adapter/core/kibana_market_candles.js.map +1 -0
- package/dist/market_adapter/core/market_adapter_service.d.ts +210 -0
- package/dist/market_adapter/core/market_adapter_service.d.ts.map +1 -0
- package/dist/market_adapter/core/market_adapter_service.js +2328 -0
- package/dist/market_adapter/core/market_adapter_service.js.map +1 -0
- package/dist/market_adapter/core/strategies/ama.d.ts +2 -0
- package/dist/market_adapter/core/strategies/ama.d.ts.map +1 -0
- package/dist/market_adapter/core/strategies/ama.js +138 -0
- package/dist/market_adapter/core/strategies/ama.js.map +1 -0
- package/dist/market_adapter/core/strategies/ama_slope_model.d.ts +50 -0
- package/dist/market_adapter/core/strategies/ama_slope_model.d.ts.map +1 -0
- package/dist/market_adapter/core/strategies/ama_slope_model.js +143 -0
- package/dist/market_adapter/core/strategies/ama_slope_model.js.map +1 -0
- package/dist/market_adapter/core/strategies/atr/calculator.d.ts +12 -0
- package/dist/market_adapter/core/strategies/atr/calculator.d.ts.map +1 -0
- package/dist/market_adapter/core/strategies/atr/calculator.js +47 -0
- package/dist/market_adapter/core/strategies/atr/calculator.js.map +1 -0
- package/dist/market_adapter/core/strategies/collateral_manager.d.ts +32 -0
- package/dist/market_adapter/core/strategies/collateral_manager.d.ts.map +1 -0
- package/dist/market_adapter/core/strategies/collateral_manager.js +68 -0
- package/dist/market_adapter/core/strategies/collateral_manager.js.map +1 -0
- package/dist/market_adapter/core/strategies/regime_gate.d.ts +66 -0
- package/dist/market_adapter/core/strategies/regime_gate.d.ts.map +1 -0
- package/dist/market_adapter/core/strategies/regime_gate.js +189 -0
- package/dist/market_adapter/core/strategies/regime_gate.js.map +1 -0
- package/dist/market_adapter/index.d.ts +10 -0
- package/dist/market_adapter/index.d.ts.map +1 -0
- package/dist/market_adapter/index.js +71 -0
- package/dist/market_adapter/index.js.map +1 -0
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.d.ts +3 -0
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.d.ts.map +1 -0
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +1165 -0
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +1 -0
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts +54 -0
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +1 -0
- package/dist/market_adapter/inputs/fetch_lp_data.js +743 -0
- package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -0
- package/dist/market_adapter/inputs/kibana_source.d.ts +68 -0
- package/dist/market_adapter/inputs/kibana_source.d.ts.map +1 -0
- package/dist/market_adapter/inputs/kibana_source.js +143 -0
- package/dist/market_adapter/inputs/kibana_source.js.map +1 -0
- package/dist/market_adapter/interval_utils.d.ts +6 -0
- package/dist/market_adapter/interval_utils.d.ts.map +1 -0
- package/dist/market_adapter/interval_utils.js +14 -0
- package/dist/market_adapter/interval_utils.js.map +1 -0
- package/dist/market_adapter/log_format.d.ts +16 -0
- package/dist/market_adapter/log_format.d.ts.map +1 -0
- package/dist/market_adapter/log_format.js +72 -0
- package/dist/market_adapter/log_format.js.map +1 -0
- package/dist/market_adapter/lp_chart_core.d.ts +6 -0
- package/dist/market_adapter/lp_chart_core.d.ts.map +1 -0
- package/dist/market_adapter/lp_chart_core.js +874 -0
- package/dist/market_adapter/lp_chart_core.js.map +1 -0
- package/dist/market_adapter/lp_chart_runner.d.ts +135 -0
- package/dist/market_adapter/lp_chart_runner.d.ts.map +1 -0
- package/dist/market_adapter/lp_chart_runner.js +337 -0
- package/dist/market_adapter/lp_chart_runner.js.map +1 -0
- package/dist/market_adapter/lp_chart_strategy_loader.d.ts +23 -0
- package/dist/market_adapter/lp_chart_strategy_loader.d.ts.map +1 -0
- package/dist/market_adapter/lp_chart_strategy_loader.js +169 -0
- package/dist/market_adapter/lp_chart_strategy_loader.js.map +1 -0
- package/dist/market_adapter/market_adapter.d.ts +133 -0
- package/dist/market_adapter/market_adapter.d.ts.map +1 -0
- package/dist/market_adapter/market_adapter.js +1331 -0
- package/dist/market_adapter/market_adapter.js.map +1 -0
- package/dist/market_adapter/merge_lp_data.d.ts +3 -0
- package/dist/market_adapter/merge_lp_data.d.ts.map +1 -0
- package/dist/market_adapter/merge_lp_data.js +125 -0
- package/dist/market_adapter/merge_lp_data.js.map +1 -0
- package/dist/market_adapter/test_helpers.d.ts +14 -0
- package/dist/market_adapter/test_helpers.d.ts.map +1 -0
- package/dist/market_adapter/test_helpers.js +22 -0
- package/dist/market_adapter/test_helpers.js.map +1 -0
- package/dist/market_adapter/utils/adapter_client.d.ts +20 -0
- package/dist/market_adapter/utils/adapter_client.d.ts.map +1 -0
- package/dist/market_adapter/utils/adapter_client.js +88 -0
- package/dist/market_adapter/utils/adapter_client.js.map +1 -0
- package/dist/market_adapter/utils/atomic_write.d.ts +9 -0
- package/dist/market_adapter/utils/atomic_write.d.ts.map +1 -0
- package/dist/market_adapter/utils/atomic_write.js +13 -0
- package/dist/market_adapter/utils/atomic_write.js.map +1 -0
- package/dist/market_adapter/utils/chain.d.ts +50 -0
- package/dist/market_adapter/utils/chain.d.ts.map +1 -0
- package/dist/market_adapter/utils/chain.js +196 -0
- package/dist/market_adapter/utils/chain.js.map +1 -0
- package/dist/market_adapter/utils/data_discovery.d.ts +6 -0
- package/dist/market_adapter/utils/data_discovery.d.ts.map +1 -0
- package/dist/market_adapter/utils/data_discovery.js +35 -0
- package/dist/market_adapter/utils/data_discovery.js.map +1 -0
- package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts +15 -0
- package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts.map +1 -0
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js +60 -0
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js.map +1 -0
- package/dist/market_adapter/utils/file_lock.d.ts +19 -0
- package/dist/market_adapter/utils/file_lock.d.ts.map +1 -0
- package/dist/market_adapter/utils/file_lock.js +191 -0
- package/dist/market_adapter/utils/file_lock.js.map +1 -0
- package/dist/market_adapter/utils/native_history.d.ts +19 -0
- package/dist/market_adapter/utils/native_history.d.ts.map +1 -0
- package/dist/market_adapter/utils/native_history.js +172 -0
- package/dist/market_adapter/utils/native_history.js.map +1 -0
- package/dist/market_adapter/utils/paths.d.ts +5 -0
- package/dist/market_adapter/utils/paths.d.ts.map +1 -0
- package/dist/market_adapter/utils/paths.js +7 -0
- package/dist/market_adapter/utils/paths.js.map +1 -0
- package/dist/modules/account_bots.d.ts +112 -0
- package/dist/modules/account_bots.d.ts.map +1 -0
- package/dist/modules/account_bots.js +1259 -0
- package/dist/modules/account_bots.js.map +1 -0
- package/dist/modules/account_orders.d.ts +273 -0
- package/dist/modules/account_orders.d.ts.map +1 -0
- package/dist/modules/account_orders.js +662 -0
- package/dist/modules/account_orders.js.map +1 -0
- package/dist/modules/authority_resolver.d.ts +2 -0
- package/dist/modules/authority_resolver.d.ts.map +1 -0
- package/dist/modules/authority_resolver.js +231 -0
- package/dist/modules/authority_resolver.js.map +1 -0
- package/dist/modules/bitshares-native/chain_client.d.ts +38 -0
- package/dist/modules/bitshares-native/chain_client.d.ts.map +1 -0
- package/dist/modules/bitshares-native/chain_client.js +322 -0
- package/dist/modules/bitshares-native/chain_client.js.map +1 -0
- package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts +59 -0
- package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts.map +1 -0
- package/dist/modules/bitshares-native/crypto/ecc.browser.js +456 -0
- package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +1 -0
- package/dist/modules/bitshares-native/crypto/ecc.d.ts +66 -0
- package/dist/modules/bitshares-native/crypto/ecc.d.ts.map +1 -0
- package/dist/modules/bitshares-native/crypto/ecc.js +557 -0
- package/dist/modules/bitshares-native/crypto/ecc.js.map +1 -0
- package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts +2 -0
- package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts.map +1 -0
- package/dist/modules/bitshares-native/crypto/ecc_selector.js +20 -0
- package/dist/modules/bitshares-native/crypto/ecc_selector.js.map +1 -0
- package/dist/modules/bitshares-native/index.d.ts +3 -0
- package/dist/modules/bitshares-native/index.d.ts.map +1 -0
- package/dist/modules/bitshares-native/index.js +32 -0
- package/dist/modules/bitshares-native/index.js.map +1 -0
- package/dist/modules/bitshares-native/resolvers.d.ts +40 -0
- package/dist/modules/bitshares-native/resolvers.d.ts.map +1 -0
- package/dist/modules/bitshares-native/resolvers.js +161 -0
- package/dist/modules/bitshares-native/resolvers.js.map +1 -0
- package/dist/modules/bitshares-native/serial/chain_constants.d.ts +56 -0
- package/dist/modules/bitshares-native/serial/chain_constants.d.ts.map +1 -0
- package/dist/modules/bitshares-native/serial/chain_constants.js +92 -0
- package/dist/modules/bitshares-native/serial/chain_constants.js.map +1 -0
- package/dist/modules/bitshares-native/serial/index.d.ts +10 -0
- package/dist/modules/bitshares-native/serial/index.d.ts.map +1 -0
- package/dist/modules/bitshares-native/serial/index.js +14 -0
- package/dist/modules/bitshares-native/serial/index.js.map +1 -0
- package/dist/modules/bitshares-native/serial/operations.d.ts +102 -0
- package/dist/modules/bitshares-native/serial/operations.d.ts.map +1 -0
- package/dist/modules/bitshares-native/serial/operations.js +615 -0
- package/dist/modules/bitshares-native/serial/operations.js.map +1 -0
- package/dist/modules/bitshares-native/serial/serializer.d.ts +64 -0
- package/dist/modules/bitshares-native/serial/serializer.d.ts.map +1 -0
- package/dist/modules/bitshares-native/serial/serializer.js +252 -0
- package/dist/modules/bitshares-native/serial/serializer.js.map +1 -0
- package/dist/modules/bitshares-native/serial/types.d.ts +120 -0
- package/dist/modules/bitshares-native/serial/types.d.ts.map +1 -0
- package/dist/modules/bitshares-native/serial/types.js +837 -0
- package/dist/modules/bitshares-native/serial/types.js.map +1 -0
- package/dist/modules/bitshares-native/signing_client.d.ts +6 -0
- package/dist/modules/bitshares-native/signing_client.d.ts.map +1 -0
- package/dist/modules/bitshares-native/signing_client.js +141 -0
- package/dist/modules/bitshares-native/signing_client.js.map +1 -0
- package/dist/modules/bitshares-native/subscriptions.d.ts +6 -0
- package/dist/modules/bitshares-native/subscriptions.d.ts.map +1 -0
- package/dist/modules/bitshares-native/subscriptions.js +865 -0
- package/dist/modules/bitshares-native/subscriptions.js.map +1 -0
- package/dist/modules/bitshares-native/transport.d.ts +51 -0
- package/dist/modules/bitshares-native/transport.d.ts.map +1 -0
- package/dist/modules/bitshares-native/transport.js +447 -0
- package/dist/modules/bitshares-native/transport.js.map +1 -0
- package/dist/modules/bitshares-native/tx/builder.d.ts +30 -0
- package/dist/modules/bitshares-native/tx/builder.d.ts.map +1 -0
- package/dist/modules/bitshares-native/tx/builder.js +262 -0
- package/dist/modules/bitshares-native/tx/builder.js.map +1 -0
- package/dist/modules/bitshares_client.d.ts +129 -0
- package/dist/modules/bitshares_client.d.ts.map +1 -0
- package/dist/modules/bitshares_client.js +627 -0
- package/dist/modules/bitshares_client.js.map +1 -0
- package/dist/modules/bot_settings.d.ts +33 -0
- package/dist/modules/bot_settings.d.ts.map +1 -0
- package/dist/modules/bot_settings.js +328 -0
- package/dist/modules/bot_settings.js.map +1 -0
- package/dist/modules/bots_file_lock.d.ts +88 -0
- package/dist/modules/bots_file_lock.d.ts.map +1 -0
- package/dist/modules/bots_file_lock.js +161 -0
- package/dist/modules/bots_file_lock.js.map +1 -0
- package/dist/modules/chain_keys.d.ts +302 -0
- package/dist/modules/chain_keys.d.ts.map +1 -0
- package/dist/modules/chain_keys.js +1095 -0
- package/dist/modules/chain_keys.js.map +1 -0
- package/dist/modules/chain_orders.d.ts +423 -0
- package/dist/modules/chain_orders.d.ts.map +1 -0
- package/dist/modules/chain_orders.js +1201 -0
- package/dist/modules/chain_orders.js.map +1 -0
- package/dist/modules/cli_whitelist_args.d.ts +6 -0
- package/dist/modules/cli_whitelist_args.d.ts.map +1 -0
- package/dist/modules/cli_whitelist_args.js +13 -0
- package/dist/modules/cli_whitelist_args.js.map +1 -0
- package/dist/modules/config.d.ts +57 -0
- package/dist/modules/config.d.ts.map +1 -0
- package/dist/modules/config.js +107 -0
- package/dist/modules/config.js.map +1 -0
- package/dist/modules/constants.d.ts +635 -0
- package/dist/modules/constants.d.ts.map +1 -0
- package/dist/modules/constants.js +1464 -0
- package/dist/modules/constants.js.map +1 -0
- package/dist/modules/cr_planner.d.ts +51 -0
- package/dist/modules/cr_planner.d.ts.map +1 -0
- package/dist/modules/cr_planner.js +299 -0
- package/dist/modules/cr_planner.js.map +1 -0
- package/dist/modules/credential_policy.d.ts +188 -0
- package/dist/modules/credential_policy.d.ts.map +1 -0
- package/dist/modules/credential_policy.js +1452 -0
- package/dist/modules/credential_policy.js.map +1 -0
- package/dist/modules/credential_runtime.d.ts +42 -0
- package/dist/modules/credential_runtime.d.ts.map +1 -0
- package/dist/modules/credential_runtime.js +148 -0
- package/dist/modules/credential_runtime.js.map +1 -0
- package/dist/modules/credential_session_cache.d.ts +36 -0
- package/dist/modules/credential_session_cache.d.ts.map +1 -0
- package/dist/modules/credential_session_cache.js +106 -0
- package/dist/modules/credential_session_cache.js.map +1 -0
- package/dist/modules/credit_runtime.d.ts +412 -0
- package/dist/modules/credit_runtime.d.ts.map +1 -0
- package/dist/modules/credit_runtime.js +2866 -0
- package/dist/modules/credit_runtime.js.map +1 -0
- package/dist/modules/crypto/browser_provider.d.ts +15 -0
- package/dist/modules/crypto/browser_provider.d.ts.map +1 -0
- package/dist/modules/crypto/browser_provider.js +113 -0
- package/dist/modules/crypto/browser_provider.js.map +1 -0
- package/dist/modules/crypto/index.d.ts +9 -0
- package/dist/modules/crypto/index.d.ts.map +1 -0
- package/dist/modules/crypto/index.js +44 -0
- package/dist/modules/crypto/index.js.map +1 -0
- package/dist/modules/crypto/node_provider.d.ts +15 -0
- package/dist/modules/crypto/node_provider.d.ts.map +1 -0
- package/dist/modules/crypto/node_provider.js +74 -0
- package/dist/modules/crypto/node_provider.js.map +1 -0
- package/dist/modules/crypto/provider.d.ts +34 -0
- package/dist/modules/crypto/provider.d.ts.map +1 -0
- package/dist/modules/crypto/provider.js +3 -0
- package/dist/modules/crypto/provider.js.map +1 -0
- package/dist/modules/crypto/pure_ripemd160.d.ts +8 -0
- package/dist/modules/crypto/pure_ripemd160.d.ts.map +1 -0
- package/dist/modules/crypto/pure_ripemd160.js +142 -0
- package/dist/modules/crypto/pure_ripemd160.js.map +1 -0
- package/dist/modules/crypto/pure_scrypt.d.ts +23 -0
- package/dist/modules/crypto/pure_scrypt.d.ts.map +1 -0
- package/dist/modules/crypto/pure_scrypt.js +161 -0
- package/dist/modules/crypto/pure_scrypt.js.map +1 -0
- package/dist/modules/crypto/pure_secp256k1.d.ts +29 -0
- package/dist/modules/crypto/pure_secp256k1.d.ts.map +1 -0
- package/dist/modules/crypto/pure_secp256k1.js +195 -0
- package/dist/modules/crypto/pure_secp256k1.js.map +1 -0
- package/dist/modules/crypto/sync.d.ts +13 -0
- package/dist/modules/crypto/sync.d.ts.map +1 -0
- package/dist/modules/crypto/sync.js +37 -0
- package/dist/modules/crypto/sync.js.map +1 -0
- package/dist/modules/dexbot_class.d.ts +1074 -0
- package/dist/modules/dexbot_class.d.ts.map +1 -0
- package/dist/modules/dexbot_class.js +4613 -0
- package/dist/modules/dexbot_class.js.map +1 -0
- package/dist/modules/dexbot_credential_client.d.ts +71 -0
- package/dist/modules/dexbot_credential_client.d.ts.map +1 -0
- package/dist/modules/dexbot_credential_client.js +224 -0
- package/dist/modules/dexbot_credential_client.js.map +1 -0
- package/dist/modules/dexbot_fill_runtime.d.ts +173 -0
- package/dist/modules/dexbot_fill_runtime.d.ts.map +1 -0
- package/dist/modules/dexbot_fill_runtime.js +217 -0
- package/dist/modules/dexbot_fill_runtime.js.map +1 -0
- package/dist/modules/dexbot_maintenance_runtime.d.ts +279 -0
- package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -0
- package/dist/modules/dexbot_maintenance_runtime.js +1613 -0
- package/dist/modules/dexbot_maintenance_runtime.js.map +1 -0
- package/dist/modules/env.d.ts +12 -0
- package/dist/modules/env.d.ts.map +1 -0
- package/dist/modules/env.js +57 -0
- package/dist/modules/env.js.map +1 -0
- package/dist/modules/fund_registry.d.ts +96 -0
- package/dist/modules/fund_registry.d.ts.map +1 -0
- package/dist/modules/fund_registry.js +261 -0
- package/dist/modules/fund_registry.js.map +1 -0
- package/dist/modules/general_settings.d.ts +36 -0
- package/dist/modules/general_settings.d.ts.map +1 -0
- package/dist/modules/general_settings.js +63 -0
- package/dist/modules/general_settings.js.map +1 -0
- package/dist/modules/graceful_shutdown.d.ts +86 -0
- package/dist/modules/graceful_shutdown.d.ts.map +1 -0
- package/dist/modules/graceful_shutdown.js +164 -0
- package/dist/modules/graceful_shutdown.js.map +1 -0
- package/dist/modules/key_store.d.ts +60 -0
- package/dist/modules/key_store.d.ts.map +1 -0
- package/dist/modules/key_store.js +215 -0
- package/dist/modules/key_store.js.map +1 -0
- package/dist/modules/launcher/bot_supervisor.d.ts +84 -0
- package/dist/modules/launcher/bot_supervisor.d.ts.map +1 -0
- package/dist/modules/launcher/bot_supervisor.js +1067 -0
- package/dist/modules/launcher/bot_supervisor.js.map +1 -0
- package/dist/modules/launcher/child_env.d.ts +9 -0
- package/dist/modules/launcher/child_env.d.ts.map +1 -0
- package/dist/modules/launcher/child_env.js +78 -0
- package/dist/modules/launcher/child_env.js.map +1 -0
- package/dist/modules/launcher/credential_bootstrap.d.ts +22 -0
- package/dist/modules/launcher/credential_bootstrap.d.ts.map +1 -0
- package/dist/modules/launcher/credential_bootstrap.js +303 -0
- package/dist/modules/launcher/credential_bootstrap.js.map +1 -0
- package/dist/modules/launcher/credential_daemon.d.ts +32 -0
- package/dist/modules/launcher/credential_daemon.d.ts.map +1 -0
- package/dist/modules/launcher/credential_daemon.js +173 -0
- package/dist/modules/launcher/credential_daemon.js.map +1 -0
- package/dist/modules/launcher/credential_secret.d.ts +6 -0
- package/dist/modules/launcher/credential_secret.d.ts.map +1 -0
- package/dist/modules/launcher/credential_secret.js +15 -0
- package/dist/modules/launcher/credential_secret.js.map +1 -0
- package/dist/modules/launcher/foreign_cred_daemon.d.ts +2 -0
- package/dist/modules/launcher/foreign_cred_daemon.d.ts.map +1 -0
- package/dist/modules/launcher/foreign_cred_daemon.js +166 -0
- package/dist/modules/launcher/foreign_cred_daemon.js.map +1 -0
- package/dist/modules/launcher/headless_password.d.ts +8 -0
- package/dist/modules/launcher/headless_password.d.ts.map +1 -0
- package/dist/modules/launcher/headless_password.js +33 -0
- package/dist/modules/launcher/headless_password.js.map +1 -0
- package/dist/modules/launcher/launch_modes.d.ts +36 -0
- package/dist/modules/launcher/launch_modes.d.ts.map +1 -0
- package/dist/modules/launcher/launch_modes.js +129 -0
- package/dist/modules/launcher/launch_modes.js.map +1 -0
- package/dist/modules/launcher/market_adapter_runtime.d.ts +43 -0
- package/dist/modules/launcher/market_adapter_runtime.d.ts.map +1 -0
- package/dist/modules/launcher/market_adapter_runtime.js +217 -0
- package/dist/modules/launcher/market_adapter_runtime.js.map +1 -0
- package/dist/modules/launcher/market_adapter_watchdog.d.ts +26 -0
- package/dist/modules/launcher/market_adapter_watchdog.d.ts.map +1 -0
- package/dist/modules/launcher/market_adapter_watchdog.js +214 -0
- package/dist/modules/launcher/market_adapter_watchdog.js.map +1 -0
- package/dist/modules/launcher/monolithic_runtime.d.ts +89 -0
- package/dist/modules/launcher/monolithic_runtime.d.ts.map +1 -0
- package/dist/modules/launcher/monolithic_runtime.js +425 -0
- package/dist/modules/launcher/monolithic_runtime.js.map +1 -0
- package/dist/modules/launcher/runtime_entry.d.ts +26 -0
- package/dist/modules/launcher/runtime_entry.d.ts.map +1 -0
- package/dist/modules/launcher/runtime_entry.js +49 -0
- package/dist/modules/launcher/runtime_entry.js.map +1 -0
- package/dist/modules/launcher/status_reporting.d.ts +48 -0
- package/dist/modules/launcher/status_reporting.d.ts.map +1 -0
- package/dist/modules/launcher/status_reporting.js +113 -0
- package/dist/modules/launcher/status_reporting.js.map +1 -0
- package/dist/modules/launcher/supervisor_control.d.ts +6 -0
- package/dist/modules/launcher/supervisor_control.d.ts.map +1 -0
- package/dist/modules/launcher/supervisor_control.js +59 -0
- package/dist/modules/launcher/supervisor_control.js.map +1 -0
- package/dist/modules/logger.d.ts +2 -0
- package/dist/modules/logger.d.ts.map +1 -0
- package/dist/modules/logger.js +71 -0
- package/dist/modules/logger.js.map +1 -0
- package/dist/modules/market_adapter_whitelist.d.ts +22 -0
- package/dist/modules/market_adapter_whitelist.d.ts.map +1 -0
- package/dist/modules/market_adapter_whitelist.js +82 -0
- package/dist/modules/market_adapter_whitelist.js.map +1 -0
- package/dist/modules/node_health_cache.d.ts +55 -0
- package/dist/modules/node_health_cache.d.ts.map +1 -0
- package/dist/modules/node_health_cache.js +134 -0
- package/dist/modules/node_health_cache.js.map +1 -0
- package/dist/modules/node_manager.d.ts +215 -0
- package/dist/modules/node_manager.d.ts.map +1 -0
- package/dist/modules/node_manager.js +628 -0
- package/dist/modules/node_manager.js.map +1 -0
- package/dist/modules/order/accounting.d.ts +349 -0
- package/dist/modules/order/accounting.d.ts.map +1 -0
- package/dist/modules/order/accounting.js +1191 -0
- package/dist/modules/order/accounting.js.map +1 -0
- package/dist/modules/order/async_lock.d.ts +126 -0
- package/dist/modules/order/async_lock.d.ts.map +1 -0
- package/dist/modules/order/async_lock.js +195 -0
- package/dist/modules/order/async_lock.js.map +1 -0
- package/dist/modules/order/export.d.ts +129 -0
- package/dist/modules/order/export.d.ts.map +1 -0
- package/dist/modules/order/export.js +316 -0
- package/dist/modules/order/export.js.map +1 -0
- package/dist/modules/order/format.d.ts +158 -0
- package/dist/modules/order/format.d.ts.map +1 -0
- package/dist/modules/order/format.js +232 -0
- package/dist/modules/order/format.js.map +1 -0
- package/dist/modules/order/grid.d.ts +549 -0
- package/dist/modules/order/grid.d.ts.map +1 -0
- package/dist/modules/order/grid.js +1746 -0
- package/dist/modules/order/grid.js.map +1 -0
- package/dist/modules/order/grid_reconcile.d.ts +154 -0
- package/dist/modules/order/grid_reconcile.d.ts.map +1 -0
- package/dist/modules/order/grid_reconcile.js +1192 -0
- package/dist/modules/order/grid_reconcile.js.map +1 -0
- package/dist/modules/order/index.d.ts +55 -0
- package/dist/modules/order/index.d.ts.map +1 -0
- package/dist/modules/order/index.js +79 -0
- package/dist/modules/order/index.js.map +1 -0
- package/dist/modules/order/logger.d.ts +136 -0
- package/dist/modules/order/logger.d.ts.map +1 -0
- package/dist/modules/order/logger.js +614 -0
- package/dist/modules/order/logger.js.map +1 -0
- package/dist/modules/order/logger_state.d.ts +133 -0
- package/dist/modules/order/logger_state.d.ts.map +1 -0
- package/dist/modules/order/logger_state.js +170 -0
- package/dist/modules/order/logger_state.js.map +1 -0
- package/dist/modules/order/manager.d.ts +413 -0
- package/dist/modules/order/manager.d.ts.map +1 -0
- package/dist/modules/order/manager.js +1605 -0
- package/dist/modules/order/manager.js.map +1 -0
- package/dist/modules/order/processed_fill_store.d.ts +135 -0
- package/dist/modules/order/processed_fill_store.d.ts.map +1 -0
- package/dist/modules/order/processed_fill_store.js +288 -0
- package/dist/modules/order/processed_fill_store.js.map +1 -0
- package/dist/modules/order/runner.d.ts +70 -0
- package/dist/modules/order/runner.d.ts.map +1 -0
- package/dist/modules/order/runner.js +140 -0
- package/dist/modules/order/runner.js.map +1 -0
- package/dist/modules/order/strategy.d.ts +196 -0
- package/dist/modules/order/strategy.d.ts.map +1 -0
- package/dist/modules/order/strategy.js +398 -0
- package/dist/modules/order/strategy.js.map +1 -0
- package/dist/modules/order/sync_engine.d.ts +386 -0
- package/dist/modules/order/sync_engine.d.ts.map +1 -0
- package/dist/modules/order/sync_engine.js +1459 -0
- package/dist/modules/order/sync_engine.js.map +1 -0
- package/dist/modules/order/utils/math.d.ts +677 -0
- package/dist/modules/order/utils/math.d.ts.map +1 -0
- package/dist/modules/order/utils/math.js +1172 -0
- package/dist/modules/order/utils/math.js.map +1 -0
- package/dist/modules/order/utils/order.d.ts +572 -0
- package/dist/modules/order/utils/order.d.ts.map +1 -0
- package/dist/modules/order/utils/order.js +1145 -0
- package/dist/modules/order/utils/order.js.map +1 -0
- package/dist/modules/order/utils/system.d.ts +268 -0
- package/dist/modules/order/utils/system.d.ts.map +1 -0
- package/dist/modules/order/utils/system.js +1261 -0
- package/dist/modules/order/utils/system.js.map +1 -0
- package/dist/modules/order/utils/validate.d.ts +280 -0
- package/dist/modules/order/utils/validate.d.ts.map +1 -0
- package/dist/modules/order/utils/validate.js +918 -0
- package/dist/modules/order/utils/validate.js.map +1 -0
- package/dist/modules/order/working_grid.d.ts +212 -0
- package/dist/modules/order/working_grid.d.ts.map +1 -0
- package/dist/modules/order/working_grid.js +279 -0
- package/dist/modules/order/working_grid.js.map +1 -0
- package/dist/modules/path_api.d.ts +32 -0
- package/dist/modules/path_api.d.ts.map +1 -0
- package/dist/modules/path_api.js +148 -0
- package/dist/modules/path_api.js.map +1 -0
- package/dist/modules/paths.d.ts +58 -0
- package/dist/modules/paths.d.ts.map +1 -0
- package/dist/modules/paths.js +82 -0
- package/dist/modules/paths.js.map +1 -0
- package/dist/modules/process_discovery.d.ts +58 -0
- package/dist/modules/process_discovery.d.ts.map +1 -0
- package/dist/modules/process_discovery.js +265 -0
- package/dist/modules/process_discovery.js.map +1 -0
- package/dist/modules/runtime.d.ts +34 -0
- package/dist/modules/runtime.d.ts.map +1 -0
- package/dist/modules/runtime.js +98 -0
- package/dist/modules/runtime.js.map +1 -0
- package/dist/modules/runtime_settings.d.ts +12 -0
- package/dist/modules/runtime_settings.d.ts.map +1 -0
- package/dist/modules/runtime_settings.js +122 -0
- package/dist/modules/runtime_settings.js.map +1 -0
- package/dist/modules/settings_merge.d.ts +38 -0
- package/dist/modules/settings_merge.d.ts.map +1 -0
- package/dist/modules/settings_merge.js +246 -0
- package/dist/modules/settings_merge.js.map +1 -0
- package/dist/modules/storage/browser_adapter.d.ts +56 -0
- package/dist/modules/storage/browser_adapter.d.ts.map +1 -0
- package/dist/modules/storage/browser_adapter.js +231 -0
- package/dist/modules/storage/browser_adapter.js.map +1 -0
- package/dist/modules/storage/index.d.ts +28 -0
- package/dist/modules/storage/index.d.ts.map +1 -0
- package/dist/modules/storage/index.js +52 -0
- package/dist/modules/storage/index.js.map +1 -0
- package/dist/modules/storage/node_adapter.d.ts +49 -0
- package/dist/modules/storage/node_adapter.d.ts.map +1 -0
- package/dist/modules/storage/node_adapter.js +167 -0
- package/dist/modules/storage/node_adapter.js.map +1 -0
- package/dist/modules/storage/types.d.ts +92 -0
- package/dist/modules/storage/types.d.ts.map +1 -0
- package/dist/modules/storage/types.js +3 -0
- package/dist/modules/storage/types.js.map +1 -0
- package/dist/modules/types.d.ts +1382 -0
- package/dist/modules/types.d.ts.map +1 -0
- package/dist/modules/types.js +11 -0
- package/dist/modules/types.js.map +1 -0
- package/dist/modules/utils/base58check.d.ts +12 -0
- package/dist/modules/utils/base58check.d.ts.map +1 -0
- package/dist/modules/utils/base58check.js +112 -0
- package/dist/modules/utils/base58check.js.map +1 -0
- package/dist/modules/utils/build_dir.d.ts +7 -0
- package/dist/modules/utils/build_dir.d.ts.map +1 -0
- package/dist/modules/utils/build_dir.js +8 -0
- package/dist/modules/utils/build_dir.js.map +1 -0
- package/dist/modules/utils/fs_utils.d.ts +25 -0
- package/dist/modules/utils/fs_utils.d.ts.map +1 -0
- package/dist/modules/utils/fs_utils.js +27 -0
- package/dist/modules/utils/fs_utils.js.map +1 -0
- package/dist/modules/utils/math_utils.d.ts +10 -0
- package/dist/modules/utils/math_utils.d.ts.map +1 -0
- package/dist/modules/utils/math_utils.js +17 -0
- package/dist/modules/utils/math_utils.js.map +1 -0
- package/dist/modules/validate_profiles.d.ts +37 -0
- package/dist/modules/validate_profiles.d.ts.map +1 -0
- package/dist/modules/validate_profiles.js +369 -0
- package/dist/modules/validate_profiles.js.map +1 -0
- package/dist/pm2.d.ts +167 -0
- package/dist/pm2.d.ts.map +1 -0
- package/dist/pm2.js +998 -0
- package/dist/pm2.js.map +1 -0
- package/dist/scripts/analyze-git.d.ts +11 -0
- package/dist/scripts/analyze-git.d.ts.map +1 -0
- package/dist/scripts/analyze-git.js +851 -0
- package/dist/scripts/analyze-git.js.map +1 -0
- package/dist/scripts/analyze-orders.d.ts +17 -0
- package/dist/scripts/analyze-orders.d.ts.map +1 -0
- package/dist/scripts/analyze-orders.js +1568 -0
- package/dist/scripts/analyze-orders.js.map +1 -0
- package/dist/scripts/diagnose-kibana-candles.d.ts +3 -0
- package/dist/scripts/diagnose-kibana-candles.d.ts.map +1 -0
- package/dist/scripts/diagnose-kibana-candles.js +82 -0
- package/dist/scripts/diagnose-kibana-candles.js.map +1 -0
- package/dist/scripts/diagnose-pool-history.d.ts +3 -0
- package/dist/scripts/diagnose-pool-history.d.ts.map +1 -0
- package/dist/scripts/diagnose-pool-history.js +296 -0
- package/dist/scripts/diagnose-pool-history.js.map +1 -0
- package/dist/scripts/divergence-calc.d.ts +26 -0
- package/dist/scripts/divergence-calc.d.ts.map +1 -0
- package/dist/scripts/divergence-calc.js +119 -0
- package/dist/scripts/divergence-calc.js.map +1 -0
- package/dist/scripts/generate_lp_chart.d.ts +31 -0
- package/dist/scripts/generate_lp_chart.d.ts.map +1 -0
- package/dist/scripts/generate_lp_chart.js +92 -0
- package/dist/scripts/generate_lp_chart.js.map +1 -0
- package/dist/scripts/generate_mainnet_corpus_report.d.ts +24 -0
- package/dist/scripts/generate_mainnet_corpus_report.d.ts.map +1 -0
- package/dist/scripts/generate_mainnet_corpus_report.js +237 -0
- package/dist/scripts/generate_mainnet_corpus_report.js.map +1 -0
- package/dist/scripts/generate_market_adapter_whitelist.d.ts +2 -0
- package/dist/scripts/generate_market_adapter_whitelist.d.ts.map +1 -0
- package/dist/scripts/generate_market_adapter_whitelist.js +111 -0
- package/dist/scripts/generate_market_adapter_whitelist.js.map +1 -0
- package/dist/scripts/migrate_bot_keys.d.ts +6 -0
- package/dist/scripts/migrate_bot_keys.d.ts.map +1 -0
- package/dist/scripts/migrate_bot_keys.js +301 -0
- package/dist/scripts/migrate_bot_keys.js.map +1 -0
- package/dist/scripts/native_release_gates.d.ts +3 -0
- package/dist/scripts/native_release_gates.d.ts.map +1 -0
- package/dist/scripts/native_release_gates.js +52 -0
- package/dist/scripts/native_release_gates.js.map +1 -0
- package/dist/scripts/print_grid.d.ts +16 -0
- package/dist/scripts/print_grid.d.ts.map +1 -0
- package/dist/scripts/print_grid.js +80 -0
- package/dist/scripts/print_grid.js.map +1 -0
- package/dist/scripts/run-tests.d.ts +2 -0
- package/dist/scripts/run-tests.d.ts.map +1 -0
- package/dist/scripts/run-tests.js +49 -0
- package/dist/scripts/run-tests.js.map +1 -0
- package/dist/scripts/sync-version.d.ts +14 -0
- package/dist/scripts/sync-version.d.ts.map +1 -0
- package/dist/scripts/sync-version.js +158 -0
- package/dist/scripts/sync-version.js.map +1 -0
- package/dist/scripts/test-credit-renewal.d.ts +2 -0
- package/dist/scripts/test-credit-renewal.d.ts.map +1 -0
- package/dist/scripts/test-credit-renewal.js +329 -0
- package/dist/scripts/test-credit-renewal.js.map +1 -0
- package/dist/scripts/update.d.ts +24 -0
- package/dist/scripts/update.d.ts.map +1 -0
- package/dist/scripts/update.js +650 -0
- package/dist/scripts/update.js.map +1 -0
- package/dist/scripts/validate_bots.d.ts +16 -0
- package/dist/scripts/validate_bots.d.ts.map +1 -0
- package/dist/scripts/validate_bots.js +106 -0
- package/dist/scripts/validate_bots.js.map +1 -0
- package/dist/scripts/verify-browser-bundle.d.ts +22 -0
- package/dist/scripts/verify-browser-bundle.d.ts.map +1 -0
- package/dist/scripts/verify-browser-bundle.js +339 -0
- package/dist/scripts/verify-browser-bundle.js.map +1 -0
- package/dist/unlock.d.ts +48 -0
- package/dist/unlock.d.ts.map +1 -0
- package/dist/unlock.js +925 -0
- package/dist/unlock.js.map +1 -0
- package/package.json +112 -0
- package/scripts/README.md +356 -0
- package/scripts/clear-all.sh +195 -0
- package/scripts/clear-logs.sh +95 -0
- package/scripts/clear-market-adapter.sh +196 -0
- package/scripts/clear-orders.sh +113 -0
- package/scripts/create-bot-symlinks.sh +51 -0
- package/scripts/postinstall.js +9 -0
- package/scripts/reset-settings.sh +118 -0
|
@@ -0,0 +1,804 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* AMA SWEEP BACKTEST — persistent grid simulation
|
|
4
|
+
*
|
|
5
|
+
* Models the real bot mechanics:
|
|
6
|
+
* - Orders sit at FIXED chain prices until canceled or filled
|
|
7
|
+
* - When AMA drifts past reposition threshold, grid re-centers
|
|
8
|
+
* - Grid compression: AMA shift pushes one side's orders closer to market
|
|
9
|
+
* - Order sizing depends on capital, ratio (range width), and weight profile
|
|
10
|
+
* - Three weight profiles: valley, neutral, mountain (symmetric buy/sell)
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* tsx analysis/bot_fitting/backtest_ama_sweep.ts --data <path-to-lp-candles.json>
|
|
14
|
+
* tsx analysis/bot_fitting/backtest_ama_sweep.ts --data <path-to-lp-candles.json> --spread 4:16:1 --increment 0.5:4:0.25
|
|
15
|
+
*/
|
|
16
|
+
const fs = require('fs');
|
|
17
|
+
const path = require('path');
|
|
18
|
+
const os = require('os');
|
|
19
|
+
const { Worker, isMainThread, parentPort, workerData } = require('worker_threads');
|
|
20
|
+
const { calculateAMA } = require('../../market_adapter/core/strategies/ama');
|
|
21
|
+
const { range } = require('../math_utils');
|
|
22
|
+
const { parseListOrRange, loadLpData, fmt } = require('./shared_utils');
|
|
23
|
+
const { readJSON, writeJSON } = require('../../modules/utils/fs_utils');
|
|
24
|
+
const DEFAULT_MAX_ORDERS = 20; // matches bot default activeOrders per side
|
|
25
|
+
const DEFAULT_FEE_ROUNDTRIP_PCT = 0.20;
|
|
26
|
+
const DEFAULT_MIN_SPREAD_FACTOR = 2.1;
|
|
27
|
+
const DEFAULT_CAPITAL = 10000; // notional units per side
|
|
28
|
+
const DEFAULT_BTS_CREATE_FEE = 0.48260;
|
|
29
|
+
const DEFAULT_BTS_CANCEL_FEE = 0.00482;
|
|
30
|
+
const DEFAULT_BTS_MAKER_CREATE_FACTOR = 0.10;
|
|
31
|
+
const DEFAULT_TX_FEE_PRICE = 1.0;
|
|
32
|
+
// Weight profiles (symmetric for both sides)
|
|
33
|
+
// valley: heavier at edges (outer levels), lighter near center
|
|
34
|
+
// neutral: equal across all levels
|
|
35
|
+
// mountain: heavier near center, lighter at edges
|
|
36
|
+
const WEIGHT_PROFILES = {
|
|
37
|
+
valley: -0.8, // negative = invert decay → outer levels get more
|
|
38
|
+
neutral: 0, // flat = equal distribution
|
|
39
|
+
mountain: 1.5, // strong decay → inner levels get more
|
|
40
|
+
};
|
|
41
|
+
// Search grid defaults — centered around bot defaults (spread=2%, increment=0.5%)
|
|
42
|
+
// Spread = distance from center to first order on each side (half the bid-ask gap)
|
|
43
|
+
// Increment = distance between successive orders on the same side
|
|
44
|
+
const DEFAULT_SPREAD_VALUES = [...range(0.5, 4, 0.25), ...range(5, 12, 1)];
|
|
45
|
+
const DEFAULT_INCREMENT_VALUES = [...range(0.2, 2, 0.1), ...range(2.5, 8, 0.5)];
|
|
46
|
+
const DEFAULT_RATIO_VALUES = [1.05, 1.1, 1.15, 1.2, 1.3, 1.5, 2, 3, 5, 10];
|
|
47
|
+
// Reposition threshold: AMA must move this fraction from last grid center to trigger re-center
|
|
48
|
+
const DEFAULT_REPOSITION_PCT = 2.5;
|
|
49
|
+
function jsonSafe(key, val) {
|
|
50
|
+
if (val === -Infinity || val === Infinity)
|
|
51
|
+
return null;
|
|
52
|
+
return val;
|
|
53
|
+
}
|
|
54
|
+
function parseArgs() {
|
|
55
|
+
const args = process.argv.slice(2);
|
|
56
|
+
const out = {
|
|
57
|
+
dataPath: null,
|
|
58
|
+
resultsPath: null,
|
|
59
|
+
spreadValues: DEFAULT_SPREAD_VALUES,
|
|
60
|
+
incrementValues: DEFAULT_INCREMENT_VALUES,
|
|
61
|
+
ratioValues: DEFAULT_RATIO_VALUES,
|
|
62
|
+
maxOrders: DEFAULT_MAX_ORDERS,
|
|
63
|
+
feeRoundtripPct: DEFAULT_FEE_ROUNDTRIP_PCT,
|
|
64
|
+
minSpreadFactor: DEFAULT_MIN_SPREAD_FACTOR,
|
|
65
|
+
capital: DEFAULT_CAPITAL,
|
|
66
|
+
repositionPct: DEFAULT_REPOSITION_PCT,
|
|
67
|
+
btsCreateFee: DEFAULT_BTS_CREATE_FEE,
|
|
68
|
+
btsCancelFee: DEFAULT_BTS_CANCEL_FEE,
|
|
69
|
+
makerCreateFactor: DEFAULT_BTS_MAKER_CREATE_FACTOR,
|
|
70
|
+
txFeePrice: DEFAULT_TX_FEE_PRICE,
|
|
71
|
+
topN: 15,
|
|
72
|
+
};
|
|
73
|
+
for (let i = 0; i < args.length; i++) {
|
|
74
|
+
const arg = args[i];
|
|
75
|
+
const val = args[i + 1];
|
|
76
|
+
if (arg === '--help' || arg === '-h') {
|
|
77
|
+
printHelp();
|
|
78
|
+
process.exit(0);
|
|
79
|
+
}
|
|
80
|
+
if (!val)
|
|
81
|
+
continue;
|
|
82
|
+
switch (arg) {
|
|
83
|
+
case '--data':
|
|
84
|
+
out.dataPath = path.resolve(val);
|
|
85
|
+
i++;
|
|
86
|
+
break;
|
|
87
|
+
case '--results':
|
|
88
|
+
out.resultsPath = path.resolve(val);
|
|
89
|
+
i++;
|
|
90
|
+
break;
|
|
91
|
+
case '--spread':
|
|
92
|
+
out.spreadValues = parseListOrRange(val, DEFAULT_SPREAD_VALUES);
|
|
93
|
+
i++;
|
|
94
|
+
break;
|
|
95
|
+
case '--increment':
|
|
96
|
+
out.incrementValues = parseListOrRange(val, DEFAULT_INCREMENT_VALUES);
|
|
97
|
+
i++;
|
|
98
|
+
break;
|
|
99
|
+
case '--ratio':
|
|
100
|
+
out.ratioValues = parseListOrRange(val, DEFAULT_RATIO_VALUES);
|
|
101
|
+
i++;
|
|
102
|
+
break;
|
|
103
|
+
case '--max-orders':
|
|
104
|
+
out.maxOrders = Number(val);
|
|
105
|
+
i++;
|
|
106
|
+
break;
|
|
107
|
+
case '--fee':
|
|
108
|
+
out.feeRoundtripPct = Number(val);
|
|
109
|
+
i++;
|
|
110
|
+
break;
|
|
111
|
+
case '--min-spread-factor':
|
|
112
|
+
out.minSpreadFactor = Number(val);
|
|
113
|
+
i++;
|
|
114
|
+
break;
|
|
115
|
+
case '--capital':
|
|
116
|
+
out.capital = Number(val);
|
|
117
|
+
i++;
|
|
118
|
+
break;
|
|
119
|
+
case '--reposition':
|
|
120
|
+
out.repositionPct = Number(val);
|
|
121
|
+
i++;
|
|
122
|
+
break;
|
|
123
|
+
case '--bts-create-fee':
|
|
124
|
+
out.btsCreateFee = Number(val);
|
|
125
|
+
i++;
|
|
126
|
+
break;
|
|
127
|
+
case '--bts-cancel-fee':
|
|
128
|
+
out.btsCancelFee = Number(val);
|
|
129
|
+
i++;
|
|
130
|
+
break;
|
|
131
|
+
case '--maker-create-factor':
|
|
132
|
+
out.makerCreateFactor = Number(val);
|
|
133
|
+
i++;
|
|
134
|
+
break;
|
|
135
|
+
case '--tx-fee-price':
|
|
136
|
+
out.txFeePrice = Number(val);
|
|
137
|
+
i++;
|
|
138
|
+
break;
|
|
139
|
+
case '--top':
|
|
140
|
+
out.topN = Number(val);
|
|
141
|
+
i++;
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (!out.dataPath) {
|
|
146
|
+
throw new Error('--data <path-to-lp-candles.json> is required');
|
|
147
|
+
}
|
|
148
|
+
if (!out.resultsPath) {
|
|
149
|
+
throw new Error('--results <path-to-optimization-results.json> is required');
|
|
150
|
+
}
|
|
151
|
+
return out;
|
|
152
|
+
}
|
|
153
|
+
function printHelp() {
|
|
154
|
+
console.log('AMA Sweep Backtest — persistent grid simulation with weight profiles');
|
|
155
|
+
console.log('');
|
|
156
|
+
console.log('Usage:');
|
|
157
|
+
console.log(' tsx analysis/bot_fitting/backtest_ama_sweep.ts [options]');
|
|
158
|
+
console.log('');
|
|
159
|
+
console.log('Options:');
|
|
160
|
+
console.log(' --data <path> LP candle JSON');
|
|
161
|
+
console.log(' --results <path> AMA optimizer results JSON');
|
|
162
|
+
console.log(' --spread <spec> Spread values (% ): 1:10:0.5 or 2,4,8');
|
|
163
|
+
console.log(' --increment <spec> Increment values (%): 0.5:5:0.5 or 1,2,3');
|
|
164
|
+
console.log(' --ratio <spec> Max/min ratio: 1.5,2,3,5');
|
|
165
|
+
console.log(' --max-orders <n> Max orders per side (default: 20, actual limited by ratio+increment)');
|
|
166
|
+
console.log(' --fee <pct> Round-trip fee % (default: 0.20)');
|
|
167
|
+
console.log(' --min-spread-factor <n> Spread >= factor * increment (default: 2.1)');
|
|
168
|
+
console.log(' --capital <n> Notional capital per side (default: 10000)');
|
|
169
|
+
console.log(' --reposition <pct> AMA drift % to trigger re-center (default: 2.5)');
|
|
170
|
+
console.log(' --bts-create-fee <n> BTS create fee (default: 0.48260)');
|
|
171
|
+
console.log(' --bts-cancel-fee <n> BTS cancel fee (default: 0.00482)');
|
|
172
|
+
console.log(' --maker-create-factor Maker share of create fee (default: 0.10)');
|
|
173
|
+
console.log(' --tx-fee-price <n> Convert BTS fees into backtest units (default: 1.0)');
|
|
174
|
+
console.log(' --top <n> Show top N results (default: 15)');
|
|
175
|
+
}
|
|
176
|
+
function loadAmaStrategies(resultsPath) {
|
|
177
|
+
const json = readJSON(resultsPath);
|
|
178
|
+
const amas = json.meta?.amas;
|
|
179
|
+
if (!amas)
|
|
180
|
+
throw new Error('No meta.amas found in results file.');
|
|
181
|
+
const out = [];
|
|
182
|
+
for (const [key, val] of Object.entries(amas)) {
|
|
183
|
+
const v = val;
|
|
184
|
+
if (!v || !Number.isFinite(v.er))
|
|
185
|
+
continue;
|
|
186
|
+
out.push({ id: key, name: v.label || key, er: v.er, fast: v.fast, slow: v.slow });
|
|
187
|
+
}
|
|
188
|
+
out.sort((a, b) => a.id.localeCompare(b.id));
|
|
189
|
+
if (out.length === 0)
|
|
190
|
+
throw new Error('No valid AMA strategies found');
|
|
191
|
+
return out;
|
|
192
|
+
}
|
|
193
|
+
// ── Order sizing with weight profiles ────────────────────────────────────────
|
|
194
|
+
/**
|
|
195
|
+
* Allocate capital across N levels using weight profile.
|
|
196
|
+
* weight > 0: mountain (more near center, exponential decay outward)
|
|
197
|
+
* weight = 0: neutral (equal)
|
|
198
|
+
* weight < 0: valley (more at edges, inverted decay)
|
|
199
|
+
*
|
|
200
|
+
* @param {number} totalFunds Capital for this side
|
|
201
|
+
* @param {number} n Number of levels
|
|
202
|
+
* @param {number} weight Profile weight factor
|
|
203
|
+
* @param {number} incrementFactor Increment as fraction (e.g. 0.02 for 2%)
|
|
204
|
+
* @returns {number[]} Size per level, index 0 = closest to center
|
|
205
|
+
*/
|
|
206
|
+
function allocateFundsByWeights(totalFunds, n, weight, incrementFactor) {
|
|
207
|
+
if (n <= 0)
|
|
208
|
+
return [];
|
|
209
|
+
if (weight === 0) {
|
|
210
|
+
const sz = totalFunds / n;
|
|
211
|
+
return new Array(n).fill(sz);
|
|
212
|
+
}
|
|
213
|
+
const base = 1 - incrementFactor;
|
|
214
|
+
const absWeight = Math.abs(weight);
|
|
215
|
+
const raw = new Array(n);
|
|
216
|
+
for (let i = 0; i < n; i++) {
|
|
217
|
+
// i=0 is closest to center
|
|
218
|
+
raw[i] = Math.pow(base, i * absWeight);
|
|
219
|
+
}
|
|
220
|
+
if (weight < 0) {
|
|
221
|
+
// Valley: reverse so outer levels (high i) get the large weights
|
|
222
|
+
raw.reverse();
|
|
223
|
+
}
|
|
224
|
+
const total = raw.reduce((s, w) => s + w, 0) || 1;
|
|
225
|
+
return raw.map((w) => (w / total) * totalFunds);
|
|
226
|
+
}
|
|
227
|
+
// ── Persistent grid simulation ───────────────────────────────────────────────
|
|
228
|
+
/**
|
|
229
|
+
* Build a fresh grid centered at `center`.
|
|
230
|
+
*
|
|
231
|
+
* Grid placement (matches real bot):
|
|
232
|
+
* Level k (1-based):
|
|
233
|
+
* offset_k = spreadPct/2/100 + (k-1) * incrementPct
|
|
234
|
+
* buyPrice = center * (1 - offset_k)
|
|
235
|
+
* sellPrice = center * (1 + offset_k)
|
|
236
|
+
*
|
|
237
|
+
* So spread controls the dead zone around center (no orders within spread/2),
|
|
238
|
+
* and increment is the gap between successive orders on the same side.
|
|
239
|
+
*
|
|
240
|
+
* Returns arrays of buy and sell order objects with fixed chain prices and sizes.
|
|
241
|
+
*/
|
|
242
|
+
function buildGrid(center, params, capitalPerSide, weightFactor) {
|
|
243
|
+
const { incrementPct, maxMinRatio, maxOrders, spreadPct } = params;
|
|
244
|
+
const minBound = center / maxMinRatio;
|
|
245
|
+
const maxBound = center * maxMinRatio;
|
|
246
|
+
const halfSpread = spreadPct / 200; // as fraction
|
|
247
|
+
const buys = [];
|
|
248
|
+
const sells = [];
|
|
249
|
+
// Fill as many levels as fit within ratio bounds (up to maxOrders cap)
|
|
250
|
+
for (let k = 1; k <= maxOrders; k++) {
|
|
251
|
+
const offset = halfSpread + (k - 1) * incrementPct;
|
|
252
|
+
if (offset >= 0.95)
|
|
253
|
+
continue;
|
|
254
|
+
const buyPrice = center * (1 - offset);
|
|
255
|
+
const sellPrice = center * (1 + offset);
|
|
256
|
+
// Bounds check — skip levels outside ratio range
|
|
257
|
+
if (buyPrice < minBound || sellPrice > maxBound)
|
|
258
|
+
continue;
|
|
259
|
+
buys.push({ level: k, price: buyPrice, filledBar: -1 });
|
|
260
|
+
sells.push({ level: k, price: sellPrice, filledBar: -1 });
|
|
261
|
+
}
|
|
262
|
+
// Size allocation — index 0 = closest to center
|
|
263
|
+
const buySizes = allocateFundsByWeights(capitalPerSide, buys.length, weightFactor, incrementPct);
|
|
264
|
+
const sellSizes = allocateFundsByWeights(capitalPerSide, sells.length, weightFactor, incrementPct);
|
|
265
|
+
buys.forEach((o, i) => { o.size = buySizes[i] || 0; });
|
|
266
|
+
sells.forEach((o, i) => { o.size = sellSizes[i] || 0; });
|
|
267
|
+
return { buys, sells };
|
|
268
|
+
}
|
|
269
|
+
function closeFilledInventoryAtPrice(openBuys, openSells, exitPrice, feeRoundtripPct) {
|
|
270
|
+
if (!Number.isFinite(exitPrice) || exitPrice <= 0) {
|
|
271
|
+
return { grossUnits: 0, profitUnits: 0, closedOrders: 0 };
|
|
272
|
+
}
|
|
273
|
+
let grossUnits = 0;
|
|
274
|
+
let profitUnits = 0;
|
|
275
|
+
let closedOrders = 0;
|
|
276
|
+
for (const order of openBuys.values()) {
|
|
277
|
+
if (!order?.filled || !Number.isFinite(order.price) || order.price <= 0)
|
|
278
|
+
continue;
|
|
279
|
+
if (!Number.isFinite(order.size) || order.size <= 0)
|
|
280
|
+
continue;
|
|
281
|
+
const grossPct = (exitPrice / order.price - 1) * 100;
|
|
282
|
+
const netPct = grossPct - feeRoundtripPct;
|
|
283
|
+
grossUnits += order.size * (grossPct / 100);
|
|
284
|
+
profitUnits += order.size * (netPct / 100);
|
|
285
|
+
closedOrders++;
|
|
286
|
+
}
|
|
287
|
+
for (const order of openSells.values()) {
|
|
288
|
+
if (!order?.filled || !Number.isFinite(order.price) || order.price <= 0)
|
|
289
|
+
continue;
|
|
290
|
+
if (!Number.isFinite(order.size) || order.size <= 0)
|
|
291
|
+
continue;
|
|
292
|
+
const grossPct = (order.price / exitPrice - 1) * 100;
|
|
293
|
+
const netPct = grossPct - feeRoundtripPct;
|
|
294
|
+
grossUnits += order.size * (grossPct / 100);
|
|
295
|
+
profitUnits += order.size * (netPct / 100);
|
|
296
|
+
closedOrders++;
|
|
297
|
+
}
|
|
298
|
+
return { grossUnits, profitUnits, closedOrders };
|
|
299
|
+
}
|
|
300
|
+
function countCancelableOrders(openBuys, openSells) {
|
|
301
|
+
let count = 0;
|
|
302
|
+
for (const order of openBuys.values()) {
|
|
303
|
+
if (!order?.filled)
|
|
304
|
+
count++;
|
|
305
|
+
}
|
|
306
|
+
for (const order of openSells.values()) {
|
|
307
|
+
if (!order?.filled)
|
|
308
|
+
count++;
|
|
309
|
+
}
|
|
310
|
+
return count;
|
|
311
|
+
}
|
|
312
|
+
function simulatePersistentGrid(candles, amaValues, params, weightName, weightFactor) {
|
|
313
|
+
const { spreadPct, incrementPct, maxMinRatio, maxOrders, feeRoundtripPct, capital, repositionThreshold, btsCreateFee, btsCancelFee, makerCreateFactor, txFeePrice } = params;
|
|
314
|
+
const skip = Math.max(20, Math.floor(candles.length * 0.1));
|
|
315
|
+
const capitalPerSide = capital;
|
|
316
|
+
// State
|
|
317
|
+
let gridCenter = amaValues[skip];
|
|
318
|
+
let grid = buildGrid(gridCenter, params, capitalPerSide, weightFactor);
|
|
319
|
+
let lastRepositionBar = skip;
|
|
320
|
+
// Open orders: maps level -> { price, size, bar, side }
|
|
321
|
+
const openBuys = new Map();
|
|
322
|
+
const openSells = new Map();
|
|
323
|
+
// Place initial orders
|
|
324
|
+
for (const o of grid.buys)
|
|
325
|
+
openBuys.set(o.level, { price: o.price, size: o.size, bar: skip });
|
|
326
|
+
for (const o of grid.sells)
|
|
327
|
+
openSells.set(o.level, { price: o.price, size: o.size, bar: skip });
|
|
328
|
+
let matchedPairs = 0;
|
|
329
|
+
let totalProfitUnits = 0; // profit in capital units (size * netPct)
|
|
330
|
+
let totalGrossUnits = 0;
|
|
331
|
+
let touchedOrders = 0;
|
|
332
|
+
let canceledOnReposition = 0;
|
|
333
|
+
let repositionCount = 0;
|
|
334
|
+
let peakOpenOrders = 0;
|
|
335
|
+
let imbalanceSum = 0;
|
|
336
|
+
let imbalanceSamples = 0;
|
|
337
|
+
let matchedOpenDurationBars = 0;
|
|
338
|
+
let gridAgeSumBars = 0;
|
|
339
|
+
let maxGridAgeBars = 0;
|
|
340
|
+
let centerDriftSumPct = 0;
|
|
341
|
+
let maxCenterDriftPct = 0;
|
|
342
|
+
let nearThresholdBars = 0;
|
|
343
|
+
let triggerDriftSumPct = 0;
|
|
344
|
+
let runningProfit = 0;
|
|
345
|
+
let peakEquityProfit = 0;
|
|
346
|
+
let maxDrawdown = 0;
|
|
347
|
+
// Track inventory risk: net exposure from filled-but-unmatched orders
|
|
348
|
+
let inventoryExposure = 0; // positive = long (bought), negative = short (sold)
|
|
349
|
+
let maxInventoryExposure = 0;
|
|
350
|
+
const liveBars = candles.length - skip - 1;
|
|
351
|
+
const ordersPerSide = grid.buys.length; // actual orders placed per side (clipped by ratio)
|
|
352
|
+
const makerCreateFeeBts = btsCreateFee * makerCreateFactor;
|
|
353
|
+
const newOrdersPerReposition = ordersPerSide * 2;
|
|
354
|
+
for (let i = skip + 1; i < candles.length; i++) {
|
|
355
|
+
const ama = amaValues[i];
|
|
356
|
+
const hi = candles[i].high;
|
|
357
|
+
const lo = candles[i].low;
|
|
358
|
+
const gridAgeBars = i - lastRepositionBar;
|
|
359
|
+
// ── Reposition check: AMA drifted too far from grid center ──────
|
|
360
|
+
const drift = Math.abs(ama - gridCenter) / gridCenter;
|
|
361
|
+
const driftPct = drift * 100;
|
|
362
|
+
centerDriftSumPct += driftPct;
|
|
363
|
+
if (driftPct > maxCenterDriftPct)
|
|
364
|
+
maxCenterDriftPct = driftPct;
|
|
365
|
+
gridAgeSumBars += gridAgeBars;
|
|
366
|
+
if (gridAgeBars > maxGridAgeBars)
|
|
367
|
+
maxGridAgeBars = gridAgeBars;
|
|
368
|
+
if (drift >= repositionThreshold * 0.5)
|
|
369
|
+
nearThresholdBars++;
|
|
370
|
+
if (drift >= repositionThreshold) {
|
|
371
|
+
triggerDriftSumPct += driftPct;
|
|
372
|
+
canceledOnReposition += countCancelableOrders(openBuys, openSells);
|
|
373
|
+
repositionCount++;
|
|
374
|
+
const exitPrice = Number.isFinite(ama) && ama > 0 ? ama : candles[i].close;
|
|
375
|
+
const forcedClose = closeFilledInventoryAtPrice(openBuys, openSells, exitPrice, feeRoundtripPct);
|
|
376
|
+
totalGrossUnits += forcedClose.grossUnits;
|
|
377
|
+
totalProfitUnits += forcedClose.profitUnits;
|
|
378
|
+
runningProfit += forcedClose.profitUnits;
|
|
379
|
+
// Unmatched inventory is realized on reposition (position closed at market)
|
|
380
|
+
inventoryExposure = 0;
|
|
381
|
+
openBuys.clear();
|
|
382
|
+
openSells.clear();
|
|
383
|
+
// Re-center grid
|
|
384
|
+
gridCenter = ama;
|
|
385
|
+
grid = buildGrid(gridCenter, params, capitalPerSide, weightFactor);
|
|
386
|
+
lastRepositionBar = i;
|
|
387
|
+
for (const o of grid.buys)
|
|
388
|
+
openBuys.set(o.level, { price: o.price, size: o.size, bar: i });
|
|
389
|
+
for (const o of grid.sells)
|
|
390
|
+
openSells.set(o.level, { price: o.price, size: o.size, bar: i });
|
|
391
|
+
}
|
|
392
|
+
// ── Track imbalance & peak ──────────────────────────────────────
|
|
393
|
+
const currentOpen = openBuys.size + openSells.size;
|
|
394
|
+
if (currentOpen > peakOpenOrders)
|
|
395
|
+
peakOpenOrders = currentOpen;
|
|
396
|
+
imbalanceSum += Math.abs(openBuys.size - openSells.size);
|
|
397
|
+
imbalanceSamples++;
|
|
398
|
+
// ── Check fills on PERSISTENT orders (fixed chain prices) ───────
|
|
399
|
+
// Only check UNFILLED orders (skip already-filled pending match)
|
|
400
|
+
const filledBuysThisBar = [];
|
|
401
|
+
const filledSellsThisBar = [];
|
|
402
|
+
for (const [lvl, order] of openBuys) {
|
|
403
|
+
if (!order.filled && lo <= order.price) {
|
|
404
|
+
filledBuysThisBar.push({ lvl, order });
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
for (const [lvl, order] of openSells) {
|
|
408
|
+
if (!order.filled && hi >= order.price) {
|
|
409
|
+
filledSellsThisBar.push({ lvl, order });
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
// Process buy fills
|
|
413
|
+
for (const fb of filledBuysThisBar) {
|
|
414
|
+
touchedOrders++;
|
|
415
|
+
inventoryExposure += fb.order.size; // bought → long exposure
|
|
416
|
+
// Mark as filled, waiting for paired sell at same level
|
|
417
|
+
openBuys.set(fb.lvl, { ...fb.order, filled: true, filledBar: i, side: 'buy' });
|
|
418
|
+
}
|
|
419
|
+
// Process sell fills
|
|
420
|
+
for (const fs of filledSellsThisBar) {
|
|
421
|
+
touchedOrders++;
|
|
422
|
+
inventoryExposure -= fs.order.size; // sold → short exposure
|
|
423
|
+
// Mark as filled, waiting for paired buy at same level
|
|
424
|
+
openSells.set(fs.lvl, { ...fs.order, filled: true, filledBar: i, side: 'sell' });
|
|
425
|
+
}
|
|
426
|
+
// Match completed pairs: both buy AND sell at same level are filled
|
|
427
|
+
for (let k = 1; k <= maxOrders; k++) {
|
|
428
|
+
const buyEntry = openBuys.get(k);
|
|
429
|
+
const sellEntry = openSells.get(k);
|
|
430
|
+
if (!buyEntry?.filled || !sellEntry?.filled)
|
|
431
|
+
continue;
|
|
432
|
+
// Matched pair!
|
|
433
|
+
openBuys.delete(k);
|
|
434
|
+
openSells.delete(k);
|
|
435
|
+
matchedPairs++;
|
|
436
|
+
const duration = Math.abs(sellEntry.filledBar - buyEntry.filledBar);
|
|
437
|
+
matchedOpenDurationBars += duration;
|
|
438
|
+
const avgSize = (buyEntry.size + sellEntry.size) / 2;
|
|
439
|
+
const pairGrossPct = (sellEntry.price / buyEntry.price - 1) * 100;
|
|
440
|
+
const pairNetPct = pairGrossPct - feeRoundtripPct;
|
|
441
|
+
const profitUnits = avgSize * (pairNetPct / 100);
|
|
442
|
+
totalGrossUnits += avgSize * (pairGrossPct / 100);
|
|
443
|
+
totalProfitUnits += profitUnits;
|
|
444
|
+
runningProfit += profitUnits;
|
|
445
|
+
}
|
|
446
|
+
// Track max inventory exposure
|
|
447
|
+
const absExposure = Math.abs(inventoryExposure);
|
|
448
|
+
if (absExposure > maxInventoryExposure)
|
|
449
|
+
maxInventoryExposure = absExposure;
|
|
450
|
+
// ── Drawdown tracking ───────────────────────────────────────────
|
|
451
|
+
const markPrice = Number.isFinite(candles[i].close) && candles[i].close > 0
|
|
452
|
+
? candles[i].close
|
|
453
|
+
: ((Number.isFinite(ama) && ama > 0) ? ama : gridCenter);
|
|
454
|
+
const unrealized = closeFilledInventoryAtPrice(openBuys, openSells, markPrice, feeRoundtripPct).profitUnits;
|
|
455
|
+
const equityProfit = runningProfit + unrealized;
|
|
456
|
+
if (equityProfit > peakEquityProfit)
|
|
457
|
+
peakEquityProfit = equityProfit;
|
|
458
|
+
const dd = peakEquityProfit - equityProfit;
|
|
459
|
+
if (dd > maxDrawdown)
|
|
460
|
+
maxDrawdown = dd;
|
|
461
|
+
}
|
|
462
|
+
const fillEfficiency = touchedOrders > 0 ? (matchedPairs / touchedOrders) * 100 : 0;
|
|
463
|
+
const pairsPerDay = liveBars > 0 ? matchedPairs / (liveBars / 24) : 0;
|
|
464
|
+
const avgOpenDurationBars = matchedPairs > 0 ? matchedOpenDurationBars / matchedPairs : 0;
|
|
465
|
+
const avgImbalance = imbalanceSamples > 0 ? imbalanceSum / imbalanceSamples : 0;
|
|
466
|
+
const avgProfitPerPair = matchedPairs > 0 ? totalProfitUnits / matchedPairs : 0;
|
|
467
|
+
const profitPerCapital = capital > 0 ? totalProfitUnits / (capital * 2) : 0; // total capital = 2 sides
|
|
468
|
+
const maxDrawdownPct = capital > 0 ? (maxDrawdown / (capital * 2)) * 100 : 0;
|
|
469
|
+
const avgGridAgeBars = liveBars > 0 ? gridAgeSumBars / liveBars : 0;
|
|
470
|
+
const avgCenterDriftPct = liveBars > 0 ? centerDriftSumPct / liveBars : 0;
|
|
471
|
+
const nearThresholdBarsPct = liveBars > 0 ? (nearThresholdBars / liveBars) * 100 : 0;
|
|
472
|
+
const avgTriggerDriftPct = repositionCount > 0 ? triggerDriftSumPct / repositionCount : 0;
|
|
473
|
+
const avgCancelOrdersPerReposition = repositionCount > 0 ? canceledOnReposition / repositionCount : 0;
|
|
474
|
+
const estimatedFeePerRepositionBts = newOrdersPerReposition * makerCreateFeeBts + avgCancelOrdersPerReposition * btsCancelFee;
|
|
475
|
+
const totalRepositionFeesBts = repositionCount * estimatedFeePerRepositionBts;
|
|
476
|
+
const feePerDayBts = liveBars > 0 ? totalRepositionFeesBts / (liveBars / 24) : 0;
|
|
477
|
+
const totalRepositionFeeUnits = totalRepositionFeesBts * txFeePrice;
|
|
478
|
+
const netProfitUnits = totalProfitUnits - totalRepositionFeeUnits;
|
|
479
|
+
const netProfitPerCapital = capital > 0 ? netProfitUnits / (capital * 2) : 0;
|
|
480
|
+
// Score: profit per capital scaled by activity (log pairs to avoid pure frequency chasing)
|
|
481
|
+
const activityBonus = matchedPairs > 0 ? Math.log10(matchedPairs) : null;
|
|
482
|
+
const grossScore = activityBonus == null ? -Infinity : (profitPerCapital * 100 * activityBonus - maxDrawdownPct * 0.5);
|
|
483
|
+
const netScore = activityBonus == null ? -Infinity : (netProfitPerCapital * 100 * activityBonus - maxDrawdownPct * 0.5);
|
|
484
|
+
const score = netScore;
|
|
485
|
+
return {
|
|
486
|
+
weightName,
|
|
487
|
+
spreadPct,
|
|
488
|
+
incrementPct: incrementPct * 100, // store as %
|
|
489
|
+
maxMinRatio,
|
|
490
|
+
matchedPairs,
|
|
491
|
+
touchedOrders,
|
|
492
|
+
fillEfficiency,
|
|
493
|
+
totalProfitUnits,
|
|
494
|
+
totalGrossUnits,
|
|
495
|
+
profitPerCapital,
|
|
496
|
+
pairsPerDay,
|
|
497
|
+
avgOpenDurationBars,
|
|
498
|
+
avgProfitPerPair,
|
|
499
|
+
peakOpenOrders,
|
|
500
|
+
avgImbalance,
|
|
501
|
+
canceledOnReposition,
|
|
502
|
+
repositionCount,
|
|
503
|
+
maxDrawdown,
|
|
504
|
+
maxDrawdownPct,
|
|
505
|
+
maxInventoryExposure,
|
|
506
|
+
avgGridAgeBars,
|
|
507
|
+
maxGridAgeBars,
|
|
508
|
+
avgCenterDriftPct,
|
|
509
|
+
maxCenterDriftPct,
|
|
510
|
+
nearThresholdBarsPct,
|
|
511
|
+
avgTriggerDriftPct,
|
|
512
|
+
makerCreateFeeBts,
|
|
513
|
+
btsCancelFee,
|
|
514
|
+
avgCancelOrdersPerReposition,
|
|
515
|
+
estimatedFeePerRepositionBts,
|
|
516
|
+
totalRepositionFeesBts,
|
|
517
|
+
feePerDayBts,
|
|
518
|
+
netProfitUnits,
|
|
519
|
+
netProfitPerCapital,
|
|
520
|
+
ordersPerSide,
|
|
521
|
+
grossScore,
|
|
522
|
+
netScore,
|
|
523
|
+
score,
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
// ── Per-AMA sweep logic (runs in main thread or worker) ─────────────────────
|
|
527
|
+
function sweepOneAma(strategy, candles, closes, weightEntries, cfg) {
|
|
528
|
+
const amaValues = calculateAMA(closes, { erPeriod: strategy.er, fastPeriod: strategy.fast, slowPeriod: strategy.slow });
|
|
529
|
+
let best = null;
|
|
530
|
+
const top5 = [];
|
|
531
|
+
const allSims = [];
|
|
532
|
+
let evaluated = 0;
|
|
533
|
+
const minSpreadFactor = Number.isFinite(cfg.minSpreadFactor) && cfg.minSpreadFactor > 0 ? cfg.minSpreadFactor : null;
|
|
534
|
+
for (const spreadPct of cfg.spreadValues) {
|
|
535
|
+
for (const incrementPctRaw of cfg.incrementValues) {
|
|
536
|
+
if (spreadPct < cfg.feeRoundtripPct + 0.01)
|
|
537
|
+
continue;
|
|
538
|
+
if (minSpreadFactor != null && spreadPct < (incrementPctRaw * minSpreadFactor))
|
|
539
|
+
continue;
|
|
540
|
+
for (const maxMinRatio of cfg.ratioValues) {
|
|
541
|
+
for (const [weightName, weightFactor] of weightEntries) {
|
|
542
|
+
evaluated++;
|
|
543
|
+
const sim = simulatePersistentGrid(candles, amaValues, {
|
|
544
|
+
spreadPct,
|
|
545
|
+
incrementPct: incrementPctRaw / 100,
|
|
546
|
+
maxMinRatio,
|
|
547
|
+
maxOrders: cfg.maxOrders,
|
|
548
|
+
feeRoundtripPct: cfg.feeRoundtripPct,
|
|
549
|
+
capital: cfg.capital,
|
|
550
|
+
repositionThreshold: cfg.repositionPct / 100,
|
|
551
|
+
btsCreateFee: cfg.btsCreateFee,
|
|
552
|
+
btsCancelFee: cfg.btsCancelFee,
|
|
553
|
+
makerCreateFactor: cfg.makerCreateFactor,
|
|
554
|
+
txFeePrice: cfg.txFeePrice,
|
|
555
|
+
}, weightName, weightFactor);
|
|
556
|
+
if (!best || sim.score > best.score)
|
|
557
|
+
best = sim;
|
|
558
|
+
if (sim.matchedPairs > 0) {
|
|
559
|
+
const t5key = `${sim.spreadPct}|${sim.incrementPct}|${sim.maxMinRatio}|${sim.weightName}`;
|
|
560
|
+
const existing = top5.findIndex((t) => `${t.spreadPct}|${t.incrementPct}|${t.maxMinRatio}|${t.weightName}` === t5key);
|
|
561
|
+
if (existing < 0) {
|
|
562
|
+
top5.push(sim);
|
|
563
|
+
top5.sort((a, b) => b.score - a.score);
|
|
564
|
+
if (top5.length > 5)
|
|
565
|
+
top5.length = 5;
|
|
566
|
+
}
|
|
567
|
+
allSims.push(sim);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
return { strategy, best, top5, allSims, evaluated };
|
|
574
|
+
}
|
|
575
|
+
// ── Worker thread handler ───────────────────────────────────────────────────
|
|
576
|
+
if (!isMainThread) {
|
|
577
|
+
const { strategy, candles, closes, weightEntries, cfg } = workerData;
|
|
578
|
+
const result = sweepOneAma(strategy, candles, closes, weightEntries, cfg);
|
|
579
|
+
parentPort.postMessage(result);
|
|
580
|
+
process.exit(0);
|
|
581
|
+
}
|
|
582
|
+
// ── Parallel dispatch (main thread) ─────────────────────────────────────────
|
|
583
|
+
function runParallel(strategies, candles, closes, weightEntries, cfg) {
|
|
584
|
+
const numCpus = Math.min(os.cpus().length, strategies.length);
|
|
585
|
+
console.log(` Workers: ${numCpus} threads (${os.cpus().length} CPUs available)\n`);
|
|
586
|
+
return Promise.all(strategies.map((strategy) => {
|
|
587
|
+
return new Promise((resolve, reject) => {
|
|
588
|
+
const worker = new Worker(__filename, {
|
|
589
|
+
workerData: { strategy, candles, closes, weightEntries, cfg },
|
|
590
|
+
});
|
|
591
|
+
worker.on('message', resolve);
|
|
592
|
+
worker.on('error', reject);
|
|
593
|
+
worker.on('exit', (code) => {
|
|
594
|
+
if (code !== 0)
|
|
595
|
+
reject(new Error(`Worker exited with code ${code}`));
|
|
596
|
+
});
|
|
597
|
+
});
|
|
598
|
+
}));
|
|
599
|
+
}
|
|
600
|
+
// ── Main ────────────────────────────────────────────────────────────────────
|
|
601
|
+
async function run() {
|
|
602
|
+
const cfg = parseArgs();
|
|
603
|
+
const loaded = loadLpData(cfg.dataPath);
|
|
604
|
+
const candles = loaded.candles;
|
|
605
|
+
const closes = candles.map((c) => c.close);
|
|
606
|
+
const strategies = loadAmaStrategies(cfg.resultsPath);
|
|
607
|
+
const weightEntries = Object.entries(WEIGHT_PROFILES);
|
|
608
|
+
const totalCombos = cfg.spreadValues.length * cfg.incrementValues.length *
|
|
609
|
+
cfg.ratioValues.length * weightEntries.length;
|
|
610
|
+
console.log('================================================================================');
|
|
611
|
+
console.log(' AMA SWEEP BACKTEST — persistent grid + weight profiles');
|
|
612
|
+
console.log('================================================================================');
|
|
613
|
+
console.log(` Data: ${path.basename(cfg.dataPath)} (${candles.length} candles, ~${(candles.length / 24).toFixed(0)} days)`);
|
|
614
|
+
console.log(` AMAs: ${strategies.map((s) => s.id).join(', ')}`);
|
|
615
|
+
console.log(` Weights: ${weightEntries.map(([n, w]) => `${n}(${w})`).join(', ')}`);
|
|
616
|
+
console.log(` Spread: ${cfg.spreadValues[0]}..${cfg.spreadValues[cfg.spreadValues.length - 1]}% (${cfg.spreadValues.length})`);
|
|
617
|
+
console.log(` Increment: ${cfg.incrementValues[0]}..${cfg.incrementValues[cfg.incrementValues.length - 1]}% (${cfg.incrementValues.length})`);
|
|
618
|
+
console.log(` Ratio: ${cfg.ratioValues[0]}..${cfg.ratioValues[cfg.ratioValues.length - 1]} (${cfg.ratioValues.length})`);
|
|
619
|
+
console.log(` Max orders: ${cfg.maxOrders}/side (actual count from ratio+increment) | Capital: ${cfg.capital}/side | Fee: ${cfg.feeRoundtripPct}%`);
|
|
620
|
+
console.log(` Spread floor: > fee (${cfg.feeRoundtripPct}%)`);
|
|
621
|
+
console.log(` Reposition: ${cfg.repositionPct}% AMA drift from grid center`);
|
|
622
|
+
console.log(` Tx model: create=${fmt(cfg.btsCreateFee, 5)} BTS, cancel=${fmt(cfg.btsCancelFee, 5)} BTS, maker=${fmt(cfg.makerCreateFactor * 100, 1)}%, 1 BTS=${fmt(cfg.txFeePrice, 2)} units`);
|
|
623
|
+
console.log(` Combos/AMA: ${totalCombos} | Total: ${totalCombos * strategies.length}\n`);
|
|
624
|
+
// ── Run AMA sweeps in parallel (one worker per AMA strategy) ──────
|
|
625
|
+
const byAma = [];
|
|
626
|
+
const allResults = [];
|
|
627
|
+
const workerResults = await runParallel(strategies, candles, closes, weightEntries, cfg);
|
|
628
|
+
for (const wr of workerResults) {
|
|
629
|
+
byAma.push(wr);
|
|
630
|
+
for (const sim of wr.allSims) {
|
|
631
|
+
allResults.push({ strategy: wr.strategy, sim });
|
|
632
|
+
}
|
|
633
|
+
const b = wr.best;
|
|
634
|
+
const bestLabel = b && b.matchedPairs > 0
|
|
635
|
+
? `score=${fmt(b.score, 1)} pairs=${b.matchedPairs} net/cap=${fmt(b.netProfitPerCapital * 100, 1)}% gross=${fmt(b.profitPerCapital * 100, 1)}%`
|
|
636
|
+
: 'no fills';
|
|
637
|
+
process.stdout.write(` ${wr.strategy.id} (ER=${wr.strategy.er}, F=${wr.strategy.fast}, S=${wr.strategy.slow}): ${wr.evaluated} combos, ${bestLabel}\n`);
|
|
638
|
+
}
|
|
639
|
+
// ── Per-AMA best ────────────────────────────────────────────────────────
|
|
640
|
+
console.log('\n================================================================================');
|
|
641
|
+
console.log(' BEST PARAMS PER AMA');
|
|
642
|
+
console.log('================================================================================');
|
|
643
|
+
console.log('AMA | wt | spr% | inc% | ratio | nOrd | pairs | net/cap | gross/cap | drift | fee/d | score');
|
|
644
|
+
console.log('------+-------+-------+-------+-------+------+--------+---------+-----------+-------+-------+------');
|
|
645
|
+
for (const row of byAma) {
|
|
646
|
+
const b = row.best;
|
|
647
|
+
if (!b || b.matchedPairs === 0) {
|
|
648
|
+
console.log(`${row.strategy.id.padEnd(5)} | (no fills)`);
|
|
649
|
+
continue;
|
|
650
|
+
}
|
|
651
|
+
console.log(`${row.strategy.id.padEnd(5)} | ` +
|
|
652
|
+
`${b.weightName.padEnd(5)} | ` +
|
|
653
|
+
`${fmt(b.spreadPct, 1).padStart(5)} | ` +
|
|
654
|
+
`${fmt(b.incrementPct, 1).padStart(5)} | ` +
|
|
655
|
+
`${fmt(b.maxMinRatio, 2).padStart(5)} | ` +
|
|
656
|
+
`${String(b.ordersPerSide).padStart(4)} | ` +
|
|
657
|
+
`${String(b.matchedPairs).padStart(6)} | ` +
|
|
658
|
+
`${fmt(b.netProfitPerCapital * 100, 2).padStart(7)}% | ` +
|
|
659
|
+
`${fmt(b.profitPerCapital * 100, 2).padStart(10)}% | ` +
|
|
660
|
+
`${fmt(b.avgCenterDriftPct, 2).padStart(5)}% | ` +
|
|
661
|
+
`${fmt(b.feePerDayBts, 2).padStart(5)} | ` +
|
|
662
|
+
`${fmt(b.score, 1).padStart(6)}`);
|
|
663
|
+
}
|
|
664
|
+
// ── Top 5 per AMA ───────────────────────────────────────────────────────
|
|
665
|
+
for (const row of byAma) {
|
|
666
|
+
if (row.top5.length === 0)
|
|
667
|
+
continue;
|
|
668
|
+
console.log(`\n ${row.strategy.id} — Top 5:`);
|
|
669
|
+
console.log(' # | wt | spr% | inc% | ratio | nOrd | pairs | net/cap | drift | gAge | fee/d | score');
|
|
670
|
+
console.log(' --+-------+-------+-------+-------+------+--------+---------+-------+------+-------+------');
|
|
671
|
+
row.top5.forEach((b, idx) => {
|
|
672
|
+
console.log(` ${idx + 1} | ` +
|
|
673
|
+
`${b.weightName.padEnd(5)} | ` +
|
|
674
|
+
`${fmt(b.spreadPct, 1).padStart(5)} | ` +
|
|
675
|
+
`${fmt(b.incrementPct, 1).padStart(5)} | ` +
|
|
676
|
+
`${fmt(b.maxMinRatio, 2).padStart(5)} | ` +
|
|
677
|
+
`${String(b.ordersPerSide).padStart(4)} | ` +
|
|
678
|
+
`${String(b.matchedPairs).padStart(6)} | ` +
|
|
679
|
+
`${fmt(b.netProfitPerCapital * 100, 2).padStart(7)}% | ` +
|
|
680
|
+
`${fmt(b.avgCenterDriftPct, 2).padStart(5)}% | ` +
|
|
681
|
+
`${fmt(b.avgGridAgeBars, 0).padStart(4)} | ` +
|
|
682
|
+
`${fmt(b.feePerDayBts, 2).padStart(5)} | ` +
|
|
683
|
+
`${fmt(b.score, 1).padStart(6)}`);
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
// ── Global ranking (deduplicated) ───────────────────────────────────────
|
|
687
|
+
allResults.sort((a, b) => b.sim.score - a.sim.score);
|
|
688
|
+
const seen = new Set();
|
|
689
|
+
const deduped = [];
|
|
690
|
+
for (const r of allResults) {
|
|
691
|
+
const key = `${r.strategy.id}|${r.sim.spreadPct}|${r.sim.incrementPct}|${r.sim.maxMinRatio}|${r.sim.weightName}`;
|
|
692
|
+
if (seen.has(key))
|
|
693
|
+
continue;
|
|
694
|
+
seen.add(key);
|
|
695
|
+
deduped.push(r);
|
|
696
|
+
}
|
|
697
|
+
if (deduped.length === 0) {
|
|
698
|
+
console.log('\n NO CONFIGURATIONS PRODUCED ANY MATCHED PAIRS.');
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
const topN = Math.min(cfg.topN, deduped.length);
|
|
702
|
+
console.log(`\n================================================================================`);
|
|
703
|
+
console.log(` GLOBAL TOP ${topN}`);
|
|
704
|
+
console.log('================================================================================');
|
|
705
|
+
console.log('# | AMA | wt | spr% | inc% | ratio | nOrd | pairs | net/cap | drift | fee/d | score');
|
|
706
|
+
console.log('---+-------+-------+-------+-------+-------+------+--------+---------+-------+-------+------');
|
|
707
|
+
for (let i = 0; i < topN; i++) {
|
|
708
|
+
const { strategy, sim } = deduped[i];
|
|
709
|
+
console.log(`${String(i + 1).padStart(2)} | ` +
|
|
710
|
+
`${strategy.id.padEnd(5)} | ` +
|
|
711
|
+
`${sim.weightName.padEnd(5)} | ` +
|
|
712
|
+
`${fmt(sim.spreadPct, 1).padStart(5)} | ` +
|
|
713
|
+
`${fmt(sim.incrementPct, 1).padStart(5)} | ` +
|
|
714
|
+
`${fmt(sim.maxMinRatio, 2).padStart(5)} | ` +
|
|
715
|
+
`${String(sim.ordersPerSide).padStart(4)} | ` +
|
|
716
|
+
`${String(sim.matchedPairs).padStart(6)} | ` +
|
|
717
|
+
`${fmt(sim.netProfitPerCapital * 100, 2).padStart(7)}% | ` +
|
|
718
|
+
`${fmt(sim.avgCenterDriftPct, 2).padStart(5)}% | ` +
|
|
719
|
+
`${fmt(sim.feePerDayBts, 2).padStart(5)} | ` +
|
|
720
|
+
`${fmt(sim.score, 1).padStart(6)}`);
|
|
721
|
+
}
|
|
722
|
+
// ── Winner ──────────────────────────────────────────────────────────────
|
|
723
|
+
const winner = deduped[0];
|
|
724
|
+
console.log(`\n================================================================================`);
|
|
725
|
+
console.log(` WINNER`);
|
|
726
|
+
console.log('================================================================================');
|
|
727
|
+
console.log(` AMA: ${winner.strategy.id} (ER=${winner.strategy.er}, Fast=${winner.strategy.fast}, Slow=${winner.strategy.slow})`);
|
|
728
|
+
console.log(` Weight: ${winner.sim.weightName} (${WEIGHT_PROFILES[winner.sim.weightName]})`);
|
|
729
|
+
console.log(` Spread: ${fmt(winner.sim.spreadPct, 1)}%`);
|
|
730
|
+
console.log(` Increment: ${fmt(winner.sim.incrementPct, 1)}%`);
|
|
731
|
+
console.log(` Ratio: ${fmt(winner.sim.maxMinRatio, 1)}x`);
|
|
732
|
+
console.log(` Pairs: ${winner.sim.matchedPairs} (${fmt(winner.sim.pairsPerDay, 2)}/day)`);
|
|
733
|
+
console.log(` Fill eff: ${fmt(winner.sim.fillEfficiency, 1)}%`);
|
|
734
|
+
console.log(` Profit/cap: gross ${fmt(winner.sim.profitPerCapital * 100, 2)}% | net ${fmt(winner.sim.netProfitPerCapital * 100, 2)}%`);
|
|
735
|
+
console.log(` Net profit: ${fmt(winner.sim.netProfitUnits, 0)} units after ${fmt(winner.sim.totalRepositionFeesBts, 1)} BTS reposition fees`);
|
|
736
|
+
console.log(` Avg/pair: ${fmt(winner.sim.avgProfitPerPair, 2)} units`);
|
|
737
|
+
console.log(` Max DD: ${fmt(winner.sim.maxDrawdownPct, 2)}%`);
|
|
738
|
+
console.log(` Repositions: ${winner.sim.repositionCount}`);
|
|
739
|
+
console.log(` Grid age: avg ${fmt(winner.sim.avgGridAgeBars, 1)} bars | max ${fmt(winner.sim.maxGridAgeBars, 0)} bars`);
|
|
740
|
+
console.log(` Drift: avg ${fmt(winner.sim.avgCenterDriftPct, 2)}% | max ${fmt(winner.sim.maxCenterDriftPct, 2)}% | near-threshold ${fmt(winner.sim.nearThresholdBarsPct, 1)}%`);
|
|
741
|
+
console.log(` Tx burn: ${fmt(winner.sim.estimatedFeePerRepositionBts, 4)} BTS/reposition | ${fmt(winner.sim.feePerDayBts, 2)} BTS/day`);
|
|
742
|
+
console.log(` Score: ${fmt(winner.sim.score, 2)}`);
|
|
743
|
+
// ── Save JSON ───────────────────────────────────────────────────────────
|
|
744
|
+
const outName = `ama_sweep_results_${path.basename(cfg.dataPath, '.json')}.json`;
|
|
745
|
+
const outPath = path.join(__dirname, outName);
|
|
746
|
+
writeJSON(outPath, {
|
|
747
|
+
meta: {
|
|
748
|
+
generatedAt: new Date().toISOString(),
|
|
749
|
+
dataPath: path.relative(process.cwd(), cfg.dataPath),
|
|
750
|
+
resultsPath: path.relative(process.cwd(), cfg.resultsPath),
|
|
751
|
+
candles: candles.length,
|
|
752
|
+
days: candles.length / 24,
|
|
753
|
+
maxOrders: cfg.maxOrders,
|
|
754
|
+
capitalPerSide: cfg.capital,
|
|
755
|
+
feeRoundtripPct: cfg.feeRoundtripPct,
|
|
756
|
+
repositionPct: cfg.repositionPct,
|
|
757
|
+
btsCreateFee: cfg.btsCreateFee,
|
|
758
|
+
btsCancelFee: cfg.btsCancelFee,
|
|
759
|
+
makerCreateFactor: cfg.makerCreateFactor,
|
|
760
|
+
txFeePrice: cfg.txFeePrice,
|
|
761
|
+
weightProfiles: WEIGHT_PROFILES,
|
|
762
|
+
search: {
|
|
763
|
+
spreadValues: cfg.spreadValues,
|
|
764
|
+
incrementValues: cfg.incrementValues,
|
|
765
|
+
ratioValues: cfg.ratioValues,
|
|
766
|
+
minSpreadFactor: cfg.minSpreadFactor,
|
|
767
|
+
combosPerAma: totalCombos,
|
|
768
|
+
totalCombos: totalCombos * strategies.length,
|
|
769
|
+
},
|
|
770
|
+
scoring: 'netProfitPerCapital * 100 * log10(max(1, matchedPairs)) - maxDrawdownPct * 0.5',
|
|
771
|
+
},
|
|
772
|
+
strategies,
|
|
773
|
+
perAma: byAma.map((row) => ({
|
|
774
|
+
strategy: row.strategy,
|
|
775
|
+
evaluated: row.evaluated,
|
|
776
|
+
best: row.best,
|
|
777
|
+
top5: row.top5,
|
|
778
|
+
})),
|
|
779
|
+
globalTop: deduped.slice(0, Math.max(cfg.topN, 20)).map(({ strategy, sim }) => ({
|
|
780
|
+
ama: strategy.id,
|
|
781
|
+
amaParams: { er: strategy.er, fast: strategy.fast, slow: strategy.slow },
|
|
782
|
+
...sim,
|
|
783
|
+
})),
|
|
784
|
+
winner: {
|
|
785
|
+
ama: winner.strategy.id,
|
|
786
|
+
amaParams: { er: winner.strategy.er, fast: winner.strategy.fast, slow: winner.strategy.slow },
|
|
787
|
+
...winner.sim,
|
|
788
|
+
},
|
|
789
|
+
});
|
|
790
|
+
console.log(`\nSaved: ${path.relative(process.cwd(), outPath)}`);
|
|
791
|
+
}
|
|
792
|
+
if (require.main === module) {
|
|
793
|
+
run().catch((err) => { console.error(err); process.exit(1); });
|
|
794
|
+
}
|
|
795
|
+
module.exports = {
|
|
796
|
+
WEIGHT_PROFILES,
|
|
797
|
+
allocateFundsByWeights,
|
|
798
|
+
buildGrid,
|
|
799
|
+
closeFilledInventoryAtPrice,
|
|
800
|
+
countCancelableOrders,
|
|
801
|
+
simulatePersistentGrid,
|
|
802
|
+
sweepOneAma,
|
|
803
|
+
};
|
|
804
|
+
//# sourceMappingURL=backtest_ama_sweep.js.map
|