FORWARD CURVE Module¶
Performs API requests to KYOS API and stores the curve inputs in a generalized format in CSV files or returns a (pandas.DataFrame)
Changelog¶
Version | Description |
---|---|
4.2.0 | Allow submonthly granularity curves in get_curve_api method |
2.0.1 | only create ForwardCurves directory if isCSVWrite is true |
1.6.7 | Create a dataframe instead of CSV files, when the isCSVWrite argument of the get_curve_api module is 0. |
1.6.6 | Module get_curve_api added. |
Documentation¶
get_curve_api(fwdCurveID, granularityID, deliveryTypes, tradingDates, isCSVWrite)
¶
Performs API requests to KYOS API and stores the curve inputs in a generalized format in CSV files or returns a pandas.DataFrame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fwdCurveID
|
int
|
id of the curve profile |
required |
granularityID
|
int
|
half-hour:1, hour:2, day:3, month:5 |
required |
deliveryTypes
|
list | int
|
list of delivery type ids(int array), base load:1, peak:2, off-peak:3 |
required |
tradingDates
|
list
|
list of trading dates(string array) e.g. ['2019-01-01', '2019-01-02', '2019-01-03'] |
required |
isCSVWrite
|
bool
|
indicator of creating csv files, 0 or 1, we will provide a DataFrame in case of zero. |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
Contains all requested curves. If isCSVWrite equals 1 then the dataframe will be empty and the curves will be saved as CSV files on the disk in directory ./ForwardCurves. |
Note
KYOS API provides the curves with the daylight saving switches for the half-hourly and hourly curves. KYOS API supports base load, peak and off-peak delivery types only for monthly granularity.
Examples:
>>> from kyoslib_py.forward_curve import get_curve_api
>>> arg = {'fwdCurveID': 4, 'granularityID': 5, 'deliveryTypes': [1, 2, 3],
>>> 'tradingDates': ['2019-01-01', '2019-01-02'], 'isCSVWrite': 1}
>>> curves_df = get_curve_api(**arg)
>>> arg = {'fwdCurveID': 4, 'granularityID': 5, 'deliveryTypes': 1 ,
>>> 'tradingDates': '2019-01-01', 'isCSVWrite': 1}
>>> curves_df2 = get_curve_api(**arg)
write_curve_to_csv(curves, delTypes, grID, fullFileName)
¶
Stores the forward curves in generalized data format on the disk in ./ForwardCurves directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
curves
|
dict
|
HTTP response body which provided by kyos_api.call_kyos_api_v1 |
required |
delTypes
|
list
|
baseload:1, peak:2, offpeak:3 |
required |
grID
|
int
|
granularity id of the requested forward curve(e.g. half-hour:1, hour:2, day:3, month:5) |
required |
fullFileName
|
str
|
full path of the file(e.g. "./ForwardCurves/ForwardCurveDaily_2_20200101") |
required |
Note
The current implementation allows to store only data based on monthly granularity.
Examples:
>>> from kyoslib_py.forward_curve import write_curve_to_csv
>>> curves = {}
>>> data = {}
>>> month = {}
>>> baseload = [{'date':'2020-01-01', 'value':20.2}, {'date':'2020-02-01', 'value':30.3}]
>>> month['baseload'] = baseload
>>> data['month'] = month
>>> curves['data'] = data
>>> write_curve_to_csv(curves, [1, 2, 3], 5, "./ForwardCurves/ForwardCurveMonthlyDeliveryTypes_2_20200101")