Skip to content

request.currency_rate is rejected even in a branch that can never run #228

Closed

Description

@letiep97

Summary

Any reference to request.currency_rate fails analysis, even when it sits in a branch whose condition is a literal true. Scripts written for several markets often keep a conversion branch for non-USD symbols; today the whole script cannot be translated, even when backtested on a USD-quoted symbol where the branch is never taken.

Versions

pineforge-codegen 1.6.1

Reproduction

//@version=6
strategy('Currency branch')
rate = true ? 1.0 : request.currency_rate('EUR', 'USD')
plot(rate)

ANALYZER 3:42 request.currency_rate(...) is not supported.

Request

Either support request.currency_rate (daily rate feed supplied by the host, like other request.* data), or translate it to a run-time error raised only if the call is actually evaluated, so scripts that never take that branch can run.

Activity

  1. letiep97 commented on Oct 20, 2026

    @letiep97
    Author

    Still reproduces on main (aebad8c). A pointer in case it helps:

    request.currency_rate is listed in HARD_REJECT_FUNC (support_checker.py#L164), so any reference fails whether or not it can run.

    • Moving it to the no-data request family (NO_DATA_REQUEST_FUNC, support_checker.py#L152-L158, and NO_DATA_REQUEST_FUNCS, external_requests.py#L121) would cover uses that only reach display or alerts.
    • That rule is static, though: a branch that is never taken but feeds a quantity would still be refused. For that case, lowering the call to something that raises the run's error only when it is actually evaluated, as runtime.error() does (codegen/visit_call.py#L2368-L2373), would give the behaviour the issue asks for.

    Real support needs a rate feed from the host, which is your design call.

  2. luisleo526 commented on Oct 25, 2026

    @luisleo526
    Contributor

    Thank you for the report. Confirmed in the v1.7.0 source: any reference to request.currency_rate is rejected at analysis time, even in a branch that can never run. This is not fixed in v1.7.0. We are not adding a currency-rate data feed in this change. The planned change is the second option you suggested: translate the call so that it raises a run-time error only if the call is actually evaluated, so scripts that never take that branch can run. We expect to open the pull request on 2026-10-27.

  3. letiep97 commented on Oct 28, 2026

    @letiep97
    Author

    Verified on main (11b5ca5, with engine 1.6.1): the reproduction with request.currency_rate in a branch that never runs now translates and runs. Thank you for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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