Base class for positions.
Parameters: | entryOrder (pyalgotrade.broker.Order) – The order used to enter the position. |
---|
Note
This is a base class and should not be used directly.
Returns the pyalgotrade.broker.Order used to enter the position.
Returns True if an order to exit the position should be automatically placed.
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 difference between the order prices. It does include commisions.
Returns the number of shares used to enter this position.
Returns the ratio between the order prices. It doesn’t include commisions.
Set to True to automatically place the exit order in the last bar for the session.
Base class for strategies.
Parameters: |
|
---|
Note
This is a base class and should not be used directly.
Generates a buy market order to enter a long position.
Parameters: |
|
---|---|
Return type: | The Position entered. |
Generates a buy limit order to enter a long position.
Parameters: |
|
---|---|
Return type: | The Position entered. |
Generates a sell short market order to enter a short position.
Parameters: |
|
---|---|
Return type: | The Position entered. |
Generates a sell short limit order to enter a short position.
Parameters: |
|
---|---|
Return type: | The Position entered. |
Generates the exit order for the position.
Parameters: |
|
---|
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 enterLong() or enterShort(). |
---|
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 enterLong() or enterShort(). |
---|
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 enterLong() or enterShort(). |
---|
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 enterLong() or enterShort(). |
---|
Override (optional) to get notified when the strategy finished executing. The default implementation is empty.
Parameters: | bars (pyalgotrade.bar.Bars.) – The latest bars processed. |
---|
Override (optional) to get notified when the strategy starts executing. The default implementation is empty.
Call once (and only once) to backtest the strategy.