diff --git a/CHANGELOG.md b/CHANGELOG.md index 7361afd9d..7b3bf88e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * Added a context type representing a range of time (`fdc3.timerange`). ([#706](https://github.com/finos/FDC3/pull/706)) * Added a context type representing a Currency (`fdc3.currency`). ([#708](https://github.com/finos/FDC3/pull/708)) * Added a context type representing the price and value of a holding (`fdc3.valuation`). ([#709](https://github.com/finos/FDC3/pull/709)) +* Added a context type representing a Chart (`fdc3.chart`). ([#715](https://github.com/finos/FDC3/pull/715)) * Addition of `ViewProfile` and deprecation of `ViewContact` intents. Changes based on ([#619](https://github.com/finos/FDC3/pull/619)) * Added a new context type `ChatInitSettings` to initialize a chat creation with new optional parameters ([#620](https://github.com/finos/FDC3/pull/620)) * Added a `ViewResearch` Intent to be used when a user wants to see the latest research on a particular stock ([#623](https://github.com/finos/FDC3/pull/623)) diff --git a/docs/context/ref/Chart.md b/docs/context/ref/Chart.md new file mode 100644 index 000000000..260ac858c --- /dev/null +++ b/docs/context/ref/Chart.md @@ -0,0 +1,91 @@ +--- +id: Chart +sidebar_label: Chart +title: Chart +hide_title: true +--- +# `Chart` + +A context type representing details of a Chart, which may be used to request plotting of a particular chart or to otherwise share details of its composition, such as: + +* A list of instruments for comparison +* The time period to plot the chart over +* The style of chart (line, bar, mountain, candle etc.) +* Other settings such as indicators to calculate, or data representing drawings and annotations + +In addition to handling requests to plot charts, a charting application may use this type to output a representation of what it is currently displaying so that it can be recorded by another application. + +## Type + +`fdc3.chart` + +## Schema + +https://fdc3.finos.org/schemas/next/chart.schema.json + +## Details + +| Property | Type | Required | Example Value | +|------------------|-----------------|----------|----------------------| +| `type` | string | Yes | `'fdc3.chart'` | +| `instruments` | Instrument[] | Yes |
[
  {
    "type": "fdc3.instrument",
    "id": {
      "ticker": "AAPL"
    }
  },
  {
    "type": "fdc3.instrument",
    "id": {
      "ticker": "MSFT"
    }
  }
]
| +| `range` | TimeRange | No |
{
  "type": "fdc3.timerange",
  "startTime": "2022-03-30T15:44:44+00:00",
  "endTime": "2022-04-30T23:59:59+00:00"
}
| +| `style` | string | No | one of: `'line'`, `'bar'`, `'stacked-bar'`, `'mountain'`, `'candle'`, `'pie'`, `'scatter'`, `'histogram'`, `'heatmap'`, `'custom'` | +| `otherConfig`* | object | No | `{ /* unstandardized additional config */}` | + +\* It is common for charts to support other configuration, such as indicators, annotations etc., which do not have standarized formats, but may be included in the `otherConfig` element. + +## Example + +```js +const chart = { + type: "fdc3.chart", + instruments: [ + { + type: "fdc3.instrument", + id: { + ticker: "AAPL" + } + }, + { + type: "fdc3.instrument", + id: { + ticker: "GOOG" + } + } + ], + range: { + type: "fdc3.timeRange", + startTime: "2020-09-01T08:00:00.000Z", + endTime: "2020-10-31T08:00:00.000Z" + }, + style: "line", + otherConfig: { + indicators: [ + { + name: "ma", + parameters: { + period: 14, + type: "ema" + } + }, + { + name: "volume" + } + ] + } +}; + +fdc3.raiseIntent("ViewChart", chart); +``` + +## See Also + +Other Types + +* [Instrument](Instrument) +* [TimeRange](TimeRange) + +Intents + +* [ViewChart](../../intents/ref/ViewChart) diff --git a/docs/context/ref/Instrument.md b/docs/context/ref/Instrument.md index 614639ece..5446b5ea3 100644 --- a/docs/context/ref/Instrument.md +++ b/docs/context/ref/Instrument.md @@ -66,11 +66,14 @@ fdc3.broadcast(instrument) ## See Also Other Types + - [InstrumentList](InstrumentList) +- [Chart](Chart) - [Position](Position) - [Portfolio](Portfolio) Intents + - [ViewAnalysis](../../intents/ref/ViewAnalysis) - [ViewChart](../../intents/ref/ViewChart) - [ViewInstrument](../../intents/ref/ViewInstrument) @@ -79,4 +82,5 @@ Intents - [ViewResearch](../../intents/ref/ViewResearch) FINOS Financial Objects + - [Instrument](https://fo.finos.org/docs/objects/instrument) diff --git a/docs/context/ref/TimeRange.md b/docs/context/ref/TimeRange.md index effe0ae3d..f03b00dfe 100644 --- a/docs/context/ref/TimeRange.md +++ b/docs/context/ref/TimeRange.md @@ -75,3 +75,9 @@ const timeRange = { endTime: "2022-03-30T16:44:44.123Z" } ``` + +## See Also + +Other Types + +- [Chart](Chart) diff --git a/docs/intents/ref/ViewChart.md b/docs/intents/ref/ViewChart.md index 60da1077e..de32d76d1 100644 --- a/docs/intents/ref/ViewChart.md +++ b/docs/intents/ref/ViewChart.md @@ -6,7 +6,7 @@ hide_title: true --- # `ViewChart` -Display a chart for the provided instrument(s). +Display a chart for the provided context. ## Intent Name @@ -18,6 +18,7 @@ Display a chart for the provided instrument(s). ## Possible Contexts +* [Chart](../../context/ref/Chart) * [Instrument](../../context/ref/Instrument) * [InstrumentList](../../context/ref/InstrumentList) * [Portfolio](../../context/ref/Portfolio) @@ -25,6 +26,7 @@ Display a chart for the provided instrument(s). ## Example +Request a chart for an instrument: ```js const instrument = { type: 'fdc3.instrument', @@ -37,13 +39,60 @@ const instrument = { fdc3.raiseIntent('ViewChart', instrument) ``` +Request a specific chart: + +```js +const chart = { + type: "fdc3.chart", + instruments: [ + { + type: "fdc3.instrument", + id: { + ticker: "AAPL" + } + }, + { + type: "fdc3.instrument", + id: { + ticker: "GOOG" + } + } + ], + range: { + type: "fdc3.timeRange", + startTime: "2020-09-01T08:00:00.000Z", + endTime: "2020-10-31T08:00:00.000Z" + }, + style: "line", + otherConfig: { + indicators: [ + { + name: "ma", + parameters: { + period: 14, + type: "ema" + } + }, + { + name: "volume" + } + ] + } +}; + +fdc3.raiseIntent("ViewChart", chart); +``` + ## See Also Context -- [Instrument](../../context/ref/Instrument) -- [InstrumentList](../../context/ref/InstrumentList) -- [Portfolio](../../context/ref/Portfolio) -- [Position](../../context/ref/Position) + +* [Chart](../../context/ref/Chart) +* [Instrument](../../context/ref/Instrument) +* [InstrumentList](../../context/ref/InstrumentList) +* [Portfolio](../../context/ref/Portfolio) +* [Position](../../context/ref/Position) Intents -- [ViewQuote](ViewQuote) \ No newline at end of file + +* [ViewQuote](ViewQuote) \ No newline at end of file diff --git a/src/context/ContextType.ts b/src/context/ContextType.ts index e2c321558..46f7017b5 100644 --- a/src/context/ContextType.ts +++ b/src/context/ContextType.ts @@ -1,4 +1,5 @@ export enum ContextTypes { + Chart = 'fdc3.chart', Contact = 'fdc3.contact', ContactList = 'fdc3.contactList', Country = 'fdc3.country', @@ -9,8 +10,8 @@ export enum ContextTypes { Portfolio = 'fdc3.portfolio', Position = 'fdc3.position', Nothing = 'fdc3.nothing', - Valuation = 'fdc3.valuation', TimeRange = 'fdc3.timerange', + Valuation = 'fdc3.valuation', } export type ContextType = ContextTypes | string; diff --git a/src/context/schemas.json b/src/context/schemas.json index 1f584022c..153d5700a 100644 --- a/src/context/schemas.json +++ b/src/context/schemas.json @@ -3,6 +3,7 @@ "https://fdc3.finos.org/schemas/next/chatInitSettings.schema.json" ], "Context": ["https://fdc3.finos.org/schemas/next/context.schema.json"], + "Chart": ["https://fdc3.finos.org/schemas/next/chart.schema.json"], "Contact": ["https://fdc3.finos.org/schemas/next/contact.schema.json"], "ContactList": ["https://fdc3.finos.org/schemas/next/contactList.schema.json"], "Currency": ["https://fdc3.finos.org/schemas/next/currency.schema.json"], diff --git a/src/context/schemas/chart.schema.json b/src/context/schemas/chart.schema.json new file mode 100644 index 000000000..ab541e70c --- /dev/null +++ b/src/context/schemas/chart.schema.json @@ -0,0 +1,27 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://fdc3.finos.org/schemas/next/chart.schema.json", + "type": "object", + "title": "Chart", + "allOf": [{ "$ref": "context.schema.json#" }], + "properties": { + "type": { "const": "fdc3.chart" }, + "instruments": { + "type": "array", + "items": { + "$ref": "instrument.schema.json#" + } + }, + "range": { + "$ref": "timerange.schema.json#" + }, + "style": { + "type": "string", + "enum": [ "line", "bar", "stacked-bar", "mountain", "candle", "pie", "scatter", "histogram", "heatmap", "custom"] + }, + "otherConfig": { + "type": "object" + } + }, + "required": ["instruments"] +} diff --git a/website/sidebars.json b/website/sidebars.json index 8af4fdea9..a176e98cf 100644 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -58,6 +58,7 @@ "context/overview", "context/spec", "context/ref/Context", + "context/ref/Chart", "context/ref/ChatInitSettings", "context/ref/Contact", "context/ref/ContactList", diff --git a/website/static/schemas/next/chart.schema.json b/website/static/schemas/next/chart.schema.json new file mode 100644 index 000000000..ab541e70c --- /dev/null +++ b/website/static/schemas/next/chart.schema.json @@ -0,0 +1,27 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://fdc3.finos.org/schemas/next/chart.schema.json", + "type": "object", + "title": "Chart", + "allOf": [{ "$ref": "context.schema.json#" }], + "properties": { + "type": { "const": "fdc3.chart" }, + "instruments": { + "type": "array", + "items": { + "$ref": "instrument.schema.json#" + } + }, + "range": { + "$ref": "timerange.schema.json#" + }, + "style": { + "type": "string", + "enum": [ "line", "bar", "stacked-bar", "mountain", "candle", "pie", "scatter", "histogram", "heatmap", "custom"] + }, + "otherConfig": { + "type": "object" + } + }, + "required": ["instruments"] +}