Intelligence, Advanced Charting & Trading Platform
fix/chartnova-progressive-loading-2026-10-15
diagnostics/chartnova-blank-screen-2026-10-15
diagnostics/chartnova-stage2-v27-preview-2026-10-15
docs/chartnova-stage1-reconcile-manifest-2026-10-15
feature/chartnova-ios-widget
feature/chartnova-light-catalog-lazy-series-2026-10-15
feature/chartnova-market-terminal
feature/chartnova-multimarket-chart-ws-foundation
feature/chartnova-neon-direct-history
feature/chartnova-neon-history
feature/paper-trading-risk-controls-2026-10-14
fix/alpha-vantage-live-payload
fix/chartnova-progressive-loading-2026-10-15
fix/live-proof-runner-cwd-2026-10-14
foundation/phase-0
foundation/postgres-core
main
ops/chartnova-emergency-rollback-2026-10-15
phase-1/candle-builder
phase-1/data-proof-artifact
phase-1/data-proof-metrics
phase-1/data-proof-report
phase-1/external-gates-state
phase-1/gold-api-fallback
phase-1/ingestion-pipeline
phase-1/live-proof-runner
phase-1/market-calendar
phase-1/market-domain
phase-1/neon-live-proof
phase-1/persistence-contract
phase-1/postgres-ci
phase-1/provider-adapters
phase-1/provider-recovery
phase-1/quality-propagation
phase-1/spike-detection
phase-1/xau-provider-adapter
risk/chartnova-alert-runtime-atomic-2026-10-22
risk/chartnova-atomic-outbox-2026-10-22
risk/chartnova-seven-track-safety-2026-10-21
safety/p0-triage-2026-10-13
| 1 | import test from 'node:test'; |
| 2 | import assert from 'node:assert/strict'; |
| 3 | import { |
| 4 | parseNavasanLatest, |
| 5 | NAVASAN_SYMBOLS, |
| 6 | } from '../src/adapters/navasan.mjs'; |
| 7 | |
| 8 | const providerTimestamp = Math.floor(new Date('2026-10-05T07:59:00Z').valueOf() / 1000); |
| 9 | const receivedAt = new Date('2026-10-05T08:00:02Z'); |
| 10 | |
| 11 | test('maps Navasan usd_sell to canonical USD_IRT_FREE and converts IRR to IRT', () => { |
| 12 | const payload = { |
| 13 | usd_sell: { |
| 14 | value: '1200000', |
| 15 | change: 1000, |
| 16 | timestamp: providerTimestamp, |
| 17 | date: '1405-07-13 11:29:00', |
| 18 | }, |
| 19 | }; |
| 20 | |
| 21 | const result = parseNavasanLatest({ payload, receivedAt }); |
| 22 | |
| 23 | assert.equal(result.length, 1); |
| 24 | assert.equal(result[0].canonicalSymbol, 'USD_IRT_FREE'); |
| 25 | assert.equal(result[0].price, 120000); |
| 26 | assert.equal(result[0].rawUnit, 'IRR_PER_USD'); |
| 27 | assert.equal(result[0].providerCode, 'navasan'); |
| 28 | }); |
| 29 | |
| 30 | test('maps Navasan 18ayar to canonical GOLD18_IRT and converts IRR to IRT', () => { |
| 31 | const payload = { |
| 32 | '18ayar': { |
| 33 | value: '90000000', |
| 34 | change: 0, |
| 35 | timestamp: providerTimestamp, |
| 36 | date: '1405-07-13 11:29:00', |
| 37 | }, |
| 38 | }; |
| 39 | |
| 40 | const result = parseNavasanLatest({ payload, receivedAt }); |
| 41 | |
| 42 | assert.equal(result[0].canonicalSymbol, 'GOLD18_IRT'); |
| 43 | assert.equal(result[0].price, 9000000); |
| 44 | assert.equal(result[0].rawUnit, 'IRR_PER_GRAM'); |
| 45 | }); |
| 46 | |
| 47 | test('ignores unmapped Navasan instruments rather than guessing', () => { |
| 48 | const payload = { |
| 49 | sekkeh: { value: '1000000', timestamp: providerTimestamp, date: 'x' }, |
| 50 | }; |
| 51 | const result = parseNavasanLatest({ payload, receivedAt }); |
| 52 | assert.deepEqual(result, []); |
| 53 | }); |
| 54 | |
| 55 | test('rejects malformed mapped observations', () => { |
| 56 | assert.throws(() => parseNavasanLatest({ |
| 57 | payload: { usd_sell: { value: 'not-a-number', timestamp: providerTimestamp } }, |
| 58 | receivedAt, |
| 59 | }), /numeric/i); |
| 60 | }); |
| 61 | |
| 62 | test('locks the explicit Navasan symbol map', () => { |
| 63 | assert.deepEqual(NAVASAN_SYMBOLS, { |
| 64 | usd_sell: { canonicalSymbol: 'USD_IRT_FREE', rawUnit: 'IRR_PER_USD' }, |
| 65 | '18ayar': { canonicalSymbol: 'GOLD18_IRT', rawUnit: 'IRR_PER_GRAM' }, |
| 66 | }); |
| 67 | }); |