backtrader.sizers.fixedsize module¶
Fixed Size Sizer Module - Fixed stake position sizing.
This module provides the FixedSize sizer for using a fixed stake size in trading operations.
- Classes:
FixedSize: Returns a fixed stake size for orders.
示例
>>> cerebro.addsizer(bt.sizers.FixedSize, stake=10)
- class backtrader.sizers.fixedsize.FixedSize[源代码]¶
基类:
SizerThis sizer simply returns a fixed size for any operation. Size can be controlled by the number of tranches that a system wishes to use to scale into trades by specifying the
tranchesparameter.This class has been refactored from legacy params tuple to the new ParameterDescriptor system for Day 36-38 of the metaprogramming removal project.
- Params:
stake(default:1)tranches(default:1)
- stake¶
Advanced parameter descriptor with type checking and validation.
This descriptor replaces the metaclass-based parameter system with a more modern and maintainable approach. It provides:
Automatic type checking and conversion
Value validation
Default value handling
Documentation support
Python 3.6+ __set_name__ support
- tranches¶
Advanced parameter descriptor with type checking and validation.
This descriptor replaces the metaclass-based parameter system with a more modern and maintainable approach. It provides:
Automatic type checking and conversion
Value validation
Default value handling
Documentation support
Python 3.6+ __set_name__ support
- class backtrader.sizers.fixedsize.FixedReverser[源代码]¶
基类:
SizerThis sizer returns the needes fixed size to reverse an open position or the fixed size to open one
To open a position: return the param
stakeTo reverse a position: return 2 * stake
- Params:
stake(default:1)
- stake¶
Advanced parameter descriptor with type checking and validation.
This descriptor replaces the metaclass-based parameter system with a more modern and maintainable approach. It provides:
Automatic type checking and conversion
Value validation
Default value handling
Documentation support
Python 3.6+ __set_name__ support
- class backtrader.sizers.fixedsize.FixedSizeTarget[源代码]¶
基类:
SizerThis sizer simply returns a fixed target size, useful when coupled with Target Orders and specifically
cerebro.target_order_size(). Size can be controlled by the number of tranches that a system wishes to use to scale into trades by specifying thetranchesparameter.- Params:
stake(default:1)tranches(default:1)
- stake¶
Advanced parameter descriptor with type checking and validation.
This descriptor replaces the metaclass-based parameter system with a more modern and maintainable approach. It provides:
Automatic type checking and conversion
Value validation
Default value handling
Documentation support
Python 3.6+ __set_name__ support
- tranches¶
Advanced parameter descriptor with type checking and validation.
This descriptor replaces the metaclass-based parameter system with a more modern and maintainable approach. It provides:
Automatic type checking and conversion
Value validation
Default value handling
Documentation support
Python 3.6+ __set_name__ support