דלגו לתוכן
פתיחת RaamTrade

RC2_FSTRING_SPEC

תוכן זה אינו זמין עדיין בשפה שלך.

Unrecognized f-string format spec. The value is interpolated without formatting.

This is a WARNING, not an error

Your strategy still compiles and still runs. The interpolated value appears in the string unformatted — full precision, no padding, no separators. Nothing else changes.

What it means

f-strings are translated into .NET interpolated strings, and the format spec after the : has to be translated with them. The transpiler maps the specs that have a faithful .NET equivalent; a spec outside that set has no honest translation, so instead of guessing at one it drops the spec, keeps the value, and warns.

Supported specs

Spec Meaning Example
.Nf Fixed-point, N decimals f"{rsi.value:.1f}" → 62.4
.Ne / .NE Scientific notation f"{x:.2e}"
.Ng / .NG General (shortest of fixed/scientific) f"{x:.3g}"
.N% Percent, N decimals (value × 100) f"{x:.2%}"
d Integer f"{n:d}"
x / X Hex, lower / upper case f"{n:x}"

Anything else — thousands separators, alignment and padding, explicit signs, zero-fill — is not translated.

Why it happens

You reached for a Python spec that has no direct .NET counterpart:

# ⚠️ each of these warns, and interpolates the raw value instead
self.buy(self.trade, reason=f"Entry at {self.trade.close:,.2f}") # ',' grouping
self.buy(self.trade, reason=f"Entry at {self.trade.close:>10}") # alignment / padding
self.buy(self.trade, reason=f"Entry at {self.trade.close:+.2f}") # explicit sign

The strategy compiles. reason just ends up carrying the unformatted number.

How to fix it

Use a supported spec — for money and indicator values, .Nf is almost always what was meant:

class Report(Strategy):
trade = Symbol()
sizing = FixedCapital()
def execute(self):
rsi = RSI(14, on=self.trade)
if rsi.value < 30 and self.trade.is_flat:
self.buy(self.trade, reason=f"RSI is {rsi.value:.1f}")
if rsi.value > 70 and self.trade.is_long:
self.sell(self.trade, self.trade.position,
reason=f"Exit at {self.trade.close:.2f} after {self.bar_count:d} bars")

If you specifically need grouping or padding, do it in the numbers rather than the spec — round with round(x, 2) and interpolate the result.

  • Python Subset — where f-strings sit in the language.
  • Order Verbs — reason= is the most common place an f-string shows up.