-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
351111a
commit e3f956d
Showing
1 changed file
with
172 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Input values\n", | ||
"odds_win_site1 = 1.3\n", | ||
"odds_lost_site1 = 3.930\n", | ||
"odds_win_site2 = 1.42\n", | ||
"odds_lost_site2 = 2.9\n", | ||
"total_investment = 100" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def has_arbitrage_opportunity(odds):\n", | ||
" total_inverse_odds = sum(1 / odd for odd in odds)\n", | ||
" return total_inverse_odds < 1" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def calculate_arbitrage_percentage(odds):\n", | ||
" total_inverse_odds = sum(1 / odd for odd in odds)\n", | ||
" arbitrage_percentage = (1 - total_inverse_odds) * 100\n", | ||
" return arbitrage_percentage" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def calculate_optimal_stakes(total_investment, odds):\n", | ||
" total_inverse_odds = sum(1 / odd for odd in odds)\n", | ||
" stakes = [(total_investment * (1 / odd)) / total_inverse_odds for odd in odds]\n", | ||
" return stakes" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def calculate_total_return(stakes, odds):\n", | ||
" total_returns = [stake * odd for stake, odd in zip(stakes, odds)]\n", | ||
" return total_returns" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def calculate_guaranteed_profit(total_investment, total_returns):\n", | ||
" min_total_return = min(total_returns)\n", | ||
" guaranteed_profit = min_total_return - total_investment\n", | ||
" return guaranteed_profit" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Arbitrage Opportunity (lost-site1 and win-site2): Yes\n", | ||
"Arbitrage Percentage (lost-site1 and win-site2): 4.13%\n", | ||
"Optimal Stakes (lost-site1 and win-site2): [26.542056074766354, 73.45794392523365]\n", | ||
"Total Returns (lost-site1 and win-site2): [104.31028037383177, 104.31028037383177]\n", | ||
"Guaranteed Profit (lost-site1 and win-site2): 4.31\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# Check for arbitrage opportunities\n", | ||
"arbitrage_opportunities = []\n", | ||
"\n", | ||
"# Combination 1: win-site1 and lost-site2\n", | ||
"if has_arbitrage_opportunity([odds_win_site1, odds_lost_site2]):\n", | ||
" arbitrage_percentage = calculate_arbitrage_percentage([odds_win_site1, odds_lost_site2])\n", | ||
" optimal_stakes = calculate_optimal_stakes(total_investment, [odds_win_site1, odds_lost_site2])\n", | ||
" total_returns = calculate_total_return(optimal_stakes, [odds_win_site1, odds_lost_site2])\n", | ||
" guaranteed_profit = calculate_guaranteed_profit(total_investment, total_returns)\n", | ||
" arbitrage_opportunities.append({\n", | ||
" \"description\": \"win-site1 and lost-site2\",\n", | ||
" \"arbitrage_percentage\": arbitrage_percentage,\n", | ||
" \"optimal_stakes\": optimal_stakes,\n", | ||
" \"total_returns\": total_returns,\n", | ||
" \"guaranteed_profit\": guaranteed_profit\n", | ||
" })\n", | ||
"\n", | ||
"# Combination 2: lost-site1 and win-site2\n", | ||
"if has_arbitrage_opportunity([odds_lost_site1, odds_win_site2]):\n", | ||
" arbitrage_percentage = calculate_arbitrage_percentage([odds_lost_site1, odds_win_site2])\n", | ||
" optimal_stakes = calculate_optimal_stakes(total_investment, [odds_lost_site1, odds_win_site2])\n", | ||
" total_returns = calculate_total_return(optimal_stakes, [odds_lost_site1, odds_win_site2])\n", | ||
" guaranteed_profit = calculate_guaranteed_profit(total_investment, total_returns)\n", | ||
" arbitrage_opportunities.append({\n", | ||
" \"description\": \"lost-site1 and win-site2\",\n", | ||
" \"arbitrage_percentage\": arbitrage_percentage,\n", | ||
" \"optimal_stakes\": optimal_stakes,\n", | ||
" \"total_returns\": total_returns,\n", | ||
" \"guaranteed_profit\": guaranteed_profit\n", | ||
" })\n", | ||
"\n", | ||
"# Output Results\n", | ||
"if arbitrage_opportunities:\n", | ||
" for opportunity in arbitrage_opportunities:\n", | ||
" print(f\"Arbitrage Opportunity ({opportunity['description']}): Yes\")\n", | ||
" print(f\"Arbitrage Percentage ({opportunity['description']}): {opportunity['arbitrage_percentage']:.2f}%\")\n", | ||
" print(f\"Optimal Stakes ({opportunity['description']}): {opportunity['optimal_stakes']}\")\n", | ||
" print(f\"Total Returns ({opportunity['description']}): {opportunity['total_returns']}\")\n", | ||
" print(f\"Guaranteed Profit ({opportunity['description']}): {opportunity['guaranteed_profit']:.2f}\")\n", | ||
"else:\n", | ||
" print(\"No Arbitrage Opportunities Found\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.12.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |