detquantlib 3.8.1__tar.gz → 3.9.0__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.
Files changed (21) hide show
  1. {detquantlib-3.8.1 → detquantlib-3.9.0}/PKG-INFO +1 -1
  2. {detquantlib-3.8.1 → detquantlib-3.9.0}/detquantlib/data/databases/detdatabase.py +69 -20
  3. {detquantlib-3.8.1 → detquantlib-3.9.0}/pyproject.toml +1 -1
  4. {detquantlib-3.8.1 → detquantlib-3.9.0}/LICENSE.txt +0 -0
  5. {detquantlib-3.8.1 → detquantlib-3.9.0}/README.md +0 -0
  6. {detquantlib-3.8.1 → detquantlib-3.9.0}/detquantlib/__init__.py +0 -0
  7. {detquantlib-3.8.1 → detquantlib-3.9.0}/detquantlib/data/__init__.py +0 -0
  8. {detquantlib-3.8.1 → detquantlib-3.9.0}/detquantlib/data/entsoe/entsoe.py +0 -0
  9. {detquantlib-3.8.1 → detquantlib-3.9.0}/detquantlib/data/sftp/sftp.py +0 -0
  10. {detquantlib-3.8.1 → detquantlib-3.9.0}/detquantlib/dates/__init__.py +0 -0
  11. {detquantlib-3.8.1 → detquantlib-3.9.0}/detquantlib/dates/dates.py +0 -0
  12. {detquantlib-3.8.1 → detquantlib-3.9.0}/detquantlib/figures/__init__.py +0 -0
  13. {detquantlib-3.8.1 → detquantlib-3.9.0}/detquantlib/figures/plotly_figures.py +0 -0
  14. {detquantlib-3.8.1 → detquantlib-3.9.0}/detquantlib/outputs/__init__.py +0 -0
  15. {detquantlib-3.8.1 → detquantlib-3.9.0}/detquantlib/outputs/outputs_interface.py +0 -0
  16. {detquantlib-3.8.1 → detquantlib-3.9.0}/detquantlib/stats/__init__.py +0 -0
  17. {detquantlib-3.8.1 → detquantlib-3.9.0}/detquantlib/stats/data_analysis.py +0 -0
  18. {detquantlib-3.8.1 → detquantlib-3.9.0}/detquantlib/tradable_products/__init__.py +0 -0
  19. {detquantlib-3.8.1 → detquantlib-3.9.0}/detquantlib/tradable_products/tradable_products.py +0 -0
  20. {detquantlib-3.8.1 → detquantlib-3.9.0}/detquantlib/utils/__init__.py +0 -0
  21. {detquantlib-3.8.1 → detquantlib-3.9.0}/detquantlib/utils/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: detquantlib
3
- Version: 3.8.1
3
+ Version: 3.9.0
4
4
  Summary: An internal library containing functions and classes that can be used across Quant models.
5
5
  License-File: LICENSE.txt
6
6
  Author: DET
@@ -100,6 +100,25 @@ class DetDatabase:
100
100
 
101
101
  return df
102
102
 
103
+ @staticmethod
104
+ def get_table_name(def_key: str) -> str:
105
+ """
106
+ Gets the name of a database table, according to the following logic:
107
+ 1) First, try to get the table name from the corresponding environment variable.
108
+ 2) If the environment variable is not defined, revert to the default table name.
109
+
110
+ Args:
111
+ def_key: Definitions dictionary key corresponding to the desired table
112
+
113
+ Returns:
114
+ Database table name
115
+ """
116
+ definition = DetDatabaseDefinitions.DEFINITIONS[def_key]
117
+ table = os.getenv(definition["env_variable"])
118
+ if table is None:
119
+ table = definition["default_table_name"]
120
+ return table
121
+
103
122
  def load_entsoe_day_ahead_spot_prices(
104
123
  self,
105
124
  commodity_name: str,
@@ -211,7 +230,7 @@ class DetDatabase:
211
230
  end_date_str = end_delivery_date.strftime("%Y-%m-%d %H:%M:%S")
212
231
 
213
232
  # Create query
214
- table = DetDatabaseDefinitions.DEFINITIONS["table_name_entsoe_day_ahead_spot_price"]
233
+ table = DetDatabase.get_table_name("entsoe_day_ahead_spot_price")
215
234
  query = (
216
235
  f"SELECT {columns_str} FROM {table} "
217
236
  f"WHERE MapCode='{map_code}' "
@@ -410,7 +429,7 @@ class DetDatabase:
410
429
  end_date_str = end_delivery_date.strftime("%Y-%m-%d %H:%M:%S")
411
430
 
412
431
  # Create query
413
- table = DetDatabaseDefinitions.DEFINITIONS["table_name_entsoe_imbalance_price"]
432
+ table = DetDatabase.get_table_name("entsoe_imbalance_price")
414
433
  query = (
415
434
  f"SELECT {columns_str} FROM {table} "
416
435
  f"WHERE MapCode='{map_code}' "
@@ -543,7 +562,7 @@ class DetDatabase:
543
562
  end_trading_date_str = end_trading_date.strftime("%Y-%m-%d")
544
563
 
545
564
  # Create query
546
- table = DetDatabaseDefinitions.DEFINITIONS["table_name_futures_eod_settlement_price"]
565
+ table = DetDatabase.get_table_name("futures_tt")
547
566
  query = (
548
567
  f"SELECT {columns_str} FROM {table} "
549
568
  f"WHERE CommodityName='{commodity_name}' "
@@ -615,7 +634,7 @@ class DetDatabase:
615
634
  columns_str = f"[{'], ['.join(columns)}]"
616
635
 
617
636
  # Create query
618
- table = DetDatabaseDefinitions.DEFINITIONS["table_name_commodity"]
637
+ table = DetDatabase.get_table_name("commodity")
619
638
  query = f"SELECT {columns_str} FROM {table} {conditions}"
620
639
 
621
640
  # Query db
@@ -698,7 +717,7 @@ class DetDatabase:
698
717
  end_trading_date_str = end_trading_date.strftime("%Y-%m-%d")
699
718
 
700
719
  # Create query
701
- table = DetDatabaseDefinitions.DEFINITIONS["table_name_account_position"]
720
+ table = DetDatabase.get_table_name("account_position")
702
721
  query = (
703
722
  f"SELECT {columns_str} FROM {table} "
704
723
  f"WHERE InsertionTimestamp>='{start_trading_date_str}' "
@@ -756,7 +775,7 @@ class DetDatabase:
756
775
  identifiers_str = ", ".join(f"'{i}'" for i in identifiers)
757
776
 
758
777
  # Create query
759
- table = DetDatabaseDefinitions.DEFINITIONS["table_name_instruments"]
778
+ table = DetDatabase.get_table_name("instrument")
760
779
  query = f"SELECT {columns_str} FROM {table} WHERE [id] IN ({identifiers_str})"
761
780
 
762
781
  # Query db
@@ -817,7 +836,7 @@ class DetDatabase:
817
836
  end_trading_date_str = end_trading_date.strftime("%Y-%m-%d")
818
837
 
819
838
  # Create query
820
- table = DetDatabaseDefinitions.DEFINITIONS["table_name_eex_eod_price"]
839
+ table = DetDatabase.get_table_name("futures_eex")
821
840
  query = (
822
841
  f"SELECT {columns_str} FROM {table} "
823
842
  f"WHERE Product LIKE '{product_code}' "
@@ -926,7 +945,7 @@ class DetDatabase:
926
945
  forecast_date_str = forecast_date.strftime("%Y-%m-%d")
927
946
 
928
947
  # Create query
929
- table = DetDatabaseDefinitions.DEFINITIONS["table_name_forecast_customer_volume"]
948
+ table = DetDatabase.get_table_name("client_volume_forecast")
930
949
  query = (
931
950
  f"SELECT {columns_str} FROM {table} "
932
951
  f"WHERE Profile='{profile}' "
@@ -1031,7 +1050,7 @@ class DetDatabase:
1031
1050
  columns_str = f"[{'], ['.join(columns)}]"
1032
1051
 
1033
1052
  # Create query
1034
- table = DetDatabaseDefinitions.DEFINITIONS["table_name_customer_day_ahead_auction_bids"]
1053
+ table = DetDatabase.get_table_name("client_day_ahead_auction_bids")
1035
1054
  query = (
1036
1055
  f"SELECT {columns_str} FROM {table} "
1037
1056
  f"WHERE ClientId='{client_id}' "
@@ -1102,7 +1121,7 @@ class DetDatabase:
1102
1121
  columns_str = f"[{'], ['.join(columns)}]"
1103
1122
 
1104
1123
  # Create query
1105
- table = DetDatabaseDefinitions.DEFINITIONS["table_name_client"]
1124
+ table = DetDatabase.get_table_name("client")
1106
1125
  query = f"SELECT {columns_str} FROM {table} {conditions}"
1107
1126
 
1108
1127
  # Query db
@@ -1154,14 +1173,44 @@ class DetDatabaseDefinitions:
1154
1173
  """A class containing some hard-coded definitions related to the DET database."""
1155
1174
 
1156
1175
  DEFINITIONS = dict(
1157
- table_name_commodity="[META].[Commodity]",
1158
- table_name_entsoe_day_ahead_spot_price="[ENTSOE].[DayAheadSpotPrice]",
1159
- table_name_entsoe_imbalance_price="[ENTSOE].[ImbalancePrice]",
1160
- table_name_futures_eod_settlement_price="[VW].[EODSettlementPrice]",
1161
- table_name_account_position="[TT].[AccountPosition]",
1162
- table_name_instruments="[TT].[Instrument]",
1163
- table_name_eex_eod_price="[EEX].[EODPrice]",
1164
- table_name_forecast_customer_volume="[DISP].[ForecastGold]",
1165
- table_name_customer_day_ahead_auction_bids="[TRADE].[ClientBid]",
1166
- table_name_client="[META].[Client]",
1176
+ commodity=dict(
1177
+ env_variable="DET_DB_TABLE_COMMODITY",
1178
+ default_table_name="[META].[Commodity]",
1179
+ ),
1180
+ entsoe_day_ahead_spot_price=dict(
1181
+ env_variable="DET_DB_TABLE_ENTSOE_DA",
1182
+ default_table_name="[ENTSOE].[DayAheadSpotPrice]",
1183
+ ),
1184
+ entsoe_imbalance_price=dict(
1185
+ env_variable="DET_DB_TABLE_ENTSOE_IB",
1186
+ default_table_name="[ENTSOE].[ImbalancePrice]",
1187
+ ),
1188
+ futures_tt=dict(
1189
+ env_variable="DET_DB_TABLE_FUTURES_TT",
1190
+ default_table_name="[VW].[EODSettlementPrice]",
1191
+ ),
1192
+ futures_eex=dict(
1193
+ env_variable="DET_DB_TABLE_FUTURES_EEX",
1194
+ default_table_name="[EEX].[EODPrice]",
1195
+ ),
1196
+ account_position=dict(
1197
+ env_variable="DET_DB_TABLE_ACCOUNT_POSITION",
1198
+ default_table_name="[TT].[AccountPosition]",
1199
+ ),
1200
+ instrument=dict(
1201
+ env_variable="DET_DB_TABLE_INSTRUMENT",
1202
+ default_table_name="[TT].[Instrument]",
1203
+ ),
1204
+ client_volume_forecast=dict(
1205
+ env_variable="DET_DB_TABLE_CLIENT_VOLUME_FORECAST",
1206
+ default_table_name="[DISP].[ForecastGold]",
1207
+ ),
1208
+ client_day_ahead_auction_bids=dict(
1209
+ env_variable="DET_DB_TABLE_CLIENT_DA_AUCTION_BIDS",
1210
+ default_table_name="[TRADE].[ClientBid]",
1211
+ ),
1212
+ client=dict(
1213
+ env_variable="DET_DB_TABLE_CLIENT",
1214
+ default_table_name="[META].[Client]",
1215
+ ),
1167
1216
  )
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "detquantlib"
3
- version = "3.8.1"
3
+ version = "3.9.0"
4
4
  description = "An internal library containing functions and classes that can be used across Quant models."
5
5
  authors = ["DET"]
6
6
  readme = "README.md"
File without changes
File without changes