Bases: object
Base class for orders.
Parameters: |
|
---|
Note
This is a base class and should not be used directly.
Valid type parameter values are:
- Order.Type.MARKET
- Order.Type.LIMIT
- Order.Type.STOP
- Order.Type.STOP_LIMIT
Valid action parameter values are:
- Order.Action.BUY
- Order.Action.BUY_TO_COVER
- Order.Action.SELL
- Order.Action.SELL_SHORT
Returns the order id.
Note
This will be None if the order was not submitted.
Returns the order type. Valid order types are:
Returns the datetime when the order was submitted.
Returns the order action. Valid order actions are:
Returns the order state. Valid order states are:
Returns True if the order is active.
Returns True if the order state is Order.State.INITIAL.
Returns True if the order state is Order.State.SUBMITTED.
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.PARTIALLY_FILLED.
Returns True if the order state is Order.State.FILLED.
Returns the instrument identifier.
Returns the quantity.
Returns the number of shares that have been executed.
Returns the number of shares still outstanding.
Returns the average price of the shares that have been executed, or None if nothing has been filled.
Returns True if the order is good till 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. |
---|
Note
This can’t be changed once the order is submitted.
Returns True if the order should be completely filled or else canceled.
Sets the All-Or-None property for this order.
Parameters: | allOrNone (boolean.) – True if the order should be completely filled. |
---|
Note
This can’t be changed once the order is submitted.
Returns the last execution information for this order, or None if nothing has been filled so far. This will be different every time an order, or part of it, gets filled.
Return type: | OrderExecutionInfo. |
---|
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).
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.
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.
Bases: pyalgotrade.broker.Order
Base class for stop limit orders.
Note
This is a base class and should not be used directly.
Returns the stop price.
Returns the limit price.
Bases: object
Execution information for an order.
Returns the fill price.
Returns the quantity.
Returns the commission applied.
Returns the datatime.datetime when the order was executed.
Bases: pyalgotrade.observer.Subject
Base class for brokers.
Note
This is a base class and should not be used directly.
Returns the available cash.
Parameters: | includeShort (boolean.) – Include cash from short positions. |
---|
Returns the number of shares for an instrument.
Returns a dictionary that maps instruments to shares.
Returns a sequence with the orders that are still active.
Parameters: | instrument (string.) – An optional instrument identifier to return only the active orders for the given instrument. |
---|
Submits an order.
Parameters: | order (Order.) – The order to submit. |
---|
Note
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 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 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. |
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. |
Bases: object
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 execution.
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 strategy used to calculate order commissions.
Return type: | Commission. |
---|
Returns the portfolio value (cash + shares).
Returns the pyalgotrade.broker.fillstrategy.FillStrategy currently set.
Sets the strategy to use to calculate order commissions.
Parameters: | commission (Commission.) – An object responsible for calculating order commissions. |
---|
Sets the pyalgotrade.broker.fillstrategy.FillStrategy to use.
Bases: object
Base class for slippage models.
Note
This is a base class and should not be used directly.
Returns the slipped price per share for an order.
Parameters: |
|
---|---|
Return type: | float. |
Bases: pyalgotrade.broker.slippage.SlippageModel
A no slippage model.
Bases: pyalgotrade.broker.slippage.SlippageModel
A volume share slippage model as defined in Zipline’s VolumeShareSlippage model. The slippage is calculated by multiplying the price impact constant by the square of the ratio of the order to the total volume.
Check https://www.quantopian.com/help#ide-slippage for more details.
Parameters: | priceImpact (float.) – Defines how large of an impact your order will have on the backtester’s price calculation. |
---|
Bases: object
Base class for order filling strategies for the backtester.
Override to return the fill price and quantity 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 and quantity 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 and quantity 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 and quantity 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. |
Override (optional) to get notified when the broker is about to process new bars.
Parameters: |
|
---|
Override (optional) to get notified when an order was filled, or partially filled.
Parameters: |
|
---|
Bases: pyalgotrade.broker.fillstrategy.FillStrategy
Default fill strategy.
Parameters: | volumeLimit (float) – The proportion of the volume that orders 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
Set the slippage model to use.
Parameters: | slippageModel (pyalgotrade.broker.slippage.SlippageModel) – The slippage model. |
---|
Set the volume limit.
Parameters: | volumeLimit (float) – The proportion of the volume that orders can take up in a bar. Must be > 0 and <= 1. |
---|