Skip to content

Latest commit

 

History

History
635 lines (467 loc) · 14.4 KB

README.md

File metadata and controls

635 lines (467 loc) · 14.4 KB

image

Artesian.SDK

This Library provides read access to the Artesian API

Getting Started

Installation

You can install the toolbox directly from the Matlab File Exchange.

Alternatively, to install this package go to the release page and download the Artesian.SDK.mltbx file and double click on it to install in Matlab.

How to use

The Artesian.SDK instance can be configured using API-Key authentication

cfg = ArtesianServiceConfig("https://fake-artesian-env/", "{api-key}");

QueryService

Using the ArtesianServiceConfig we create an instance of the QueryService which is used to create Actual, Versioned and Market Assessment time series queries

Actual Time Series

qs = QueryService(cfg);
data = qs.CreateActual() ...
       .ForMarketData([100000001,100000002,100000003]) ...
       .InAbsoluteDateRange("2018-01-01","2018-01-02") ...
       .InTimeZone("UTC") ...
       .InGranularity(GranularityEnum.Hour) ...
       .Execute()

To construct an Actual Time Series the following must be provided.

Actual QueryDescription
Market Data IDProvide a market data id or set of market data id's to query
Time GranularitySpecify the granularity type
Time Extraction WindowAn extraction time window for data to be queried

Go to Time Extraction window section

Versioned Time Series

qs = QueryService(cfg);
q = qs.CreateVersioned() ...
       .ForMarketData([100000004,100000005,100000006]) ...
       .InAbsoluteDateRange("2018-01-01","2018-01-02") ...
       .InTimeZone("UTC") ...
       .InGranularity(GranularityEnum.Hour);


q.ForMUV().Execute()
q.ForLastNVersions(2).Execute()
q.ForLastOfDays("2019-03-12","2019-03-16").Execute()
q.ForLastOfDays("P0Y0M-2D","P0Y0M2D").Execute()
q.ForLastOfDays("P0Y0M-2D").Execute()
q.ForLastOfMonths("2019-03-12","2019-03-16").Execute()
q.ForLastOfMonths("P0Y-1M0D","P0Y1M0D").Execute()
q.ForLastOfMonths("P0Y-1M0D").Execute()
q.ForVersion("2019-03-12T14:30:00").Execute()

To construct a Versioned Time Series the following must be provided.

Versioned QueryDescription
Market Data IDProvide a market data id or set of market data id's to query
Time GranularitySpecify the granularity type
Versioned Time Extraction WindowVersioned extraction time window
Time Extraction WindowAn extraction time window for data to be queried

Go to Time Extraction window section

Market Assessment Time Series

qs = QueryService(cfg);
data = qs.CreateMarketAssessment() ...
       .ForMarketData([100000007,100000008]) ...
       .ForProducts(["D+1","Feb-18"]) ...
       .InAbsoluteDateRange("2018-01-01","2018-01-02") ...
       .Execute()

To construct a Market Assessment Time Series the following must be provided.

Mas QueryDescription
Market Data IDProvide a market data id or set of market data id's to query
ProductProvide a product or set of products
Time Extraction WindowAn extraction time window for data to be queried

Go to Time Extraction window section

Auction Time Series

qs = QueryService(cfg);

data = qs.CreateAuction() ...
  .ForMarketData([100000001]) ...
  .InAbsoluteDateRange("2020-03-01", "2020-04-01") ...
  .Execute();

To construct an Auction Time Series the following must be provided.

Auction Query Description
Market Data ID Provide a market data id or set of market data id's to query
Time Extraction Window An extraction time window for data to be queried

Artesian SDK Extraction Windows

Extraction window types for queries.

Date Range

 .InAbsoluteDateRange("2018-08-01", "2018-08-10")

Relative Interval

 .InRelativeInterval(RelativeIntervalEnum.RollingMonth)

Period

 .InRelativePeriod("P5D")

Period Range

 .InRelativePeriodRange("P-3D", "P10D")

MarketData Service

Using the ArtesianServiceConfig cfg we create an instance of the MarketDataService which is used to retrieve MarketData infos.

mds = MarketDataService(cfg);

MarketData Acl

AddRoles

user = AclPrincipal(PrincipalTypeEnum.User, "[email protected]");
mds.Acl.AddRoles(Acl("/system/marketdata/", {AclRoles("Reader", user)}))

RemoveRoles

user = AclPrincipal(PrincipalTypeEnum.User, "[email protected]");
mds.Acl.RemoveRoles(Acl("/system/marketdata/", {AclRoles("Reader", user)}))

Get

mds.Acl.GetRoles(
  1, % page
  10, % pageSize
  {"[email protected]"} % principalIds
);

mds.Acl.ReadRolesByPath(
  "/system/marketdata/", % path
);

MarketData Admin

Create

mds.Admin.Create(
  AuthGroup("Test group", {"[email protected]", "[email protected]"})
);

Update

mds.Admin.Update(
  1000, % groupId
  AuthGroup("Test group", {"[email protected]", "[email protected]"})
);

Remove

mds.Admin.Remove(
  1000 % groupId
);

Get

mds.Admin.GetById(
  1000 % groupId
);

mds.Admin.Get(
  1, % page
  10 % pageSize
);

mds.Admin.ReadUserPrincipals(
  "[email protected]"
);

MarketData ApiKey

Create

mds.ApiKey.Create(
  ApiKey("2020-02-10T00:00:00Z", "Api key Description")
);

Delete

mds.ApiKey.Delete(
  1000 % apiKeyId
);

Get

mds.ApiKey.GetById(
  1000 % apiKeyId
);

mds.ApiKey.GetByUserId(
  1, % page
  10, % pageSize
  "[email protected]"
);

MarketData CustomFilter

Create

filter = {};
filter.test = {"1"};
filter.test2 = {"2"};
mds.CustomFilter.Create(CustomFilter("test filter2","search test", filter))

Update

filter = {};
filter.type = {"VersionedTimeSerie"};
filter.providerName = {"JAO"};

mds.CustomFilter.Update(
  1000, % filterId
  CustomFilter("filter name", "search text", filter)
);

Delete

mds.CustomFilter.Delete(
  1000 % filterId
);

Get

mds.CustomFilter.GetById(
  1000 % filterId
);

mds.CustomFilter.Get(
  1, % page
  10 % pageSize
);

MarketData SearchFacet

filter = {};
filter.page = 1;
filter.pageSize = 10;
filter.searchText = "Search";
filter.sorts = "MarketDataName asc";
innerFilter = {}
innerFilter.ProviderName = "JAO"
filter.filters = innerFilter;

mds.SearchFacet.Search(
  filter
);

MarketData TimeTransform

Create

mds.TimeTransform.Create(TimeTransform("MatTest", TransformTypeEnum.SimpleShift, "1D", "1D","3D"))

Update

mds.TimeTransform.Update(
  1000, % timeTransformId
  TimeTransform("MatTest", TransformTypeEnum.SimpleShift, "1D", "1D","3D")
);

Delete

mds.TimeTransform.Delete(
  1000 % timeTransformId
);

Get

mds.TimeTransform.GetById(
  1000 % timeTransformId
);

mds.TimeTransform.Get(
  1, % page
  10, % pageSize
  true % userDefined
);

MarketData MarketDataRegistry

Create

data = MarketDataEntityInput("testMatlab", ...
    "testmatlabcurveVer", ...
    "Day", ...
    "CET", ...
    AggregationRuleEnum.Undefined, ...
    MarketDataTypeEnum.ActualTimeSerie ...
);

mds.MarketData.Create(data);

Update

data = MarketDataEntityInput("testMatlab", ...
    "testmatlabcurveVer", ...
    "Day", ...
    "CET", ...
    AggregationRuleEnum.Undefined, ...
    MarketDataTypeEnum.ActualTimeSerie ...
);
data.MarketDataId = "100000001";

mds.MarketData.Update(data);

Delete

mds.MarketData.Delete(
  100000001 % marketDataId
);

Get

mds.MarketData.GetById(
  100000001 % marketDataId
);

mds.MarketData.GetByProviderName(
  MarketDataIdentifier("Provider","CurveName")
);

page = 1;
pageSize = 100;
res = mds.MarketData.ReadCurveRange(100000004, page, pageSize);

MarketData UpsertCurve

Upsert Actual

rows = [];
rows = [rows {{"2022-01-01T00:00:00", 1}}];
rows = [rows {{"2022-01-02T00:00:00", 2}}];

id = MarketDataIdentifier("ArkLab","ActualCurve");
data = UpsertCurveDataActual(id, "CET", "2022-01-01T00:00:00Z", rows);
mds.UpsertCurve.Upsert(data);

Upsert Versioned

rows = [];
rows = [rows {{"2022-01-01T00:00:00", 1}}];
rows = [rows {{"2022-01-02T00:00:00", 2}}];

id = MarketDataIdentifier("ArkLab","VersionedCurve");
data = UpsertCurveDataVersioned(id, "2022-01-01T00:00:00","CET", "2022-01-01T00:00:00Z", rows);
mds.UpsertCurve.Upsert(data);

Upsert MarketAssessment

Market assessment product fields:

  • settlement
  • open
  • close
  • high
  • low
  • volumePaid
  • volumeGiven
  • volume
rows = [];
rows = [rows {{"2022-01-01T00:00:00" {{"Jan-22" {{"open" 6}, {"close" 7}}}}}}];

id = MarketDataIdentifier("ArkLab","MarketAssessmentCurve");
data = UpsertCurveDataMarketAssessment(id, "CET", "2022-01-01T00:00:00Z", rows);
mds.UpsertCurve.Upsert(data);

Upsert BidAsk

BidAsk product fields:

  • bestBidPrice
  • bestAskPrice
  • bestBidQuantity
  • bestAskQuantity
  • lastPrice
  • lastQuantity
rows = [];
rows = [rows {{"2022-01-01T00:00:00" {{"Jan-22" {{"bestBidPrice" 6}, {"bestBidQuantity" 7}}}}}}];

id = MarketDataIdentifier("ArkLab","BidAskCurve");
data = UpsertCurveDataBidAsk(id, "CET", "2022-01-01T00:00:00Z", rows);
mds.UpsertCurve.Upsert(data);

Upsert Auction

rows = [];
rows = [rows {{"2022-01-01T00:00:00", AuctionBid("2022-01-01T00:00:00", {{1 1}}, {{2 2}})}}];

id = MarketDataIdentifier("ArkLab", "AuctionCurve");
data = UpsertCurveDataAuction(id, "CET", "2022-01-01T00:00:00Z", rows);

MarketData DeleteCurve

Delete Actual

id = MarketDataIdentifier("ArkLab","ActualCurve");
data = DeleteCurveDataActual(id, "CET", "2022-01-01T00:00:00", "2022-01-02T00:00:00");
mds.DeleteCurve.Delete(data);

To delete the whole range, just call the DeleteCurveDataActual, without date range

id = MarketDataIdentifier("ArkLab","ActualCurve");
data = DeleteCurveDataActual(id, "CET");
mds.DeleteCurve.Delete(data);

Delete Versioned

id = MarketDataIdentifier("ArkLab","VersionedCurve");
data = DeleteCurveDataVersioned(id, "2022-01-01T00:00:00", "CET", "2022-01-01T00:00:00", "2022-01-02T00:00:00");
mds.DeleteCurve.Delete(data);

To delete the whole range, just call the DeleteCurveDataVersioned, without date range

id = MarketDataIdentifier("ArkLab","VersionedCurve");
data = DeleteCurveDataVersioned(id, "2022-01-01T00:00:00", "CET");
mds.DeleteCurve.Delete(data);

Delete MarketAssessment

id = MarketDataIdentifier("ArkLab","MarketAssessmentCurve");
product = {"Jan-22"};

data = DeleteCurveDataMarketAssessment(id, "CET", product, "2022-01-01T00:00:00", "2022-01-02T00:00:00");
mds.DeleteCurve.Delete(data);

To delete the whole range, just call the DeleteCurveDataMarketAssessment, without date range

id = MarketDataIdentifier("ArkLab","MarketAssessmentCurve");
data = DeleteCurveDataMarketAssessment(id, "CET", product);
mds.DeleteCurve.Delete(data);

Delete BidAsk

id = MarketDataIdentifier("ArkLab","BidAskCurve");
product = {"Jan-22"};

data = DeleteCurveDataBidAsk(id, "CET", product, "2022-01-01T00:00:00", "2022-01-02T00:00:00");
mds.DeleteCurve.Delete(data);

To delete the whole range, just call the DeleteCurveDataBidAsk, without date range

id = MarketDataIdentifier("ArkLab","BidAskCurve");
data = DeleteCurveDataBidAsk(id, "CET", product);
mds.DeleteCurve.Delete(data);

Delete Auction

id = MarketDataIdentifier("ArkLab", "AuctionCurve");
data = DeleteCurveDataAuction(id, "CET", "2022-01-01T00:00:00", "2022-01-02T00:00:00");

To delete the whole range, just call the DeleteCurveDataAuction, without date range

id = MarketDataIdentifier("ArkLab","AuctionCurve");
data = DeleteCurveDataAuction(id, "CET");
mds.DeleteCurve.Delete(data);

GMEPublicOffer Service

Using the ArtesianServiceConfig cfg we create an instance of the GMEPublicOfferService which is used to retrieve MarketData infos.

gme = GMEPublicOfferService(cfg);

GMEPublicOfferQuery

Create a GMEPublicOfferQuery using the GMEPublicOfferService.

gme.CreateGMEPublicOfferQuery() ...
   .ForDate("2020-04-01") ...
   .ForPurpose(Purpose.BID) ...
   .ForStatus(Status.ACC) ...
   .Execute()

GME Public Offer Required Filters

GME Public Offer Query Description
ForDate Provide a date for extraction
ForPurpose Provide a purpose (BID or OFF) for extraction
ForStatus Provide a status for extraction

GME Public Offer Optional Filters

GME Public Offer Query Description
ForOperator Provide a list of Operators (string[])
ForUnit Provide a list of Units (string[])
ForMarket Provide a list of Markets (Market[])
ForScope Provide a list of Scopes (Scope[])
ForBAType Provide a list of BATypes (BAType[])
ForZone Provide a list of Zones (Zone[])
ForUnitType Provide a list of UnitTypes (UnitType[])
ForGenerationType Provide a list of GenerationTypes (GenerationType[])
WithPagination Provide paging info (uint32 page, uint32 pageSize)

Links