Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save quantra-go-algo/cc135143874eb247b37dce718ecdb032 to your computer and use it in GitHub Desktop.

Select an option

Save quantra-go-algo/cc135143874eb247b37dce718ecdb032 to your computer and use it in GitHub Desktop.
guardrailed-llm-agent — Step 6: From Policy to Position: Sizing with Volatility Targeting (snippet 1)
def action_to_base_exposure(action, size):
# Maps LLM output to a base exposure in [0.5, 1.0]. No shorts.
if action == 'LONG':
return LONG_FULL_EXP if size >= 1.0 else LONG_HALF_EXP # 1.0 or 0.8
return FLAT_EXP # 0.5: never fully exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment