Base class for positions.
Parameters: |
|
---|
Note
This is a base class and should not be used directly.
Returns True if the entry order was filled.
Returns True if the exit order was filled.
Returns the pyalgotrade.broker.Order used to enter the position.
Returns True if an order to exit the position should be automatically submitted when the session is about to close.
Returns the pyalgotrade.broker.Order used to exit the position. If this position hasn’t been closed yet, None is returned.
Returns the instrument used for this position.
Returns the position’s net profit.
Returns the number of shares used to enter this position.
Returns the ratio between the order prices. It doesn’t include commisions.
Returns the position’s returns.
Set to True to automatically place an exit order when the session is about to close. Only useful for intraday trading.
Note
If the entry order was not filled by the time the session is about to close, it will get canceled.
Base class for strategies.
Parameters: |
|
---|
Note
This is a base class and should not be used directly.
Generates a buy pyalgotrade.broker.MarketOrder to enter a long position.
Parameters: |
|
---|---|
Return type: | The Position entered. |
Generates a buy pyalgotrade.broker.LimitOrder to enter a long position.
Parameters: |
|
---|---|
Return type: | The Position entered. |
Generates a buy pyalgotrade.broker.StopOrder to enter a long position.
Parameters: |
|
---|---|
Return type: | The Position entered. |
Generates a buy pyalgotrade.broker.StopLimitOrder order to enter a long position.
Parameters: |
|
---|---|
Return type: | The Position entered. |
Generates a sell short pyalgotrade.broker.MarketOrder to enter a short position.
Parameters: |
|
---|---|
Return type: | The Position entered. |
Generates a sell short pyalgotrade.broker.LimitOrder to enter a short position.
Parameters: |
|
---|---|
Return type: | The Position entered. |
Generates a sell short pyalgotrade.broker.StopOrder to enter a short position.
Parameters: |
|
---|---|
Return type: | The Position entered. |
Generates a sell short pyalgotrade.broker.StopLimitOrder order to enter a short position.
Parameters: |
|
---|---|
Return type: | The Position entered. |
Generates the exit order for the position.
Parameters: |
|
---|
Note
Returns the pyalgotrade.broker.Broker used to handle order executions.
Returns the datetime.datetime for the current pyalgotrade.bar.Bar.
Returns the pyalgotrade.barfeed.BarFeed that this strategy is using.
Override (mandatory) to get notified when new bars are available. The default implementation raises an Exception.
This is the method to override to enter your trading logic and enter/exit positions.
Parameters: | bars (pyalgotrade.bar.Bars.) – The current bars. |
---|
Override (optional) to get notified when the order submitted to enter a position was canceled. The default implementation is empty.
Parameters: | position (Position.) – A position returned by any of the enterLongXXX or enterShortXXX methods. |
---|
Override (optional) to get notified when the order submitted to enter a position was filled. The default implementation is empty.
Parameters: | position (Position.) – A position returned by any of the enterLongXXX or enterShortXXX methods. |
---|
Override (optional) to get notified when the order submitted to exit a position was canceled. The default implementation is empty.
Parameters: | position (Position.) – A position returned by any of the enterLongXXX or enterShortXXX methods. |
---|
Override (optional) to get notified when the order submitted to exit a position was filled. The default implementation is empty.
Parameters: | position (Position.) – A position returned by any of the enterLongXXX or enterShortXXX methods. |
---|
Override (optional) to get notified when the strategy finished executing. The default implementation is empty.
Parameters: | bars (pyalgotrade.bar.Bars.) – The last bars processed. |
---|
Override (optional) to get notified when an order gets updated. This is only called if the order was placed using the broker interface directly.
Parameters: | order (pyalgotrade.broker.Order.) – The order updated. |
---|
Override (optional) to get notified when the strategy starts executing. The default implementation is empty.
Call once (and only once) to backtest the strategy.