lfqian commited on
Commit
ea74d4d
·
1 Parent(s): 702467f

fix: prevent double filtering of trading days for BMRN and stocks

Browse files
Files changed (1) hide show
  1. src/views/LiveView.vue +36 -10
src/views/LiveView.vue CHANGED
@@ -170,7 +170,14 @@ const winners = computed(() => {
170
  const cur = byAgent.get(k)
171
  if (!cur || score(r) > score(cur)) byAgent.set(k, r)
172
  }
173
- return [...byAgent.values()]
 
 
 
 
 
 
 
174
  })
175
 
176
  /* chart selections */
@@ -200,16 +207,20 @@ async function buildSeq(sel) {
200
 
201
  seq.sort((a,b) => (a.date > b.date ? 1 : -1))
202
 
203
- const isCrypto = assetCode === 'BTC' || assetCode === 'ETH'
204
- let filtered = seq
205
- if (!isCrypto) filtered = await filterRowsToNyseTradingDays(seq)
206
-
207
- const cutoff = ASSET_CUTOFF[assetCode]
208
- if (cutoff) {
209
- const t0 = new Date(cutoff + 'T00:00:00Z')
210
- filtered = filtered.filter(r => new Date(r.date + 'T00:00:00Z') >= t0)
 
 
 
211
  }
212
- return filtered
 
213
  }
214
 
215
  async function computeEquities(sel) {
@@ -217,11 +228,26 @@ async function computeEquities(sel) {
217
  if (!seq.length) return null
218
 
219
  const cfg = (STRATEGIES || []).find(s => s.id === sel.strategy) || { strategy: 'long_only', tradingMode: 'aggressive', fee: 0.0005 }
 
 
 
 
 
 
 
 
 
220
 
221
  const stratY = computeStrategyEquity(seq, 100000, cfg.fee, cfg.strategy, cfg.tradingMode) || []
222
  const bhY = computeBuyHoldEquity(seq, 100000) || []
223
  const lastIdx = Math.min(stratY.length, bhY.length) - 1
224
  if (lastIdx < 0) return null
 
 
 
 
 
 
225
 
226
  return { date: seq[lastIdx].date, stratLast: stratY[lastIdx], bhLast: bhY[lastIdx] }
227
  }
 
170
  const cur = byAgent.get(k)
171
  if (!cur || score(r) > score(cur)) byAgent.set(k, r)
172
  }
173
+ const result = [...byAgent.values()]
174
+ console.log('[Live winners from leaderboard]', result.map(r => ({
175
+ agent: r.agent_name,
176
+ model: r.model,
177
+ strategy: r.strategy,
178
+ balance: r.balance
179
+ })))
180
+ return result
181
  })
182
 
183
  /* chart selections */
 
207
 
208
  seq.sort((a,b) => (a.date > b.date ? 1 : -1))
209
 
210
+ // 如果使用了 decision_ids,数据已经预过滤,不需要再次处理
211
+ // 只有在没有 decision_ids 时才需要过滤交易日
212
+ if (!ids.length) {
213
+ const isCrypto = assetCode === 'BTC' || assetCode === 'ETH'
214
+ if (!isCrypto) seq = await filterRowsToNyseTradingDays(seq)
215
+
216
+ const cutoff = ASSET_CUTOFF[assetCode]
217
+ if (cutoff) {
218
+ const t0 = new Date(cutoff + 'T00:00:00Z')
219
+ seq = seq.filter(r => new Date(r.date + 'T00:00:00Z') >= t0)
220
+ }
221
  }
222
+
223
+ return seq
224
  }
225
 
226
  async function computeEquities(sel) {
 
228
  if (!seq.length) return null
229
 
230
  const cfg = (STRATEGIES || []).find(s => s.id === sel.strategy) || { strategy: 'long_only', tradingMode: 'aggressive', fee: 0.0005 }
231
+
232
+ console.log('[Live computeEquities]', {
233
+ agent: sel.agent_name,
234
+ model: sel.model,
235
+ strategy: sel.strategy,
236
+ config: cfg,
237
+ seqLength: seq.length,
238
+ decision_ids: sel.decision_ids?.length || 'none'
239
+ })
240
 
241
  const stratY = computeStrategyEquity(seq, 100000, cfg.fee, cfg.strategy, cfg.tradingMode) || []
242
  const bhY = computeBuyHoldEquity(seq, 100000) || []
243
  const lastIdx = Math.min(stratY.length, bhY.length) - 1
244
  if (lastIdx < 0) return null
245
+
246
+ console.log('[Live computeEquities result]', {
247
+ agent: sel.agent_name,
248
+ stratLast: stratY[lastIdx],
249
+ bhLast: bhY[lastIdx]
250
+ })
251
 
252
  return { date: seq[lastIdx].date, stratLast: stratY[lastIdx], bhLast: bhY[lastIdx] }
253
  }