beast-agent 2.71.0 → 2.72.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/package.json +1 -1
- package/src/main.js +101 -33
package/package.json
CHANGED
package/src/main.js
CHANGED
|
@@ -13665,9 +13665,53 @@ function finTsFeedText(limit) {
|
|
|
13665
13665
|
return feed.map((x) => `- ${x.who}: ${String(x.text || '').replace(/\s+/g, ' ').slice(0, 220)}`).join('\n');
|
|
13666
13666
|
}
|
|
13667
13667
|
|
|
13668
|
-
/*
|
|
13669
|
-
|
|
13668
|
+
/* SAHİP TALİMATI: Trade Ajanı kartına yazılan strateji notu (Jev state'ine girer) */
|
|
13669
|
+
function finTsStrategyText() {
|
|
13670
|
+
try {
|
|
13671
|
+
return String(finCfg().strategy || '').slice(0, 1000);
|
|
13672
|
+
} catch {
|
|
13673
|
+
return '';
|
|
13674
|
+
}
|
|
13675
|
+
}
|
|
13676
|
+
|
|
13677
|
+
/* Talimattan ZAMAN DİLİMİ çıkar: "M15", "1m", "1 dk", "4 saat" → M15/M1/H4 */
|
|
13678
|
+
function finTsStrategyTf() {
|
|
13679
|
+
const s = String(finTsStrategyText() || '');
|
|
13680
|
+
const m = s.match(/\b(M1|M5|M15|M30|H1|H4|D1|W1|MN1)\b/i);
|
|
13681
|
+
if (m) return m[1].toUpperCase();
|
|
13682
|
+
const dk = s.match(/\b(\d{1,2})\s*(?:m|dk|dakika)\b/i);
|
|
13683
|
+
if (dk) return finLearnNormTf('M' + Number(dk[1]));
|
|
13684
|
+
const st = s.match(/\b(\d{1,2})\s*(?:h|saat)\b/i);
|
|
13685
|
+
if (st) return finLearnNormTf('H' + Number(st[1]));
|
|
13686
|
+
return '';
|
|
13687
|
+
}
|
|
13688
|
+
|
|
13689
|
+
/* Talimat "zorunlu giriş" istiyor mu? ("her mumda işlem açmak zorundasın" gibi)
|
|
13690
|
+
Olumsuz yazım ("zorunlu değil") modu AÇMAZ. */
|
|
13691
|
+
function finTsMandatoryEntry() {
|
|
13692
|
+
const s = String(finTsStrategyText() || '').toLowerCase();
|
|
13693
|
+
if (!s) return false;
|
|
13694
|
+
if (/zorunlu değil|mecbur değil|zorunda değil/.test(s)) return false;
|
|
13695
|
+
return /her mum|her barda?|her mumda|işlem açmak zorunda|her zaman işlem|sürekli işlem|durmadan işlem|zorunlu (?:olarak )?(?:işlem|giriş|al|sat)|mecbur/.test(s);
|
|
13696
|
+
}
|
|
13697
|
+
|
|
13698
|
+
/* Ritim: talimatta M1 → işlem ajanı turları en hızlı 60 sn, M5 → 300 sn
|
|
13699
|
+
(rol ajanları analiz ritmini korur; yalnız trader + sembol işçileri hızlanır) */
|
|
13700
|
+
function finTsStrategyPaceSec(agent) {
|
|
13701
|
+
const base = finPaceSec();
|
|
13702
|
+
if (!agent || agent.role) return base;
|
|
13703
|
+
const tf = finTsStrategyTf();
|
|
13704
|
+
if (tf === 'M1') return Math.max(30, Math.min(base, 60));
|
|
13705
|
+
if (tf === 'M5') return Math.max(60, Math.min(base, 300));
|
|
13706
|
+
return base;
|
|
13707
|
+
}
|
|
13708
|
+
|
|
13709
|
+
/* ZAMAN DİLİMİ: önce SAHİBİN TALİMATI (işlem ajanları için), sonra öğrenmede
|
|
13710
|
+
en iyi net getiren periyot (>=3 işlem), sonra ajanın seçimi, sonra rol
|
|
13711
|
+
varsayılanı (rol ajanları kendi analiz periyodunu korur) */
|
|
13670
13712
|
function finTsPickTf(agent, symbol) {
|
|
13713
|
+
const owned = !(agent && agent.role) ? finTsStrategyTf() : '';
|
|
13714
|
+
if (owned) return owned;
|
|
13671
13715
|
try {
|
|
13672
13716
|
const sym = String(symbol || '').toUpperCase();
|
|
13673
13717
|
const e = finLearnLoad().symbols[sym];
|
|
@@ -14078,6 +14122,10 @@ async function finTypeSafeRound(sid, agent) {
|
|
|
14078
14122
|
/* KALİBRASYON: öğrenilmiş eşik + risk çarpanı + kazandıran kurallar */
|
|
14079
14123
|
kalibrasyon: symbols.map((s) => finTsCalState(s, market[s] && market[s].tf)).filter(Boolean).join('\n') || '(kalibrasyon verisi henüz yok)',
|
|
14080
14124
|
ekip_yanitlari: finTsFeedText(6),
|
|
14125
|
+
/* SAHİBİN TALİMATI (Trade Ajanı kartı): Jev bunu BİRİNCİL kural kabul eder;
|
|
14126
|
+
talimat "zorunlu giriş" içeriyorsa kod eşikleri devre dışı bırakır. */
|
|
14127
|
+
sahip_talimati: finTsStrategyText() || '(yok — temel teknik okuma)',
|
|
14128
|
+
talimat_modu: finTsMandatoryEntry() ? 'ZORUNLU GİRİŞ — bu turda işlem açmak zorunlu (bekle yok); yönü sen seç' : '',
|
|
14081
14129
|
};
|
|
14082
14130
|
for (const sym of symbols) {
|
|
14083
14131
|
const d = market[sym];
|
|
@@ -14099,31 +14147,42 @@ async function finTypeSafeRound(sid, agent) {
|
|
|
14099
14147
|
if (symbols.includes(s)) posBySym[s] = p;
|
|
14100
14148
|
}
|
|
14101
14149
|
const questions = {};
|
|
14150
|
+
const talimatZorunlu = finTsMandatoryEntry();
|
|
14102
14151
|
symbols.forEach((sym, i) => {
|
|
14103
14152
|
questions['yon_' + i] = {
|
|
14104
14153
|
type: 'choice',
|
|
14105
|
-
instructions:
|
|
14106
|
-
|
|
14107
|
-
|
|
14108
|
-
|
|
14109
|
-
|
|
14110
|
-
|
|
14154
|
+
instructions: talimatZorunlu
|
|
14155
|
+
? `${sym} ${market[sym].tf}: SAHİBİN TALİMATI GEREĞİ bu turda işlem açmak ZORUNDASIN — 'bekle' YOK. Yönü sen seç: gösterge/momentum/yapıya göre en olası yön (buy/sell). Sahip talimatı state'tedir, birincil kuraldır.`
|
|
14156
|
+
: `${sym} ${market[sym].tf} grafiğinde verilen fiyat, gösterge, pozisyon, öğrenme geçmişi, ekip yanıtları ve SAHİP TALİMATINA göre kısa vadeli doğru aksiyon nedir? Emin değilsen bekle.`,
|
|
14157
|
+
criteria: talimatZorunlu
|
|
14158
|
+
? {
|
|
14159
|
+
buy: 'LONG aç — bu turda giriş zorunlu, yükseliş tarafı daha olası',
|
|
14160
|
+
sell: 'SHORT aç — bu turda giriş zorunlu, düşüş tarafı daha olası',
|
|
14161
|
+
}
|
|
14162
|
+
: {
|
|
14163
|
+
buy: 'LONG aç — yükseliş teyidi var (yapı/momentum/EMA eğimi destekliyor)',
|
|
14164
|
+
sell: 'SHORT aç — düşüş teyidi var',
|
|
14165
|
+
bekle: 'İşlem açma — teyit yok, belirsiz ya da riskli',
|
|
14166
|
+
},
|
|
14111
14167
|
};
|
|
14112
14168
|
questions['teyit_' + i] = {
|
|
14113
14169
|
type: 'noul',
|
|
14114
14170
|
instructions: `${sym} fiyat yapısı ve momentum, 'yon_' + ${i} kararını gerçekten destekliyor mu?`,
|
|
14115
14171
|
criteria: { true: 'Net destekliyor', false: 'Zayıf/çelişkili' },
|
|
14116
14172
|
};
|
|
14117
|
-
/* GİRİŞ TİPİ + RİSK PROFİLİ: seviyeleri KOD hesaplar (ATR/EMA), kararı Jev verir
|
|
14118
|
-
|
|
14119
|
-
|
|
14120
|
-
|
|
14121
|
-
|
|
14122
|
-
|
|
14123
|
-
|
|
14124
|
-
|
|
14125
|
-
|
|
14126
|
-
|
|
14173
|
+
/* GİRİŞ TİPİ + RİSK PROFİLİ: seviyeleri KOD hesaplar (ATR/EMA), kararı Jev verir.
|
|
14174
|
+
"Zorunlu giriş" modunda bekleyen emir sorulmaz — giriş garanti olsun diye market. */
|
|
14175
|
+
if (!talimatZorunlu) {
|
|
14176
|
+
questions['emir_' + i] = {
|
|
14177
|
+
type: 'choice',
|
|
14178
|
+
instructions: `${sym} sinyali onaylanırsa giriş tipi ne olsun? Anında mı gir (market), geri çekilme mi bekle (limit), kırılım teyidi mi bekle (stop)? Giriş seviyesini kod ATR/EMA'dan hesaplar.`,
|
|
14179
|
+
criteria: {
|
|
14180
|
+
market: 'Anında piyasadan gir — kaçırma riski yok, fiyat şimdiki',
|
|
14181
|
+
limit: 'Geri çekilmede limit emir — daha iyi fiyat bekle (ATR/EMA seviyesi)',
|
|
14182
|
+
stop: 'Kırılımda stop emir — momentum teyidi bekle (ATR seviyesi)',
|
|
14183
|
+
},
|
|
14184
|
+
};
|
|
14185
|
+
}
|
|
14127
14186
|
questions['risk_' + i] = {
|
|
14128
14187
|
type: 'choice',
|
|
14129
14188
|
instructions: `${sym} için SL/TP profili? Seviyeleri kod ATR'den hesaplar; volatilite ve öğrenme geçmişini dikkate al.`,
|
|
@@ -14207,6 +14266,7 @@ async function finTypeSafeRound(sid, agent) {
|
|
|
14207
14266
|
if (!financeState.agents.has(sidS)) return;
|
|
14208
14267
|
const c = finTsChoice(ans, 'yon_' + i);
|
|
14209
14268
|
const conf = finTsNoul(ans, 'teyit_' + i);
|
|
14269
|
+
const confVal = conf == null ? 0 : conf;
|
|
14210
14270
|
const pos = posBySym[sym];
|
|
14211
14271
|
/* JEV FİYAT ALARMI: seçilen seviyeye tek seferlik alarm (kurulumu kod yapar) */
|
|
14212
14272
|
try { await finTsSetAlarm(sidS, agent, sym, market[sym], ans, i, lines); } catch {}
|
|
@@ -14233,13 +14293,17 @@ async function finTypeSafeRound(sid, agent) {
|
|
|
14233
14293
|
lines.push(`- ${sym}: ${finTsFmtChoice(c)} → BEKLE`);
|
|
14234
14294
|
continue;
|
|
14235
14295
|
}
|
|
14236
|
-
|
|
14237
|
-
|
|
14238
|
-
|
|
14239
|
-
|
|
14240
|
-
|
|
14241
|
-
|
|
14242
|
-
|
|
14296
|
+
/* SAHİP TALİMATI "zorunlu giriş" diyorsa eşik/teyit kapıları UYGULANMAZ
|
|
14297
|
+
(talimat birincil kural) — yön Jev'in seçimidir. */
|
|
14298
|
+
if (!talimatZorunlu) {
|
|
14299
|
+
if (!(c.p >= thAction) || c.p - c.second < FIN_TS_MARGIN_P) {
|
|
14300
|
+
lines.push(`- ${sym}: ${finTsFmtChoice(c)} → öğrenilmiş eşik p≥${thAction.toFixed(2)}/fark altı, BEKLE`);
|
|
14301
|
+
continue;
|
|
14302
|
+
}
|
|
14303
|
+
if (conf == null || conf < FIN_TS_CONFIRM_P) {
|
|
14304
|
+
lines.push(`- ${sym}: ${finTsFmtChoice(c)} · teyit=${conf == null ? 'yok' : conf.toFixed(2)} < ${FIN_TS_CONFIRM_P} → BEKLE`);
|
|
14305
|
+
continue;
|
|
14306
|
+
}
|
|
14243
14307
|
}
|
|
14244
14308
|
if (opened >= 1 || posList.length + pendCount >= (Number(f.maxPositions) || 3)) {
|
|
14245
14309
|
lines.push(`- ${sym}: sinyal güçlü (${c.choice} p=${c.p.toFixed(2)}) ama pozisyon+bekleyen emir sınırı dolu — bu tur açılmadı`);
|
|
@@ -14262,9 +14326,10 @@ async function finTypeSafeRound(sid, agent) {
|
|
|
14262
14326
|
const prof = { siki: [1.0, 2.0], dengeli: [1.5, 2.5], genis: [2.0, 3.5] }[profKey];
|
|
14263
14327
|
const slDist = Math.max(atr > 0 ? atr * prof[0] : entryRef * 0.003, entryRef * 0.0004);
|
|
14264
14328
|
const tpDist = Math.max(atr > 0 ? atr * prof[1] : entryRef * 0.006, slDist * 1.2);
|
|
14265
|
-
/* EMİR TİPİ: market / limit / stop — Jev seçer, giriş seviyesini kod kurar
|
|
14266
|
-
|
|
14267
|
-
const
|
|
14329
|
+
/* EMİR TİPİ: market / limit / stop — Jev seçer, giriş seviyesini kod kurar.
|
|
14330
|
+
Zorunlu giriş modunda MARKET sabittir (bekleyen emir açık pozisyon değildir). */
|
|
14331
|
+
const emirC = talimatZorunlu ? null : finTsChoice(ans, 'emir_' + i);
|
|
14332
|
+
const emirKind = talimatZorunlu ? 'market' : (emirC && emirC.p >= FIN_TS_CONFIRM_P && emirC.p - emirC.second >= FIN_TS_MARGIN_P ? String(emirC.choice) : 'market');
|
|
14268
14333
|
let orderType = 'market';
|
|
14269
14334
|
let entry = entryRef;
|
|
14270
14335
|
if (emirKind === 'limit') {
|
|
@@ -14303,9 +14368,10 @@ async function finTypeSafeRound(sid, agent) {
|
|
|
14303
14368
|
timeframe: market[sym].tf,
|
|
14304
14369
|
comment: 'TS',
|
|
14305
14370
|
reason:
|
|
14306
|
-
`TypeSafe: yön ${c.choice} p=${c.p.toFixed(2)} fark=${(c.p - c.second).toFixed(2)} teyit=${
|
|
14371
|
+
`TypeSafe: yön ${c.choice} p=${c.p.toFixed(2)} fark=${(c.p - c.second).toFixed(2)} teyit=${confVal.toFixed(2)}` +
|
|
14307
14372
|
(orderType !== 'market' ? ` · ${orderType} @${entry}` : '') +
|
|
14308
|
-
` · ${profKey} profil
|
|
14373
|
+
` · ${profKey} profil` +
|
|
14374
|
+
(talimatZorunlu ? ' · SAHİP TALİMATI (zorunlu giriş)' : ''),
|
|
14309
14375
|
},
|
|
14310
14376
|
{ sessionId: sidS }
|
|
14311
14377
|
);
|
|
@@ -14323,7 +14389,7 @@ async function finTypeSafeRound(sid, agent) {
|
|
|
14323
14389
|
action: c.choice,
|
|
14324
14390
|
p: c.p,
|
|
14325
14391
|
pSecond: c.second,
|
|
14326
|
-
confirm:
|
|
14392
|
+
confirm: confVal,
|
|
14327
14393
|
hour: new Date().getHours(),
|
|
14328
14394
|
emaAlign: ind.ema50 != null && ind.ema200 != null ? (ind.ema50 > ind.ema200) === (c.choice === 'buy') : null,
|
|
14329
14395
|
rsi: ind.rsi14,
|
|
@@ -14336,7 +14402,8 @@ async function finTypeSafeRound(sid, agent) {
|
|
|
14336
14402
|
(orderType === 'market'
|
|
14337
14403
|
? `- ${sym}: ⚡ MARKET ${c.choice.toUpperCase()} açıldı (lot ${r.opened && r.opened.volume}, SL ${sl}, TP ${tp}, risk %${riskPct}${cal.riskMult !== 1 ? ` ×${cal.riskMult}` : ''})`
|
|
14338
14404
|
: `- ${sym}: ⏳ ${emirLabel} emri kondu @${entry} (${profKey} profil, SL ${sl}, TP ${tp}, risk %${riskPct})`) +
|
|
14339
|
-
` · p=${c.p.toFixed(2)} teyit=${
|
|
14405
|
+
` · p=${c.p.toFixed(2)} teyit=${confVal.toFixed(2)} · tf=${market[sym].tf}` +
|
|
14406
|
+
(talimatZorunlu ? ' · TALİMAT: zorunlu giriş' : '') +
|
|
14340
14407
|
(thAction !== FIN_TS_DEFAULT_TH.action ? ` · öğrenilmiş eşik p≥${thAction.toFixed(2)}` : '')
|
|
14341
14408
|
);
|
|
14342
14409
|
} else if (r && r.ok && r.shadow) {
|
|
@@ -14426,7 +14493,8 @@ async function finTypeSafeRound(sid, agent) {
|
|
|
14426
14493
|
try { financeLog('[typesafe] tur hatası (' + sidS + '): ' + String((e && e.message) || e)); } catch {}
|
|
14427
14494
|
} finally {
|
|
14428
14495
|
agent.tsBusy = false;
|
|
14429
|
-
|
|
14496
|
+
/* RİTİM: sahip talimatı M1/M5 diyorsa ana trader turları ona göre hızlanır */
|
|
14497
|
+
finTsSchedule(sidS, agent, finTsStrategyPaceSec(agent));
|
|
14430
14498
|
if (agent.main && financeState.agents.has(sidS)) finPush('trader', { state: 'idle', round: agent.round, mode: 'typesafe' });
|
|
14431
14499
|
}
|
|
14432
14500
|
}
|