Signal#
-
class sigtech.framework.signal.signal_object.Signal
Baseclasses:
FrameworkObject
The signal class creates a signal object that uses the same
.history()
API as the framework.Keyword arguments:
start_date
: minimum date output time series.end_date
: maximum date output time series.function
: the function object that will produce the output.function_name
: function address for database persistence.underliers
: A dictionary where keys correspond to the inputs of the function argument and value to the name of the object. This object can be of any type with output of timeseries, dataframe or dictionary, e.g. instruments, strategies or other signal objects.
Example: Creates signal object that has a history that is half the SPXT Index.
def func(ts, n): return ts / n example_signal_obj = sig.Signal( function=func, underliers={'ts': 'SPXT INDEX'}, params={'n': 2} )
-
additional_dependencies: Optional[list]
-
args: Optional[list]
-
cache_history: Optional[bool]
-
property data_point
Field used when retrieving history.
-
property data_source
Data source of the signal.
-
data_source_all: Optional[list[str]]
-
db_sector: Optional[str]
-
property dependency_type
Dependency Type
-
end_date: Optional[date]
-
end_dt: Optional[datetime]
-
function: Optional[Callable]
-
function_name: Optional[str]
-
property history_fields: list[str]
Fields for this signal.
-
params: Optional[dict]
-
property prime_history_field: str
The main history field returned by default.
-
start_date: Optional[date]
-
start_dt: Optional[datetime]
-
property supplementary_fields
Enable the definition of additional fields.
-
ticker: Optional[str]
-
underliers: Optional[dict]
-
check_all_signal_inputs()
Validate the signal inputs.
-
check_signal_parameters()
Validate the signal parameters.
-
clear_calc_history()
Clear the signal and underliers history.
-
clear_history()
Clear the signal history.
-
clone(name=None)
Clone the signal object.
- Parameters:
name – Ticker identifier of the cloned signal.
- Returns:
Signal object.
-
create_operator_signal(other, signal_function, input_names=None)
Create a signal operator.
- Parameters:
other – Signal object.
signal_function – Signal operation identifier.
input_names – List of input identifiers.
- Returns:
Signal object.
-
deep_clone()
Clone the signal object (deep copy).
-
ewma(ts)
EWMA operator.
- Parameters:
window – Size of the window.
ts – Input timeseries.
- Returns:
pandas Series or DataFrame.
-
explode_initial_data()
Serialise the signal object.
-
get_dependents()
Return the set of dependents.
-
get_underlying_data()
Return a DataFrame of underliers.
-
get_underlying_names(filter_signals=False)
Return the names of signal underliers.
- Parameters:
filter_signals – If True, signals are filtered out (default is False).
- Returns:
List of underlier identifiers.
-
has_preloaded_history(field=None, data_point=None)
Called by the Dependencies framework - arguments not used
-
history()
Return the signal history. The history is first built if the signal was not already calculated.
- Returns:
Signal history.
-
insert()
Update all dependents and return a new signal object.
-
intraday_history(period: timedelta, start_dt=None, end_dt=None, timezone=None)
Return the signal history. The history is first built if the signal was not already calculated.
- Parameters:
period – period of history requested
start_dt – filter the output by datetime range
end_dt – filter the output by datetime range
timezone – set the timezone of the returned series to this value
- Returns:
Signal history.
-
ma(ts)
Rolling average operator.
- Parameters:
window – Size of the window.
ts – Input timeseries.
- Returns:
pandas Series or DataFrame.
-
macd(short_window: int = 12, long_window: int = 26) Series
Moving Average Convergence Divergence Indicator.
See
macd()
for details.- Parameters:
ts – Close price timeseries.
short_window – Short moving average periods.
long_window – Long moving average periods.
- Returns:
Series of indicator values.
-
map_underliers()
Return a dict of underliers.
-
normalize_weights() DataFrame
Normalise weights to have 100% gross notional.
- Parameters:
ts – Input timeseries.
- Returns:
pandas Dataframe.
normalize_weights = sig.signal_library.allocation.normalize_weights normalize_weights( pd.DataFrame({'A': [2, 2, 2], 'B': [1, 2, 1]}) )
Returns:
A
B
0
0.67
0.33
1
0.5
0.5
2
0.67
0.33
-
normalize_weights_zero_filled() DataFrame
Normalise weights to have 100% gross notional and fill empty values with zeros.
- Parameters:
ts – Input timeseries.
- Returns:
pandas Dataframe.
normalize_weights_zero_filled = sig.signal_library.allocation.normalize_weights_zero_filled normalize_weights_zero_filled( pd.DataFrame({'A': [1,np.nan,2], 'B': [0.5, np.nan, np.nan]}) )
Returns:
# A
B
0
0.67
0.33
1
0.0
0.0
2
1.0
0.0
-
percentile()
Expand the percentile rank of a timeseries.
- Parameters:
ts – pandas Series or DataFrame.
- Returns:
pandas Series or DataFrame.
-
print_code(lines=None, imports=None, underlier_set=None)
Code print method.
- Parameters:
lines – List of code lines.
imports – List of imports.
underlier_set – Set of underliers.
-
replace_with(node)
Update all dependents given a new node.
- Parameters:
node – Input node.
-
set_calendar(calendar_name)
Set the signal object calendar.
- Parameters:
calendar_name – Calendar identifier.
-
sigmoid(ts)
Sigmoid operator.
- Parameters:
factor – Factor value.
ts – Input timeseries.
- Returns:
pandas Series or DataFrame.
-
simple_ma_signal(long_span, df)
Create a signal based on rolling average cross operator.
- Parameters:
short_span – Size of the short span window.
long_span – Size of the long span window.
df – Input DataFrame.
- Returns:
Signal
object.
-
store_signal_diagnoistics(df, df_name)
Store the serialised signal items.
- Parameters:
df – Input data.
df_name – Storage name.
-
truncate(var, intraday=False)
Set start and end date for historical outputs of time series, dataframes or dictionaries.
- Parameters:
var – Input history.
intraday – bool - is var an intra-day time series
- Returns:
Truncated history.
-
update(underliers=None, params=None, del_underliers=None, del_params=None, **kwargs)
Update the signal object.
- Parameters:
underliers – Dict of underliers to add.
params – Dict of parameters to add.
del_underliers – Dict of underliers to remove.
del_params – Dict of parameters to remove.
-
vol(*, ts, factor=252, **kwargs)
Volatility operator.
- Parameters:
ts – pandas Series or DataFrame.
factor – Volatility factor (default is 252).
- Returns:
pandas Series or DataFrame.
-
z_score(centered=True, min_periods=None, ts=None)
Z-score calculation.
- Parameters:
period – Size of the moving window.
centered – If set to True, do not consider the rolling mean (default is True).
min_periods – Minimum number of observations in window required to have a value.
ts – Input timeseries.