← Todos los ejemplos
Ejemplo 60
Gamma flip fade
a strategy that reads the dealers' gamma. Under the gamma flip the dealers hedge with the move and it runs; over it they hedge against
- Categoría
- Host: necesita los datos y el motor de la terminal
- Permisos
- orders.submit
- Antes de ejecutarlo
- BTC options listed (the data engine's capture reads the chain); a market on a BTC perpetual.
- Qué hace
- asks the terminal to run the strategy on that market; once running it places orders on the account the person chose.
- Cómo ejecutarlo
- Add script on the title bar's script icon; or backtest it from a program with backtest.run (at most ten days at a time).
- Lenguaje
>=0.2.0, <0.3.0- Host
>=0.1.15, <0.2.0- Necesita
- features >=0.1.8, <0.2.0trade >=0.1.0, <0.2.0
Código
// Purpose: a strategy that reads the dealers' gamma. Under the gamma flip the dealers hedge with the move and it runs; over it they hedge against // it and it is pinned. The strategy sells a rally into the call wall when price is over the flip, and buys a dip into the put wall; it leaves at the flip. // The levels come from the options listed on the asset, as the gamma ladder draws them (`days` 7: only the expiries within a week). A backtest is // given the readings of the options chain from the data engine's history of them, a live run reads the chain itself: the same events, the same levels. // // HONEST NOTE: written to the specification and checked that it compiles and hands over a strategy; its edge has not been measured. Dealer // positioning (long calls, short puts) is an assumption, not a reading, and a level moves in steps (the chain is read every five minutes). // Category: host // Permissions: orders.submit // Preconditions: BTC options listed (the data engine's capture reads the chain); a market on a BTC perpetual. // Side effects: asks the terminal to run the strategy on that market; once running it places orders on the account the person chose. // Run: Add script on the title bar's script icon; or backtest it from a program with backtest.run (at most ten days at a time). lang ">=0.2.0, <0.3.0"; host "ttt" ">=0.1.15, <0.2.0"; requires "features" ">=0.1.8, <0.2.0"; requires "trade" ">=0.1.0, <0.2.0"; strategy gamma_flip_fade(size: Quantity) version "1.0.0" { let px = features.price(features.Source.AggTrades); let flip = features.gamma_flip(7); let call_wall = features.gamma_call_wall(7); let put_wall = features.gamma_put_wall(7); rule fade_the_rally when exposure_is(Exposure.Flat) && px > flip && px > call_wall * 0.998 => order(Side.Sell, Intent.Open, OrderType.Market, Sizing.Fixed(size), Protect.Bracket(flip, call_wall * 1.004)); rule buy_the_dip when exposure_is(Exposure.Flat) && px > flip && px < put_wall * 1.002 => order(Side.Buy, Intent.Open, OrderType.Market, Sizing.Fixed(size), Protect.Bracket(call_wall, put_wall * 0.996)); flatten_on_stop; } fn main() -> Result<Unit, Error> { let run = trade.run(gamma_flip_fade(qty(0.01)))?; print(run.name + " on " + run.target + ": " + run.state); return Ok(()); }