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

Language Overview

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

RaamCode is a strict subset of Python that compiles to sandboxed C# at strategy-publish time. There is no Python runtime — your code is translated to .NET bytecode and executed inside a Roslyn-loaded assembly. The transpiler is the sandbox.

Treat this section as the canonical contract. Every primitive, verb, and rule documented here is enforced by the transpiler and verified by tests.

The ten things you’ll get wrong if you treat it as Python

Every row below has been a real bug. Skim this once before you write your first strategy.

# Python instinct RaamCode reality Why
1 self.is_flat self.trade.is_flat Position helpers live on the symbol slot, not on self.
2 self.buy(stop=price) self.buy(self.trade, stop=price) Order verbs require the target symbol as the first arg.
3 self.sell(self.trade, stop=p) self.sell(self.trade, self.trade.position, stop=p) Exit verbs require an explicit quantity.
4 self.stop_loss = 2.0 self.stop_loss(2.0) Exit rules are function calls, not assignments.
5 import pandas blocked No imports. No external code. Ever.
6 print(x) print(x) Allowed. Each call emits one row to the Console / Log tab on the board.
7 try: ... except: blocked Error handling is the platform’s job.
8 my_list = [1,2,3] as state blocked Persistent state is int, float, bool, str only.
9 Indicator anywhere Indicators at top of execute() only They need every bar’s data to compute correctly.
10 def execute(self): returns value Implicit hold If execute() finishes without a signal, the position holds.

How to read these pages

Each language page covers one primitive end to end: signature, every valid invocation, every diagnostic the transpiler emits, and a minimal working example. They are not tutorials — they are a contract.

If you want to learn by doing, start with the Quickstart or the Examples gallery. Come back here when you need an answer.

What runs underneath

When you save a strategy, the platform:

  1. Parses your code as Python (CPython AST).
  2. Runs the transpiler — type-checks, structure-validates, hoists indicators, and emits equivalent C#.
  3. Compiles the C# via Roslyn into an assembly.
  4. Loads the assembly into an isolated AssemblyLoadContext (the sandbox).
  5. Registers the strategy in the catalog. From then on, every backtest / paper / live run uses that compiled DLL.

You never see steps 2–4. The diagnostics panel in the editor surfaces any transpiler error inline with line numbers — see the Error Reference for every code.

Where the truth lives

  • This site — what the language guarantees to users.
  • src/Application/Raamtrade.Trading.Compilation/ — the transpiler implementation. Source of truth for every diagnostic and every emitted construct.
  • docs-site/sdk/raamcode/reference.md — the internal, denser version of this section. Engineers read it; both files change together (docs-as-contract).

If a page here disagrees with the transpiler, the transpiler wins and this page is a bug — please report it.