-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsniper.py
More file actions
51 lines (40 loc) · 998 Bytes
/
Copy pathsniper.py
File metadata and controls
51 lines (40 loc) · 998 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
42
43
44
45
46
47
48
49
50
51
"""
Full Sniper — time-window, entry/exit thresholds, event callbacks.
Usage:
python examples/sniper.py
"""
import polyalpha
from polyalpha.bots import Sniper
client = polyalpha.Client(balance=100)
sniper = Sniper(
client=client,
asset="BTC",
timeframe="5m",
side="UP",
entry_price=0.92,
exit_price=0.88,
window_seconds=35,
amount=20.0,
)
@sniper.on("market_found")
def on_market_found(market):
print(f"Market found: {market}")
@sniper.on("entry")
def on_entry(order):
print(f"Entry filled: {order}")
@sniper.on("exit")
def on_exit(reason):
print(f"Position exited: {reason}")
@sniper.on("resolve")
def on_resolve(outcome, pnl):
print(f"Resolved: {outcome} P&L=${pnl:.2f}")
@sniper.on("rollover")
def on_rollover(market):
print(f"Position rolled over to next window: {market}")
@sniper.on("error")
def on_error(err):
print(f"Error: {err}")
@sniper.on("stop")
def on_stop(reason):
print(f"Stopped: {reason}")
sniper.run()