| | import pytest |
| | from src.strategies.arbitrage import CrossPlatformArbitrage, IntraMarketArbitrage |
| |
|
| | def test_cross_platform_arbitrage_profitable(): |
| | scanner = CrossPlatformArbitrage(min_profit_threshold=0.01) |
| | |
| | |
| | scanner.update_state('polymarket', '0x217...', bid=0.50, bid_size=1000, ask=0.52, ask_size=1000) |
| | scanner.update_state('kalshi', 'KXUS2024', bid=0.55, bid_size=1500, ask=0.57, ask_size=500) |
| | |
| | opps = scanner.scan_opportunities() |
| | |
| | assert len(opps) == 1 |
| | opp = opps[0] |
| | |
| | assert opp.buy_platform == 'polymarket' |
| | assert opp.sell_platform == 'kalshi' |
| | assert opp.buy_price == 0.52 |
| | assert opp.sell_price == 0.55 |
| | assert opp.buy_size == 1000 |
| | assert opp.expected_profit_margin > 0.01 |
| |
|
| | def test_cross_platform_arbitrage_no_opportunity(): |
| | scanner = CrossPlatformArbitrage(min_profit_threshold=0.01) |
| | |
| | |
| | scanner.update_state('polymarket', '0x217...', bid=0.53, bid_size=1000, ask=0.54, ask_size=1000) |
| | scanner.update_state('kalshi', 'KXUS2024', bid=0.53, bid_size=1500, ask=0.54, ask_size=500) |
| | |
| | opps = scanner.scan_opportunities() |
| | assert len(opps) == 0 |
| |
|
| | def test_intra_market_arbitrage(): |
| | scanner = IntraMarketArbitrage(min_profit_threshold=0.01) |
| | |
| | |
| | margin = scanner.check_parity_violation(ask_yes=0.45, ask_no=0.45) |
| | |
| | assert margin is not None |
| | assert round(margin, 2) == 0.10 |
| | |
| | |
| | margin_eff = scanner.check_parity_violation(ask_yes=0.52, ask_no=0.52) |
| | assert margin_eff is None |
| |
|