@dsh-ft/dsh-fft-paper-trading 0.6.3 → 0.7.1
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/lib/client.js +9 -1
- package/node_modules/@ftshare-lab/dsh-kline/CHANGELOG.md +47 -0
- package/node_modules/@ftshare-lab/dsh-kline/README.en.md +107 -201
- package/node_modules/@ftshare-lab/dsh-kline/README.md +106 -216
- package/node_modules/@ftshare-lab/dsh-kline/chart_service.py +3 -2
- package/node_modules/@ftshare-lab/dsh-kline/config/dsh-tool-catalog.json +103 -11
- package/node_modules/@ftshare-lab/dsh-kline/core/calc.py +8 -0
- package/node_modules/@ftshare-lab/dsh-kline/lib/chart-applications.js +1 -1
- package/node_modules/@ftshare-lab/dsh-kline/lib/chart-context.js +1 -1
- package/node_modules/@ftshare-lab/dsh-kline/lib/chart-observation.js +11 -1
- package/node_modules/@ftshare-lab/dsh-kline/lib/chart-sources.js +6 -1
- package/node_modules/@ftshare-lab/dsh-kline/lib/client.js +2971 -835
- package/node_modules/@ftshare-lab/dsh-kline/lib/drawing-feedback.js +35 -3
- package/node_modules/@ftshare-lab/dsh-kline/lib/pattern-groups.js +91 -0
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/PanelHost.d.ts +25 -0
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/chart-handoff.d.ts +5 -0
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/client-context.d.ts +2 -0
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/conversation.d.ts +4 -0
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/generated-view.d.ts +1 -1
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/host-options.d.ts +38 -0
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/host-panels.d.ts +55 -0
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/mode-preferences.d.ts +13 -1
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/ui-onboarding.d.ts +3 -9
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/pattern-groups.d.ts +2 -0
- package/node_modules/@ftshare-lab/dsh-kline/package.json +27 -6
- package/node_modules/@ftshare-lab/dsh-kline/scripts/run-dsh-kline.mjs +4 -1
- package/node_modules/@ftshare-lab/dsh-kline/server.py +46 -25
- package/node_modules/@ftshare-lab/dsh-kline/tools/automatic_analysis.py +158 -0
- package/node_modules/@ftshare-lab/dsh-kline/tools/channel_candidates.py +1 -1
- package/node_modules/@ftshare-lab/dsh-kline/tools/chart_context.py +1 -1
- package/node_modules/@ftshare-lab/dsh-kline/tools/chart_edits.py +30 -12
- package/node_modules/@ftshare-lab/dsh-kline/tools/chart_functions.py +53 -68
- package/node_modules/@ftshare-lab/dsh-kline/tools/chart_indicators.py +3 -1
- package/node_modules/@ftshare-lab/dsh-kline/tools/closed_daily.py +68 -0
- package/node_modules/@ftshare-lab/dsh-kline/tools/draw.py +18 -2
- package/node_modules/@ftshare-lab/dsh-kline/tools/drawing_feedback.py +2 -2
- package/node_modules/@ftshare-lab/dsh-kline/tools/fetch.py +2 -3
- package/node_modules/@ftshare-lab/dsh-kline/tools/nine_count.py +66 -0
- package/node_modules/@ftshare-lab/dsh-kline/tools/pattern_groups.py +103 -0
- package/node_modules/@ftshare-lab/dsh-kline/tools/polylines.py +12 -6
- package/node_modules/@ftshare-lab/dsh-kline/tools/price_patterns.py +311 -0
- package/node_modules/@ftshare-lab/dsh-kline/tools/range_candidates.py +1 -1
- package/node_modules/@ftshare-lab/dsh-kline/tools/recent_drawing_candidates.py +123 -0
- package/package.json +4 -4
- package/src/client/index.js +8 -0
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/PaperKlinePanel.d.ts +0 -15
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/canvas-panel.d.ts +0 -33
- package/node_modules/@ftshare-lab/dsh-kline/lib/types/client/host-services.d.ts +0 -55
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"instructions": "IMPORTANT workflow policy: For ordinary K-line requests, call analyze_kline exactly once. It performs one configured-source fetch, deterministic calculations, and chart generation against one row set. FTShare is optional: when another tool or application already has OHLCV rows, call analyze_kline_rows exactly once. Never call health, fetch_candles, or calc_metrics as a preflight or follow-up; never use shell, filesystem, scripts, web probes, or another chart generator for the same request. Do not switch providers or reconstruct market rows. If the provider rejects a symbol or interval, explain that error and stop; do not probe other symbols or substitute another interval unless the user explicitly asks. Use fetch_candles only when raw OHLCV rows are explicitly requested, and use calc_metrics only for caller-supplied rows. analyze_kline_rows accepts OHLCV rows from any user-selected data source without persisting provider state. Only calculate and annotate support and resistance when the user explicitly requests it: pass metrics including support_resistance or set mark_support_resistance=true. In DeepSeek Harness, say that the interactive chart is open in the right sidebar only when chart_ready is true; otherwise explain that the chart service is unavailable. Do not create files or claim that a chart was rendered based on a script or URL. Report count, interval, latest, and indicator values exactly as returned; do not infer a different bar count from the selected timeframe. Keep support/resistance labels from the metrics, but describe whether each level is above or below the latest close instead of calling an above-price support a current support. Use data_source_status, configure_ftshare, or test_ftshare_connection only when the user explicitly asks to inspect or configure a data source. Use market_pulse for an explicit whole-market overview, and use security_intelligence for an explicit request about a mainland stock's sector linkage, capital flows, or trading events; neither tool replaces analyze_kline for chart analysis. For the chart currently on screen, use get_chart_context with context_ref from THIS conversation's current runtime context. Never guess a reference, borrow another conversation or treat an older chart_session as live UI state. The context reports browser observations, separate loaded/visible ranges and stored drawing objects, not visual proof. After analyze_kline opens a chart, use the newly injected current-view reference to read its candles; an earlier launcher reference can become inactive during mounting. An inactive/loading reference is NOT a reason to call fetch_candles or analyze_kline again. Re-read a fresh reference when available, or report that the view is not ready. Context references are read-only and are NOT chart_session tokens. For ALL current-view drawing creates/updates/deletes, including literal requests, use get_chart_context -> prepare_chart_edit -> apply_chart_edit -> get_chart_edit_status, never legacy snapshot mutations. For Fibonacci, labeled paths or reusable geometry, discover list_chart_functions and run_chart_function against fresh context, then pass edit.result_ref into that same guarded workflow. Functions calculate; they do not apply drawings or automatically discover pivots. For standard technical indicators on the current loaded chart, discover list_ta_functions, then run_ta_function and optionally read_ta_result. These TA-Lib results are analysis_only, may have null/no-finite outputs, and do not draw by themselves. Only when the user explicitly requests a price-pane drawing may a finite SMA/EMA(close, 2..200) result be selected as kind=series_line, or a finite BBANDS(close, SMA middle) result as one kind=price_band three-line group, but only when selectable_render_targets advertises that kind. Pass the result_ref as edit.ta_result_ref into prepare_chart_edit; other TA results remain read-only. Never copy long output arrays into edit parameters. prepare_chart_edit prepares one guarded candidate using the observed revision and aligned source chart_session; supply a stable request_id for retries. Preparation does NOT apply to the browser. Then apply_chart_edit queues that exact candidate to its owning view; get_chart_edit_status reads its acknowledgment. queued/delivered are NOT applied. applied confirms view STATE, not screen pixels. Unknown results must not be automatically resent or bypassed with old snapshot-only tools. Read fresh current context before the next edit. For pending status use one bounded wait_ms=3000 query; if still pending explain it, do not tightly poll. expired/needs_attention is not an acknowledgment or permission to resend. drawing_feedback reports browser chart-object API observations, not screen pixels. created means registered object with matched shape/style; time_range_overlap only checks the reported time-axis span (current in get_chart_context, historical in get_chart_edit_status), NOT price-axis visibility or screen pixels. outside_time_viewport is geometric scope only, and outside_loaded_price_envelope is a warning, NOT proof the line is hidden. The edit interaction describes only its target object; other drawing_feedback items may need separate review. Explain hidden/failed/unknown items and their reasons; never turn apply_status=applied or created into a claim of visual verification. get_chart_context feedback is current-view observation; get_chart_edit_status feedback is historical for that application. Do not silently apply snapshot-only tools to a different symbol/period/range shown in the browser. If context is stale, ambiguous or unavailable explain that state instead of re-fetching market data to guess it. The create/update/delete_horizontal_line and create/update/delete_trend_line tools are LEGACY SNAPSHOT ONLY, for explicitly requested snapshot editing, not charts on screen. get_horizontal_lines/get_trend_lines read named snapshots only. No tool auto-selects anchors. Two-point segments require two explicit times and prices; date-only anchors use Asia/Shanghai and must match existing bars. Intraday anchors require exact bar-close ISO times with timezone or Unix seconds. Never fabricate unavailable anchors, snap dates, or substitute automatic levels. Distinguish literal drawing from analysis-assisted drawing. For literal requests, preserve the original USER-requested fields and ask about missing or ambiguous coordinates. When the user explicitly asks you to find/analyze a region or propose a drawing, YOU, the host, may derive a candidate from this conversation's actual chart candles; read fresh current context before making the proposal, not just old conversation rows. the plugin does not choose anchors or assess pattern quality. Do not ask the user to supply every coordinate merely because the execution tool needs explicit parameters. If the user asks for a proposal first, do not prepare, queue or mutate drawings before their confirmation. Give one preferred candidate with exact existing-bar dates, prices, a short data-grounded reason and a limitation; offer alternatives only when materially useful. Treat the user's confirmation as approval of THAT stated proposal plus their overrides. After confirmation read fresh context; if instrument/period/rows or relevant objects have changed, reassess and seek confirmation rather than silently moving the approved bounds. Numerical claims must agree with the candles; do not call volume monotonically declining when an intervening bar increases, or describe a subjective candidate as uniquely correct. For a chosen region, get_chart_context with region_start_time/region_end_time returns deterministic region_measurements without fetching or changing charts. body_envelope contains all open/close bodies; body_overlap is their common intersection, not the same range. Use boundary_evidence for the actual date and open/close field of each extremum. An empty intersection has no price shared by EVERY body; a point intersection shares exactly one. Never reinterpret relation=empty/exists=false as a shared zero-width point. Empty common intersection does NOT imply a gap uncovered by ANY body. The candidate difference is not an uncovered gap; union coverage is not measured. State only the measured result and its evidence, without extra coverage claims. Use volume_changes to distinguish a net decline from a monotonic decline. These measurements do NOT classify the region as a platform. Check chosen bounds with this before asking approval. If the data do not support a consolidation region, say so; do not force a platform, invent prices or imply a profitable prediction. Keep ordinary replies concise: proposal or changed object, reason/limitation, and one useful confirmation; omit internal IDs, revisions and protocol fields unless the user requests them or they explain a failure. For current-view parallel channels use prepare_chart_edit with kind=channel; create/update/delete_channel are LEGACY SNAPSHOT ONLY. Geometry requires two baseline anchors and a third time/price on the other boundary, within the start/end window. In literal mode ask for missing anchors; in authorized analysis mode derive and explain all three from real data under the proposal rules above. Geometry uses candle indices and linear prices, not elapsed calendar time. Before proposing a host-chosen channel, use read-only preview_chart_channel with three explicit anchors to check parallel geometry and full-region per-bar deviations. It never selects/fits anchors, draws, scores pattern quality or extends beyond the chosen dates. Horizontal body intersection is not a necessary criterion for a sloped channel. For current-view platform/range boxes use prepare_chart_edit with kind=rectangle; create/update/delete_rectangle are LEGACY SNAPSHOT ONLY. Specify start/end bar times and lower/upper prices. These draw finite rectangles, not automatic consolidation detection or flat channels. Ask for missing bounds in literal mode; an authorized host analysis may propose bounds from actual candles, but the execution tool always needs explicit values. Never swap reversed times/prices or replace a rectangle with two horizontal lines. Preserve the user's FULL requested label, without abbreviating T or U. Honor explicit colors: blue/蓝色=info, green/绿色=success, orange/橙色=warning, red/红色=danger. The token success in drawing style requests means green, not a generic success status. After each mutation call verify_chart_drawings with the original USER-requested fields, or the user-approved proposal and overrides, and the returned stable ID, NOT fields copied from the mutation result. Keep those expectations independently of the execution result. Verify exists=false after deletion; include requested name/color/anchors on create/update. If mismatched, correct only those requested fields using latest chart_session and verify again. Do not claim a name/color was applied merely because publication succeeded. A matched snapshot check is not visual verification. Perform drawing mutations sequentially, using each returned new chart_session; parallel edits of the same parent snapshot create branches, not a merged chart. Drawing tools never fetch candles; always use the latest chart_session returned in this conversation and its exact symbol. A mutation publishes a NEW immutable chart snapshot. It does not include manual browser edits. Do not re-run analyze_kline just to edit a line. Published commands are not proof of visible rendering: when render_verified is false say they were published, not visually verified. Market data may be delayed, incomplete, or unavailable; results and indicators are informational and do not constitute investment advice.",
|
|
2
|
+
"instructions": "IMPORTANT workflow policy: For ordinary K-line requests, call analyze_kline exactly once. It performs one configured-source fetch, deterministic calculations, and chart generation against one row set. FTShare is optional: when another tool or application already has OHLCV rows, call analyze_kline_rows exactly once. Never call health, fetch_candles, or calc_metrics as a preflight or follow-up; never use shell, filesystem, scripts, web probes, or another chart generator for the same request. Do not switch providers or reconstruct market rows. If the provider rejects a symbol or interval, explain that error and stop; do not probe other symbols or substitute another interval unless the user explicitly asks. Use fetch_candles only when raw OHLCV rows are explicitly requested, and use calc_metrics only for caller-supplied rows. analyze_kline_rows accepts OHLCV rows from any user-selected data source without persisting provider state. Only calculate and annotate support and resistance when the user explicitly requests it: pass metrics including support_resistance or set mark_support_resistance=true. In DeepSeek Harness, say that the interactive chart is open in the right sidebar only when chart_ready is true; otherwise explain that the chart service is unavailable. Do not create files or claim that a chart was rendered based on a script or URL. Report count, interval, latest, and indicator values exactly as returned; do not infer a different bar count from the selected timeframe. Keep support/resistance labels from the metrics, but describe whether each level is above or below the latest close instead of calling an above-price support a current support. Use data_source_status, configure_ftshare, or test_ftshare_connection only when the user explicitly asks to inspect or configure a data source. Use market_pulse for an explicit whole-market overview, and use security_intelligence for an explicit request about a mainland stock's sector linkage, capital flows, or trading events; neither tool replaces analyze_kline for chart analysis. For the chart currently on screen, use get_chart_context with context_ref from THIS conversation's current runtime context. Never guess a reference, borrow another conversation or treat an older chart_session as live UI state. The context reports browser observations, separate loaded/visible ranges and stored drawing objects, not visual proof. After analyze_kline opens a chart, use the newly injected current-view reference to read its candles; an earlier launcher reference can become inactive during mounting. An inactive/loading reference is NOT a reason to call fetch_candles or analyze_kline again. Re-read a fresh reference when available, or report that the view is not ready. Context references are read-only and are NOT chart_session tokens. For ALL current-view drawing creates/updates/deletes, including literal requests, use get_chart_context -> prepare_chart_edit -> apply_chart_edit -> get_chart_edit_status, never legacy snapshot mutations. For Fibonacci, labeled paths or reusable geometry, discover list_chart_functions and run_chart_function against fresh context, then pass edit.result_ref into that same guarded workflow. Functions calculate; candidate functions find recent rule-based geometry but never apply it. A direct request to DRAW a named tool or automatic shape authorizes the host to select the newest valid candidate and finish prepare/apply/status in the same turn, without another save or confirmation step. Check its type, dates, status and data quality; if none fits, report that rather than invent geometry. Requests to analyze or propose only remain read-only. User-specified anchors or candidate numbers take precedence. Use price_pattern_candidates for reversal shapes, nine_count for Nine Count, recent_drawing_candidates for ordinary horizontal/trend/Fibonacci/ABC, and channel_candidates/range_candidates for automatic channel/range drawings. For standard technical indicators on the current loaded chart, discover list_ta_functions, then run_ta_function and optionally read_ta_result. These TA-Lib results are analysis_only, may have null/no-finite outputs, and do not draw by themselves. Only when the user explicitly requests a price-pane drawing may a finite SMA/EMA(close, 2..200) result be selected as kind=series_line, or a finite BBANDS(close, SMA middle) result as one kind=price_band three-line group, but only when selectable_render_targets advertises that kind. Pass the result_ref as edit.ta_result_ref into prepare_chart_edit; other TA results remain read-only. Never copy long output arrays into edit parameters. prepare_chart_edit prepares one guarded candidate using the observed revision and aligned source chart_session; supply a stable request_id for retries. Preparation does NOT apply to the browser. Then apply_chart_edit queues that exact candidate to its owning view; get_chart_edit_status reads its acknowledgment. queued/delivered are NOT applied. applied confirms view STATE, not screen pixels. Unknown results must not be automatically resent or bypassed with old snapshot-only tools. Read fresh current context before the next edit. For pending status use one bounded wait_ms=3000 query; if still pending explain it, do not tightly poll. expired/needs_attention is not an acknowledgment or permission to resend. drawing_feedback reports browser chart-object API observations, not screen pixels. created means registered object with matched shape/style; time_range_overlap only checks the reported time-axis span (current in get_chart_context, historical in get_chart_edit_status), NOT price-axis visibility or screen pixels. outside_time_viewport is geometric scope only, and outside_loaded_price_envelope is a warning, NOT proof the line is hidden. The edit interaction describes only its target object; other drawing_feedback items may need separate review. Explain hidden/failed/unknown items and their reasons; never turn apply_status=applied or created into a claim of visual verification. get_chart_context feedback is current-view observation; get_chart_edit_status feedback is historical for that application. Do not silently apply snapshot-only tools to a different symbol/period/range shown in the browser. If context is stale, ambiguous or unavailable explain that state instead of re-fetching market data to guess it. The create/update/delete_horizontal_line and create/update/delete_trend_line tools are LEGACY SNAPSHOT ONLY, for explicitly requested snapshot editing, not charts on screen. get_horizontal_lines/get_trend_lines read named snapshots only. Execution tools do not choose anchors. Two-point segments require two explicit times and prices; date-only anchors use Asia/Shanghai and must match existing bars. Intraday anchors require exact bar-close ISO times with timezone or Unix seconds. Never fabricate unavailable anchors, snap dates, or substitute automatic levels. Distinguish literal drawing from analysis-assisted drawing. For literal requests, preserve the original USER-requested fields and ask about missing or ambiguous coordinates. For a direct automatic drawing request with no coordinates, use the appropriate candidate function on this current chart and apply its newest suitable result without another prompt. The host reviews the result first; a candidate on another symbol, period or source is unusable. When the user explicitly asks you to find/analyze a region or propose a drawing, YOU, the host, may derive a candidate from this conversation's actual chart candles; read fresh current context before making the proposal, not just old conversation rows. execution tools do not choose anchors or assess pattern quality. Do not ask the user to supply every coordinate merely because the execution tool needs explicit parameters. If the user asks for a proposal first, do not prepare, queue or mutate drawings before their confirmation. Give one preferred candidate with exact existing-bar dates, prices, a short data-grounded reason and a limitation; offer alternatives only when materially useful. Treat the user's confirmation as approval of THAT stated proposal plus their overrides. After confirmation read fresh context; if instrument/period/rows or relevant objects have changed, reassess and seek confirmation rather than silently moving the approved bounds. Numerical claims must agree with the candles; do not call volume monotonically declining when an intervening bar increases, or describe a subjective candidate as uniquely correct. For a chosen region, get_chart_context with region_start_time/region_end_time returns deterministic region_measurements without fetching or changing charts. body_envelope contains all open/close bodies; body_overlap is their common intersection, not the same range. Use boundary_evidence for the actual date and open/close field of each extremum. An empty intersection has no price shared by EVERY body; a point intersection shares exactly one. Never reinterpret relation=empty/exists=false as a shared zero-width point. Empty common intersection does NOT imply a gap uncovered by ANY body. The candidate difference is not an uncovered gap; union coverage is not measured. State only the measured result and its evidence, without extra coverage claims. Use volume_changes to distinguish a net decline from a monotonic decline. These measurements do NOT classify the region as a platform. Check chosen bounds with this before asking approval. If the data do not support a consolidation region, say so; do not force a platform, invent prices or imply a profitable prediction. Keep ordinary replies concise: proposal or changed object, reason/limitation, and one useful next action; omit internal IDs, revisions and protocol fields unless the user requests them or they explain a failure. For current-view parallel channels use prepare_chart_edit with kind=channel; create/update/delete_channel are LEGACY SNAPSHOT ONLY. Geometry requires two baseline anchors and a third time/price on the other boundary, within the start/end window. In literal mode ask for missing anchors; in authorized analysis mode derive and explain all three from real data under the proposal rules above. Geometry uses candle indices and linear prices, not elapsed calendar time. Before proposing a host-chosen channel, use read-only preview_chart_channel with three explicit anchors to check parallel geometry and full-region per-bar deviations. It never selects/fits anchors, draws, scores pattern quality or extends beyond the chosen dates. Horizontal body intersection is not a necessary criterion for a sloped channel. For current-view platform/range boxes use prepare_chart_edit with kind=rectangle; create/update/delete_rectangle are LEGACY SNAPSHOT ONLY. Specify start/end bar times and lower/upper prices. These draw finite rectangles, not automatic consolidation detection or flat channels. Ask for missing bounds in literal mode; an authorized host analysis may propose bounds from actual candles, but the execution tool always needs explicit values. Never swap reversed times/prices or replace a rectangle with two horizontal lines. Preserve the user's FULL requested label, without abbreviating T or U. Honor explicit colors: blue/蓝色=info, green/绿色=success, orange/橙色=warning, red/红色=danger. The token success in drawing style requests means green, not a generic success status. After each mutation call verify_chart_drawings with the original USER-requested fields, or the user-approved proposal and overrides, and the returned stable ID, NOT fields copied from the mutation result. Keep those expectations independently of the execution result. Verify exists=false after deletion; include requested name/color/anchors on create/update. If mismatched, correct only those requested fields using latest chart_session and verify again. Do not claim a name/color was applied merely because publication succeeded. A matched snapshot check is not visual verification. Perform drawing mutations sequentially, using each returned new chart_session; parallel edits of the same parent snapshot create branches, not a merged chart. Drawing tools never fetch candles; always use the latest chart_session returned in this conversation and its exact symbol. A mutation publishes a NEW immutable chart snapshot. It does not include manual browser edits. Do not re-run analyze_kline just to edit a line. Published commands are not proof of visible rendering: when render_verified is false say they were published, not visually verified. Market data may be delayed, incomplete, or unavailable; results and indicators are informational and do not constitute investment advice.",
|
|
3
3
|
"tools": [
|
|
4
4
|
{
|
|
5
5
|
"description": "Check runtime health only when the user explicitly asks for a health check.",
|
|
@@ -432,7 +432,7 @@
|
|
|
432
432
|
}
|
|
433
433
|
],
|
|
434
434
|
"default": null,
|
|
435
|
-
"description": "ma / vol / macd / kdj / boll / rsi / atr / vwap",
|
|
435
|
+
"description": "ma / ema / vol / macd / kdj / boll / rsi / atr / vwap",
|
|
436
436
|
"title": "Indicators"
|
|
437
437
|
},
|
|
438
438
|
"interval": {
|
|
@@ -603,7 +603,7 @@
|
|
|
603
603
|
}
|
|
604
604
|
],
|
|
605
605
|
"default": null,
|
|
606
|
-
"description": "ma / vol / macd / kdj / boll / rsi / atr / vwap",
|
|
606
|
+
"description": "ma / ema / vol / macd / kdj / boll / rsi / atr / vwap",
|
|
607
607
|
"title": "Indicators"
|
|
608
608
|
},
|
|
609
609
|
"interval": {
|
|
@@ -713,7 +713,7 @@
|
|
|
713
713
|
"annotations": {
|
|
714
714
|
"readOnlyHint": true
|
|
715
715
|
},
|
|
716
|
-
"description": "Read the current conversation's live browser observation without fetching or changing charts.\n\nRead fresh context before analysis
|
|
716
|
+
"description": "Read the current conversation's live browser observation without fetching or changing charts.\n\nRead fresh context before analysis and again before edits if the view may have changed.\nWhen the user asks to find a drawing region, the HOST may choose a candidate from actual\ncandles; the plugin does not choose/classify it. Before asking approval for that chosen\nregion, call this with paired region_start_time/region_end_time to check numeric claims.\nA proposal-first request must not prepare/apply drawings before confirmation. A direct\ndrawing request may select and apply the newest suitable candidate without another prompt. Keep ordinary\nproposals concise; avoid arbitrary universal pattern thresholds and internal IDs.\nAn inactive initial reference during mounting requires a newly injected current-view\nreference, NOT another market fetch or analyze call.\nVisible candles are actual viewport-index rows, not all loaded candles; unknown viewport\nstays unknown. Limit samples the last rows with explicit truncation. Stored object inventory\nis not proof of rendering; live_view_editable=false. No old-snapshot or global-latest fallback.\ndata_provenance reports provider metadata and browser-input vs displayed intervals, not\nvendor-native granularity. local_aggregation (e.g. day -> week) explains a normal interval\ndifference, not stale data by itself; aggregation completeness is NOT verified. Unknown\nproviders/transforms must not be guessed. This metadata is not source-snapshot alignment\nor edit authorization; guarded edits still require exact current candles and AI inventory.\nAfter local period/range/symbol changes the browser can seal and confirm its current\nsource without fetching or drawing. A pending/unconfirmed source is not editable: wait\nfor fresh context, never refetch or fall back to old snapshot tools. Source binding does\nnot approve a drawing proposal or move existing objects into a different period.\nUse time_display's deterministic +08:00 ISO/date labels when reporting dates; do not\nmentally convert Unix seconds or guess dates. Minute anchors require exact ISO times.\nOptional paired region times measure the full loaded region (max 4000 bars), independently\nof returned candle sampling. source_status is allowlisted diagnostic metadata only:\nchecking means wait for a fresh report, blocked means follow next_action; an uncertain\ndrawing outcome must be checked via get_chart_edit_status, never resent automatically.\nSource aligned is not drawing approval, pixel proof, vendor freshness or a guard bypass.\nRecheck only republishes/checks the current browser chart; it does not fetch quotes or queue drawings.\nBody envelope != common body intersection; volume net change\n!= monotonic change. Measurements do not select/classify a platform or authorize drawing.\nboundary_evidence gives an actual bar's +08:00 date/ISO, source_fields (open/close/low/high),\nprice and matched_bar_count for each extreme; ties use the first matching bar, not a unique\nor preferred drawing anchor. Cite these, not guessed dates. body_overlap's candidate lower\nis max(body lows), candidate upper is min(body highs): lower>upper is EMPTY (no shared\nprice shared by EVERY body), equality is a POINT, lower<upper is a RANGE. Never turn exists=false/relation=empty\ninto a shared point. These diagnostic candidates are not drawable bounds when empty.\nEmpty common intersection does NOT imply a gap uncovered by ANY body. The candidate\ndifference is not an uncovered gap; union coverage is not measured. Report the measured\nresult with its witnesses, not extra coverage claims. A claim about a specific bar must\nbe checked against that bar's actual open/close values, not inferred from the intersection.",
|
|
717
717
|
"inputSchema": {
|
|
718
718
|
"properties": {
|
|
719
719
|
"candle_scope": {
|
|
@@ -843,7 +843,7 @@
|
|
|
843
843
|
"annotations": {
|
|
844
844
|
"readOnlyHint": true
|
|
845
845
|
},
|
|
846
|
-
"description": "Discover implemented deterministic chart functions, parameters, versions and limits.\n\nNo market fetch, chart mutation or arbitrary code execution. Candidate functions propose\nrule-based geometry for review; they do not draw or claim professional pattern confirmation.\nFunctions: fibonacci_retracement, parallel_channel, range_box, labeled_polyline,\npivot_candidates, regression_channel, channel_candidates, range_candidates, price_series_line,\nconditional_annotation, price_band, price_sticks.\npivot_candidates reports confirmed strict local extrema; regression_channel computes OLS statistics;\nchannel_candidates v3 proposes bounded three-anchor geometry from confirmed pivots. Default scope=current\nrequires a recent end anchor and checks the arithmetic extension through the latest bar; scope=historical\nis for past geometry only, with no current breakout inference. Zero candidates does not prove\na lack of recent confirmed pivots; inspect pivot_scan and rejection_counts. range_candidates proposes\nhorizontal boxes ending at the latest loaded bar, distinct from explicitly drawn range_box.\
|
|
846
|
+
"description": "Discover implemented deterministic chart functions, parameters, versions and limits.\n\nNo market fetch, chart mutation or arbitrary code execution. Candidate functions propose\nrule-based geometry for review; they do not draw or claim professional pattern confirmation.\nFunctions: fibonacci_retracement, parallel_channel, range_box, labeled_polyline,\npivot_candidates, recent_drawing_candidates, regression_channel, channel_candidates, range_candidates, price_pattern_candidates, nine_count, price_series_line,\nconditional_annotation, price_band, price_sticks.\npivot_candidates reports confirmed strict local extrema; regression_channel computes OLS statistics;\nchannel_candidates v3 proposes bounded three-anchor geometry from confirmed pivots. Default scope=current\nrequires a recent end anchor and checks the arithmetic extension through the latest bar; scope=historical\nis for past geometry only, with no current breakout inference. Zero candidates does not prove\na lack of recent confirmed pivots; inspect pivot_scan and rejection_counts. range_candidates proposes\nhorizontal boxes ending at the latest loaded bar, distinct from explicitly drawn range_box.\nAnalysis functions are read-only and may validly return no candidate. price_pattern_candidates\nuses closed A/HK/US daily bars for double tops/bottoms, head-and-shoulders and frozen ranges;\nnine_count records each close-vs-four-back count without retrospective deletion.\nlabeled_polyline connects 2..8 explicitly labeled anchors, not automatic Elliott wave recognition.\nprice_series_line uses current loaded OHLC or SMA(close, 2..200) and an optional price comparison.\nIt returns a bounded result_ref; null warmup/false-condition bars break the price-pane line.\nconditional_annotation selects only the latest loaded bar matching a required price condition;\nits result uses the existing guarded text, number or icon annotation kind, not a batch of marks.\nprice_band fills between two OHLC/SMA price sources in the candle pane. Its upper boundary\nmust stay strictly above the lower boundary on every eligible bar; warmup/false conditions break the band.\nprice_sticks draws independent vertical strokes between two OHLC/SMA price sources on matching bars;\nzero-length endpoints are omitted. This is not a full formula interpreter.",
|
|
847
847
|
"inputSchema": {
|
|
848
848
|
"properties": {},
|
|
849
849
|
"title": "list_chart_functionsArguments",
|
|
@@ -1055,7 +1055,7 @@
|
|
|
1055
1055
|
"annotations": {
|
|
1056
1056
|
"readOnlyHint": true
|
|
1057
1057
|
},
|
|
1058
|
-
"description": "Calculate on explicitly aligned current loaded candles; return immutable result_ref, NOT a drawing.\n\nRead get_chart_context first.
|
|
1058
|
+
"description": "Calculate on explicitly aligned current loaded candles; return immutable result_ref, NOT a drawing.\n\nRead get_chart_context first. Preserve user-specified anchors/bounds. For a direct automatic\ndrawing request select the newest suitable result after checking type and data quality; ask\nwhen a literal coordinate request is incomplete. pivot_candidates,\nrecent_drawing_candidates, regression_channel, channel_candidates, range_candidates, price_pattern_candidates and nine_count return analysis-only results;\nnever pass these refs as edit.result_ref. A direct request to draw authorizes the host to\nchoose a suitable candidate; an analysis-only or proposal-first request does not. For channel,\nrange and price-pattern candidates pass edit.candidate_result_ref, candidate_number (1-based)\nand user_confirmed_candidate=true after selection. Default channel scope=current may return no candidate;\nhistorical scope must not be described as a current channel or current breakout signal.\nIf no candidate passes, report only that no anchor triple met every rule; do not infer\nthat recent pivots or real-world channel structure are absent. Inspect pivot_scan for pivots.\nNo market fetch, LLM coordinate arithmetic,\nconfirmed pattern identification, arbitrary formula/code or chart selection.\nFibonacci levels are B-r*(B-A), ratios 0..1, linear price, exact loaded-bar times.\nFor drawing functions, pass result_ref into prepare_chart_edit's edit (no duplicate anchors/bounds/ratios), then\napply_chart_edit and get_chart_edit_status. For analysis-only functions, inspect the result first;\nchannel/range/price-pattern candidates have the selected-candidate route. A nine_count\nresult_ref can create or replace one nine_count snapshot group. Recompute after data/period/adjustment changes.\nprice_series_line takes value_source={kind:open/high/low/close} or {kind:sma,period:2..200},\noptional condition={left:PriceSource,op:gt/gte/lt/lte,right:{source:PriceSource}|{constant:positive_price}}.\nNo host-provided price arrays or executable formulas. Zero matched bars are not drawable.\nconditional_annotation requires annotation_kind, anchor_source and condition, plus exactly one\nmatching annotation_text / annotation_value / annotation_icon. It chooses the latest matching\nloaded bar and returns one guarded annotation result_ref; no match means no drawing.\nprice_band requires upper_source and lower_source, with optional condition. Crossing or equal\nboundaries are rejected; no matched bars are not drawable. Full arrays remain plugin-side.\nprice_sticks requires start_source and end_source, with optional condition. Each matched bar has\none independent stroke; equal endpoints, warmup and false conditions do not draw a stroke.\nStyle edits reuse the existing object ID; calculation alone never means drawn/applied.\nlabeled_polyline creates a group from parameters.points (unique labels, increasing times).\nTo move one labeled point, skip recalculation and use prepare_chart_edit with the current\nobject_id, point_label and point_time/point_price. Do NOT copy/rewrite all points or invent anchors.",
|
|
1059
1059
|
"inputSchema": {
|
|
1060
1060
|
"$defs": {
|
|
1061
1061
|
"ChartFunctionParameters": {
|
|
@@ -1073,6 +1073,24 @@
|
|
|
1073
1073
|
"default": null,
|
|
1074
1074
|
"description": "条件标注所用价格锚点,取最新一根满足条件的已加载K线"
|
|
1075
1075
|
},
|
|
1076
|
+
"anchor_times": {
|
|
1077
|
+
"anyOf": [
|
|
1078
|
+
{
|
|
1079
|
+
"items": {
|
|
1080
|
+
"type": "integer"
|
|
1081
|
+
},
|
|
1082
|
+
"maxItems": 5,
|
|
1083
|
+
"minItems": 3,
|
|
1084
|
+
"type": "array"
|
|
1085
|
+
},
|
|
1086
|
+
{
|
|
1087
|
+
"type": "null"
|
|
1088
|
+
}
|
|
1089
|
+
],
|
|
1090
|
+
"default": null,
|
|
1091
|
+
"description": "用户按时间顺序指定的形态锚点,仍须通过标准规则验证",
|
|
1092
|
+
"title": "Anchor Times"
|
|
1093
|
+
},
|
|
1076
1094
|
"annotation_icon": {
|
|
1077
1095
|
"anyOf": [
|
|
1078
1096
|
{
|
|
@@ -1133,6 +1151,19 @@
|
|
|
1133
1151
|
"default": null,
|
|
1134
1152
|
"title": "Annotation Value"
|
|
1135
1153
|
},
|
|
1154
|
+
"closed_daily_only": {
|
|
1155
|
+
"anyOf": [
|
|
1156
|
+
{
|
|
1157
|
+
"type": "boolean"
|
|
1158
|
+
},
|
|
1159
|
+
{
|
|
1160
|
+
"type": "null"
|
|
1161
|
+
}
|
|
1162
|
+
],
|
|
1163
|
+
"default": null,
|
|
1164
|
+
"description": "只使用可确认收盘的 A/港/美股单日线",
|
|
1165
|
+
"title": "Closed Daily Only"
|
|
1166
|
+
},
|
|
1136
1167
|
"condition": {
|
|
1137
1168
|
"anyOf": [
|
|
1138
1169
|
{
|
|
@@ -1163,6 +1194,38 @@
|
|
|
1163
1194
|
"description": "通道候选方向;默认both",
|
|
1164
1195
|
"title": "Direction"
|
|
1165
1196
|
},
|
|
1197
|
+
"display_bars": {
|
|
1198
|
+
"anyOf": [
|
|
1199
|
+
{
|
|
1200
|
+
"maximum": 240,
|
|
1201
|
+
"minimum": 30,
|
|
1202
|
+
"type": "integer"
|
|
1203
|
+
},
|
|
1204
|
+
{
|
|
1205
|
+
"type": "null"
|
|
1206
|
+
}
|
|
1207
|
+
],
|
|
1208
|
+
"default": null,
|
|
1209
|
+
"title": "Display Bars"
|
|
1210
|
+
},
|
|
1211
|
+
"drawing_type": {
|
|
1212
|
+
"anyOf": [
|
|
1213
|
+
{
|
|
1214
|
+
"enum": [
|
|
1215
|
+
"horizontal",
|
|
1216
|
+
"trend",
|
|
1217
|
+
"fibonacci",
|
|
1218
|
+
"abc"
|
|
1219
|
+
],
|
|
1220
|
+
"type": "string"
|
|
1221
|
+
},
|
|
1222
|
+
{
|
|
1223
|
+
"type": "null"
|
|
1224
|
+
}
|
|
1225
|
+
],
|
|
1226
|
+
"default": null,
|
|
1227
|
+
"title": "Drawing Type"
|
|
1228
|
+
},
|
|
1166
1229
|
"end_price": {
|
|
1167
1230
|
"anyOf": [
|
|
1168
1231
|
{
|
|
@@ -1358,6 +1421,30 @@
|
|
|
1358
1421
|
"default": null,
|
|
1359
1422
|
"title": "Parallel Time"
|
|
1360
1423
|
},
|
|
1424
|
+
"pattern_types": {
|
|
1425
|
+
"anyOf": [
|
|
1426
|
+
{
|
|
1427
|
+
"items": {
|
|
1428
|
+
"enum": [
|
|
1429
|
+
"double_top",
|
|
1430
|
+
"double_bottom",
|
|
1431
|
+
"head_shoulders_top",
|
|
1432
|
+
"head_shoulders_bottom",
|
|
1433
|
+
"platform"
|
|
1434
|
+
],
|
|
1435
|
+
"type": "string"
|
|
1436
|
+
},
|
|
1437
|
+
"maxItems": 5,
|
|
1438
|
+
"minItems": 1,
|
|
1439
|
+
"type": "array"
|
|
1440
|
+
},
|
|
1441
|
+
{
|
|
1442
|
+
"type": "null"
|
|
1443
|
+
}
|
|
1444
|
+
],
|
|
1445
|
+
"default": null,
|
|
1446
|
+
"title": "Pattern Types"
|
|
1447
|
+
},
|
|
1361
1448
|
"points": {
|
|
1362
1449
|
"anyOf": [
|
|
1363
1450
|
{
|
|
@@ -1678,9 +1765,12 @@
|
|
|
1678
1765
|
"range_box",
|
|
1679
1766
|
"labeled_polyline",
|
|
1680
1767
|
"pivot_candidates",
|
|
1768
|
+
"recent_drawing_candidates",
|
|
1681
1769
|
"regression_channel",
|
|
1682
1770
|
"channel_candidates",
|
|
1683
1771
|
"range_candidates",
|
|
1772
|
+
"price_pattern_candidates",
|
|
1773
|
+
"nine_count",
|
|
1684
1774
|
"price_series_line",
|
|
1685
1775
|
"conditional_annotation",
|
|
1686
1776
|
"price_band",
|
|
@@ -1711,7 +1801,7 @@
|
|
|
1711
1801
|
"name": "run_chart_function"
|
|
1712
1802
|
},
|
|
1713
1803
|
{
|
|
1714
|
-
"description": "DEFAULT entry for ALL browser-chart drawing creates/updates/deletes, including Fibonacci and labeled paths.\n\nRead get_chart_context first, then prepare here, apply_chart_edit, get_chart_edit_status.\nIncludes literal requests; legacy create/update/delete_* tools edit snapshots, NOT the current view.\nPrepare, NOT APPLY, one current-view drawing candidate with revision/alignment guards.\n\nFor proposal-first requests, call only AFTER the user approves the host's stated candidate;\nread fresh current context first, and preserve independently saved approved coordinates\nand user overrides. If relevant state changed, reassess before preparing. The host reasons,\nthe executor does not choose points or validate pattern quality.\nAccept edit.result_ref from run_chart_function instead of direct anchors/bounds/ratios;\nname/color and applicable display switches may accompany a result reference.\nFor
|
|
1804
|
+
"description": "DEFAULT entry for ALL browser-chart drawing creates/updates/deletes, including Fibonacci and labeled paths.\n\nRead get_chart_context first, then prepare here, apply_chart_edit, get_chart_edit_status.\nIncludes literal requests; legacy create/update/delete_* tools edit snapshots, NOT the current view.\nPrepare, NOT APPLY, one current-view drawing candidate with revision/alignment guards.\n\nFor proposal-first requests, call only AFTER the user approves the host's stated candidate.\nFor direct drawing requests, select the newest suitable result and continue without another prompt;\nread fresh current context first, and preserve independently saved approved coordinates\nand user overrides. If relevant state changed, reassess before preparing. The host reasons,\nthe executor does not choose points or validate pattern quality.\nAccept edit.result_ref from run_chart_function instead of direct anchors/bounds/ratios;\nname/color and applicable display switches may accompany a result reference.\nFor selected channel/range/price-pattern candidates use edit.candidate_result_ref, candidate_number\n(1-based) and user_confirmed_candidate=true with action=create or update; do not copy candidate coordinates.\nAn unconfirmed or stale candidate remains analysis only and cannot create a drawing.\nFor series_line, create or change source/condition using the price_series_line result_ref;\nstyle-only updates and delete use the stable object_id. Calculation and indicator registration\ndo not prove canvas pixels visible.\nA finite SMA/EMA(close, 2..200) result may use edit.ta_result_ref for series_line; a finite\nBBANDS(close, SMA middle) result may use it for one price_band containing upper/middle/lower.\nBoth require an explicit drawing request and selectable_render_targets for the chosen kind.\nDo not pass other TA outputs, manually copy series values or conflate these AI objects with\nthe built-in indicator toggles.\nFor conditional_annotation, create or recompute an existing text/number/icon annotation using\nits result_ref with matching edit.kind; style-only edits and deletion use object_id.\nFor price_band, use its result_ref with edit.kind=price_band to create/recompute one bounded\nprice-pane object; style-only updates and deletion use its stable object_id.\nFor price_sticks, use its result_ref with edit.kind=price_sticks; its independent strokes share\none stable object_id. Style-only updates and deletion do not recompute the price series.\nFor Fibonacci geometry use the function result; style-only edits/delete need no recalculation.\nFor labeled_polyline creation use run_chart_function and edit.result_ref. To move one point,\npass current object_id + point_label + point_time/point_price. A new current-chart\nlabeled_polyline result_ref may replace the whole group under the same object_id;\ndirect copied point arrays remain disallowed for updates.\nPoint labels are group-local; ambiguous group names require clarification. ABC/1..5 labels\nare user/host-specified annotations, not algorithmically recognized or validated waves.\nFor explicit point labels, text_annotation uses anchor_time + anchor_price + annotation_text;\nnumber_annotation uses anchor_time + anchor_price + annotation_value. Both update/delete by object_id\nand display literal user-provided content; the plugin does not calculate the value or select anchors.\nicon_annotation uses anchor_time + anchor_price + annotation_icon (arrow_up, arrow_down or diamond),\nand follows the same guarded create/update/delete flow.\nReuses deterministic AI drawing families. Reject stale/ambiguous/inactive contexts,\nunaligned snapshots, manual objects and parallel edits from a consumed revision.\nA replay returns the same candidate, never publishes another. Unknown publication outcomes\nstop retries. No fetching or automatic chart selection. Use apply_chart_edit explicitly next.",
|
|
1715
1805
|
"inputSchema": {
|
|
1716
1806
|
"$defs": {
|
|
1717
1807
|
"ChartEdit": {
|
|
@@ -1809,7 +1899,7 @@
|
|
|
1809
1899
|
}
|
|
1810
1900
|
],
|
|
1811
1901
|
"default": null,
|
|
1812
|
-
"description": "
|
|
1902
|
+
"description": "用户指定或宿主从最新合格结果中选择的候选序号,从1开始",
|
|
1813
1903
|
"title": "Candidate Number"
|
|
1814
1904
|
},
|
|
1815
1905
|
"candidate_result_ref": {
|
|
@@ -1823,7 +1913,7 @@
|
|
|
1823
1913
|
}
|
|
1824
1914
|
],
|
|
1825
1915
|
"default": null,
|
|
1826
|
-
"description": "
|
|
1916
|
+
"description": "当前图自动候选的只读引用;用户直接要求自动绘图时可选择第一项",
|
|
1827
1917
|
"title": "Candidate Result Ref"
|
|
1828
1918
|
},
|
|
1829
1919
|
"color": {
|
|
@@ -1891,6 +1981,8 @@
|
|
|
1891
1981
|
"series_line",
|
|
1892
1982
|
"price_band",
|
|
1893
1983
|
"price_sticks",
|
|
1984
|
+
"price_pattern",
|
|
1985
|
+
"nine_count",
|
|
1894
1986
|
"all_drawings"
|
|
1895
1987
|
],
|
|
1896
1988
|
"title": "Kind",
|
|
@@ -2152,7 +2244,7 @@
|
|
|
2152
2244
|
}
|
|
2153
2245
|
],
|
|
2154
2246
|
"default": null,
|
|
2155
|
-
"description": "
|
|
2247
|
+
"description": "用户明确要求直接绘图或选定候选时填 true;仅分析/提案请求不可填",
|
|
2156
2248
|
"title": "User Confirmed Candidate"
|
|
2157
2249
|
}
|
|
2158
2250
|
},
|
|
@@ -3779,5 +3871,5 @@
|
|
|
3779
3871
|
"name": "verify_chart_drawings"
|
|
3780
3872
|
}
|
|
3781
3873
|
],
|
|
3782
|
-
"version": "0.6.
|
|
3874
|
+
"version": "0.6.11"
|
|
3783
3875
|
}
|
|
@@ -20,6 +20,7 @@ from core.ta_engine import ENGINE_VERSION, NATIVE_VERSION, arrays as _ta_arrays,
|
|
|
20
20
|
# Defaults (shared by calc_metrics + draw_kline)
|
|
21
21
|
# ---------------------------------------------------------------------------
|
|
22
22
|
DEFAULT_MA_PERIODS = [5, 10, 20, 30, 60]
|
|
23
|
+
DEFAULT_EMA_PERIOD = 20
|
|
23
24
|
DEFAULT_LOOKBACK = 60
|
|
24
25
|
DEFAULT_TOLERANCE_PCT = 0.5 # support/resistance touch band
|
|
25
26
|
DEFAULT_RSI_PERIOD = 14
|
|
@@ -95,6 +96,13 @@ def series_ma(
|
|
|
95
96
|
return {f"ma{int(p)}": _ta_map(rows, talib.SMA(close, timeperiod=int(p))) for p in periods}
|
|
96
97
|
|
|
97
98
|
|
|
99
|
+
def series_ema(rows: list[dict[str, Any]], period: int = DEFAULT_EMA_PERIOD) -> dict[int, float]:
|
|
100
|
+
"""Return the TA-Lib EMA(close) series keyed by candle time."""
|
|
101
|
+
if not rows:
|
|
102
|
+
return {}
|
|
103
|
+
return _ta_map(rows, talib.EMA(_ta_arrays(rows)["close"], timeperiod=int(period)))
|
|
104
|
+
|
|
105
|
+
|
|
98
106
|
def series_vol_ma(
|
|
99
107
|
rows: list[dict[str, Any]],
|
|
100
108
|
period: int = DEFAULT_VOLUME_MA,
|
|
@@ -166,6 +166,6 @@ export class ChartApplications {
|
|
|
166
166
|
await this.write(path, app); // Record delivery before sending it to a browser.
|
|
167
167
|
return { candidate_chart_session: token, context_ref: view.ref, conversation_id: view.conversation, view_id: view.view,
|
|
168
168
|
expected_revision: view.revision, lease_id: app.lease_id, expires_at_ms: app.expires_at_ms, base_state: app.base_state,
|
|
169
|
-
payload: { symbol: payload.symbol, interval: payload.interval, chartCommands: payload.chartCommands.filter((c) => ['DRAW_HORIZONTAL_LINE', 'DRAW_AGENT_TREND_LINE', 'DRAW_AGENT_CHANNEL', 'DRAW_AGENT_RECTANGLE', 'DRAW_AGENT_FIBONACCI', 'DRAW_AGENT_POLYLINE', 'DRAW_AGENT_ANNOTATION', 'DRAW_AGENT_SERIES_LINE', 'DRAW_AGENT_PRICE_BAND', 'DRAW_AGENT_PRICE_STICKS'].includes(c.type)) } };
|
|
169
|
+
payload: { symbol: payload.symbol, interval: payload.interval, chartCommands: payload.chartCommands.filter((c) => ['DRAW_HORIZONTAL_LINE', 'DRAW_AGENT_TREND_LINE', 'DRAW_AGENT_CHANNEL', 'DRAW_AGENT_RECTANGLE', 'DRAW_AGENT_FIBONACCI', 'DRAW_AGENT_POLYLINE', 'DRAW_AGENT_ANNOTATION', 'DRAW_AGENT_SERIES_LINE', 'DRAW_AGENT_PRICE_BAND', 'DRAW_AGENT_PRICE_STICKS', 'DRAW_AGENT_PRICE_PATTERN', 'DRAW_AGENT_NINE_COUNT'].includes(c.type)) } };
|
|
170
170
|
}
|
|
171
171
|
}
|
|
@@ -143,7 +143,7 @@ export class ChartContextBroker {
|
|
|
143
143
|
return 'dsh_kline interaction contract: The host reasons; the plugin only observes, measures and executes. '
|
|
144
144
|
+ 'For ALL drawings on this browser chart, including literal create/update/delete, use get_chart_context -> prepare_chart_edit -> apply_chart_edit -> get_chart_edit_status. Never use legacy snapshot mutation tools for the current chart. '
|
|
145
145
|
+ 'For Fibonacci and reusable geometry, use list_chart_functions / run_chart_function on fresh current context and pass edit.result_ref into prepare_chart_edit, without copying computed coordinates or mixing direct geometry. Functions calculate but never apply. Explicit anchors or a user-authorized host proposal are required. pivot_candidates and regression_channel are analysis-only: pivots report confirmed strict local extrema; regression_channel reports OLS close-price channel statistics over explicit start/end bars. Neither chooses drawing anchors or creates drawings. No arbitrary code. '
|
|
146
|
-
+ 'labeled_polyline connects 2..8 explicitly labeled points as one object, not automatic wave recognition. Create with a function result_ref; to move one point use object_id + point_label + point_time/point_price
|
|
146
|
+
+ 'labeled_polyline connects 2..8 explicitly labeled points as one object, not automatic wave recognition. Create with a function result_ref; to move one point use object_id + point_label + point_time/point_price without copying neighbours. A new bound function result_ref can replace the complete group under its stable object_id. Direct copied point arrays remain disallowed on update. Labels are group-local, so clarify ambiguous group names. Whole-group name/color/delete use the existing ID. '
|
|
147
147
|
+ 'text_annotation, number_annotation and icon_annotation create one AI-owned time/price anchored marker each using anchor_time + anchor_price and annotation_text, annotation_value or annotation_icon (arrow_up, arrow_down or diamond). Update/delete by the exact object_id; content, anchor, name and color changes share the guarded prepare/apply flow. These are literal annotations, not calculated analysis. '
|
|
148
148
|
+ 'For user-authorized analysis, derive candidates from fresh actual candles; do not demand all coordinates from the user. '
|
|
149
149
|
+ 'Before proposing a chosen region, read get_chart_context with region_start_time/region_end_time to check its measurements. '
|
|
@@ -4,6 +4,7 @@ import { sanitizeChartAnnotation } from "./chart-annotations.js";
|
|
|
4
4
|
import { seriesObservation } from "./price-series.js";
|
|
5
5
|
import { bandObservation } from "./price-bands.js";
|
|
6
6
|
import { sticksObservation } from "./price-sticks.js";
|
|
7
|
+
import { patternGroupObservation } from "./pattern-groups.js";
|
|
7
8
|
const TOKEN = /^[A-Za-z0-9_-]{32}$/;
|
|
8
9
|
export function text(value, max = 128) {
|
|
9
10
|
if (typeof value !== 'string' || value.length > max || /[\x00-\x1f]/.test(value))
|
|
@@ -105,6 +106,13 @@ export function sanitizeChartContext(raw) {
|
|
|
105
106
|
throw Error('invalid_context_sticks');
|
|
106
107
|
Object.assign(result, sticksObservation(drawing));
|
|
107
108
|
}
|
|
109
|
+
if (drawing.kind === 'price_pattern' || drawing.kind === 'nine_count') {
|
|
110
|
+
if (typeof drawing.geometry_hash !== 'string' || !/^[a-f0-9]{64}$/.test(drawing.geometry_hash)
|
|
111
|
+
|| !Number.isSafeInteger(drawing.bar_count) || drawing.bar_count < 0 || drawing.bar_count > 240
|
|
112
|
+
|| !['price_patterns_v1', 'nine_count_v1'].includes(drawing.rule_version))
|
|
113
|
+
throw Error('invalid_context_pattern_group');
|
|
114
|
+
Object.assign(result, patternGroupObservation(drawing));
|
|
115
|
+
}
|
|
108
116
|
if (drawing.kind === 'labeled_polyline')
|
|
109
117
|
result.points = sanitizePolylinePoints(drawing.points);
|
|
110
118
|
else if (['text_annotation', 'number_annotation', 'icon_annotation'].includes(drawing.kind)) {
|
|
@@ -199,7 +207,7 @@ export function drawingInventory(payload) {
|
|
|
199
207
|
const kinds = { DRAW_HORIZONTAL_LINE: 'horizontal_line', DRAW_AGENT_TREND_LINE: 'trend_line',
|
|
200
208
|
DRAW_AGENT_CHANNEL: 'channel', DRAW_AGENT_RECTANGLE: 'rectangle', DRAW_AGENT_FIBONACCI: 'fibonacci_retracement', DRAW_AGENT_POLYLINE: 'labeled_polyline',
|
|
201
209
|
DRAW_AGENT_ANNOTATION: 'annotation', DRAW_AGENT_SERIES_LINE: 'series_line', DRAW_AGENT_PRICE_BAND: 'price_band',
|
|
202
|
-
DRAW_AGENT_PRICE_STICKS: 'price_sticks' };
|
|
210
|
+
DRAW_AGENT_PRICE_STICKS: 'price_sticks', DRAW_AGENT_PRICE_PATTERN: 'price_pattern', DRAW_AGENT_NINE_COUNT: 'nine_count' };
|
|
203
211
|
return (payload.chartCommands ?? []).filter((c) => kinds[c.type]).map((c) => {
|
|
204
212
|
const d = { id: c.id, kind: kinds[c.type], origin: 'ai', name: c.label ?? '', color: c.color ?? 'info', interval: c.interval ?? payload.interval };
|
|
205
213
|
if (c.type === 'DRAW_HORIZONTAL_LINE')
|
|
@@ -210,6 +218,8 @@ export function drawingInventory(payload) {
|
|
|
210
218
|
Object.assign(d, bandObservation(c));
|
|
211
219
|
else if (c.type === 'DRAW_AGENT_PRICE_STICKS')
|
|
212
220
|
Object.assign(d, sticksObservation(c));
|
|
221
|
+
else if (c.type === 'DRAW_AGENT_PRICE_PATTERN' || c.type === 'DRAW_AGENT_NINE_COUNT')
|
|
222
|
+
Object.assign(d, patternGroupObservation(c));
|
|
213
223
|
else if (c.type === 'DRAW_AGENT_ANNOTATION') {
|
|
214
224
|
const annotation = sanitizeChartAnnotation(c);
|
|
215
225
|
d.kind = annotation.kind;
|
|
@@ -12,8 +12,9 @@ import { sanitizePriceSeriesCommand } from "./price-series.js";
|
|
|
12
12
|
import { sanitizePriceBandCommand } from "./price-bands.js";
|
|
13
13
|
import { candleSequenceHash } from "./candle-sequence.js";
|
|
14
14
|
import { sanitizePriceSticksCommand } from "./price-sticks.js";
|
|
15
|
+
import { sanitizePatternGroupCommand } from "./pattern-groups.js";
|
|
15
16
|
const TOKEN = /^[A-Za-z0-9_-]{32}$/;
|
|
16
|
-
const AI = new Set(['DRAW_HORIZONTAL_LINE', 'DRAW_AGENT_TREND_LINE', 'DRAW_AGENT_CHANNEL', 'DRAW_AGENT_RECTANGLE', 'DRAW_AGENT_FIBONACCI', 'DRAW_AGENT_POLYLINE', 'DRAW_AGENT_ANNOTATION', 'DRAW_AGENT_SERIES_LINE', 'DRAW_AGENT_PRICE_BAND', 'DRAW_AGENT_PRICE_STICKS']);
|
|
17
|
+
const AI = new Set(['DRAW_HORIZONTAL_LINE', 'DRAW_AGENT_TREND_LINE', 'DRAW_AGENT_CHANNEL', 'DRAW_AGENT_RECTANGLE', 'DRAW_AGENT_FIBONACCI', 'DRAW_AGENT_POLYLINE', 'DRAW_AGENT_ANNOTATION', 'DRAW_AGENT_SERIES_LINE', 'DRAW_AGENT_PRICE_BAND', 'DRAW_AGENT_PRICE_STICKS', 'DRAW_AGENT_PRICE_PATTERN', 'DRAW_AGENT_NINE_COUNT']);
|
|
17
18
|
const INTERVALS = ['minute', 'day', 'week', 'month', 'quarter', 'year'];
|
|
18
19
|
function finite(value, positive = false) {
|
|
19
20
|
if (typeof value !== 'number' || !Number.isFinite(value) || positive && value <= 0)
|
|
@@ -119,6 +120,9 @@ export function sanitizeSourcePayload(raw, state) {
|
|
|
119
120
|
throw Error('source_sequence_rows_mismatch');
|
|
120
121
|
return clean;
|
|
121
122
|
}
|
|
123
|
+
if (type === 'DRAW_AGENT_PRICE_PATTERN' || type === 'DRAW_AGENT_NINE_COUNT') {
|
|
124
|
+
return sanitizePatternGroupCommand(c, state.interval);
|
|
125
|
+
}
|
|
122
126
|
if (type === 'TEXT_MARKER')
|
|
123
127
|
return { type, id: text(c.id ?? '', 256), text: text(c.text ?? '', 256), ...point(c), color: color(c.color ?? 'info') };
|
|
124
128
|
if (type === 'DRAW_TREND_LINE')
|
|
@@ -187,6 +191,7 @@ export function sanitizeSourcePayload(raw, state) {
|
|
|
187
191
|
meta.updated_at = raw.data_meta.updated_at;
|
|
188
192
|
const payload = { symbol: state.symbol, name: state.name, interval: state.interval, interval_value: state.interval_value,
|
|
189
193
|
adjust: state.adjust, range_key: state.range_key, count: state.candles.length, indicators: state.indicators,
|
|
194
|
+
display_volume_unit: state.display_volume_unit,
|
|
190
195
|
indicators_explicit: true, data_meta: meta, chartCommands: commands };
|
|
191
196
|
if (canonicalAI({ ...state, drawings: drawingInventory(payload) }) !== canonicalAI(state))
|
|
192
197
|
throw Error('source_inventory_mismatch');
|