-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgabagool.rhai
More file actions
51 lines (42 loc) · 1.36 KB
/
gabagool.rhai
File metadata and controls
51 lines (42 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Gabagool Combined-Price Arb
// Inspired by gabagool22's strategy. Monitors both sides and enters
// when the combined YES bid + NO bid drops below $0.99, buying the
// cheaper side first, then completing the pair on a later tick.
//
// Usage: pf run --script examples/gabagool.rhai --db path/to/spread_arb.db
let yes_placed = false;
let no_placed = false;
fn on_tick(snap) {
if yes_placed && no_placed {
return [];
}
let combined = snap.yes_bid + snap.no_bid;
// Only enter when combined price is below $0.99
if combined >= 0.99 {
return [];
}
let actions = [];
// First entry: pick the cheaper side
if !yes_placed && !no_placed {
if snap.yes_bid <= snap.no_bid && snap.yes_bid > 0.0 {
yes_placed = true;
actions.push(bid("yes", snap.yes_bid, SHARES));
} else if snap.no_bid > 0.0 {
no_placed = true;
actions.push(bid("no", snap.no_bid, SHARES));
}
}
// Second entry: complete the pair
if yes_placed && !no_placed && snap.no_bid > 0.0 {
no_placed = true;
actions.push(bid("no", snap.no_bid, SHARES));
} else if no_placed && !yes_placed && snap.yes_bid > 0.0 {
yes_placed = true;
actions.push(bid("yes", snap.yes_bid, SHARES));
}
actions
}
fn on_reset() {
yes_placed = false;
no_placed = false;
}