Skip to content

Commit

Permalink
Merge pull request #715 from finos/654-chart-context-type
Browse files Browse the repository at this point in the history
654 chart context type
  • Loading branch information
kriswest authored May 20, 2022
2 parents 611edf8 + cf302c2 commit b6ebac2
Show file tree
Hide file tree
Showing 10 changed files with 215 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
91 changes: 91 additions & 0 deletions docs/context/ref/Chart.md
Original file line number Diff line number Diff line change
@@ -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 | <pre>[<br>&emsp;&emsp;{<br>&emsp;&emsp;&emsp;&emsp;"type": "fdc3.instrument",<br>&emsp;&emsp;&emsp;&emsp;"id": {<br>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;"ticker": "AAPL"<br>&emsp;&emsp;&emsp;&emsp;}<br>&emsp;&emsp;},<br>&emsp;&emsp;{<br>&emsp;&emsp;&emsp;&emsp;"type": "fdc3.instrument",<br>&emsp;&emsp;&emsp;&emsp;"id": {<br>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;"ticker": "MSFT"<br>&emsp;&emsp;&emsp;&emsp;}<br>&emsp;&emsp;}<br>]</pre> |
| `range` | TimeRange | No | <pre>{<br>&emsp;&emsp;"type": "fdc3.timerange",<br>&emsp;&emsp;"startTime": "2022-03-30T15:44:44+00:00",<br>&emsp;&emsp;"endTime": "2022-04-30T23:59:59+00:00"<br>}</pre> |
| `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)
4 changes: 4 additions & 0 deletions docs/context/ref/Instrument.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -79,4 +82,5 @@ Intents
- [ViewResearch](../../intents/ref/ViewResearch)

FINOS Financial Objects

- [Instrument](https://fo.finos.org/docs/objects/instrument)
6 changes: 6 additions & 0 deletions docs/context/ref/TimeRange.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,9 @@ const timeRange = {
endTime: "2022-03-30T16:44:44.123Z"
}
```

## See Also

Other Types

- [Chart](Chart)
61 changes: 55 additions & 6 deletions docs/intents/ref/ViewChart.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -18,13 +18,15 @@ 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)
* [Position](../../context/ref/Position)

## Example

Request a chart for an instrument:
```js
const instrument = {
type: 'fdc3.instrument',
Expand All @@ -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)

* [ViewQuote](ViewQuote)
3 changes: 2 additions & 1 deletion src/context/ContextType.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export enum ContextTypes {
Chart = 'fdc3.chart',
Contact = 'fdc3.contact',
ContactList = 'fdc3.contactList',
Country = 'fdc3.country',
Expand All @@ -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;
1 change: 1 addition & 0 deletions src/context/schemas.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
27 changes: 27 additions & 0 deletions src/context/schemas/chart.schema.json
Original file line number Diff line number Diff line change
@@ -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"]
}
1 change: 1 addition & 0 deletions website/sidebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"context/overview",
"context/spec",
"context/ref/Context",
"context/ref/Chart",
"context/ref/ChatInitSettings",
"context/ref/Contact",
"context/ref/ContactList",
Expand Down
27 changes: 27 additions & 0 deletions website/static/schemas/next/chart.schema.json
Original file line number Diff line number Diff line change
@@ -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"]
}

0 comments on commit b6ebac2

Please sign in to comment.