Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 17 additions & 1 deletion src/quantlib_st/config/configdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"""

from pathlib import Path
from typing import Optional, Union
from typing import Optional, Union, Any

import os
import yaml
Expand Down Expand Up @@ -45,6 +45,14 @@


class Config(object):
# Common configuration attributes (type hints for IDE)
trading_rules: Any
forecast_scalar_estimate: Any
forecast_scalar_fixed: Any
instruments: Any
parameters: Any
base_currency: Any

def __init__(
self,
config_object: Optional[Union[str, dict, list]] = None,
Expand Down Expand Up @@ -110,6 +118,14 @@ def add_single_element(self, element_name):
elements.append(element_name)
self._elements = elements

def __getattr__(self, name: str) -> Any:
# This allows Pylance to know that Config can have dynamic attributes
# and prevents "unknown attribute" errors.
# We only get here if the attribute isn't already defined in __dict__
raise AttributeError(
f"'{type(self).__name__}' object has no attribute '{name}'"
)

def get_element(self, element_name):
try:
result = getattr(self, element_name)
Expand Down
20 changes: 17 additions & 3 deletions src/quantlib_st/systems/basesystem.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
from typing import Optional
from typing import Optional, TYPE_CHECKING

if TYPE_CHECKING:
from quantlib_st.systems.forecasting import Rules
from quantlib_st.systems.accounts.accounts_stage import Account
from quantlib_st.systems.rawdata import RawData

# from quantlib_st.systems.forecast_combine import ForecastCombine
from quantlib_st.systems.forecast_scale_cap import ForecastScaleCap

from quantlib_st.config.configdata import Config
from quantlib_st.config.instruments import (
Expand Down Expand Up @@ -40,6 +48,12 @@ class System(object):

"""

rules: "Rules"
accounts: "Account"
rawdata: "RawData"
# combForecast: "ForecastCombine"
forecastScaleCap: "ForecastScaleCap"

def __init__(
self,
stage_list: list,
Expand Down Expand Up @@ -129,11 +143,11 @@ def log(self):
return self._log

@property
def data(self):
def data(self) -> simData:
return self._data

@property
def config(self):
def config(self) -> Config:
return self._config

@property
Expand Down
Loading