Set a limit on the number of shares and/or dollar value held for the given sid. Limits are treated as absolute values and are enforced at the time that the algo attempts to place an order for sid. This means that it's possible to end up with more than the max number of shares
(self,
asset=None,
max_shares=None,
max_notional=None,
on_error='fail')
| 2097 | |
| 2098 | @api_method |
| 2099 | def set_max_position_size(self, |
| 2100 | asset=None, |
| 2101 | max_shares=None, |
| 2102 | max_notional=None, |
| 2103 | on_error='fail'): |
| 2104 | """Set a limit on the number of shares and/or dollar value held for the |
| 2105 | given sid. Limits are treated as absolute values and are enforced at |
| 2106 | the time that the algo attempts to place an order for sid. This means |
| 2107 | that it's possible to end up with more than the max number of shares |
| 2108 | due to splits/dividends, and more than the max notional due to price |
| 2109 | improvement. |
| 2110 | |
| 2111 | If an algorithm attempts to place an order that would result in |
| 2112 | increasing the absolute value of shares/dollar value exceeding one of |
| 2113 | these limits, raise a TradingControlException. |
| 2114 | |
| 2115 | Parameters |
| 2116 | ---------- |
| 2117 | asset : Asset, optional |
| 2118 | If provided, this sets the guard only on positions in the given |
| 2119 | asset. |
| 2120 | max_shares : int, optional |
| 2121 | The maximum number of shares to hold for an asset. |
| 2122 | max_notional : float, optional |
| 2123 | The maximum value to hold for an asset. |
| 2124 | """ |
| 2125 | control = MaxPositionSize(asset=asset, |
| 2126 | max_shares=max_shares, |
| 2127 | max_notional=max_notional, |
| 2128 | on_error=on_error) |
| 2129 | self.register_trading_control(control) |
| 2130 | |
| 2131 | @api_method |
| 2132 | def set_max_order_size(self, |