Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tutorial] add basic example of EOM and LTM comparison #265

Merged
merged 10 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
4 changes: 3 additions & 1 deletion assume/common/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,9 @@ def calculate_cashflow(self, product_type: str, orderbook: Orderbook):
cashflow * self.index.freq.n
)
else:
cashflow = float(order["accepted_price"] * order["accepted_volume"])
cashflow = float(
order.get("accepted_price", 0) * order.get("accepted_volume", 0)
)
hours = (end - start) / timedelta(hours=1)
self.outputs[f"{product_type}_cashflow"].loc[start:end_excl] += (
cashflow * hours
Expand Down
5 changes: 4 additions & 1 deletion assume/markets/base_market.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,10 @@
self.all_orders = []
for order in rejected_orderbook:
order["accepted_volume"] = 0
order["accepted_price"] = market_meta[0]["price"]
if len(market_meta) > 0:
order["accepted_price"] = market_meta[0]["price"]
else:
order["accepted_price"] = 0

Check warning on line 444 in assume/markets/base_market.py

View check run for this annotation

Codecov / codecov/patch

assume/markets/base_market.py#L444

Added line #L444 was not covered by tests
self.open_auctions - set(market_products)

accepted_orderbook.sort(key=itemgetter("agent_id"))
Expand Down
2 changes: 1 addition & 1 deletion assume/markets/clearing_algorithms/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def clear(
rejected_orders.append(demand_order)
continue

assert dem_vol == gen_vol
# assert dem_vol == gen_vol
# now add the next demand order
dem_vol += -demand_order["volume"]
demand_order["accepted_volume"] = demand_order["volume"]
Expand Down
5 changes: 3 additions & 2 deletions assume/scenario/loader_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-or-later

import logging
from datetime import datetime
from datetime import datetime, timedelta
from typing import Optional, Tuple

import dateutil.rrule as rr
Expand Down Expand Up @@ -283,7 +283,8 @@ async def load_scenario_folder_async(

index = pd.date_range(
start=start,
end=end,
# end time needs to be a little ahead for forecasts
end=end + timedelta(days=1),
freq=config["time_step"],
)
# get extra parameters for bidding strategies
Expand Down
1 change: 1 addition & 0 deletions assume/scenario/loader_oeds.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# SPDX-FileCopyrightText: ASSUME Developers
#
# SPDX-License-Identifier: AGPL-3.0-or-later

import logging
import os
import shutil
Expand Down
1 change: 1 addition & 0 deletions docs/source/examples/05_market_comparison.nblink
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"path": "../../../examples/notebooks/05_market_comparison.ipynb"}
3 changes: 3 additions & 0 deletions docs/source/examples/05_market_comparison.nblink.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: ASSUME Developers

SPDX-License-Identifier: AGPL-3.0-or-later
1 change: 1 addition & 0 deletions docs/source/examples_basic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ Here you can find several tutorials on how to use ASSUME framework to get you st
examples/01_minimal_manual_example.nblink
examples/02_automated_run_example.nblink
examples/04_Reinforcement_learning_example.nblink
examples/05_market_comparison.nblink
35,041 changes: 35,041 additions & 0 deletions examples/inputs/example_02c/availability_df.csv

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions examples/inputs/example_02c/availability_df.csv.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: ASSUME Developers

SPDX-License-Identifier: AGPL-3.0-or-later
58 changes: 58 additions & 0 deletions examples/inputs/example_02c/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# SPDX-FileCopyrightText: ASSUME Developers
#
# SPDX-License-Identifier: AGPL-3.0-or-later

eom_case:
start_date: 2019-01-01 00:00
end_date: 2019-01-21 00:00
time_step: 1h
markets_config:
EOM:
operator: EOM_operator
product_type: energy

products:
- duration: 1h
count: 1
first_delivery: 1h
opening_frequency: 1h
opening_duration: 1h
volume_unit: MWh
maximum_volume: 1000000
price_unit: EUR/MWh
market_mechanism: pay_as_clear
ltm_case:
start_date: 2019-01-01 00:00
end_date: 2019-01-21 00:00
time_step: 1h
markets_config:
EOM:
operator: EOM_operator
product_type: energy
start_date: 2018-12-31 23:00
products:
- duration: 1h
count: 1
first_delivery: 1h
opening_frequency: 1h
opening_duration: 1h
volume_unit: MWh
maximum_volume: 1000000
price_unit: EUR/MWh
market_mechanism: pay_as_clear

# Long Term Market - 7d contracts
LTM_OTC:
operator: LTM_operator
product_type: energy
start_date: 2018-12-31 22:00
products:
- duration: 7d
count: 1
first_delivery: 2h
opening_frequency: 7d
opening_duration: 1h
volume_unit: MW
maximum_volume: 1000000
price_unit: EUR/MW
market_mechanism: pay_as_bid
Loading