@vizzor/cli 0.7.0 → 0.8.0
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/dist/index.js +103 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5973,6 +5973,106 @@ var init_trend_following = __esm({
|
|
|
5973
5973
|
}
|
|
5974
5974
|
});
|
|
5975
5975
|
|
|
5976
|
+
// src/core/agent/strategies/ml-adaptive.ts
|
|
5977
|
+
function evaluateWithRules(signals) {
|
|
5978
|
+
const reasoning = [];
|
|
5979
|
+
let score = 0;
|
|
5980
|
+
if (signals.rsi !== null) {
|
|
5981
|
+
if (signals.rsi < 25) {
|
|
5982
|
+
score += 35;
|
|
5983
|
+
reasoning.push(`RSI deeply oversold (${signals.rsi.toFixed(0)})`);
|
|
5984
|
+
} else if (signals.rsi < 35) {
|
|
5985
|
+
score += 20;
|
|
5986
|
+
reasoning.push(`RSI oversold zone (${signals.rsi.toFixed(0)})`);
|
|
5987
|
+
} else if (signals.rsi > 75) {
|
|
5988
|
+
score -= 35;
|
|
5989
|
+
reasoning.push(`RSI deeply overbought (${signals.rsi.toFixed(0)})`);
|
|
5990
|
+
} else if (signals.rsi > 65) {
|
|
5991
|
+
score -= 20;
|
|
5992
|
+
reasoning.push(`RSI overbought zone (${signals.rsi.toFixed(0)})`);
|
|
5993
|
+
}
|
|
5994
|
+
}
|
|
5995
|
+
if (signals.macdHistogram !== null) {
|
|
5996
|
+
if (signals.macdHistogram > 0) {
|
|
5997
|
+
score += 15;
|
|
5998
|
+
reasoning.push("MACD bullish momentum");
|
|
5999
|
+
} else {
|
|
6000
|
+
score -= 15;
|
|
6001
|
+
reasoning.push("MACD bearish momentum");
|
|
6002
|
+
}
|
|
6003
|
+
}
|
|
6004
|
+
if (signals.ema12 !== null && signals.ema26 !== null) {
|
|
6005
|
+
const crossPct = signals.ema26 !== 0 ? (signals.ema12 - signals.ema26) / signals.ema26 * 100 : 0;
|
|
6006
|
+
if (crossPct > 0.5) {
|
|
6007
|
+
score += 20;
|
|
6008
|
+
reasoning.push(`Golden cross (EMA12 > EMA26 by ${crossPct.toFixed(2)}%)`);
|
|
6009
|
+
} else if (crossPct < -0.5) {
|
|
6010
|
+
score -= 20;
|
|
6011
|
+
reasoning.push(`Death cross (EMA12 < EMA26 by ${Math.abs(crossPct).toFixed(2)}%)`);
|
|
6012
|
+
}
|
|
6013
|
+
}
|
|
6014
|
+
if (signals.bollingerPercentB !== null) {
|
|
6015
|
+
if (signals.bollingerPercentB < 0.1) {
|
|
6016
|
+
score += 15;
|
|
6017
|
+
reasoning.push("Price at lower Bollinger Band \u2014 potential bounce");
|
|
6018
|
+
} else if (signals.bollingerPercentB > 0.9) {
|
|
6019
|
+
score -= 15;
|
|
6020
|
+
reasoning.push("Price at upper Bollinger Band \u2014 potential resistance");
|
|
6021
|
+
}
|
|
6022
|
+
}
|
|
6023
|
+
if (signals.fundingRate !== null) {
|
|
6024
|
+
if (signals.fundingRate > 5e-4) {
|
|
6025
|
+
score -= 10;
|
|
6026
|
+
reasoning.push("High funding rate \u2014 overleveraged longs");
|
|
6027
|
+
} else if (signals.fundingRate < -3e-4) {
|
|
6028
|
+
score += 10;
|
|
6029
|
+
reasoning.push("Negative funding \u2014 capitulation signal");
|
|
6030
|
+
}
|
|
6031
|
+
}
|
|
6032
|
+
if (signals.fearGreed !== null) {
|
|
6033
|
+
if (signals.fearGreed < 20) {
|
|
6034
|
+
score += 10;
|
|
6035
|
+
reasoning.push("Extreme fear \u2014 contrarian bullish");
|
|
6036
|
+
} else if (signals.fearGreed > 80) {
|
|
6037
|
+
score -= 10;
|
|
6038
|
+
reasoning.push("Extreme greed \u2014 contrarian bearish");
|
|
6039
|
+
}
|
|
6040
|
+
}
|
|
6041
|
+
if (signals.priceChange24h !== null) {
|
|
6042
|
+
if (signals.priceChange24h > 5) {
|
|
6043
|
+
score += 10;
|
|
6044
|
+
} else if (signals.priceChange24h < -5) {
|
|
6045
|
+
score -= 10;
|
|
6046
|
+
}
|
|
6047
|
+
}
|
|
6048
|
+
const confidence = Math.min(95, Math.abs(score));
|
|
6049
|
+
if (score > 20) {
|
|
6050
|
+
return { action: "buy", confidence, reasoning };
|
|
6051
|
+
} else if (score < -20) {
|
|
6052
|
+
return { action: "sell", confidence, reasoning };
|
|
6053
|
+
}
|
|
6054
|
+
return {
|
|
6055
|
+
action: "hold",
|
|
6056
|
+
confidence: Math.max(30, 50 - Math.abs(score)),
|
|
6057
|
+
reasoning: [...reasoning, "Mixed signals \u2014 holding"]
|
|
6058
|
+
};
|
|
6059
|
+
}
|
|
6060
|
+
var mlAdaptiveStrategy;
|
|
6061
|
+
var init_ml_adaptive = __esm({
|
|
6062
|
+
"src/core/agent/strategies/ml-adaptive.ts"() {
|
|
6063
|
+
"use strict";
|
|
6064
|
+
init_client();
|
|
6065
|
+
init_feature_engineer();
|
|
6066
|
+
mlAdaptiveStrategy = {
|
|
6067
|
+
name: "ml-adaptive",
|
|
6068
|
+
description: "ML-powered strategy using contextual bandit approach. Uses LSTM/RF predictions when available, falls back to rule-based when < 100 training samples.",
|
|
6069
|
+
evaluate(signals) {
|
|
6070
|
+
return evaluateWithRules(signals);
|
|
6071
|
+
}
|
|
6072
|
+
};
|
|
6073
|
+
}
|
|
6074
|
+
});
|
|
6075
|
+
|
|
5976
6076
|
// src/core/agent/manager.ts
|
|
5977
6077
|
import { randomUUID } from "crypto";
|
|
5978
6078
|
function getStrategy(name) {
|
|
@@ -6143,9 +6243,11 @@ var init_manager = __esm({
|
|
|
6143
6243
|
init_engine();
|
|
6144
6244
|
init_momentum();
|
|
6145
6245
|
init_trend_following();
|
|
6246
|
+
init_ml_adaptive();
|
|
6146
6247
|
STRATEGIES = {
|
|
6147
6248
|
momentum: momentumStrategy,
|
|
6148
|
-
"trend-following": trendFollowingStrategy
|
|
6249
|
+
"trend-following": trendFollowingStrategy,
|
|
6250
|
+
"ml-adaptive": mlAdaptiveStrategy
|
|
6149
6251
|
};
|
|
6150
6252
|
engines = /* @__PURE__ */ new Map();
|
|
6151
6253
|
}
|