eptr2 1.1.4.dev0__tar.gz → 1.2.0.dev0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- eptr2-1.2.0.dev0/.gitignore +167 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/PKG-INFO +19 -19
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/README.md +3 -0
- eptr2-1.2.0.dev0/eptr2/tutorials/composite/pages/4_/360/237/222/260_Fiyat_ve_Maliyetler.py +147 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/tutorials/composite//342/255/220/357/270/217_Ana_Sayfa.py +16 -1
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/util/time.py +62 -5
- eptr2-1.2.0.dev0/pyproject.toml +40 -0
- eptr2-1.2.0.dev0/tests/__init__.py +5 -0
- eptr2-1.2.0.dev0/tests/composite/__init__.py +0 -0
- eptr2-1.2.0.dev0/tests/composite/test_consumption.py +32 -0
- eptr2-1.2.0.dev0/tests/composite/test_mms.py +37 -0
- eptr2-1.2.0.dev0/tests/composite/test_price_and_cost.py +57 -0
- eptr2-1.2.0.dev0/tests/composite/test_production.py +34 -0
- eptr2-1.2.0.dev0/uv.lock +1291 -0
- eptr2-1.1.4.dev0/pyproject.toml +0 -30
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/LICENSE +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/__init__.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/composite/__init__.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/composite/bpm.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/composite/consumption.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/composite/dabi_idm.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/composite/idm_log.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/composite/mms.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/composite/price_and_cost.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/composite/production.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/main.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/mapping/__init__.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/mapping/checks.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/mapping/help.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/mapping/parameters.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/mapping/path.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/mapping/processing.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/processing/__init__.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/processing/postprocess/__init__.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/processing/postprocess/items.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/processing/preprocess/__init__.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/processing/preprocess/calls.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/processing/preprocess/params.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/tutorials/__init__.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/tutorials/calc.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/tutorials/composite/__init__.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/tutorials/composite/common.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/tutorials/composite/pages/1_/360/237/221/251/342/200/215/360/237/222/273_Demo.py" +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/tutorials/composite/pages/2_/360/237/224/256_Pozisyonlar.py" +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/tutorials/composite/pages/3_/342/232/241/357/270/217_/303/234retim_Planlama.py" +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/tutorials/demo.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/tutorials/main.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/util/__init__.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/util/certificate.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/util/costs.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.0.dev0}/eptr2/util/evaluation.py +0 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# poetry
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
102
|
+
#poetry.lock
|
|
103
|
+
|
|
104
|
+
# pdm
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
106
|
+
#pdm.lock
|
|
107
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
108
|
+
# in version control.
|
|
109
|
+
# https://pdm.fming.dev/#use-with-ide
|
|
110
|
+
.pdm.toml
|
|
111
|
+
|
|
112
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
113
|
+
__pypackages__/
|
|
114
|
+
|
|
115
|
+
# Celery stuff
|
|
116
|
+
celerybeat-schedule
|
|
117
|
+
celerybeat.pid
|
|
118
|
+
|
|
119
|
+
# SageMath parsed files
|
|
120
|
+
*.sage.py
|
|
121
|
+
|
|
122
|
+
# Environments
|
|
123
|
+
.env
|
|
124
|
+
.venv
|
|
125
|
+
env/
|
|
126
|
+
venv/
|
|
127
|
+
ENV/
|
|
128
|
+
env.bak/
|
|
129
|
+
venv.bak/
|
|
130
|
+
|
|
131
|
+
# Spyder project settings
|
|
132
|
+
.spyderproject
|
|
133
|
+
.spyproject
|
|
134
|
+
|
|
135
|
+
# Rope project settings
|
|
136
|
+
.ropeproject
|
|
137
|
+
|
|
138
|
+
# mkdocs documentation
|
|
139
|
+
/site
|
|
140
|
+
|
|
141
|
+
# mypy
|
|
142
|
+
.mypy_cache/
|
|
143
|
+
.dmypy.json
|
|
144
|
+
dmypy.json
|
|
145
|
+
|
|
146
|
+
# Pyre type checker
|
|
147
|
+
.pyre/
|
|
148
|
+
|
|
149
|
+
# pytype static type analyzer
|
|
150
|
+
.pytype/
|
|
151
|
+
|
|
152
|
+
# Cython debug symbols
|
|
153
|
+
cython_debug/
|
|
154
|
+
|
|
155
|
+
# PyCharm
|
|
156
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
157
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
158
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
159
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
160
|
+
#.idea/
|
|
161
|
+
|
|
162
|
+
**/.DS_Store
|
|
163
|
+
data/
|
|
164
|
+
runs/
|
|
165
|
+
.vscode/
|
|
166
|
+
helpdocs/
|
|
167
|
+
creds/
|
|
@@ -1,25 +1,23 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: eptr2
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0.dev0
|
|
4
4
|
Summary: EPIAS Transparency Platform v2.0 Python client by Robokami Data
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Requires-Python:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
5
|
+
Author-email: Tideseed <info@tideseed.com>
|
|
6
|
+
License: Apache License 2.0
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Python: !=3.9.7,>=3.9.6
|
|
9
|
+
Requires-Dist: pytz>=2024.1
|
|
10
|
+
Requires-Dist: urllib3==2.5.0
|
|
15
11
|
Provides-Extra: allextras
|
|
12
|
+
Requires-Dist: pandas>=2.1.3; extra == 'allextras'
|
|
13
|
+
Requires-Dist: requests>=2.32.4; extra == 'allextras'
|
|
14
|
+
Requires-Dist: streamlit>=1.48.0; extra == 'allextras'
|
|
15
|
+
Requires-Dist: tornado>=6.5.0; extra == 'allextras'
|
|
16
16
|
Provides-Extra: dataframe
|
|
17
|
-
Requires-Dist: pandas
|
|
18
|
-
|
|
19
|
-
Requires-Dist:
|
|
20
|
-
Requires-Dist:
|
|
21
|
-
Requires-Dist: tornado (>=6.5.0) ; extra == "allextras"
|
|
22
|
-
Requires-Dist: urllib3 (==2.5.0)
|
|
17
|
+
Requires-Dist: pandas>=2.1.3; extra == 'dataframe'
|
|
18
|
+
Provides-Extra: dev
|
|
19
|
+
Requires-Dist: pytest>=7.4.0; extra == 'dev'
|
|
20
|
+
Requires-Dist: python-dotenv>=0.19.1; extra == 'dev'
|
|
23
21
|
Description-Content-Type: text/markdown
|
|
24
22
|
|
|
25
23
|
 
|
|
@@ -28,6 +26,9 @@ Description-Content-Type: text/markdown
|
|
|
28
26
|
|
|
29
27
|
This document is a quickstart guide for `eptr2` package. It is a Python client for [EPIAS Transparency Platform v2.0](https://seffaflik.epias.com.tr/home) API. It is an unofficial package with Apache License 2.0.
|
|
30
28
|
|
|
29
|
+
+ For live demo, please visit <https://eptr2demo.streamlit.app/>
|
|
30
|
+
+ For local demo, you can run `eptr2demo` at terminal after installing the library.
|
|
31
|
+
|
|
31
32
|
## Installation
|
|
32
33
|
|
|
33
34
|
You can easily install it from PyPI with the following commmand.
|
|
@@ -275,4 +276,3 @@ df2 = get_bpm_period(
|
|
|
275
276
|
)
|
|
276
277
|
```
|
|
277
278
|
|
|
278
|
-
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
This document is a quickstart guide for `eptr2` package. It is a Python client for [EPIAS Transparency Platform v2.0](https://seffaflik.epias.com.tr/home) API. It is an unofficial package with Apache License 2.0.
|
|
6
6
|
|
|
7
|
+
+ For live demo, please visit <https://eptr2demo.streamlit.app/>
|
|
8
|
+
+ For local demo, you can run `eptr2demo` at terminal after installing the library.
|
|
9
|
+
|
|
7
10
|
## Installation
|
|
8
11
|
|
|
9
12
|
You can easily install it from PyPI with the following commmand.
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
def price_and_cost_call():
|
|
2
|
+
ss = st.session_state
|
|
3
|
+
|
|
4
|
+
pb = st.progress(0, text="Veri alınıyor...")
|
|
5
|
+
df = get_hourly_price_and_cost_data(
|
|
6
|
+
eptr=ss["eptr"],
|
|
7
|
+
start_date=str(ss["price_cost_start_date"]),
|
|
8
|
+
end_date=str(ss["price_cost_end_date"]),
|
|
9
|
+
include_contract_symbol=True,
|
|
10
|
+
include_wap=True,
|
|
11
|
+
add_kupst_cost=True,
|
|
12
|
+
)
|
|
13
|
+
pb.progress(100, text="Veri alındı.")
|
|
14
|
+
time.sleep(0.3)
|
|
15
|
+
pb.empty()
|
|
16
|
+
|
|
17
|
+
if ss.get("price_cost_column_names_tr", False):
|
|
18
|
+
df = df.rename(
|
|
19
|
+
columns={
|
|
20
|
+
"date": "Tarih-Saat",
|
|
21
|
+
"mcp": "PTF",
|
|
22
|
+
"wap": "WAP",
|
|
23
|
+
"smp": "SMF",
|
|
24
|
+
"contract": "GİP Kontrat",
|
|
25
|
+
"pos_imb_price": "Pozitif Deng Fiyatı",
|
|
26
|
+
"neg_imb_price": "Negatif Deng Fiyatı",
|
|
27
|
+
"system_direction": "Sistem Yönü",
|
|
28
|
+
"sd_sign": "SY İşareti",
|
|
29
|
+
"pos_imb_cost": "Pozitif Deng Maliyeti",
|
|
30
|
+
"neg_imb_cost": "Negatif Deng Maliyeti",
|
|
31
|
+
"kupst_cost": "Birim KÜPST",
|
|
32
|
+
}
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
ss["price_and_cost_data"] = df.copy()
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def price_and_cost_code():
|
|
39
|
+
ss = st.session_state
|
|
40
|
+
|
|
41
|
+
text = f"""
|
|
42
|
+
from eptr2 import EPTR2
|
|
43
|
+
from eptr2.composite import get_hourly_price_and_cost_data
|
|
44
|
+
df = get_hourly_price_and_cost_data(
|
|
45
|
+
eptr=eptr,
|
|
46
|
+
start_date="{str(ss["price_cost_start_date"])}",
|
|
47
|
+
end_date="{str(ss["price_cost_end_date"])}",
|
|
48
|
+
include_contract_symbol=True,
|
|
49
|
+
include_wap=True,
|
|
50
|
+
add_kupst_cost=True
|
|
51
|
+
)
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
st.code(text, language="python")
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def price_and_cost_main():
|
|
58
|
+
st.title("Fiyat ve Maliyetler")
|
|
59
|
+
ss = st.session_state
|
|
60
|
+
|
|
61
|
+
# st.json(ss)
|
|
62
|
+
|
|
63
|
+
if "eptr" not in ss:
|
|
64
|
+
st.badge(
|
|
65
|
+
"EPTR2'ye bu servis için bağlı değilsiniz. Ana sayfadan giriş yapabilirsiniz.",
|
|
66
|
+
color="red",
|
|
67
|
+
icon="❌",
|
|
68
|
+
)
|
|
69
|
+
st.stop()
|
|
70
|
+
else:
|
|
71
|
+
eptr: EPTR2 = ss["eptr"]
|
|
72
|
+
|
|
73
|
+
sidebar_common()
|
|
74
|
+
tomorrow_str = offset_date_by_n_days(str(get_today_utc3()), n=1)
|
|
75
|
+
|
|
76
|
+
date_cols = st.columns([2, 2, 3, 1])
|
|
77
|
+
with date_cols[0]:
|
|
78
|
+
start_date = st.date_input(
|
|
79
|
+
"Başlangıç Tarihi",
|
|
80
|
+
value=get_previous_day(),
|
|
81
|
+
key="price_cost_start_date",
|
|
82
|
+
max_value=tomorrow_str,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
with date_cols[1]:
|
|
86
|
+
end_date = st.date_input(
|
|
87
|
+
"Bitiş Tarihi",
|
|
88
|
+
value=min(
|
|
89
|
+
tomorrow_str,
|
|
90
|
+
max(
|
|
91
|
+
str(start_date),
|
|
92
|
+
(
|
|
93
|
+
str(ss["price_cost_end_date"])
|
|
94
|
+
if ss.get("price_cost_end_date", "") != ""
|
|
95
|
+
else get_previous_day()
|
|
96
|
+
),
|
|
97
|
+
),
|
|
98
|
+
),
|
|
99
|
+
key="price_cost_end_date",
|
|
100
|
+
min_value=start_date,
|
|
101
|
+
max_value=tomorrow_str,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
with date_cols[2]:
|
|
105
|
+
st.write('<div style="height: 28px;"></div>', unsafe_allow_html=True)
|
|
106
|
+
st.button(
|
|
107
|
+
"Hesapla",
|
|
108
|
+
type="secondary",
|
|
109
|
+
key="price_cost_calculate",
|
|
110
|
+
icon="💰",
|
|
111
|
+
on_click=price_and_cost_call,
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
st.checkbox(
|
|
115
|
+
"Sütun İsimlerini Düzenle", key="price_cost_column_names_tr", value=True
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
if "price_and_cost_data" in ss:
|
|
119
|
+
st.subheader("Fiyat ve Maliyetler")
|
|
120
|
+
st.caption("Not: Bu tabloyu sağ üst köşeden csv olarak indirebilirsiniz.")
|
|
121
|
+
|
|
122
|
+
st.dataframe(
|
|
123
|
+
ss["price_and_cost_data"], use_container_width=True, hide_index=True
|
|
124
|
+
)
|
|
125
|
+
price_and_cost_code()
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
if __name__ == "__main__":
|
|
129
|
+
|
|
130
|
+
import streamlit as st
|
|
131
|
+
from eptr2 import EPTR2
|
|
132
|
+
from eptr2.composite import get_hourly_price_and_cost_data
|
|
133
|
+
from eptr2.util.time import get_previous_day, get_today_utc3, offset_date_by_n_days
|
|
134
|
+
import re
|
|
135
|
+
import pandas as pd
|
|
136
|
+
from eptr2.tutorials.composite.common import sidebar_common
|
|
137
|
+
import time
|
|
138
|
+
|
|
139
|
+
st.set_page_config(
|
|
140
|
+
page_title="Fiyat ve Maliyetler",
|
|
141
|
+
page_icon="💰",
|
|
142
|
+
layout="wide",
|
|
143
|
+
initial_sidebar_state="auto",
|
|
144
|
+
menu_items=None,
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
price_and_cost_main()
|
|
@@ -101,7 +101,16 @@ def composite_main():
|
|
|
101
101
|
"""
|
|
102
102
|
Bu sayfa, istediğiniz organizasyon, istediğiniz UEVÇB ve istediğiniz dönem aralığı için KGÜP ve KUDÜP verilerini bir arada çekmenizi sağlayan kompozit fonksiyonu çalıştırır."""
|
|
103
103
|
)
|
|
104
|
-
|
|
104
|
+
st.divider()
|
|
105
|
+
st.page_link(
|
|
106
|
+
"pages/4_💰_Fiyat_ve_Maliyetler.py",
|
|
107
|
+
label="**Fiyat ve Maliyetler**",
|
|
108
|
+
icon="💰",
|
|
109
|
+
)
|
|
110
|
+
st.markdown(
|
|
111
|
+
"""
|
|
112
|
+
Bu sayfa, istediğiniz tarih aralığı için PTF, SMF, AOF verilerini ve ilgili hesaplamaları (dengesizlik fiyat ve maliyetleri, KÜPST) bir arada çekmenizi sağlayan kompozit fonksiyonu çalıştırır."""
|
|
113
|
+
)
|
|
105
114
|
st.divider()
|
|
106
115
|
st.markdown("Diğer kompozit fonksiyonlar da yakında burada...")
|
|
107
116
|
|
|
@@ -113,6 +122,8 @@ if __name__ == "__main__":
|
|
|
113
122
|
import os
|
|
114
123
|
from eptr2.tutorials.composite.common import sidebar_common
|
|
115
124
|
|
|
125
|
+
streamlit_cloud_warning = False
|
|
126
|
+
|
|
116
127
|
st.set_page_config(
|
|
117
128
|
page_title="eptr2 Kompozit Fonksiyonlar",
|
|
118
129
|
page_icon="👩💻",
|
|
@@ -121,4 +132,8 @@ if __name__ == "__main__":
|
|
|
121
132
|
menu_items=None,
|
|
122
133
|
)
|
|
123
134
|
|
|
135
|
+
if streamlit_cloud_warning:
|
|
136
|
+
st.warning(
|
|
137
|
+
"Bu site dış bir platform olan [Streamlit Community Cloud](https://share.streamlit.io/) üzerinde çalışmaktadır ve sadece demo amaçlıdır. Erişim bilgilerinizi paylaşırken dikkatli olmanızı ve sık sık güncellemenizi tavsiye ederiz."
|
|
138
|
+
)
|
|
124
139
|
composite_main()
|
|
@@ -3,6 +3,25 @@ import pytz
|
|
|
3
3
|
from typing import Literal
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
def contract_duration(
|
|
7
|
+
contract: str, return_type: Literal["hours", "minutes", "seconds"] = "seconds"
|
|
8
|
+
) -> float:
|
|
9
|
+
close_dt = contract_close_time(contract)
|
|
10
|
+
open_dt = close_dt.replace(hour=18) - timedelta(days=1)
|
|
11
|
+
duration = close_dt - open_dt
|
|
12
|
+
seconds = duration.total_seconds()
|
|
13
|
+
if return_type == "seconds":
|
|
14
|
+
return seconds
|
|
15
|
+
elif return_type == "minutes":
|
|
16
|
+
return seconds / 60
|
|
17
|
+
elif return_type == "hours":
|
|
18
|
+
return seconds / 3600
|
|
19
|
+
else:
|
|
20
|
+
raise ValueError(
|
|
21
|
+
f"Invalid return type {return_type}. Use one of ['seconds', 'minutes', 'hours']"
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
def check_iso_format(
|
|
7
26
|
val: str | datetime,
|
|
8
27
|
strict_hour_format: bool = False,
|
|
@@ -346,13 +365,20 @@ def get_time_min_max_price_map():
|
|
|
346
365
|
return map_l
|
|
347
366
|
|
|
348
367
|
|
|
349
|
-
def contract_to_floor_ceil_prices(c):
|
|
368
|
+
def contract_to_floor_ceil_prices(c: str | None = None):
|
|
350
369
|
"""
|
|
351
370
|
Given a contract return the min and max prices
|
|
352
371
|
"""
|
|
353
372
|
|
|
354
|
-
|
|
373
|
+
### Min max price map is always sorted by date descending
|
|
355
374
|
mm_map = get_time_min_max_price_map()
|
|
375
|
+
|
|
376
|
+
### If contract is not given return the latest
|
|
377
|
+
if c is None:
|
|
378
|
+
return mm_map[0]
|
|
379
|
+
|
|
380
|
+
the_date = contract_to_datetime(c).date()
|
|
381
|
+
|
|
356
382
|
for x in mm_map:
|
|
357
383
|
if the_date >= datetime.strptime(x["date"], "%Y-%m-%d").date():
|
|
358
384
|
return x
|
|
@@ -375,13 +401,13 @@ def get_probable_settlement_date(x: str | None = None, settlement_day=15):
|
|
|
375
401
|
|
|
376
402
|
if x.month == 12:
|
|
377
403
|
# If the month is December, we set the next month to January of the next year
|
|
378
|
-
x = x.replace(year=x.year + 1, month=1)
|
|
404
|
+
x = x.replace(day=settlement_day, year=x.year + 1, month=1)
|
|
379
405
|
else:
|
|
380
406
|
# Otherwise, we just increment the month by 1
|
|
381
|
-
x = x.replace(month=x.month + 1)
|
|
407
|
+
x = x.replace(day=settlement_day, month=x.month + 1)
|
|
382
408
|
|
|
383
409
|
probable_settlement_date = x.replace(
|
|
384
|
-
day=settlement_day,
|
|
410
|
+
# day=settlement_day,
|
|
385
411
|
hour=0,
|
|
386
412
|
minute=0,
|
|
387
413
|
second=0,
|
|
@@ -457,3 +483,34 @@ def get_start_end_dates_period(period: str):
|
|
|
457
483
|
end_date = end_date.strftime("%Y-%m-%d")
|
|
458
484
|
|
|
459
485
|
return start_date, end_date
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
## https://stackoverflow.com/a/68321739/3608936
|
|
489
|
+
def contract_remaining_time_formatted(
|
|
490
|
+
contract: str,
|
|
491
|
+
day_label="D",
|
|
492
|
+
hour_label="H",
|
|
493
|
+
minute_label="m",
|
|
494
|
+
second_label="s",
|
|
495
|
+
no_time_label="-",
|
|
496
|
+
) -> str:
|
|
497
|
+
seconds = time_to_contract_close(contract)
|
|
498
|
+
if seconds is not None:
|
|
499
|
+
seconds = int(seconds)
|
|
500
|
+
d = seconds // (3600 * 24)
|
|
501
|
+
h = seconds // 3600 % 24
|
|
502
|
+
m = seconds % 3600 // 60
|
|
503
|
+
s = seconds % 3600 % 60
|
|
504
|
+
if d > 0:
|
|
505
|
+
return "{:02d}{} {:02d}{} {:02d}{} {:02d}{}".format(
|
|
506
|
+
d, day_label, h, hour_label, m, minute_label, s, second_label
|
|
507
|
+
)
|
|
508
|
+
elif h > 0:
|
|
509
|
+
return "{:02d}{} {:02d}{} {:02d}{}".format(
|
|
510
|
+
h, hour_label, m, minute_label, s, second_label
|
|
511
|
+
)
|
|
512
|
+
elif m > 0:
|
|
513
|
+
return "{:02d}{} {:02d}{}".format(m, minute_label, s, second_label)
|
|
514
|
+
elif s > 0:
|
|
515
|
+
return "{:02d}{}".format(s, second_label)
|
|
516
|
+
return no_time_label
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "eptr2"
|
|
3
|
+
version = "1.2.0.dev0"
|
|
4
|
+
description = "EPIAS Transparency Platform v2.0 Python client by Robokami Data"
|
|
5
|
+
authors = [
|
|
6
|
+
{name = "Tideseed", email = "info@tideseed.com"}
|
|
7
|
+
]
|
|
8
|
+
license = {text = "Apache License 2.0"}
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9.6,!=3.9.7"
|
|
11
|
+
dependencies = [
|
|
12
|
+
"urllib3==2.5.0",
|
|
13
|
+
"pytz>=2024.1",
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
[project.optional-dependencies]
|
|
17
|
+
dataframe = ["pandas>=2.1.3"]
|
|
18
|
+
allextras = [
|
|
19
|
+
"pandas>=2.1.3",
|
|
20
|
+
"streamlit>=1.48.0",
|
|
21
|
+
"tornado>=6.5.0",
|
|
22
|
+
"requests>=2.32.4"
|
|
23
|
+
]
|
|
24
|
+
dev = [
|
|
25
|
+
"pytest>=7.4.0",
|
|
26
|
+
"python-dotenv>=0.19.1",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.scripts]
|
|
30
|
+
eptr2demo = "eptr2.tutorials:run_composite_app"
|
|
31
|
+
|
|
32
|
+
[build-system]
|
|
33
|
+
requires = ["hatchling"]
|
|
34
|
+
build-backend = "hatchling.build"
|
|
35
|
+
|
|
36
|
+
[tool.uv]
|
|
37
|
+
dev-dependencies = [
|
|
38
|
+
"pytest>=7.4.0",
|
|
39
|
+
"python-dotenv>=0.19.1",
|
|
40
|
+
]
|
|
File without changes
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
## Add test for eptr2/composite/mms.py
|
|
2
|
+
from eptr2.composite.consumption import get_hourly_consumption_and_forecast_data
|
|
3
|
+
from dotenv import load_dotenv, find_dotenv
|
|
4
|
+
from eptr2 import EPTR2
|
|
5
|
+
import pytest
|
|
6
|
+
from tests import common_params
|
|
7
|
+
import pandas as pd
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@pytest.fixture
|
|
11
|
+
def cons_params():
|
|
12
|
+
d = common_params()
|
|
13
|
+
d = {k: v for k, v in d.items() if k in ["start_date", "end_date"]}
|
|
14
|
+
return d
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def test_eptr2_consumption(cons_params):
|
|
18
|
+
is_env_ok = load_dotenv(".env")
|
|
19
|
+
assert is_env_ok
|
|
20
|
+
|
|
21
|
+
eptr = EPTR2()
|
|
22
|
+
df = get_hourly_consumption_and_forecast_data(
|
|
23
|
+
eptr=eptr,
|
|
24
|
+
start_date=cons_params["start_date"],
|
|
25
|
+
end_date=cons_params["end_date"],
|
|
26
|
+
include_contract_symbol=True,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
assert df is not None
|
|
30
|
+
assert len(df) > 0
|
|
31
|
+
assert isinstance(df, pd.DataFrame)
|
|
32
|
+
assert "contract" in df
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
## Add test for eptr2/composite/mms.py
|
|
2
|
+
from eptr2.composite.mms import get_mms_detail
|
|
3
|
+
from dotenv import load_dotenv, find_dotenv
|
|
4
|
+
from eptr2 import EPTR2
|
|
5
|
+
import pytest
|
|
6
|
+
from tests import common_params
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@pytest.fixture
|
|
10
|
+
def mms_params():
|
|
11
|
+
d = common_params()
|
|
12
|
+
d = {k: v for k, v in d.items() if k in ["start_date", "end_date"]}
|
|
13
|
+
return d
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def test_eptr2_composite_mms(mms_params):
|
|
17
|
+
is_env_ok = load_dotenv(".env")
|
|
18
|
+
assert is_env_ok
|
|
19
|
+
|
|
20
|
+
eptr = EPTR2()
|
|
21
|
+
d = get_mms_detail(
|
|
22
|
+
eptr=eptr,
|
|
23
|
+
start_date=mms_params["start_date"],
|
|
24
|
+
end_date=mms_params["end_date"],
|
|
25
|
+
verbose=True,
|
|
26
|
+
include_contract_symbol=True,
|
|
27
|
+
include_summary=True,
|
|
28
|
+
)
|
|
29
|
+
assert d is not None
|
|
30
|
+
assert "detail" in d
|
|
31
|
+
assert "summary" in d
|
|
32
|
+
assert d["detail"] is not None
|
|
33
|
+
assert d["summary"] is not None
|
|
34
|
+
assert len(d["detail"]) > 0
|
|
35
|
+
assert len(d["summary"]) > 0
|
|
36
|
+
assert "contract" in d["detail"]
|
|
37
|
+
assert "contract" in d["summary"]
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
## Add test for eptr2/composite/mms.py
|
|
2
|
+
from eptr2.composite.price_and_cost import (
|
|
3
|
+
get_hourly_price_and_cost_data,
|
|
4
|
+
get_hourly_imbalance_data,
|
|
5
|
+
)
|
|
6
|
+
from dotenv import load_dotenv, find_dotenv
|
|
7
|
+
from eptr2 import EPTR2
|
|
8
|
+
import pytest
|
|
9
|
+
from tests import common_params
|
|
10
|
+
import pandas as pd
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@pytest.fixture
|
|
14
|
+
def pc_params():
|
|
15
|
+
d = common_params()
|
|
16
|
+
d = {k: v for k, v in d.items() if k in ["start_date", "end_date"]}
|
|
17
|
+
return d
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_eptr2_price_and_cost(pc_params):
|
|
21
|
+
is_env_ok = load_dotenv(".env")
|
|
22
|
+
assert is_env_ok
|
|
23
|
+
|
|
24
|
+
eptr = EPTR2()
|
|
25
|
+
df = get_hourly_price_and_cost_data(
|
|
26
|
+
eptr=eptr,
|
|
27
|
+
start_date=pc_params["start_date"],
|
|
28
|
+
end_date=pc_params["end_date"],
|
|
29
|
+
verbose=True,
|
|
30
|
+
include_contract_symbol=True,
|
|
31
|
+
include_wap=True,
|
|
32
|
+
add_kupst_cost=True,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
assert df is not None
|
|
36
|
+
assert len(df) > 0
|
|
37
|
+
assert isinstance(df, pd.DataFrame)
|
|
38
|
+
assert "contract" in df
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def test_eptr2_imbalance(pc_params):
|
|
42
|
+
is_env_ok = load_dotenv(".env")
|
|
43
|
+
assert is_env_ok
|
|
44
|
+
|
|
45
|
+
eptr = EPTR2()
|
|
46
|
+
df = get_hourly_imbalance_data(
|
|
47
|
+
eptr=eptr,
|
|
48
|
+
start_date=pc_params["start_date"],
|
|
49
|
+
end_date=pc_params["end_date"],
|
|
50
|
+
verbose=True,
|
|
51
|
+
include_contract_symbol=True,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
assert df is not None
|
|
55
|
+
assert len(df) > 0
|
|
56
|
+
assert isinstance(df, pd.DataFrame)
|
|
57
|
+
assert "contract" in df
|