Skip to content

Commit

Permalink
Add Balancing Reserve
Browse files Browse the repository at this point in the history
Add Balancing Reserve
  • Loading branch information
mattiamatrix authored Mar 19, 2024
2 parents 9785a54 + 733710e commit ec9ecae
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 23 deletions.
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ fail_fast: true

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-toml
- id: check-merge-conflict

- repo: https://github.com/psf/black
rev: 22.3.0
rev: 24.3.0
hooks:
- id: black

- repo: https://github.com/timothycrosley/isort
rev: 5.6.4
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort

- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies: [flake8-isort]
Expand Down
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"python.testing.pytestArgs": ["tests"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ r: bytes = client.query(date_col=date_col, start_date=start_date, end_date=end_d
* `dx-eac-eso-results-summary`
* `dx-eac-eso-sell-orders`
* `dx-eac-eso-buy-orders`
* `br-eac-eso-results-summary`
* `br-eac-eso-sell-orders`
* `br-eac-eso-buy-orders`
* `br-eac-eso-results-by-units`


### Download of files
Expand Down
2 changes: 1 addition & 1 deletion pyngeso/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .pyngeso import NgEso

__version__ = "0.3.6"
__version__ = "0.3.7"
2 changes: 1 addition & 1 deletion pyngeso/pyngeso.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def construct_filter_sql(filters: List[str], date_filtering: bool) -> str:
def validate_date_range(
start_date: Union[date, datetime], end_date: Union[date, datetime]
) -> None:
assert type(start_date) == type(
assert type(start_date) == type( # noqa: E721
end_date
), "start_date and end_date should either be both a date or a datetime object"

Expand Down
18 changes: 17 additions & 1 deletion pyngeso/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,23 @@
"dx-eac-eso-buy-orders": {
"id": "1cf68f59-8eb8-4f1d-bccf-11b5a47b24e5",
"url": "https://api.nationalgrideso.com/api/3/action/datastore_search",
}
},
"br-eac-eso-results-summary": {
"id": "1b3f2ee1-74a0-4939-a5a3-f01f19e663e4",
"url": "https://api.nationalgrideso.com/api/3/action/datastore_search",
},
"br-eac-eso-sell-orders": {
"id": "3f53c38b-d287-41af-b4c8-769abb6e707a",
"url": "https://api.nationalgrideso.com/api/3/action/datastore_search",
},
"br-eac-eso-buy-orders": {
"id": "8a549d29-52cd-4016-a04e-c01a3e31bd3a",
"url": "https://api.nationalgrideso.com/api/3/action/datastore_search",
},
"br-eac-eso-results-by-units": {
"id": "5d8e47be-e262-4398-89b0-6f93f636faf6",
"url": "https://api.nationalgrideso.com/api/3/action/datastore_search",
},
}

file_resource_ids: Dict[str, Dict[str, str]] = {
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyngeso"
version = "0.3.6"
version = "0.3.7"
description = "Simple python wrapper for the National Grid ESO Portal"
authors = [
"atsangarides <[email protected]>",
Expand Down
92 changes: 79 additions & 13 deletions tests/test_pyngeso.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def test_historic_generation_mix():
first_row = next(c)

assert "DATETIME" in headers_row
assert "2009-01-01 00:00:00" in first_row
assert "2009-01-01 00:00:00+00:00" in first_row
assert len(headers_row) == len(first_row)


Expand Down Expand Up @@ -232,8 +232,12 @@ def test_dc_volume_forecast():
end_date = date(2022, 5, 21)
filter_condition = "\"Service_Type\" = 'DC-L'"
client = NgEso("dc-volume-forecast")
r = client.query(date_col=date_col, start_date=start_date, end_date=end_date,
filters=[filter_condition])
r = client.query(
date_col=date_col,
start_date=start_date,
end_date=end_date,
filters=[filter_condition],
)

assert isinstance(r, bytes)
r_dict = json.loads(r)
Expand All @@ -251,8 +255,9 @@ def test_dcmr_block_orders():
start_date = date(2022, 5, 16)
end_date = date(2022, 5, 17)
client = NgEso("dc-dr-dm-block-orders")
r = client.query(date_col=date_col, start_date=start_date, end_date=end_date,
filters=[])
r = client.query(
date_col=date_col, start_date=start_date, end_date=end_date, filters=[]
)

assert isinstance(r, bytes)
r_dict = json.loads(r)
Expand All @@ -269,8 +274,9 @@ def test_dcmr_linear_orders():
start_date = date(2022, 5, 16)
end_date = date(2022, 5, 17)
client = NgEso("dc-dr-dm-linear-orders")
r = client.query(date_col=date_col, start_date=start_date, end_date=end_date,
filters=[])
r = client.query(
date_col=date_col, start_date=start_date, end_date=end_date, filters=[]
)

assert isinstance(r, bytes)
r_dict = json.loads(r)
Expand Down Expand Up @@ -356,9 +362,12 @@ def test_dx_eac_eso_results_summary():
assert isinstance(r, bytes)
r_dict = json.loads(r)
records = r_dict.get("result").get("records")

for r in records:
print(r)
assert isinstance(records, list)
assert len(records) > 0
assert len(records) == 36
assert len(records) == 42


@pytest.mark.vcr
Expand All @@ -381,11 +390,69 @@ def test_dx_eac_eso_sell_orders():


@pytest.mark.vcr
def test_dx_eac_eso_buy_orders():
def test_br_eac_eso_results_summary():
date_col = "deliveryStart"
start_date = datetime(2023, 11, 2, 23)
end_date = datetime(2023, 11, 3, 23)
client = NgEso("dx-eac-eso-buy-orders")
start_date = datetime(2024, 3, 14, 23)
end_date = datetime(2024, 3, 15, 23)
client = NgEso("br-eac-eso-results-summary")
r = client.query(
date_col=date_col,
start_date=start_date,
end_date=end_date,
)

assert isinstance(r, bytes)
r_dict = json.loads(r)
records = r_dict.get("result").get("records")
assert isinstance(records, list)
assert len(records) > 0
assert len(records) == 98


@pytest.mark.vcr
def test_br_eac_eso_sell_orders():
date_col = "deliveryStart"
start_date = datetime(2024, 3, 14, 23)
end_date = datetime(2024, 3, 15, 23)
client = NgEso("br-eac-eso-sell-orders")
r = client.query(
date_col=date_col,
start_date=start_date,
end_date=end_date,
)

assert isinstance(r, bytes)
r_dict = json.loads(r)
records = r_dict.get("result").get("records")
assert isinstance(records, list)
assert len(records) > 0


@pytest.mark.vcr
def test_br_eac_eso_buy_orders():
date_col = "deliveryStart"
start_date = datetime(2024, 3, 14, 23)
end_date = datetime(2024, 3, 15, 23)
client = NgEso("br-eac-eso-buy-orders")
r = client.query(
date_col=date_col,
start_date=start_date,
end_date=end_date,
)

assert isinstance(r, bytes)
r_dict = json.loads(r)
records = r_dict.get("result").get("records")
assert isinstance(records, list)
assert len(records) > 0


@pytest.mark.vcr
def test_br_eac_eso_results_by_units():
date_col = "deliveryStart"
start_date = datetime(2024, 3, 14, 23)
end_date = datetime(2024, 3, 15, 23)
client = NgEso("br-eac-eso-results-by-units")
r = client.query(
date_col=date_col,
start_date=start_date,
Expand All @@ -397,4 +464,3 @@ def test_dx_eac_eso_buy_orders():
records = r_dict.get("result").get("records")
assert isinstance(records, list)
assert len(records) > 0

0 comments on commit ec9ecae

Please sign in to comment.