chart data fixes
This commit is contained in:
@@ -172,7 +172,7 @@ onBeforeUnmount(() => {
|
||||
}
|
||||
|
||||
.main-splitter :deep(.p-splitter-gutter-handle) {
|
||||
background: #1c1c1c !important;
|
||||
background: #2e2e2e !important;
|
||||
}
|
||||
|
||||
.chart-panel,
|
||||
|
||||
@@ -28,7 +28,7 @@ const rooms = computed(() => [{
|
||||
avatar: null,
|
||||
users: [
|
||||
{ _id: CURRENT_USER_ID, username: 'You' },
|
||||
{ _id: AGENT_ID, username: 'AI Agent', status: { state: isConnected.value ? 'online' : 'offline' } }
|
||||
{ _id: AGENT_ID, username: 'AI Agent' }
|
||||
],
|
||||
unreadCount: 0,
|
||||
typingUsers: isAgentProcessing.value ? [AGENT_ID] : []
|
||||
|
||||
@@ -79,6 +79,19 @@ export class WebSocketDatafeed implements IBasicDataFeed {
|
||||
}
|
||||
|
||||
private handleMessage(message: any): void {
|
||||
// On reconnect the server sends a fresh 'connected' message.
|
||||
// Any pending requests were sent on the old socket and will never be answered,
|
||||
// so reject them immediately so TradingView can retry on the new connection.
|
||||
if (message.type === 'connected' && this.pendingRequests.size > 0) {
|
||||
console.warn('[TradingView Datafeed] WebSocket reconnected — rejecting', this.pendingRequests.size, 'stale pending request(s)')
|
||||
for (const [requestId, pending] of this.pendingRequests) {
|
||||
clearTimeout(pending.timeout)
|
||||
pending.reject(new Error('WebSocket reconnected'))
|
||||
this.pendingRequests.delete(requestId)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Handle responses to pending requests
|
||||
if (message.request_id && this.pendingRequests.has(message.request_id)) {
|
||||
console.log('[TradingView Datafeed] Found pending request for:', message.request_id)
|
||||
@@ -186,10 +199,12 @@ export class WebSocketDatafeed implements IBasicDataFeed {
|
||||
if (response.symbol_info) {
|
||||
console.log('[TradingView Datafeed] Resolved symbol info:', response.symbol_info)
|
||||
|
||||
// Store the denominators for this symbol
|
||||
// Derive scale denominators from Nautilus precision fields.
|
||||
// price_precision=2 → tick divisor=100 (prices stored as integer cents)
|
||||
// size_precision=6 → base divisor=1_000_000 (volumes stored as integer micro-units)
|
||||
const symbolKey = response.symbol_info.ticker || response.symbol_info.name
|
||||
const tickDenom = response.symbol_info.tick_denominator || 1
|
||||
const baseDenom = response.symbol_info.base_denominator || 1
|
||||
const tickDenom = Math.pow(10, response.symbol_info.price_precision ?? 0)
|
||||
const baseDenom = Math.pow(10, response.symbol_info.size_precision ?? 0)
|
||||
|
||||
this.symbolDenominators.set(symbolKey, {
|
||||
tick: tickDenom,
|
||||
@@ -232,7 +247,7 @@ export class WebSocketDatafeed implements IBasicDataFeed {
|
||||
this.sendRequest<any>({
|
||||
type: 'get_bars',
|
||||
symbol: symbolKey,
|
||||
resolution: resolution,
|
||||
period_seconds: intervalToSeconds(resolution),
|
||||
from_time: periodParams.from,
|
||||
to_time: periodParams.to,
|
||||
countback: periodParams.countBack
|
||||
|
||||
Reference in New Issue
Block a user