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 order id.
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 is active.
Returns True if the order state is Order.State.CANCELED.
Returns True if the order state is Order.State.FILLED.
Returns True if the order state is Order.State.INITIAL.
Returns True if the order state is Order.State.SUBMITTED.
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.
Bases: pyalgotrade.broker.Order
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).
Bases: pyalgotrade.broker.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.
Bases: pyalgotrade.broker.Order
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.
Bases: pyalgotrade.broker.Order
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.
Bases: pyalgotrade.observer.Subject
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.
Base class for implementing different commission schemes.
Note
This is a base class and should not be used directly.
Calculates the commission for an order.
Parameters: |
|
---|---|
Return type: | float. |
Bases: pyalgotrade.broker.backtesting.Commission
A Commission class that always returns 0.
Bases: pyalgotrade.broker.backtesting.Commission
A Commission class that charges a fixed amount for the whole trade.
Parameters: | amount (float.) – The commission for an order. |
---|
Bases: pyalgotrade.broker.backtesting.Commission
A Commission class that charges a percentage of the whole trade.
Parameters: | percentage (float.) – The percentage to charge. 0.01 means 1%, and so on. It must be smaller than 1. |
---|
Bases: pyalgotrade.broker.Broker
Backtesting broker.
Parameters: |
|
---|
Returns the available cash.
Parameters: | includeShort (boolean.) – Include cash from short positions. |
---|
Returns the commission instance.
Return type: | Commission. |
---|
Returns the portfolio value (cash + shares).
Returns the FillStrategy currently set.
Sets the available cash.
Sets the commission instance.
Parameters: | commission (Commission.) – An object responsible for calculating order commissions. |
---|
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: | A FillInfo 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: | A FillInfo 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: | A FillInfo 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: | A FillInfo or None if the order should not be filled. |
Bases: pyalgotrade.broker.backtesting.FillStrategy
Default fill strategy.
Parameters: | volumeLimit (float.) – The proportion of the volume that an order can take up in a bar. Must be > 0 and <= 1. |
---|
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.