Skip to content

Commit

Permalink
add arbitrage check for both sides
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrtye committed Oct 30, 2024
1 parent 74f9373 commit cb51cff
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions test/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
tokens_pair[token1] = token2
tokens_pair[token2] = token1

print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), "Monitor started")
print(f"Found {len(tokens_pair) // 2} markets")

url = "wss://ws-subscriptions-clob.polymarket.com/ws/market"
Expand All @@ -40,8 +41,6 @@ async def main():
)
)

print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), "Monitor started")

while True:
message = await websocket.recv()

Expand Down Expand Up @@ -97,11 +96,29 @@ async def main():
):
print(
datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
"Arbitrage opportunities found",
"Arbitrage buy opportunities found+++",
float(event1["asks"][-1]["price"])
+ float(event2["asks"][-1]["price"]),
)
print(event1["asks"][-1])
print(event2["asks"][-1])

if (
event1["bids"]
and event2["bids"]
and float(event1["bids"][-1]["price"])
+ float(event2["bids"][-1]["price"])
>= 1
):
print(
datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
"Arbitrage sell opportunities found---",
float(event1["bids"][-1]["price"])
+ float(event2["bids"][-1]["price"]),
)
print(event1["bids"][-1])
print(event2["bids"][-1])

checked.append(asset_id)
checked.append(pair_id)

Expand Down

0 comments on commit cb51cff

Please sign in to comment.