Skip to main content

Library provides read access to the Artesian API

Project description

image

Artesian.SDK

This Library provides read access to the Artesian API

Getting Started

Installation

You can install the package directly from pip.

pip install artesian-sdk

Alternatively, to install this package go to the release page .

How to use

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

from Artesian import *

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

QueryService

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

Actual Time Series

from Artesian import *

qs = QueryService(cfg);
data = qs.createActual() \
    .forMarketData([100011484,100011472,100011477,100011490,100011468,100011462,100011453]) \
    .inAbsoluteDateRange("2018-01-01","2018-01-02") \
    .inTimeZone("UTC") \
    .inGranularity(Granularity.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

from Artesian import *

qs = QueryService(cfg);
q = qs.createVersioned() \
    .forMarketData([100042422,100042283,100042285,100042281,100042287,100042291,100042289]) \
    .inAbsoluteDateRange("2018-01-01","2018-01-02") \
    .inTimeZone("UTC") \
    .inGranularity(Granularity.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()
q.forMostRecent("2019-03-12","2019-03-16").execute()
q.forMostRecent("2019-03-12T12:30:05","2019-03-16T18:42:30").execute()
q.forMostRecent("P0Y0M-2D","P0Y0M2D").execute()
q.forMostRecent("P0Y0M-2D").execute()
q.forMostRecent("2019-03-12","2019-03-16").execute()
q.forMostRecent("P0Y-1M0D","P0Y1M0D").execute()
q.forMostRecent("P0Y-1M0D").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

from Artesian import *

qs = QueryService(cfg);
data = qs.createMarketAssessment() \
    .forMarketData([100000032,100000043]) \
    .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

Bid Ask Time Series

from Artesian import *

qs = QueryService(cfg);
data = qs.createBidAsk() \
    .forMarketData([100000032,100000043]) \
    .forProducts(["D+1","Feb-18"]) \
    .inAbsoluteDateRange("2018-01-01","2018-01-02") \
    .execute()

To construct a Bid Ask 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

from Artesian import *

qs = QueryService(cfg);
data = qs.createAuction() \
    .forMarketData([100011484,100011472,100011477,100011490,100011468,100011462,100011453]) \
    .inAbsoluteDateRange("2018-01-01","2018-01-02") \
    .inTimeZone("UTC") \
    .execute()

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

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

Go to Time Extraction window section

Artesian SDK Extraction Windows

Extraction window types for queries.

Date Range

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

Relative Interval

 .inRelativeInterval(RelativeInterval.ROLLING_WEEK)

Period

 .inRelativePeriod("P5D")

Period Range

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

Filler Strategy

All extraction types (Actual,Versioned, Market Assessment and BidAsk) have an optional filler strategy.

var versionedSeries = qs        
  .createVersioned() \
  .forMarketData([100000001]) \
  .forLastNVersions(1) \
  .inGranularity(Granularity.Day) \
  .inAbsoluteDateRange(new Date("2018-1-1"), new Date("2018-1-10")) \
  .withFillLatestValue("P5D") \
  .execute()

Null

 .withFillNull()

None

 .withFillNone()

Custom Value

 //Timeseries
 .withFillCustomValue(123)
 // Market Assessment
 .withFillCustomValue(
    settlement = 123,
    open = 456,
    close = 789,
    high = 321,
    low = 654,
    volumePaid = 987,
    volueGiven = 213,
    volume = 435,
  )

Latest Value

 .withFillLatestValue("P5D")

MarketData Service

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

from Artesian import *

mds = MarketDataService(cfg);

To list MarketData curves

page = 1
pageSize = 100
res = mds.readCurveRange(100042422, page, pageSize, versionFrom="2016-12-20" , versionTo="2019-03-12")

Jupyter

Artesian SDK uses asyncio internally, this causes a conflict with Jupyter. You can work around this issue by add the following at the beginning of the notebook.

!pip install nest_asyncio

import nest_asyncio
nest_asyncio.apply()

Issue #3397 with workaround

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

artesian-sdk-2.2.4.tar.gz (18.7 kB view hashes)

Uploaded Source

Built Distribution

artesian_sdk-2.2.4-py3-none-any.whl (33.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page