ohlcstx module¶
Module with OHLCSTX.
ohlcstx_config ReadonlyConfig¶
Factory config for OHLCSTX.
ohlcstx_func_config ReadonlyConfig¶
Exit function config for OHLCSTX.
OHLCSTX class¶
OHLCSTX(
wrapper,
input_list,
input_mapper,
in_output_list,
output_list,
param_list,
mapper_list,
short_name,
**kwargs
)
Exit signal generator based on OHLC and stop values.
Generates exits based on entries and ohlc_stop_place_nb.
Hint
All parameters can be either a single value (per frame) or a NumPy array (per row, column, or element). To generate multiple combinations, pass them as lists.
Warning
Searches for an exit after each entry. If two entries come one after another, no exit can be placed. Consider either cleaning up entry signals prior to passing, or using OHLCSTCX.
Usage
Test each stop type:
>>> from vectorbtpro import *
>>> entries = pd.Series([True, False, False, False, False, False])
>>> price = pd.DataFrame({
... 'open': [10, 11, 12, 11, 10, 9],
... 'high': [11, 12, 13, 12, 11, 10],
... 'low': [9, 10, 11, 10, 9, 8],
... 'close': [10, 11, 12, 11, 10, 9]
... })
>>> ohlcstx = vbt.OHLCSTX.run(
... entries,
... price['open'],
... price['open'],
... price['high'],
... price['low'],
... price['close'],
... sl_stop=[0.1, np.nan, np.nan, np.nan],
... tsl_th=[np.nan, np.nan, 0.2, np.nan],
... tsl_stop=[np.nan, 0.1, 0.3, np.nan],
... tp_stop=[np.nan, np.nan, np.nan, 0.1],
... is_entry_open=True
... )
>>> ohlcstx.entries
ohlcstx_sl_stop 0.1 NaN NaN NaN
ohlcstx_tsl_th NaN NaN 0.2 NaN
ohlcstx_tsl_stop NaN 0.1 0.3 NaN
ohlcstx_tp_stop NaN NaN NaN 0.1
0 True True True True
1 False False False False
2 False False False False
3 False False False False
4 False False False False
5 False False False False
>>> ohlcstx.exits
ohlcstx_sl_stop 0.1 NaN NaN NaN
ohlcstx_tsl_th NaN NaN 0.2 NaN
ohlcstx_tsl_stop NaN 0.1 0.3 NaN
ohlcstx_tp_stop NaN NaN NaN 0.1
0 False False False False
1 False False False True
2 False False False False
3 False True False False
4 True False True False
5 False False False False
>>> ohlcstx.stop_price
ohlcstx_sl_stop 0.1 NaN NaN NaN
ohlcstx_tsl_th NaN NaN 0.2 NaN
ohlcstx_tsl_stop NaN 0.1 0.3 NaN
ohlcstx_tp_stop NaN NaN NaN 0.1
0 NaN NaN NaN NaN
1 NaN NaN NaN 11.0
2 NaN NaN NaN NaN
3 NaN 11.7 NaN NaN
4 9.0 NaN 9.1 NaN
5 NaN NaN NaN NaN
>>> ohlcstx.stop_type_readable
ohlcstx_sl_stop 0.1 NaN NaN NaN
ohlcstx_tsl_th NaN NaN 0.2 NaN
ohlcstx_tsl_stop NaN 0.1 0.3 NaN
ohlcstx_tp_stop NaN NaN NaN 0.1
0 None None None None
1 None None None TP
2 None None None None
3 None TSL None None
4 SL None TTP None
5 None None None None
Superclasses
- Analyzable
- AttrResolverMixin
- Base
- Cacheable
- Chainable
- Comparable
- Configured
- ExtPandasIndexer
- HasSettings
- HasWrapper
- IndexApplier
- IndexingBase
- IndicatorBase
- ItemParamable
- Itemable
- PandasIndexer
- Paramable
- Pickleable
- PlotsBuilderMixin
- Prettified
- StatsBuilderMixin
- Wrapping
vectorbtpro.signals.generators.ohlcstx.ParamIndexer
Inherited members
- AttrResolverMixin.deep_getattr
- AttrResolverMixin.post_resolve_attr
- AttrResolverMixin.pre_resolve_attr
- AttrResolverMixin.resolve_attr
- AttrResolverMixin.resolve_shortcut_attr
- Base.chat
- Base.find_api
- Base.find_assets
- Base.find_docs
- Base.find_examples
- Base.find_messages
- Cacheable.get_ca_setup
- Chainable.chain
- Chainable.pipe
- Configured.copy
- Configured.equals
- Configured.get_writeable_attrs
- Configured.prettify
- Configured.replace
- Configured.resolve_merge_kwargs
- Configured.update_config
- HasSettings.get_path_setting
- HasSettings.get_path_settings
- HasSettings.get_setting
- HasSettings.get_settings
- HasSettings.has_path_setting
- HasSettings.has_path_settings
- HasSettings.has_setting
- HasSettings.has_settings
- HasSettings.reset_settings
- HasSettings.resolve_setting
- HasSettings.resolve_settings_paths
- HasSettings.set_settings
- HasWrapper.chunk
- HasWrapper.chunk_apply
- HasWrapper.get_item_keys
- HasWrapper.select_col
- HasWrapper.select_col_from_obj
- HasWrapper.should_wrap
- HasWrapper.split
- HasWrapper.split_apply
- HasWrapper.ungroup
- IndexApplier.add_levels
- IndexApplier.drop_duplicate_levels
- IndexApplier.drop_levels
- IndexApplier.drop_redundant_levels
- IndexApplier.select_levels
- IndexingBase.indexing_setter_func
- IndicatorBase.cls_dir
- IndicatorBase.column_only_select
- IndicatorBase.column_stack
- IndicatorBase.config
- IndicatorBase.dropna
- IndicatorBase.fix_docstrings
- IndicatorBase.get
- IndicatorBase.group_select
- IndicatorBase.iloc
- IndicatorBase.in_output_names
- IndicatorBase.indexing_func
- IndicatorBase.indexing_kwargs
- IndicatorBase.input_names
- IndicatorBase.items
- IndicatorBase.lazy_output_names
- IndicatorBase.level_names
- IndicatorBase.loc
- IndicatorBase.main_output
- IndicatorBase.output_flags
- IndicatorBase.output_names
- IndicatorBase.param_defaults
- IndicatorBase.param_names
- IndicatorBase.plots_defaults
- IndicatorBase.range_only_select
- IndicatorBase.rec_state
- IndicatorBase.rename
- IndicatorBase.rename_levels
- IndicatorBase.row_stack
- IndicatorBase.run_pipeline
- IndicatorBase.self_aliases
- IndicatorBase.short_name
- IndicatorBase.stats_defaults
- IndicatorBase.to_dict
- IndicatorBase.to_frame
- IndicatorBase.unpack
- IndicatorBase.unwrapped
- IndicatorBase.wrapper
- IndicatorBase.xloc
- ItemParamable.as_param
- PandasIndexer.xs
- Pickleable.decode_config
- Pickleable.decode_config_node
- Pickleable.dumps
- Pickleable.encode_config
- Pickleable.encode_config_node
- Pickleable.file_exists
- Pickleable.getsize
- Pickleable.load
- Pickleable.loads
- Pickleable.modify_state
- Pickleable.resolve_file_path
- Pickleable.save
- PlotsBuilderMixin.build_subplots_doc
- PlotsBuilderMixin.override_subplots_doc
- PlotsBuilderMixin.plots
- PlotsBuilderMixin.resolve_plots_setting
- Prettified.pprint
- StatsBuilderMixin.build_metrics_doc
- StatsBuilderMixin.override_metrics_doc
- StatsBuilderMixin.resolve_stats_setting
- StatsBuilderMixin.stats
- Wrapping.apply_to_index
- Wrapping.regroup
- Wrapping.resample
- Wrapping.resolve_column_stack_kwargs
- Wrapping.resolve_row_stack_kwargs
- Wrapping.resolve_self
- Wrapping.resolve_stack_kwargs
Subclasses
vectorbtpro.signals.generators.ohlcstx._OHLCSTX
apply_func method¶
OHLCSTX.apply_func(
i,
entries,
entry_price,
open,
high,
low,
close,
stop_price,
stop_type,
sl_stop,
tsl_th,
tsl_stop,
tp_stop,
reverse,
exit_args,
wait,
until_next,
skip_until_exit
)
Apply function.
close class property¶
Input array.
close_above method¶
Return True for each element where close is above other.
See combine_objs.
close_below method¶
Return True for each element where close is below other.
See combine_objs.
close_crossed_above method¶
Return True for each element where close is crossed_above other.
See combine_objs.
close_crossed_below method¶
Return True for each element where close is crossed_below other.
See combine_objs.
close_equal method¶
Return True for each element where close is equal other.
See combine_objs.
close_stats method¶
Stats of close as generic.
custom_func method¶
SignalFactory.with_place_func.<locals>.custom_func(
input_list,
in_output_list,
param_list,
*args,
input_shape=None,
place_args=None,
entry_place_args=None,
exit_place_args=None,
entry_args=None,
exit_args=None,
cache_args=None,
entry_kwargs=None,
exit_kwargs=None,
cache_kwargs=None,
return_cache=False,
use_cache=None,
execute_kwargs=None,
**_kwargs
)
Custom function.
entries class property¶
Input array.
entries_and method¶
Return entries AND other.
See combine_objs.
entries_or method¶
Return entries OR other.
See combine_objs.
entries_stats method¶
Stats of entries as signals.
entries_xor method¶
Return entries XOR other.
See combine_objs.
entry_place_func_nb NoneType¶
Entry placement function.
entry_price class property¶
Input array.
entry_price_above method¶
Return True for each element where entry_price is above other.
See combine_objs.
entry_price_below method¶
Return True for each element where entry_price is below other.
See combine_objs.
entry_price_crossed_above method¶
Return True for each element where entry_price is crossed_above other.
See combine_objs.
entry_price_crossed_below method¶
Return True for each element where entry_price is crossed_below other.
See combine_objs.
entry_price_equal method¶
Return True for each element where entry_price is equal other.
See combine_objs.
entry_price_stats method¶
Stats of entry_price as generic.
exit_place_func_nb method¶
OHLCSTX.exit_place_func_nb(
c,
entry_price,
open,
high,
low,
close,
stop_price_out,
stop_type_out,
sl_stop,
tsl_th,
tsl_stop,
tp_stop,
reverse,
is_entry_open=False
)
Exit placement function.
exits class property¶
Output array.
exits_and method¶
Return exits AND other.
See combine_objs.
exits_or method¶
Return exits OR other.
See combine_objs.
exits_stats method¶
Stats of exits as signals.
exits_xor method¶
Return exits XOR other.
See combine_objs.
high class property¶
Input array.
high_above method¶
Return True for each element where high is above other.
See combine_objs.
high_below method¶
Return True for each element where high is below other.
See combine_objs.
high_crossed_above method¶
Return True for each element where high is crossed_above other.
See combine_objs.
high_crossed_below method¶
Return True for each element where high is crossed_below other.
See combine_objs.
high_equal method¶
Return True for each element where high is equal other.
See combine_objs.
high_stats method¶
Stats of high as generic.
low class property¶
Input array.
low_above method¶
Return True for each element where low is above other.
See combine_objs.
low_below method¶
Return True for each element where low is below other.
See combine_objs.
low_crossed_above method¶
Return True for each element where low is crossed_above other.
See combine_objs.
low_crossed_below method¶
Return True for each element where low is crossed_below other.
See combine_objs.
low_equal method¶
Return True for each element where low is equal other.
See combine_objs.
low_stats method¶
Stats of low as generic.
open class property¶
Input array.
open_above method¶
Return True for each element where open is above other.
See combine_objs.
open_below method¶
Return True for each element where open is below other.
See combine_objs.
open_crossed_above method¶
Return True for each element where open is crossed_above other.
See combine_objs.
open_crossed_below method¶
Return True for each element where open is crossed_below other.
See combine_objs.
open_equal method¶
Return True for each element where open is equal other.
See combine_objs.
open_stats method¶
Stats of open as generic.
plot method¶
_bind_ohlcstx_plot.<locals>.plot(
column=None,
ohlc_kwargs=None,
entry_price_kwargs=None,
entry_trace_kwargs=None,
exit_trace_kwargs=None,
add_trace_kwargs=None,
fig=None,
**layout_kwargs
)
Plot OHLC, OHLCSTX.entries and OHLCSTX.exits.
Args
ohlc_kwargs:dict- Keyword arguments passed to OHLCVDFAccessor.plot.
entry_trace_kwargs:dict- Keyword arguments passed to SignalsAccessor.plot_as_entries for OHLCSTX.entries.
exit_trace_kwargs:dict- Keyword arguments passed to SignalsAccessor.plot_as_exits for OHLCSTX.exits.
fig:FigureorFigureWidget- Figure to add traces to.
**layout_kwargs- Keyword arguments for layout.
Usage
reverse_list class property¶
List of reverse values.
run class method¶
OHLCSTX.run(
entries,
entry_price,
open=nan,
high=nan,
low=nan,
close=nan,
sl_stop=Default(value=nan),
tsl_th=Default(value=nan),
tsl_stop=Default(value=nan),
tp_stop=Default(value=nan),
reverse=Default(value=False),
stop_price=nan,
stop_type=-1,
short_name='ohlcstx',
hide_params=None,
hide_default=True,
**kwargs
)
Run OHLCSTX indicator.
- Inputs:
entries,entry_price,open,high,low,close - In-place outputs:
stop_price,stop_type - Parameters:
sl_stop,tsl_th,tsl_stop,tp_stop,reverse - Outputs:
exits
Pass a list of parameter names as hide_params to hide their column levels, or True to hide all. Set hide_default to False to show the column levels of the parameters with a default value.
Other keyword arguments are passed to IndicatorBase.run_pipeline.
run_combs class method¶
OHLCSTX.run_combs(
entries,
entry_price,
open=nan,
high=nan,
low=nan,
close=nan,
sl_stop=Default(value=nan),
tsl_th=Default(value=nan),
tsl_stop=Default(value=nan),
tp_stop=Default(value=nan),
reverse=Default(value=False),
stop_price=nan,
stop_type=-1,
r=2,
param_product=False,
comb_func=itertools.combinations,
run_unique=True,
short_names=None,
hide_params=None,
hide_default=True,
**kwargs
)
Create a combination of multiple OHLCSTX indicators using function comb_func.
- Inputs:
entries,entry_price,open,high,low,close - In-place outputs:
stop_price,stop_type - Parameters:
sl_stop,tsl_th,tsl_stop,tp_stop,reverse - Outputs:
exits
comb_func must accept an iterable of parameter tuples and r. Also accepts all combinatoric iterators from itertools such as itertools.combinations. Pass r to specify how many indicators to run. Pass short_names to specify the short name for each indicator. Set run_unique to True to first compute raw outputs for all parameters, and then use them to build each indicator (faster).
Other keyword arguments are passed to OHLCSTX.run.
Note
This method should only be used when multiple indicators are needed. To test multiple parameters, pass them as lists to OHLCSTX.run.
sl_stop_list class property¶
List of sl_stop values.
stop_price class property¶
In-place output array.
stop_price_above method¶
Return True for each element where stop_price is above other.
See combine_objs.
stop_price_below method¶
Return True for each element where stop_price is below other.
See combine_objs.
stop_price_crossed_above method¶
Return True for each element where stop_price is crossed_above other.
See combine_objs.
stop_price_crossed_below method¶
Return True for each element where stop_price is crossed_below other.
See combine_objs.
stop_price_equal method¶
Return True for each element where stop_price is equal other.
See combine_objs.
stop_price_stats method¶
Stats of stop_price as generic.
stop_type class property¶
In-place output array.
stop_type_readable class property¶
stop_type in readable format based on the following mapping:
stop_type_stats method¶
Stats of stop_type based on the following mapping:
tp_stop_list class property¶
List of tp_stop values.
tsl_stop_list class property¶
List of tsl_stop values.
tsl_th_list class property¶
List of tsl_th values.