Skip to content

Expose candle settings in the public API #755

Description

@mario4tier

Candle settings are the documented way to tune the pattern functions — what counts as a "long" real body, a "doji", a "near" gap. The bindings are already compiled in (talib/_common.pxi), they're just not exported, so the only way to reach them today is through the private module:

import talib._ta_lib

talib._ta_lib._ta_set_candle_settings(
    talib._ta_lib.CandleSettingType.BodyLong,
    talib._ta_lib.RangeType.RealBody, 10, 2.0)

_ta_lib.pyx sets __all__ to the indicator names only, so from ._ta_lib import * in __init__.py doesn't pick them up, and __init__.py names only set_unstable_period / set_compatibility explicitly.

Proposal: export them like the other global-state setters.

  • talib.set_candle_settings(setting_type, range_type, avg_period, factor)
  • talib.restore_candle_default_settings(setting_type)
  • talib.CandleSettingType, talib.RangeType

No getter — the C API has only TA_SetCandleSettings and TA_RestoreCandleDefaultSettings.

Why bother: Multiple occurences where visibility might help. In #624 the answer was the private call, and it was exactly what the user needed. In #119 the very first suggestion in the thread was "try different CandleSettings" — advice nobody could actually follow from the public API. #150 is in the same neighbourhood.

I may follow up with a PR as part of the coming v0.8.1 release.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions