Skip to main content
Package containing trading functionality for creating and managing orders, positions, and commissions in Indie trading strategies.

Types

AmendOrderBuilder

type Builder class for modifying existing trading orders with updated parameters.

Methods

size
(size) -> indie.strategies.AmendOrderBuilder
Updates the size (quantity) of the existing order.
limit
(price) -> indie.strategies.AmendOrderBuilder
Updates the limit price of the existing order.
stop
(price) -> indie.strategies.AmendOrderBuilder
Updates the stop price of the existing order.
take_profit
(stop, *, limit) -> indie.strategies.AmendOrderBuilder
Updates the take profit settings of the existing order.
stop_loss
(stop, *, limit) -> indie.strategies.AmendOrderBuilder
Updates the stop loss settings of the existing order.
submit
() -> None
Builds and submits the order updates to the trading system.

Commission

type Represents trading commission settings with configurable commission type and value.

Methods

__init__
(value, commission_type) -> None
Creates a new Commission object with specified value and commission type.

ExitOrder

type Represents exit order settings for take profit and stop loss.

Fields

stop
float
Stop price for the exit order (take profit or stop loss).
limit
indie.Optional[float]
Limit price for the exit order (take profit or stop loss).

Order

type Represents a trading order with properties for tracking its status, execution type, and parameters.

Fields

id
str
Unique identifier of the order.
status
indie.strategies.order_status
Current status of the order.
execution_type
indie.strategies.order_execution_type
Execution type of the order (market, limit, stop, or stop-limit).
side
indie.strategies.order_side
Side of the order (buy or sell).
size
float
Size (quantity) of the order.
limit
indie.Optional[float]
Limit price for limit and stop-limit orders. None for market and stop orders.
stop
indie.Optional[indie.strategies.Stop]
Stop price for stop and stop-limit orders. None for market and limit orders.
take_profit
indie.Optional[indie.strategies.ExitOrder]
Take profit settings for the order. None if not set.
stop_loss
indie.Optional[indie.strategies.ExitOrder]
Stop loss settings for the order. None if not set.

Methods

cancel
() -> None
Cancels the order. Equivalent to calling Trading.cancel_order() with this order’s ID.
amend
() -> indie.strategies.AmendOrderBuilder
Returns a builder for amending this order’s parameters. Allows modification of size, limit price, and stop price.

PlaceOrderBuilder

type Builder class for creating new trading orders with specified parameters.

Methods

limit
(price) -> indie.strategies.PlaceOrderBuilder
Sets the limit price for the order. Applicable to create limit and stop-limit orders.
stop
(price, direction) -> indie.strategies.PlaceOrderBuilder
Sets the stop price for the order. Applicable to create stop and stop-limit orders.
take_profit
(stop, *, limit) -> indie.strategies.PlaceOrderBuilder
Sets the take profit settings for the order.
stop_loss
(stop, *, limit) -> indie.strategies.PlaceOrderBuilder
Sets the stop loss settings for the order.
submit
() -> indie.strategies.Order
Builds and submits the new order to the trading system. Returns the created Order object.

Position

type Represents a current trading position with size and entry price information.

Fields

size
float
Current position size. Positive for long positions, negative for short positions, zero for no position.
price
float
Average entry price of the current position.

Stop

type Represents trigger settings for a stop-order.

Fields

price
float
Trigger price for the stop order.
direction
indie.strategies.trigger_direction
The direction in which the market price should go trigger the price of the stop order.

Trading

type Main class for executing trading operations including order creation, modification, and cancellation. Provides access to account cash and position information.

Fields

cash
float
Available cash balance allocated to the strategy.
position
indie.strategies.Position
Current position object containing size and entry price.

Methods

place_order
(side, size) -> indie.strategies.PlaceOrderBuilder
Returns a builder for placing a new trading order with specified side and size.
amend_order
(id) -> indie.strategies.AmendOrderBuilder
Returns a builder to amend an existing order’s parameters by its ID.
cancel_order
(id) -> None
Cancels an existing order by its ID.

Enums

commission_type

enum Enum representing the type of commission calculation.

Static fields

PERCENT
indie.strategies.commission_type
Commission calculated as a percentage of the trade value (e.g., 0.001 for 0.1%).
FIXED
indie.strategies.commission_type
Commission calculated as a fixed amount per trade (e.g., 0.01 for $0.01).

intrabar_order_filter

enum Enum defining when orders should be executed within a bar during backtesting.

Static fields

ON_BAR_CLOSE
indie.strategies.intrabar_order_filter
Execute orders only at bar close.
FIRST_IN_BAR
indie.strategies.intrabar_order_filter
Execute only the first created order in the bar.
LAST_IN_BAR
indie.strategies.intrabar_order_filter
Execute only the last created order in the bar.
NO_FILTER
indie.strategies.intrabar_order_filter
Execute orders at any time within the bar without filtering.

market_order_price

enum Enum defining the price at which market orders are executed in backtesting.

Static fields

MARKET_PRICE
indie.strategies.market_order_price
Use the actual market price at the time of execution.
ORDER_CREATION_PRICE
indie.strategies.market_order_price
Use the price at the moment the order was created.
BAR_OPEN_PRICE
indie.strategies.market_order_price
Use the opening price of the bar.

order_execution_type

enum Enum representing the execution type of a trading order.

Static fields

MARKET
indie.strategies.order_execution_type
Market order that executes immediately at the current market price.
LIMIT
indie.strategies.order_execution_type
Limit order that executes at a specified price or better.
STOP
indie.strategies.order_execution_type
Stop order that becomes a market order when the stop price is reached.
STOP_LIMIT
indie.strategies.order_execution_type
Stop-limit order that becomes a limit order when the stop price is reached.

order_side

enum Enum representing the side of a trading order.

Static fields

BUY
indie.strategies.order_side
Buy side for a trading order.
SELL
indie.strategies.order_side
Sell side for a trading order.

order_status

enum Enum representing the current status of a trading order.

Static fields

CREATED
indie.strategies.order_status
Order has been created locally but not yet sent to the exchange.
PLACED
indie.strategies.order_status
Order has been accepted by the exchange and entered the order book.
PENDING_PLACED
indie.strategies.order_status
Order is waiting for a trigger condition to be met and has not yet entered the order book.
PARTIALLY_FILLED
indie.strategies.order_status
Order has been partially filled and remains open.
FILLED
indie.strategies.order_status
Order has been completely filled.
PARTIALLY_FILLED_CLOSED
indie.strategies.order_status
Order has been partially filled and then closed without full execution.
REJECTED
indie.strategies.order_status
Order has been rejected by the exchange.
CANCELED
indie.strategies.order_status
Order has been canceled by the strategy or by the exchange.

trigger_direction

enum Enum representing the direction of a stop order trigger.

Static fields

RISES_TO
indie.strategies.trigger_direction
Stop order is triggered when the market price rises to or above the stop price.
FALLS_TO
indie.strategies.trigger_direction
Stop order is triggered when the market price falls to or below the stop price.
AUTO
indie.strategies.trigger_direction
The system automatically determines the trigger direction based on the current market price and specified stop price. If the stop price is above the current market price, it triggers on rise; if below, it triggers on fall.