caishen

Caishen ↔ JGT Ecosystem Bridge Specification

RISE Framework Specification for Platform Integration

Spec ID: 50
Version: 1.0
Document ID: caishen-rise-jgt-bridge-v1.0
Last Updated: 2026-01-31

Creative Intent

What This Bridge Enables:

Desired Outcomes:

  1. Traders see interactive charts with Medicine Wheel overlay
  2. FDB signals detected by jgtml display in Caishen-style charts
  3. Strategy creation flows from chart to jgtfxcon execution
  4. Three-universe coherence visible on charting interface

Service Mapping

Data Layer Equivalence

Caishen Service JGT Package Integration Strategy
PDS (Price Data) jgtfxcon.JGTPDS Same FXCM API, JSON cache
CDS (Chaos Data) jgtpy.JGTCDS Equivalent signal generation
IDS (Indicators) jgtapy.Indicators Same Williams formulas
ADS (Analysis) jgtml (fdbscan) JGT as analysis engine
SDS (Strategy) jgtfxcon.jgtfxtransact JGT for order execution
BITT (Timeline) jgtutils.TLID Shared TLID format
SE (Charting) NEW: jgt-chart Web UI from Caishen spec
THS (History) NEW: jgt-data-server Snapshot API extension

Data Format Mapping

POV Format

Caishen: "EUR-USD_H4"  (dash separator)
JGT:     "EUR/USD_H4"  (slash separator)

Conversion:
  caishen_pov = jgt_pov.replace("/", "-")
  jgt_pov = caishen_pov.replace("-", "/", 1)  # Only first dash

Timeline ID (TLID)

Both platforms use same format: yyMMddHHmm

Example: "2601311430" = 2026-01-31 14:30

BarChaosItem ↔ CDS Row

Caishen BarChaosItem     JGT CDS Column
------------------       ---------------
Dt                   →   Date (index)
Ask.O/H/L/C          →   Open, High, Low, Close
Lips                 →   lips
Teeth                →   teeth
Jaw                  →   jaw
AO                   →   ao
AC                   →   ac
Zone                 →   zone (0=gray, 1=green, 2=red)
FDB                  →   fdb (combined fdbb/fdbs)
FractalBuy           →   fh
FractalSell          →   fl

Architecture Bridge

┌─────────────────────────────────────────────────────────────────────────┐
│                    UNIFIED TRADING PLATFORM                              │
├─────────────────────────────────────────────────────────────────────────┤
│                                                                          │
│  ┌────────────────────────────────────────────────────────────────────┐ │
│  │                    PRESENTATION LAYER                               │ │
│  │                                                                      │ │
│  │  ┌──────────────────┐  ┌───────────────────────────────────────┐   │ │
│  │  │    jgt-code      │  │          jgt-chart (NEW)              │   │ │
│  │  │ Terminal Agent   │  │    Caishen-style Charting UI          │   │ │
│  │  │                  │  │                                       │   │ │
│  │  │ 📊 Signal Det.   │  │  ┌─────────────────────────────────┐ │   │ │
│  │  │ 🌊 Wave Analysis │  │  │     Medicine Wheel Overlay      │ │   │ │
│  │  │ 🎯 Coordination  │  │  │    🌅 → 🌱 → 🌊 → ❄️              │ │   │ │
│  │  │                  │  │  └─────────────────────────────────┘ │   │ │
│  │  │ 🧭 Med. Wheel    │  │  ┌─────────────────────────────────┐ │   │ │
│  │  │                  │  │  │  Chart: Alligator + AO + AC     │ │   │ │
│  │  │                  │  │  │  [Fractals marked]              │ │   │ │
│  │  └────────┬─────────┘  │  └─────────────────────────────────┘ │   │ │
│  │           │            │  ┌─────────────────────────────────┐ │   │ │
│  │           │            │  │  Strategy Panel (BDBO)          │ │   │ │
│  │           │            │  │  [Create from fractal click]    │ │   │ │
│  │           │            │  └─────────────────────────────────┘ │   │ │
│  │           │            └────────────────────┬──────────────────┘   │ │
│  └───────────┼─────────────────────────────────┼──────────────────────┘ │
│              │                                 │                        │
│              ▼                                 ▼                        │
│  ┌────────────────────────────────────────────────────────────────────┐ │
│  │                    jgt-data-server (Extended)                       │ │
│  │                                                                      │ │
│  │  Existing Williams API:              New Charting API:               │ │
│  │  /api/v1/williams/dimensions         /api/v1/chart/cdb/:pov          │ │
│  │  /api/v1/perspective/:instrument     /api/v1/chart/bars/:pov         │ │
│  │                                      /api/v1/chart/snapshot          │ │
│  │                                                                      │ │
│  │  MCP Tools:                          New MCP Tools:                  │ │
│  │  get_williams_dimensions             get_chart_data                  │ │
│  │  get_perspective                     create_snapshot                 │ │
│  │  trigger_refresh                     get_wheel_state                 │ │
│  └────────────────────────────────────────────────────────────────────┘ │
│                                │                                         │
│                                ▼                                         │
│  ┌────────────────────────────────────────────────────────────────────┐ │
│  │                    DATA LAYER (JGT)                                 │ │
│  │                                                                      │ │
│  │  jgtml          jgtpy          jgtfxcon        jgtapy               │ │
│  │  - fdbscan      - JGTCDS       - JGTPDS        - Indicators         │ │
│  │  - alligator    - JGTIDS       - transact      - fractals()         │ │
│  │  - ttfcli       - cdscli                       - alligator()        │ │
│  │                                                                      │ │
│  │  $JGTPY_DATA: pds/ → cds/ → ttf/ → mlf/                             │ │
│  └────────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────┘

New jgt-data-server Endpoints

Charting Endpoints (Caishen-Compatible)

Endpoint Method Description
/api/v1/chart/cdb/{pov} GET Full ChaosDataBuilder-style response
/api/v1/chart/bars/{pov} GET BarChaosItem array for charting
/api/v1/chart/bars/{pov}?format=csv GET CSV format for compatibility
/api/v1/chart/snapshot POST Create THS snapshot
/api/v1/chart/snapshot/{id} GET Retrieve snapshot
/api/v1/chart/wheel/{instrument} GET Medicine Wheel state

Example Response: /api/v1/chart/cdb/EUR-USD_H4

{
  "Instrument": "EUR/USD",
  "Timeframe": "H4",
  "POV": "EUR-USD_H4",
  "TrendLastWave": "UP",
  "NbBarMouthIsOpen": 12,
  
  "CurrentBar": {
    "Tlid": "2601311600",
    "Dt": "2026-01-31T16:00:00Z",
    "Ask": { "O": 1.0850, "H": 1.0865, "L": 1.0842, "C": 1.0858 },
    "Lips": 1.0845,
    "Teeth": 1.0838,
    "Jaw": 1.0825,
    "AO": 0.0012,
    "AC": 0.0003,
    "Zone": 1,
    "FractalBuy": null,
    "FractalSell": 1.0860
  },
  
  "MedicineWheel": {
    "direction": "south",
    "ceremony": "wave_counting",
    "question": "Where are we in the structure?",
    "eastComplete": true,
    "southActive": true,
    "westPending": true,
    "northPending": true
  },
  
  "ThreeUniverses": {
    "signalDetection": { "state": "fdb_detected", "confidence": 0.85 },
    "waveAnalysis": { "state": "htf_aligned", "confidence": 0.78 },
    "coordination": { "state": "awaiting_risk", "confidence": 0.65 }
  }
}

Example Response: /api/v1/chart/wheel/EUR/USD

{
  "instrument": "EUR/USD",
  "currentDirection": "south",
  "ceremony": "wave_counting",
  "question": "Where are we in the structure?",
  
  "directions": {
    "east": {
      "active": false,
      "complete": true,
      "signal": { "type": "fdbb", "price": 1.0860, "timeframe": "H4" }
    },
    "south": {
      "active": true,
      "complete": false,
      "wavePosition": "Wave 3 impulse",
      "htfAlignment": true
    },
    "west": {
      "active": false,
      "complete": false,
      "riskCalculated": false
    },
    "north": {
      "active": false,
      "complete": false,
      "positionOpen": false
    }
  },
  
  "advanceCondition": "Complete HTF alignment analysis to proceed to West"
}

New MCP Tools

Chart Data Tools

const chartTools = [
  {
    name: 'get_chart_data',
    description: 'Get Caishen-compatible chart data for instrument/timeframe',
    input: { 
      instrument: string, 
      timeframe: string,
      bars?: number,     // Default 300
      format?: 'json' | 'csv'
    },
    output: { cdb: ChaosDataBuilder, bars: BarChaosItem[] }
  },
  
  {
    name: 'create_snapshot',
    description: 'Create THS snapshot of current market state',
    input: {
      instrument: string,
      timeframe: string,
      type?: SnapshotType,
      note?: string,
      strategyId?: string
    },
    output: { id: string, tlid: string }
  },
  
  {
    name: 'get_wheel_state',
    description: 'Get current Medicine Wheel state for instrument',
    input: { instrument: string },
    output: { direction: string, ceremony: string, directions: DirectionStates }
  },
  
  {
    name: 'advance_direction',
    description: 'Move to next Medicine Wheel direction after completing obligations',
    input: { 
      instrument: string,
      from: 'east' | 'south' | 'west' | 'north',
      evidence?: object  // Proof that obligations are met
    },
    output: { newDirection: string, ceremony: string }
  }
];

jgt-chart Component (New Package)

Package Purpose

Implement Caishen charting UI as React/TypeScript web application.

Component Structure

jgt-chart/
├── package.json
├── tsconfig.json
├── src/
│   ├── components/
│   │   ├── Chart/
│   │   │   ├── CChart.tsx           # Main chart control
│   │   │   ├── ChartAreaMain.tsx    # OHLC + Alligator
│   │   │   ├── ChartAreaAO.tsx      # Awesome Oscillator
│   │   │   ├── ChartAreaAC.tsx      # Accelerator
│   │   │   └── FractalMarkers.tsx   # Fractal overlays
│   │   ├── MedicineWheel/
│   │   │   ├── WheelOverlay.tsx     # Direction visualization
│   │   │   └── DirectionPanel.tsx   # Current ceremony/question
│   │   ├── Strategy/
│   │   │   ├── BDBOForm.tsx         # Strategy creation form
│   │   │   └── StrategyList.tsx     # Active strategies
│   │   └── Universe/
│   │       ├── UniverseBar.tsx      # Three-universe indicators
│   │       └── CoherenceScore.tsx   # Universe coherence display
│   ├── hooks/
│   │   ├── useChartData.ts          # Fetch from jgt-data-server
│   │   ├── useWheelState.ts         # Medicine Wheel state
│   │   └── useWebSocket.ts          # Real-time updates
│   ├── api/
│   │   └── jgtDataClient.ts         # API client
│   └── App.tsx
└── rispecs/
    └── app.specs.md

Key Components

CChart (Main Chart)

interface CChartProps {
  instrument: string;
  timeframe: string;
  showAlligator: boolean;
  showFractals: boolean;
  showAO: boolean;
  showAC: boolean;
  onFractalClick: (fractal: FractalInfo) => void;
  onBarClick: (bar: BarChaosItem) => void;
}

const CChart: React.FC<CChartProps> = ({
  instrument,
  timeframe,
  showAlligator = true,
  showFractals = true,
  showAO = true,
  showAC = true,
  onFractalClick,
  onBarClick
}) => {
  const { data, loading } = useChartData(instrument, timeframe);
  
  if (loading) return <ChartSkeleton />;
  
  return (
    <div className="cchart">
      <ChartAreaMain 
        bars={data.bars}
        showAlligator={showAlligator}
        showFractals={showFractals}
        onFractalClick={onFractalClick}
        onBarClick={onBarClick}
      />
      {showAO && <ChartAreaAO bars={data.bars} />}
      {showAC && <ChartAreaAC bars={data.bars} />}
    </div>
  );
};

WheelOverlay (Medicine Wheel)

interface WheelOverlayProps {
  instrument: string;
  onDirectionClick: (direction: MedicineWheelDirection) => void;
}

const WheelOverlay: React.FC<WheelOverlayProps> = ({
  instrument,
  onDirectionClick
}) => {
  const { state, loading } = useWheelState(instrument);
  
  if (loading) return <WheelSkeleton />;
  
  return (
    <div className="wheel-overlay">
      <div className="wheel-diagram">
        <DirectionNode 
          direction="north" 
          glyph="❄️"
          active={state.currentDirection === 'north'}
          complete={state.directions.north.complete}
          onClick={() => onDirectionClick('north')}
        />
        <DirectionNode direction="east" glyph="🌅" ... />
        <DirectionNode direction="south" glyph="🌱" ... />
        <DirectionNode direction="west" glyph="🌊" ... />
      </div>
      
      <DirectionPanel
        direction={state.currentDirection}
        ceremony={state.ceremony}
        question={state.question}
      />
    </div>
  );
};

Integration Workflow

Signal → Chart → Strategy Flow

1. jgt-code: User runs `scan EUR/USD`
   │
   ├── fdbscan detects FDB buy signal
   ├── Three-universe processing: signal_detection leads
   └── Medicine Wheel: direction = 'east'

2. jgt-chart: User opens chart UI
   │
   ├── Fetches /api/v1/chart/cdb/EUR-USD_H4
   ├── Displays candlesticks + Alligator + AO/AC
   ├── Shows FDB marker on initiating fractal
   └── Medicine Wheel overlay shows 🌅 EAST active

3. User clicks fractal on chart
   │
   ├── BDBOForm opens with pre-filled breakout price
   ├── User selects direction (Buy)
   └── User sets risk parameters

4. Strategy creation
   │
   ├── POST /api/v1/chart/snapshot (THS capture)
   ├── Strategy stored (links to snapshot)
   └── jgt-data-server notifies jgt-code via MCP

5. Medicine Wheel advances
   │
   ├── East obligations met (signal detected)
   ├── Direction advances to 'south'
   └── UI updates: 🌱 SOUTH now active

Quality Criteria

Seamless Integration: JGT data appears in Caishen-style charts
Medicine Wheel Aware: Visual direction tracking on charts
Three-Universe Display: Coherence visible in UI
Strategy Flow: Click-to-order from chart interface
Snapshot Support: THS captures integrated with UI
Real-time Updates: WebSocket for live price updates