Bitcoin Forum
July 07, 2024, 06:27:08 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 »  All
  Print  
Author Topic: Python arbitrage script between two Bitcoin sports exchanges!  (Read 6583 times)
h3xh3x (OP)
Member
**
Offline Offline

Activity: 113
Merit: 10


View Profile
August 11, 2017, 05:38:03 PM
 #1

Hey everyone,

I've developed a Python script that enables arbitrage betting between two Bitcoin-enabled sports exchanges (via API - leaving them nameless in public in case they don't approve of arb). While there're still some kinks, it should work properly within the next few hours (just pending a few bets I'd made to pay out and for me to test my new version).

I'd like to offer the script in return for people signing up for one of the exchanges using my referral link Smiley The other one, unfortunately, doesn't have a ref program. No upfront cost, no subscription, nadda. I profit when you profit Smiley (and this exchange only takes a % on your wins with that particular exchange).

What's arb betting?

Pinnacle describes it best (because they encourage arbers):

https://www.pinnacle.com/en/promotions/arbitrage-friendly
https://www.pinnacle.com/en/betting-articles/Betting-Strategy/what-is-arbitrage-betting/PSWJPK7ECRAXM2BP

What my script does:

Compares all Tennis events over the next 14 or so hours between the two exchanges, then calculates which competitions it can make a 5-15% profit from by betting both sides of the event. It then calculates the appropriate amounts to bet according to how much volume of unmatched bets there are at that price. It then places the opposing bets for either the max. value it can (based on whichever outcome's volume is lower), or the max. value the current balance on the exchanges will allow for (divided by 6) (this is a bit testy because one of the exchanges doesn't return current avail. balance, just current balance since the last event - so while there's open bets, the current bal. from last event doesn't match real available balance - to offset this the script takes the lower of either balance on either exchanges for calculation). Then, on next run (which is constant in a loop), the script would notice if there's still an arb opportunity that exists with the next layer of volume/s.

Note that the APIs don't allow auto-withdrawal of funds (I'm not going to steal your BTC).

What you'd need:
1. Preferably you'll have a Linux box, access to a free Linux VPS (Amazon AWS EC2 free tier would do the trick), or some know-how surrounding getting Python to work on Windows / Mac. I'll help you set up the script, sign up to the two exchanges, and coach you should you have any questions.
2. Some BTC - there's a minimum 1 mBTC (0.001 btc) for bets on one exchange. The other apparently has no min. bet.

Next steps for the script:

1. I'd like to repurpose the script for soccer (the only other sport the two bookies have in common) but the issue is that I don't really understand 3-outcome betting (whereas tennis has two players and two outcomes, there're far fewer betting types).
2. Integrate with fiat bookie/exchange APIs (not sure I want to do this - the ease of BTC withdraw/deposit compared to fiat makes this a more interesting proposition for BTC exchanges (plus that much is already done for tennis)).

I see no issue with sharing the script as a) I don't have much of a bankroll and this would allow me to have some financial benefit while benefitting everyone else, b) I see many, many arb opportunities (at present there are 2, with volumes at those odds of 1-4 btc).

I'll have screenshot proof of % gains from specific Tennis matches to interested parties via PM.
kolesozw
Legendary
*
Offline Offline

Activity: 1316
Merit: 1004


FRX: Ferocious Alpha


View Profile
August 11, 2017, 05:51:02 PM
 #2

Hello,

Arbitraging is interesting and I have interest to review your script. And test it.

I have some Python knowledge.
Please send it to me.

Regards

h3xh3x (OP)
Member
**
Offline Offline

Activity: 113
Merit: 10


View Profile
August 11, 2017, 05:58:17 PM
 #3

Hey @kolesozw,

I'll be able to share the script as soon as I work out the final details. As of yet it opened three trades that consumed my bankroll on one exchange, and I can't make new bets until those resolve one way or another.

My concern is that before I tweaked my code since these bets, the indicated profit % of 9ish % was eaten up as the odds I bet on were slightly worse than the odds the script was expecting - so, until I'm sure the script works as expected (and is profitable), I'll be sure to keep you updated on my progress throughout today.

Thanks for your interest!
shintosai
Hero Member
*****
Offline Offline

Activity: 756
Merit: 500



View Profile
August 11, 2017, 06:04:22 PM
 #4

Hey @kolesozw,

I'll be able to share the script as soon as I work out the final details. As of yet it opened three trades that consumed my bankroll on one exchange, and I can't make new bets until those resolve one way or another.

My concern is that before I tweaked my code since these bets, the indicated profit % of 9ish % was eaten up as the odds I bet on were slightly worse than the odds the script was expecting - so, until I'm sure the script works as expected (and is profitable), I'll be sure to keep you updated on my progress throughout today.

Thanks for your interest!
very honest answer and i think it will be worth watching this thread maybe OP will  bring something good to this community and
hopefully kolesozw will be able to test it and check it by himself and see if this can help most of us to take advantage. good luck
op keep us updated regarding to this script.

kolesozw
Legendary
*
Offline Offline

Activity: 1316
Merit: 1004


FRX: Ferocious Alpha


View Profile
August 11, 2017, 06:10:19 PM
 #5

Hey @kolesozw,

I'll be able to share the script as soon as I work out the final details. As of yet it opened three trades that consumed my bankroll on one exchange, and I can't make new bets until those resolve one way or another.

My concern is that before I tweaked my code since these bets, the indicated profit % of 9ish % was eaten up as the odds I bet on were slightly worse than the odds the script was expecting - so, until I'm sure the script works as expected (and is profitable), I'll be sure to keep you updated on my progress throughout today.

Thanks for your interest!

Sure, no problem. Just PM me when you are ready.

h3xh3x (OP)
Member
**
Offline Offline

Activity: 113
Merit: 10


View Profile
August 11, 2017, 06:11:57 PM
 #6

Thanks @shintosai!

@kolesozw, I can share the script now (assuming I can PM - unsure as I haven't tried it yet) if you understand that it had ~2% loss on the three original trades I was expecting ~9% profit on. I'll explain what I've tweaked and why I think that'll resolve the issue once I have BTC to test (or, alternatively, maybe you can test).

Will update everyone as I know more. It's about 1 hour until my tennis matches resolve, and then a BTC transfer between exchanges and I'll be able to test the new version.
h3xh3x (OP)
Member
**
Offline Offline

Activity: 113
Merit: 10


View Profile
August 11, 2017, 06:44:12 PM
 #7

Thanks @kolesozw, PMd. Smiley

@shintosai - does betcoin.ag provide an API for gathering market details / placing bets on sporting events? I see Tennis is listed, which is a good sign for compatibility with what I've done so far. Even one that's not published to the general public? I could probably drive traffic if you a) don't care about arb b) want to participate Smiley
h3xh3x (OP)
Member
**
Offline Offline

Activity: 113
Merit: 10


View Profile
August 11, 2017, 09:24:49 PM
 #8

@kolesozw, @shintosai

I've been in touch with the support departments at BetBTC and Fairlay, and they both encourage arbitrage bets Smiley They're the platforms I'd been using.

I'm having issues whereby the script executes a bet on Fairlay through the API, gets responses from the API indicated the price was accepted, but the odds I see on the Fairlay interface are far worse than the odds stated by the API (and that are quoted on the competition page).

Ie:

Tried to bet @2.78 Ask (meaning the player will lose), get feedback from the API that 2.78 is good odds, then see in the interface 1.561 odds Sad

I've just now emailed Fairlay support asking for help. Will keep everyone appraised.

Ps this is the exact same behavior I saw with the original three orders earlier today... I have add'l output this time to help troubleshooting.
h3xh3x (OP)
Member
**
Offline Offline

Activity: 113
Merit: 10


View Profile
August 11, 2017, 11:30:54 PM
 #9

To quote Fairlay:

Ok to answer your odds problem.   In the Fairlay UI we make it a bit simpler and only show the odds the user actually gets and the stake given is always the liability.

On the API however, if you lay 100mBTC  at 2.78   you are actually risking 178mBTC to win 100mBTC.       

We also just added this to the Readme file for clarification.

Best,

Team Fairlay

In short, the reason the odds were mixed up is because their advertised odds have to be calculated using the inverse.

That said, I'm still seeing profitable arb sequences using the new numbers.

@kolesozw - I'll send you a new .zip to your PM.

Note that the immediate next step is to write code so that:

When there is an unmatched order (because the order for the current most profitable volume/odds is taken up by some other market taker in those few seconds between checking and betting), the code checks all unmatched orders and modifies them to get matched by the next best volume/odd. I had a bet go through on BetBTC that didn't meet any current volume/odd, even though it existed for the few seconds where there was volume @ that odd.
WinBeast
Newbie
*
Offline Offline

Activity: 23
Merit: 1


View Profile
August 12, 2017, 02:09:42 AM
 #10

This is a really clever idea OP. I didn't realize that arbitrage was done among sports betting sites.

You're clearly an intelligent guy and you shouldn't have any trouble finding takers on your offer.

Good luck with finding someone and good work!
h3xh3x (OP)
Member
**
Offline Offline

Activity: 113
Merit: 10


View Profile
August 12, 2017, 02:17:04 AM
 #11

This is a really clever idea OP. I didn't realize that arbitrage was done among sports betting sites.

You're clearly an intelligent guy and you shouldn't have any trouble finding takers on your offer.

Good luck with finding someone and good work!

Thanks for the vote of confidence! I'm sure @kolesozw will provide an update from a trusted source as soon as we work through the script together.

As a note: I've finished writing the part of the script that adjusts unmatched orders, and it'll be tested (along with the changes for inversion of the odds on Fairlay) as soon as a Bitcoin transaction is confirmed...
h3xh3x (OP)
Member
**
Offline Offline

Activity: 113
Merit: 10


View Profile
August 12, 2017, 03:34:34 AM
 #12

OK don't ask me why but it appears Fairlay changed the way their API works since I chatted with them?

Or it works differently in different scenarios, I'm unsure until I get a reply / am able to test more.

I just made a number of predictions (all with stream 6 ie. where the code in client.py says print 6):

[{'Sub': '', 'Am': 1.0, 'Oid': '-1', 'Pri': 2.55, 'Mid': '113963738345', 'Boa': 1, 'Rid': '0', 'Mct': 0, 'Type': 0}]
[u'{"Price":2.55,"RemAmount":0.0,"State":2,"BidOrAsk":1,"PrivAmount":1.0,"PrivSubUser":"","PrivCancelAt":3155378975999999999,"makerCT":0,"_Type":0,"PrivID":636381047605239864,"PrivUserID":1007855}']
{u'_Type': 0, u'Price': 2.55, u'PrivCancelAt': 3155378975999999999, u'PrivSubUser': u'', u'State': 2, u'PrivAmount': 1.0, u'makerCT': 0, u'RemAmount': 0.0, u'PrivUserID': 1007855, u'PrivID': 636381047605239864, u'BidOrAsk': 1}


and twice:

[{'Sub': '', 'Am': 1.136717735653077, 'Oid': '-1', 'Pri': 1.68, 'Mid': '113963783574', 'Boa': 1, 'Rid': '0', 'Mct': 0, 'Type': 0}]
[u'{"Price":1.68,"RemAmount":0.0,"State":2,"BidOrAsk":1,"PrivAmount":1.13672,"PrivSubUser":"","PrivCancelAt":3155378975999999999,"makerCT":0,"_Type":0,"PrivID":636381028756943647,"PrivUserID":1007855}']
{u'_Type': 0, u'Price': 1.68, u'PrivCancelAt': 3155378975999999999, u'PrivSubUser': u'', u'State': 2, u'PrivAmount': 1.13672, u'makerCT': 0, u'RemAmount': 0.0, u'PrivUserID': 1007855, u'PrivID': 636381028756943647, u'BidOrAsk': 1}

And ended up with:

https://www.dropbox.com/s/2y4ngou9rdvicyq/Screenshot%20from%202017-08-12%2000-23-32.png

three different bets (from stream 6) that have odds matching what the API expected before it did any inverse odds calculation??

I'll be sure to keep you appraised,
Hatcher
Full Member
***
Offline Offline

Activity: 369
Merit: 111


View Profile
August 12, 2017, 04:24:41 AM
Last edit: August 12, 2017, 04:38:19 AM by Hatcher
 #13

I am interested. And it is a fair business proposal to offer this in exchange for referral bonuses from people capable of moving large amounts of BTC around to take full advantage of arbitrage possibilities. I am one of those people. So if the script works, I'd be more than happy to hop on board and register to these sites under your name.
h3xh3x (OP)
Member
**
Offline Offline

Activity: 113
Merit: 10


View Profile
August 12, 2017, 04:39:39 AM
 #14

I am interested. And it is a fair business proposal to offer this in exchange for referral bonuses from people capable of moving large amounts of BTC around to take full advantage of arbitrage possibilities. I am one of those people. So if the script works, I'll register to these sites under your name.

Hey Hatcher Smiley

I'm still working out the kinks of the script. I agree it's fair trade to collect ref signups in exchange for the script, though - seeing as how other people (such as yourself) have the bankroll to benefit, and I'd take 30% of 4% of profit (not total gain - just the difference on gain and stake) on half the bets (the ones made on BetBTC that win). Hopefully people would see the benefit of having the script run continuously, and gain considerable $ profit over time - thereby ensuring my gains through the ref. signups - while I can share the script any number times and as long as people don't bet 10s 50s BTC culmultatively on each available arb. opportunity, there should be plenty of arb for everyone!

If you're fine creating a new Fairlay and BetBTC account (Fairlay doesn't have an active ref program):

https://www.betbtc.co/?ref=8908
https://fairlay.com/#signup

and if you're fine testing the script as-is with a minimal set of deposits (with the warning that some things aren't a-ok yet), would you want to move forward at present? The faster I can get the kinks worked out, the faster I can offer the ref. signup in exchange for the script deal.

Here's the current situation:

1) Fairlay API / UI disagreed on Odds that were bet on in a Bid order (thereby breaking Arb calculation),
2) Fairlay communicated to me to use the inverse odds,
3) I switched up the script to use inverse odds in all cases,
4) Waited a few hours for bets to close and for me to have funds avail.,
5) Tried the script again.

As in my last post on the original thread, the UI and the API now agree (however this was for a Ask order - only difference I can see). Since then, the only response I got from Fairlay was:

'Sorry, it's difficult to help you with this  more than we already did.

Best,

Team Fairlay'

So I'm on my own-e-oh.

There's two cases as to what happened here:

a) the API changed for no good reason other than my support ticket (+ they didn't tell me about it),
b) the API treats Bids in the inverse and Asks as you'd expect.

Either way, further testing is required for a finished product.

I'll have some funds (but not enough, likely, to support min. 5 mBTC deposit @Fairlay - unless my few open bets at Fairlay win and I have some spare change there for further testing) in the next ~12 hours.

If you:

i) Want to test the script with your own small deposits on your own accounts, let me know and I'll share the script + startup instructions. Do you have Linux + an understanding (at any level) of Python? I can PM the script shortly / in the morning (it's ~midnight here).
ii) Want to 'donate' / lend so I can fully test the script, then provide you (and others) a finished product, you (or anyone Smiley ) can here:

336un567tBHf1ho3qpxFhEMh5pwqRZw57z (BetBTC)
1ExtwzW8Q9jk32TmfE8aCYaVHwvdRTbTe4 (this is Fairlay, min. deposit 0.005 BTC)

iii) Want to hold off until I have a finished product, that's fine too - I'll keep your name in mind when this thing finally works as expected!

Thanks again for your interest - hope to hear from you!
Hatcher
Full Member
***
Offline Offline

Activity: 369
Merit: 111


View Profile
August 12, 2017, 06:02:46 AM
 #15

I appreciate your detailed response but I'll have to take option 3 for the moment. Wish I could be of more assistance but I don't have Linux or an understanding of Python.
Yuuto
Hero Member
*****
Offline Offline

Activity: 644
Merit: 501



View Profile
August 12, 2017, 06:24:25 AM
 #16

OP, i am really interested in this bot.

I actually subscribe to bitedge which is basically the same thing - except they send you an email notification when there is an arbitrage opportunity. And a lot of the times i miss arbs because they come by when i'm sleeping or at work, which is a shame.

Since this is python based, it should run on any OS, correct?

And also this is fully automated once you set it up right? Are there only two betting exchanges available or more? Because if you have at least like 5 bookies then the chances of you getting a decent arb is increased exponentially.
M0w
Full Member
***
Offline Offline

Activity: 186
Merit: 100



View Profile
August 12, 2017, 10:51:59 AM
 #17

I am also interested in testing this script. Especially since you are using two platforms that do not care about arbitrage bettors.

I have some small knowledge about Python (I'm a C++ programmer) and have a CentOS VPS ready to test your script on. Perhaps I could even help you extending this script in the future when you plan to add more bookmakers and other features.

Let me know if you need help testing, I've also sent you a PM.

Wat is deze
h3xh3x (OP)
Member
**
Offline Offline

Activity: 113
Merit: 10


View Profile
August 12, 2017, 01:53:30 PM
 #18

Hey everyone,

@M0w - great! I'll reply to your PM in a minute. The more hands the merrier Smiley

@M0w, @Yuuto - here's my list of other exchanges I found with market / betting APIs. From what I understand, Fairlay uses Pinnacle odds (although I could be corrected here if I'm wrong). As @M0w said, the benefit of working with Fairlay and BetBTC is that they don't care about arbers - meaning that we're not risking account limits or account closures, as I gather is the issue with arbing on most bookies / exchanges.

https://www.pinnacle.com/en/api
http://betdaqtraders.com/what-web-methods-are-available/
http://smarkets.github.io/smk_api_docs/
https://developer.betfair.com/
https://developers.matchbook.com/

I'm open to suggestion if anyone finds any other exchanges / bookies with available APIs where you can 1) find arb opportunities across 2-outcome and 3-outcome sports 2) act on them by creating / modifying existing orders.

I'm also interested in dev help should people have a better understanding than I about 3-outcome Sports betting (it's a bit of a stretch to understand how BetBTC and Fairlay's API related to Arb on Tennis alone).

Yes @Yuuto it's fully automated - set and forget! It also should work on any OS that supports Python as long as it'll install pip packages like requests and PyCrypto.
lite
Legendary
*
Offline Offline

Activity: 1400
Merit: 1009


View Profile
August 12, 2017, 02:08:21 PM
 #19

I didn't knew betbtc and fairlay allowed arbitraging, it's nice to see you're providing script for free, but once high amount of arbitraging starts happening on their site they might consider changing the rules. so you might wanna keep low amount of script users!
also if their api is not reliable, you can use scrapy i think.
h3xh3x (OP)
Member
**
Offline Offline

Activity: 113
Merit: 10


View Profile
August 12, 2017, 05:19:55 PM
 #20

@M0w thanks for taking the time (and risk) to evaluate my script and point me in the right direction. I understand better now.

I feel like a noob Smiley I didn't understand sports betting enough until @M0w enlightened me. With the proper math we see no current Arb opportunities - 2 false alarms with Haase v A Mannarino on one platform and Robin Haase vs. Roger Federer on the other, and the opposite w/ Haase v A Mannarino and Robin Haase vs. Roger Federer on the other. The best arb opportunity from this run of the script is 0.3% loss...

In order to become profitable, the script will have to be extended to 1) cover more sports 2) cover more exchanges / bookies.

Here are the exchanges / bookies I can find with APIs:

1. https://fairlay.com/api/
2. https://betbtc.zendesk.com/hc/en-us/sections/201042322-Betting-API-
3. https://www.pinnacle.com/en/api
4. http://betdaqtraders.com/what-web-methods-are-available/
5. http://smarkets.github.io/smk_api_docs/
6. https://developer.betfair.com/
7. https://developers.matchbook.com/

Afaik Fairlay uses Pinnacle odds, so they should be (for the most part) equal. The question then becomes 'who opposes arb?'

1. Fairlay supports arb
2. BetBTC supports arb
3. https://www.pinnacle.com/en/promotions/arbitrage-friendly
4. http://www.betdaqtips.com/what-is-arb-betting-betdaq-explains/
5. https://help.smarkets.com/hc/en-gb/articles/115002115965-What-is-Smarkets-
6. https://betting.betfair.com/what-is-arbing-arb-betting-explained.html
7. https://insights.matchbook.com/money-nothing-aribtrage-explained/

Are you guys aware of any other bookies / exchanges that support arb and have an API?

As a note on Betfair, I'm Canadian and can't access it:

'Why can I not access Betfair?

We are sorry to inform you that as of 14th January 2016, Betfair’s products are no longer be available to residents of Canada.

On 14th January 2016 Canadian residents are no longer be able to login to Betfair. Please note that all outstandingExchange & Sportsbook bets will remain in place, please contact us if you wish to gain details of these bets, or withdraw any winnings, by contacting our helpdesk here.'

I'll have funds available to bankroll efforts into testing arb scripts across these platforms a/o Sept...
Pages: [1] 2 »  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!