Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Add market data download tool #1105

Merged
merged 30 commits into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
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
71 changes: 71 additions & 0 deletions docs/Utilities/Market_data.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
[[/Utilities/Market_data]] - ISO market data download tool

# Synopsis

Shell:

bash$ gridlabd market_data [-m|--market=MARKETNAME] [-d|--node=NODE] [-s|--startdate=STARTDATE]
[-e|--enddate=ENDDATE] [-h|--help|help] [--credentials[=FILENAME.json]]
[-n|--name=OBJNAME] [-c|--csv=CSVFILE] [-g|--glm=GLMFILE]

GLM:

#python -m market_data [-m|--market=MARKETNAME] [-d|--node=NODE] [-s|--startdate=STARTDATE]
[-e|--enddate=ENDDATE] [-h|--help|help] [--credentials[=FILENAME.json]]
[-n|--name=OBJNAME] [-c|--csv=CSVFILE] [-g|--glm=GLMFILE]

Python:

bash$ gridlabd python
>>> import market_data as md
>>> data = md.get_market_data(MARKETNAME,NODE,STARTDATE,ENDDATE[,CREDENTIALS])
>>> md.write_csv(data,CSVNAME)
>>> md.write_glm(data,GLMNAME,[NAME])

# Description

The market_data tool obtain wholesale electricity market price data from
independent system operators (ISO). The ISO must be specified using the
MARKETNAME parameter. Currently supported markets are "CAISO" and "ISONE".

In addition, the NODE must be specified when obtaining locational price data.
Lists of node names may be obtained from the market websites. For CAISO see
http://www.caiso.com/TodaysOutlook/Pages/prices.html for a map of available
price nodes. For ISONE see https://www.iso-ne.com/markets-operations/settlements/pricing-node-tables/

The STARTDATE and ENDDATE value must be specified in the form "YYYYMMDD".

When the `--credentials` option is used without parameters, the user is
prompted for a username and password. When run from a terminal window, a
browser window is automatically opened for the specific ISO website to
facilitate obtaining the username and password. The result is stored in the
default credentials file for GridLAB-D ISO credentials
(i.e., `$HOME/.gridlabd/iso_credentials.json`). When FILENAME is provided
with the credentials option, the credentials are loaded from the specified
file instead. Currently only the ISONE API requires credentials. For
example, to generate credentials for ISONE, use the command

bash$ gridlabd market_data -m=ISONE --credentials

By default the CSV data is output to the stdout, which may be redirected to a
file. If no GLM file is specified, then the CSV will contain a header row
indicating which columns contain the price and quantity data. If a GLM file
is specified, then the CSV data must be output to a file. By default the
GridLAB-D object name for the market data is generated automatically to
ensure it is unique. The object name may be specified using the `--name`
option.

# Example

bash$ gridlabd market_data -m=CAISO -d=0096WD_7_N001 -s=20220222 -e=20220223
START_TIME_PST,LMP,MW
2022-02-22 00:00:00,50.0,21372.0
2022-02-22 00:05:00,50.9,21372.0
2022-02-22 00:10:00,50.3,21372.0
2022-02-22 00:15:00,49.8,21372.0
...

# See also

* [CAISO](https://caiso.com/)
* [ISONO](https://isone.com/)
25 changes: 0 additions & 25 deletions gldcore/load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7981,31 +7981,6 @@ int GldLoader::process_macro(char *line, int size, char *_filename, int linenum)
return TRUE;
}
}
else if (strncmp(line,"#exec",5)==0)
{
char *term = strchr(line+5,' ');
char value[1024];
if (term==NULL)
{
syntax_error(filename,linenum,"#system missing system call");
strcpy(line,"\n");
return FALSE;
}
strcpy(value, strip_right_white(term+1));
IN_MYCONTEXT output_debug("%s(%d): executing system(char *cmd='%s')", filename, linenum, value);
global_return_code = system(value);
if( global_return_code != 0 )
{
syntax_error(filename,linenum,"error executing system(char *cmd='%s') -> non-zero exit code (status=%d)", value, global_return_code);
strcpy(line,"\n");
return FALSE;
}
else
{
strcpy(line,"\n");
return TRUE;
}
}
else if (strncmp(line,"#gridlabd",9)==0)
{
char *term = strchr(line+9,' ');
Expand Down
1 change: 1 addition & 0 deletions python_extras/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dist_pkgdata_DATA += python_extras/fit_filter.py
dist_pkgdata_DATA += python_extras/gridlabd-editor.png
dist_pkgdata_DATA += python_extras/gridlabd-editor.py
dist_pkgdata_DATA += python_extras/insights.py
dist_pkgdata_DATA += python_extras/market_data.py
dist_pkgdata_DATA += python_extras/metar2glm.py
dist_pkgdata_DATA += python_extras/noaa_forecast.py
dist_pkgdata_DATA += python_extras/nsrdb_weather.py
Expand Down
28 changes: 28 additions & 0 deletions python_extras/example/caiso_data.glm
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// example market_data from CAISO

#python -m market_data -m=CAISO -d=0096WD_7_N001 -s=20220222 -e=20220223 -c=/tmp/test.csv -g=/tmp/test.glm

clock
{
timezone "PST+8PDT";
starttime "2022-02-22 00:00:00 PST";
stoptime "2022-02-23 00:00:00 PST";
}

module tape
{
csv_header_type NAME;
}

#include "/tmp/test.glm"

#for MARKET in ${MARKET_DATA}
object recorder
{
parent ${MARKET};
property "LMP,MW";
file "/tmp/test_${MARKET}.csv";
}
#print saved ${MARKET} LMP and MW to /tmp/test_${MARKET}.csv
#done

28 changes: 28 additions & 0 deletions python_extras/example/isone_data.glm
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// example market_data from CAISO

#python -m market_data -m=ISONE -d=4001 -s=20220222 -e=20220223 -c=/tmp/test.csv -g=/tmp/test.glm

clock
{
timezone "EST+5EDT";
starttime "2022-02-22 00:00:00 EST";
stoptime "2022-02-23 00:00:00 EST";
}

module tape
{
csv_header_type NAME;
}

#include "/tmp/test.glm"

#for MARKET in ${MARKET_DATA}
object recorder
{
parent ${MARKET};
property "LMP,MW";
file "/tmp/test_${MARKET}.csv";
}
#print saved ${MARKET} LMP and MW to /tmp/test_${MARKET}.csv
#done

Loading