-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlast_15s.rhai
More file actions
41 lines (33 loc) · 951 Bytes
/
last_15s.rhai
File metadata and controls
41 lines (33 loc) · 951 Bytes
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
// Last 15 Seconds
// Time-gated conviction play. Waits until the final 15 seconds of a
// 15-minute window (offset >= 885,000 ms), then buys whichever side
// has a best bid at $0.98 or above -- betting the market has already
// decided the winner.
//
// Usage: pf run --script examples/last_15s.rhai --db path/to/spread_arb.db
let acted = false;
fn on_tick(snap) {
if acted {
return [];
}
// Wait until 15 seconds before window close (15min = 900,000ms)
if snap.offset_ms < 885000 {
return [];
}
let yes_bid = snap.yes_bid;
let no_bid = snap.no_bid;
// Buy YES if it looks like the winner
if yes_bid >= 0.98 && yes_bid >= no_bid {
acted = true;
return [bid("yes", yes_bid, SHARES)];
}
// Buy NO if it looks like the winner
if no_bid >= 0.98 {
acted = true;
return [bid("no", no_bid, SHARES)];
}
[]
}
fn on_reset() {
acted = false;
}