Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added X-Ray Connector. #29

Merged
merged 16 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions docs/connectors/morningstar/x-ray.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
X-Ray Connector
===============

The Morningstar X-Ray capability enables you to quickly analyze a portfolio's
holdings. You define the portfolio individually in the connector options.

The X-Ray Connector aggregates individual holdings data with the help of the
Morningstar API. Data returned by the Highcharts Connector shows how a portfolio
is diversified by region, sector, and investment style.



How to use X-Ray
----------------

You can use the X-Ray Connector to fetch portfolio data points, holding data
points, or benchmark data points. Depending on the request additional breakdown
columns might be added to the table.

In order to fetch a benchmark, you can for example

```js
const xRayConnector = MC.XRayConnector({
postman: {
environmentJSON: postmanJSON
},
dataPoints: {
type: 'benchmark',
dataPoints: [
'HistoricalPerformanceSeries',
['PerformanceReturn', 'M0', 'M1', 'M2', 'M3', 'M6', 'M12'],
'ShowBreakdown'
]
},
holdings: [
{
id: 'GB00BWDBJF10',
idType: 'ISIN',
weight: 100
}
]
});
```

For more details, see [Morningstar's X-Ray API].



<!-- Links -->



[Morningstar's X-Ray API]: https://developer.morningstar.com/direct-web-services/documentation/api-reference/portfolio-analysis-apacemea/x-ray
2 changes: 1 addition & 1 deletion src/RNANews/RNANewsConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export class RNANewsConnector extends MorningstarConnector {
}

const api = this.api = this.api || new MorningstarAPI(options.api);
const url = new MorningstarURL('/ecint/v1/timeseries/rna-news', api.baseURL);
const url = new MorningstarURL('ecint/v1/timeseries/rna-news', api.baseURL);

url.setSecuritiesOptions([security]);

Expand Down
2 changes: 0 additions & 2 deletions src/Shared/MorningstarAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ export class MorningstarAPI {
window.location.href
);

this.baseURL.pathname = '/ecint/v1/';

if (this.baseURL.protocol !== 'https:') {
throw new Error('Insecure API protocol');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Shared/MorningstarAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class MorningstarAccess {
this.url = (
options.url ?
new URL(options.url, window.location.href) :
new URL('/token/oauth', MorningstarRegion.baseURLs[MorningstarRegion.detect()])
new URL('token/oauth', MorningstarRegion.baseURLs[MorningstarRegion.detect()])
);

if (this.url.protocol !== 'https:') {
Expand Down
52 changes: 21 additions & 31 deletions src/Shared/MorningstarOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,11 @@ export interface MorningstarHoldingAmountOptions extends MorningstarSecurityOpti
*/
amount: number;

/**
* Name of holding.
*/
name?: string;

}


export interface MorningstarHoldingWeightOptions extends MorningstarSecurityOptions {

/**
* Name of holding.
*/
name?: string;

/**
* Holding weight.
*/
Expand All @@ -131,11 +121,6 @@ export interface MorningstarHoldingWeightOptions extends MorningstarSecurityOpti

export interface MorningstarHoldingValueOptions extends MorningstarSecurityOptions {

/**
* Name of holding.
*/
name?: string;

/**
* Holding value.
*/
Expand Down Expand Up @@ -196,6 +181,11 @@ export interface MorningstarSecurityOptions {
*/
idType: string;

/**
* Name of the security.
*/
name?: string;

/**
* Type of security.
*/
Expand All @@ -212,22 +202,22 @@ export interface MorningstarSecurityOptions {


export enum MorningstarSecurityType {
'Bond' = 'BD',
'529 Portfolio' = 'CT',
'Cash' = 'CASH',
'Category Average' = 'CA',
'Closed-End Fund' = 'FC',
'Economics Series' = 'EI',
'Exchange-Traded Fund' = 'FE',
'Index' = 'XI',
'Insurance Product Fund' = 'FV',
'Money Market Fund' = 'FM',
'Open-End Fund' = 'FO',
'Separate Account' = 'SA',
'Stock' = 'ST',
'UK LP SubAccounts' = 'VA',
'Unit Investment Trust' = 'FI',
'Variable Annuity' = 'V1'
Bond = 'BD',
Cash = 'CASH',
CategoryAverage = 'CA',
ClosedEndFund = 'FC',
EconomicsSeries = 'EI',
ExchangeTradedFund = 'FE',
Index = 'XI',
InsuranceProductFund = 'FV',
MoneyMarketFund = 'FM',
OpenEndFund = 'FO',
Portfolio529 = 'CT',
SeparateAccount = 'SA',
Stock = 'ST',
UKLPSubAccounts = 'VA',
UnitInvestmentTrust = 'FI',
VariableAnnuity = 'V1'
}


Expand Down
3 changes: 3 additions & 0 deletions src/Shared/MorningstarPostman.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ export namespace MorningstarPostman {
password: password.value,
username: username.value
};
if (url) {
apiOptions.access.url = `https://${url.value}`;
}
}

if (url) {
Expand Down
8 changes: 4 additions & 4 deletions src/TimeSeries/Converters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
import CumulativeReturnSeriesConverter from './CumulativeReturnSeriesConverter';
import DividendSeriesConverter from './DividendSeriesConverter';
import GrowthSeriesConverter from './GrowthSeriesConverter';
import OHLCVSeriesConverter from './OHLCVSeriesConverter';
import PriceSeriesConverter from './PriceSeriesConverter';
import RatingSeriesConverter from './RatingSeriesConverter';
import OHLCVSeriesConverter from './OHLCVSeriesConverter';


/* *
Expand All @@ -40,9 +40,9 @@ import OHLCVSeriesConverter from './OHLCVSeriesConverter';
export * from './CumulativeReturnSeriesConverter';
export * from './DividendSeriesConverter';
export * from './GrowthSeriesConverter';
export * from './OHLCVSeriesConverter';
export * from './PriceSeriesConverter';
export * from './RatingSeriesConverter';
export * from './OHLCVSeriesConverter';


/* *
Expand All @@ -56,7 +56,7 @@ export default {
CumulativeReturnSeriesConverter,
DividendSeriesConverter,
GrowthSeriesConverter,
OHLCVSeriesConverter,
PriceSeriesConverter,
RatingSeriesConverter,
OHLCVSeriesConverter
RatingSeriesConverter
};
30 changes: 12 additions & 18 deletions src/TimeSeries/TimeSeriesConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,13 @@
* */


import Converters from './Converters';
import External from '../Shared/External';
import GrowthSeriesConverter from './Converters/GrowthSeriesConverter';
import MorningstarAPI from '../Shared/MorningstarAPI';
import MorningstarConnector from '../Shared/MorningstarConnector';
import MorningstarURL from '../Shared/MorningstarURL';
import CumulativeReturnSeriesConverter from './Converters/CumulativeReturnSeriesConverter';
import DividendSeriesConverter from './Converters/DividendSeriesConverter';
import TimeSeriesOptions, { OHLCVSeriesOptions } from './TimeSeriesOptions';
import TimeSeriesRatingConverter from './Converters/RatingSeriesConverter';
import PriceSeriesConverter from './Converters/PriceSeriesConverter';
import TimeSeriesConverter from './TimeSeriesConverter';
import { OHLCVSeriesConverter } from './Converters';
import TimeSeriesOptions from './TimeSeriesOptions';


/* *
Expand All @@ -54,54 +49,52 @@ export class TimeSeriesConnector extends MorningstarConnector {


public constructor (
options: TimeSeriesOptions
options: TimeSeriesOptions = {}
) {
super(options);

switch (options.series?.type) {

case 'CumulativeReturn':
this.converter = new CumulativeReturnSeriesConverter({
this.converter = new Converters.CumulativeReturnSeriesConverter({
...options.converter,
...options.series
});
break;

case 'Dividend':
this.converter = new DividendSeriesConverter({
this.converter = new Converters.DividendSeriesConverter({
...options.converter,
...options.series
});
break;

case 'Growth':
this.converter = new GrowthSeriesConverter({
this.converter = new Converters.GrowthSeriesConverter({
...options.converter,
...options.series
});
break;

case 'Rating':
this.converter = new TimeSeriesRatingConverter({
this.converter = new Converters.RatingSeriesConverter({
...options.converter,
...options.series
});
break;

case 'Price':
this.converter = new PriceSeriesConverter({
this.converter = new Converters.PriceSeriesConverter({
...options.converter,
...options.series
});
break;

case 'OHLCV':
this.converter = new OHLCVSeriesConverter({
this.converter = new Converters.OHLCVSeriesConverter({
...options.converter,
...options.series,
securities: options.securities,
replaceZeroWithCloseValue: (options as OHLCVSeriesOptions)
.replaceZeroWithCloseValue
securities: options.securities
});
break;

Expand Down Expand Up @@ -136,6 +129,7 @@ export class TimeSeriesConnector extends MorningstarConnector {


public override async load (): Promise<this> {

await super.load();

const options = this.options;
Expand All @@ -151,7 +145,7 @@ export class TimeSeriesConnector extends MorningstarConnector {
}

const api = this.api = this.api || new MorningstarAPI(options.api);
const url = new MorningstarURL('/ecint/v1/' + this.converter.path, api.baseURL);
const url = new MorningstarURL('ecint/v1/' + this.converter.path, api.baseURL);

url.setSecuritiesOptions(securities);

Expand Down
Loading
Loading