Base class for orders.
Parameters: |
|
---|
Note
Valid action parameter values are:
- Order.Action.BUY
- Order.Action.BUY_TO_COVER
- Order.Action.SELL
- Order.Action.SELL_SHORT
This is a base class and should not be used directly.
Returns the order action.
Returns True if the order should be completely filled or else canceled.
Returns the order execution info if the order was filled, or None otherwise.
Return type: | OrderExecutionInfo. |
---|
Returns True if the order is good till canceled.
Returns the instrument identifier.
Returns the quantity.
Returns the order state.
Returns the order type
Returns True if the order state is Order.State.ACCEPTED.
Returns True if the order state is Order.State.CANCELED.
Returns True if the order state is Order.State.FILLED.
Sets the All-Or-None property for this order.
Parameters: | allOrNone (boolean.) – True if the order should be completely filled or else canceled. |
---|
Sets if the order should be good till canceled. Orders that are not filled by the time the session closes will be will be automatically canceled if they were not set as good till canceled
Parameters: | goodTillCanceled (boolean.) – True if the order should be good till canceled. |
---|
Updates the quantity.
Base class for market orders.
Note
This is a base class and should not be used directly.
Returns True if the order should be filled as close to the closing price as possible (Market-On-Close order).
Sets if the order should be filled as close to the closing price as possible (Market-On-Close order).
Base class for limit orders.
Note
This is a base class and should not be used directly.
Returns the limit price.
Updates the limit price.
Base class for stop orders.
Note
This is a base class and should not be used directly.
Returns the stop price.
Updates the stop price.
Base class for stop limit orders.
Note
This is a base class and should not be used directly.
Returns the limit price.
Returns the stop price.
Returns True if the limit order is active.
Updates the limit price.
Updates the stop price.
Execution information for a filled order.
Returns the commission applied.
Returns the datatime.datetime when the order was executed.
Returns the fill price.
Returns the quantity.
Base class for brokers.
Note
This is a base class and should not be used directly.
Requests an order to be canceled. If the order is filled an Exception is raised.
Parameters: | order (Order.) – The order to cancel. |
---|
Creates a Limit order. A limit order is an order to buy or sell a stock at a specific price or better. A buy limit order can only be executed at the limit price or lower, and a sell limit order can only be executed at the limit price or higher.
Parameters: |
|
---|---|
Return type: | A LimitOrder subclass. |
Creates a Market order. A market order is an order to buy or sell a stock at the best available price. Generally, this type of order will be executed immediately. However, the price at which a market order will be executed is not guaranteed.
Parameters: |
|
---|---|
Return type: | A MarketOrder subclass. |
Creates a Stop-Limit order. A stop-limit order is an order to buy or sell a stock that combines the features of a stop order and a limit order. Once the stop price is reached, a stop-limit order becomes a limit order that will be executed at a specified price (or better). The benefit of a stop-limit order is that the investor can control the price at which the order can be executed.
Parameters: |
|
---|---|
Return type: | A StopLimitOrder subclass. |
Creates a Stop order. A stop order, also referred to as a stop-loss order, is an order to buy or sell a stock once the price of the stock reaches a specified price, known as the stop price. When the stop price is reached, a stop order becomes a market order. A buy stop order is entered at a stop price above the current market price. Investors generally use a buy stop order to limit a loss or to protect a profit on a stock that they have sold short. A sell stop order is entered at a stop price below the current market price. Investors generally use a sell stop order to limit a loss or to protect a profit on a stock that they own.
Parameters: |
|
---|---|
Return type: | A StopOrder subclass. |
Returns a sequence with the orders that are still active.
Returns a dictionary that maps instruments to shares.
Returns the number of shares for an instrument.
Backtesting broker.
Parameters: |
|
---|
Returns the available cash.
Returns the commission instance.
Returns the portfolio value (cash + shares).
Returns the FillStrategy currently set.
Sets the available cash.
Sets the commission instance.
Sets the FillStrategy to use.
Base class for order filling strategies.
Override to return the fill price for a limit order or None if the order can’t be filled at the given time.
Parameters: |
|
---|---|
Return type: | An int/float with the fill price or None if the order should not be filled. |
Override to return the fill price for a market order or None if the order can’t be filled at the given time.
Parameters: |
|
---|---|
Return type: | An int/float with the fill price or None if the order should not be filled. |
Override to return the fill price for a stop limit order or None if the order can’t be filled at the given time.
Parameters: |
|
---|---|
Return type: | An int/float with the fill price or None if the order should not be filled. |
Override to return the fill price for a stop order or None if the order can’t be filled at the given time.
Parameters: |
|
---|---|
Return type: | An int/float with the fill price or None if the order should not be filled. |
This strategy works as follows:
A pyalgotrade.broker.MarketOrder is always filled using the open/close price.
If the stop price was penetrated with the open price, or if the bar includes the stop price, then the limit order becomes active.
Note
This is the default strategy used by the Broker.