You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
strategy.account_currency returns the symbol's quote currency, and two common uses do not compile #227
strategy.account_currency is generated as syminfo_.currency, so on a USDT-quoted symbol with strategy(currency=currency.USD) it reads USDT instead of USD. Comparing it with a currency.* constant, or concatenating it into a string, produces C++ that does not compile.
Versions
pineforge-codegen 1.6.1, pineforge-engine 1.6.1 (693fd9e6), Apple clang 17
Reproduction
Wrong value (compiles, fails at run time on BTCUSDT):
//@version=6
strategy('Account currency', currency=currency.USD)
if barstate.islast and strategy.account_currency != 'USD'
runtime.error('account currency is not USD')
plot(close)
PineForge stops with account currency is not USD. On TradingView the account currency is the currency argument (USD), so no error is raised.
Still reproduces on main (aebad8c). There are two separate causes, in case it helps:
Value.codegen/visit_expr.py#L811-L812 lowers strategy.account_currency to syminfo_.currency. On TradingView it is the strategy(currency=...) argument, and the symbol's currency only when that argument is currency.NONE. The declaration is already read in codegen/capabilities.py, so the lowering could emit that string when it isn't NONE.
Build errors. The analyzer types both strategy.account_currency and currency.* as string (analyzer/base.py#L6806, #L6902), but the C++ type inference _infer_type has a case for neither (codegen/types.py#L4042). So != takes the numeric na-aware comparison (static_cast<double> on a std::string), and + wraps the operand in std::to_string (codegen/visit_expr.py#L1602-L1611). Comparing with the literal 'USD' builds fine, which fits. Returning std::string for both in _infer_type should fix the two build failures.
Thank you for the report. We checked the v1.7.0 source and the cause of all three cases is still there: strategy.account_currency still returns the symbol's quote currency instead of the strategy's currency argument, and the comparison with a currency.* constant and the string concatenation still fail to build. This is not fixed in v1.7.0. A fix is being written now: the value will follow the currency argument of strategy() (the symbol's currency when it is omitted or currency.NONE), and both forms will build. We expect to open the pull request on 2026-10-26. This change does not add currency conversion; it only corrects the value.
Fixed by #250, merged to main: strategy.account_currency now follows the currency argument of strategy() (the symbol's currency when it is omitted or currency.NONE), and the comparison with a currency.* constant and the string concatenation both build. It will ship in the next codegen release; I will note the version here when it is published. Thank you for the clear cases.
Verified on main (11b5ca5, with engine 1.6.1): with currency=currency.USD on a symbol whose quote currency is not USD, strategy.account_currency now reads USD, and the comparison and concatenation cases both build and run. Thank you for the fix.
Activity
letiep97 commentedon Oct 20, 2026
Still reproduces on main (
aebad8c). There are two separate causes, in case it helps:strategy.account_currencytosyminfo_.currency. On TradingView it is thestrategy(currency=...)argument, and the symbol's currency only when that argument iscurrency.NONE. The declaration is already read in codegen/capabilities.py, so the lowering could emit that string when it isn'tNONE.strategy.account_currencyandcurrency.*as string (analyzer/base.py#L6806, #L6902), but the C++ type inference_infer_typehas a case for neither (codegen/types.py#L4042). So!=takes the numeric na-aware comparison (static_cast<double>on astd::string), and+wraps the operand instd::to_string(codegen/visit_expr.py#L1602-L1611). Comparing with the literal'USD'builds fine, which fits. Returningstd::stringfor both in_infer_typeshould fix the two build failures.luisleo526 commentedon Oct 25, 2026
Thank you for the report. We checked the v1.7.0 source and the cause of all three cases is still there:
strategy.account_currencystill returns the symbol's quote currency instead of the strategy'scurrencyargument, and the comparison with acurrency.*constant and the string concatenation still fail to build. This is not fixed in v1.7.0. A fix is being written now: the value will follow thecurrencyargument ofstrategy()(the symbol's currency when it is omitted orcurrency.NONE), and both forms will build. We expect to open the pull request on 2026-10-26. This change does not add currency conversion; it only corrects the value.Merge main into cx/iss-227
codegen: strategy.account_currency follows strategy(currency=...) (#227…
Merge main into cx/iss-231
luisleo526 commentedon Oct 25, 2026
Fixed by #250, merged to main:
strategy.account_currencynow follows thecurrencyargument ofstrategy()(the symbol's currency when it is omitted orcurrency.NONE), and the comparison with acurrency.*constant and the string concatenation both build. It will ship in the next codegen release; I will note the version here when it is published. Thank you for the clear cases.luisleo526 commentedon Oct 25, 2026
Update: this fix ships in the next codegen release, 1.8.0 (paired with the engine; I will confirm here when it is published).
docs: CHANGELOG: the planned 1.8.0 section with migration notes (#257)
letiep97 commentedon Oct 28, 2026
Verified on main (
11b5ca5, with engine 1.6.1): withcurrency=currency.USDon a symbol whose quote currency is not USD,strategy.account_currencynow readsUSD, and the comparison and concatenation cases both build and run. Thank you for the fix.