Skip to content
New: Star-import, signal unraveling, Python 3.12 support, and more

# ctx_helpers module

Numba-compiled helper functions for portfolio simulation.

## any_order_nb function

    any_order_nb(
        c
    )

Check whether there is any order in the current column.

## get_allocation_nb function

    get_allocation_nb(
        c
    )

Get asset value of the current column.

## get_asset_value_nb function

    get_asset_value_nb(
        c
    )

Get asset value of the current column.

## get_cash_nb function

    get_cash_nb(
        c
    )

Get cash of the current column or group with cash sharing.

## get_entry_trade_records_nb function

    get_entry_trade_records_nb(
        c,
        init_position=0.0,
        init_price=nan
    )

Get entry trade records up to this point.

## get_exit_trade_records_nb function

    get_exit_trade_records_nb(
        c,
        init_position=0.0,
        init_price=nan
    )

Get exit trade records up to this point.

## get_free_cash_nb function

    get_free_cash_nb(
        c
    )

Get free cash of the current column or group with cash sharing.

## get_last_order_nb function

    get_last_order_nb(
        c
    )

Get the last order in the current column.

## get_limit_target_price_nb function

    get_limit_target_price_nb(
        c
    )

Get limit target price.

## get_n_active_positions_nb function

    get_n_active_positions_nb(
        c
    )

Get the number of active positions in the current group (regardless of cash sharing).

## get_order_records_nb function

    get_order_records_nb(
        c
    )

Get order records up to this point.

## get_position_records_nb function

    get_position_records_nb(
        c,
        init_position=0.0,
        init_price=nan
    )

Get position records up to this point.

## get_sl_target_price_nb function

    get_sl_target_price_nb(
        c
    )

Get SL target price.

## get_tp_target_price_nb function

    get_tp_target_price_nb(
        c
    )

Get TP target price.

## get_tsl_target_price_nb function

    get_tsl_target_price_nb(
        c
    )

Get TSL/TTP target price.

## get_value_nb function

    get_value_nb(
        c
    )

Get value of the current column or group with cash sharing.

## has_free_cash_nb function

    has_free_cash_nb(
        c
    )

Check whether the current column or group with cash sharing has free cash.

## in_long_position_nb function

    in_long_position_nb(
        c
    )

Check whether the current column is in a long position.

## in_position_nb function

    in_position_nb(
        c
    )

Check whether the current column is in a position.

## in_short_position_nb function

    in_short_position_nb(
        c
    )

Check whether the current column is in a short position.

## order_closed_position_nb function

    order_closed_position_nb(
        c
    )

Check whether the order has closed out an existing position.

## order_decreased_position_nb function

    order_decreased_position_nb(
        c
    )

Check whether the order has decreased an existing position.

## order_filled_nb function

    order_filled_nb(
        c
    )

Check whether the order was filled.

## order_increased_position_nb function

    order_increased_position_nb(
        c
    )

Check whether the order has increased an existing position.

## order_opened_position_nb function

    order_opened_position_nb(
        c
    )

Check whether the order has opened a new position.

## order_reversed_position_nb function

    order_reversed_position_nb(
        c
    )

Check whether the order has reversed an existing position.

#### Cookie consent

We use cookies to recognize your repeated visits and preferences, as well as to measure the effectiveness of our documentation and whether users find what they're searching for. With your consent, you're helping us to make our documentation better.

- Google Analytics
- GitHub

Manage settings