- Glossary
- Hardware And Software Advices
- Telemetry
- Customize Ipposnif
- Tipping Service
- How to fix a broken SQL instance
1.Glossary
- ©Betfair is the largest international betting
exchange of the globe with hundreds of markets open every day.
Ipposnif can place bets only on Betfair markets.
- Betfair Markets work in a similar way to the
stock exchange markets: some people place requests to buy the
object of the market, other people place requests to sell the same
thing. When two requests match, the exchange occurs. Betfair
markets are normally linked to a sport event (like for ex. a horse
race ) and the objects exchanged are the chance to win of each
Selection(runner) of this event. A market can have a minimum of two
selections (like the market 'Match Odds' of a Tennis match)
or more selections (like the market 'Win' of a Horse Race). A sport
event can have more than one market linked to it, for example a
soccer match can have the market “Match Odds”, the
market “Correct Score” and many others. A market, when
the event is finished, can have one winning selection (like for
example in the WIN market of a horse race) or more winning
selections (like in the PLACE market of a horse races).
- Bet is a transaction on a Betfair market; every bet is defined by five elements:
- The Selection(runner) and the Market where to place the bet.
- The Type Back(buy) or Lay(sell). If the type is back you act
as a punter: if the horse wins you win the amount of your bet
multiplied by the odd of the horse, if it loses you pay the
amount of the bet. If the type is lay you act as a bookmaker:
if the horse wins you pay the amount of your bet multiplied by
the odd of the horse, if it loses you win the amount of the
bet.
- The Price(odd) of the horse defines the odd at which the
transaction must be made. If the bet placed doesn't meet a request of opposite type for the same price, it remains in a "unmatched bet" status. As soon as two bets of
opposite type have the same price, the exchange takes place. The bet has now
a “matched bet” status. Unmatched bets can be deleted in any moment by the user while matched bets cannot be deleted.
Betfair prices go from 1.01 to 1000, but not all decimals are represented with a price. The prices have increments that start with 0.01 for the lower odds, and it arrives at 10 for the higher odds.
There are 350 available prices in Betfair:
- (incr. of 0.01) 1.01, 1.02, 1.03, 1.04, 1.05, 1.06, 1.07, 1.08, 1.09, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.19, 1.20, 1.21, 1.22, 1.23, 1.24, 1.25, 1.26, 1.27, 1.28, 1.29, 1.30, 1.31, 1.32, 1.33, 1.34, 1.35, 1.36, 1.37, 1.38, 1.39, 1.40, 1.41, 1.42, 1.43, 1.44, 1.45, 1.46, 1.47, 1.48, 1.49, 1.50, 1.51, 1.52, 1.53, 1.54, 1.55, 1.56, 1.57, 1.58, 1.59, 1.60, 1.61, 1.62, 1.63, 1.64, 1.65, 1.66, 1.67, 1.68, 1.69, 1.70, 1.71, 1.72, 1.73, 1.74, 1.75, 1.76, 1.77, 1.78, 1.79, 1.80, 1.81, 1.82, 1.83, 1.84, 1.85, 1.86, 1.87, 1.88, 1.89, 1.90, 1.91, 1.92, 1.93, 1.94, 1.95, 1.96, 1.97, 1.98, 1.99, 2.00
- (incr. of 0.02) 2.02, 2.04, 2.06, 2.08, 2.10, 2.12, 2.14, 2.16, 2.18, 2.20, 2.22, 2.24, 2.26, 2.28, 2.30, 2.32, 2.34, 2.36, 2.38, 2.40, 2.42, 2.44, 2.46, 2.48, 2.50, 2.52, 2.54, 2.56, 2.58, 2.60, 2.62, 2.64, 2.66, 2.68, 2.70, 2.72, 2.74, 2.76, 2.78, 2.80, 2.82, 2.84, 2.86, 2.88, 2.90, 2.92, 2.94, 2.96, 2.98, 3.00
- (incr. of 0.05) 3.05, 3.10, 3.15, 3.20, 3.25, 3.30, 3.35, 3.40, 3.45, 3.50, 3.55, 3.60, 3.65, 3.70, 3.75, 3.80, 3.85, 3.90, 3.95, 4.00
- (incr. of 0.10) 4.10, 4.20, 4.30, 4.40, 4.50, 4.60, 4.70, 4.80, 4.90, 5.00, 5.10, 5.20, 5.30, 5.40, 5.50, 5.60, 5.70, 5.80, 5.90, 6.00
- (incr. of 0.20) 6.20, 6.40, 6.60, 6.80, 7.00, 7.20, 7.40, 7.60, 7.80, 8.00, 8.20, 8.40, 8.60, 8.80, 9.00, 9.20, 9.40, 9.60, 9.80, 10
- (incr. of 0.50) 10.50, 11, 11.50, 12, 12.50, 13, 13.50, 14, 14.50, 15, 15.50, 16, 16.50, 17, 17.50, 18, 18.50, 19, 19.50, 20
- (incr. of 1) 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
- (incr. of 2) 32, 34, 36, 38, 40, 42, 44, 46, 48, 50
- (incr. of 5) 55, 60, 65, 70, 75, 80, 85, 90, 95, 100
- (incr. of 10) 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550, 560, 570, 580, 590, 600, 610, 620, 630, 640, 650, 660, 670, 680, 690, 700, 710, 720, 730, 740, 750, 760, 770, 780, 790, 800, 810, 820, 830, 840, 850, 860, 870, 880, 890, 900, 910, 920, 930, 940, 950, 960, 970, 980, 990, 1000
- The Size(amount) of the bet defines the maximum amount of
money that you wish to exchange. Betfair takes care of
accumulating bets from different bidders in order to exchange
the maximum amount of money, and this is done in a
completely transparent and anonymous way.
- The Persistence of the bet defines the behaviour of the bet
when the event starts:
- Lapse: the unmatched bet will be voided.
- Persist: if the market goes in play, the unmatched bet
will be kept in play, otherwise the bet will be voided.
- Market_on_close: bet will be matched by Betfair using the
starting price. The starting price is calculated by Betfair conciliating all the "Market on close" requests from all the users.
- Trade is the container for bets used by Ipposnif.
A bet is always contained in a trade. Every trade contains at least one bet, but it can contain more bets
of the same or different type. Trades are produced by Ipposnif
strategies; each trade is technically an instance of the
strategy.
- Strategy is a set of criteria that defines which
runners, when and how much to bet on them. Each strategy produces
trades, and depending by the configuration it can have one trade
open at one time or more trades open at the same time on more
markets an runners.
- Hedging also called "greening up" is the operation
of counterbalancing a bet with another of the opposite type. The scope is to shorten
the loss or to cash out the profit.
- Overround: is a index showing how much the odds
of a Betfair market (back or lay) are fair. More this is index is
close to 100 and more the market is fair. For example a Back
Overround of 110 means that if the player bets all the runners
(with a size inversely proportional to the price) he will lose 10%
of the investment.
- Ticks: Increments between two prices. For example between 1.50 and 1.51 there is 1 tick of distance, between 990 and 1000 there is also 1 tick of distance. Ticks can be negative, for example between 2.2 and 2.16 there is -2 ticks of distance.
2.Hardware And Software Advices
Minimum hardware requirement
The default configuration of Ipposnif can run on a dual core 2.2Ghz
with 4GB ram and 10GB of free disk space. The program will run fluently
using a quad core with SSD disk.
Disks
Ipposnif uses SQL Server 2016 LocalDB to store data, reading and
writing millions of records every day. The data in the database is
recorded in a fragmented way, so most of the time it is spent searching
the start position of data. Classic hard disks have to mechanically
move the heads to the start position of data, instead a Solid State Disk
has no mechanical part to move and it can access data
30/40 times faster. Overall the speed increase of a database running on
SSD is between 50% and 1000%. So consider the purchase of an SSD disk
as first step to enhance the Ipposnif performance.
Processors and SQL Server
Ipposnif uses Microsoft SQL Service Broker to execute and balance the
external web requests (odds refresh, bets, etc..). Service Broker is a
powerful and scalable queue manager: it can take advantage of all
available processors, parallelizing the tasks in a reliable way.
Microsoft SQL Service Broker is part of SQL server. SQL server used by
Ipposnif is the ‘LocalDB’ version that is free but allows
the use of only one physical processor (up to 4 processor cores). So if you
have a multiprocessor PC or a PC with a single processor but more than 4 cores, you can use all of them
switching to a licensed version of SQL Server. To switch to another instance
of SQL Server, open the file ipposnif.ini with Notepad (you can find in
the same directory of the program, normally C:\Program Files
(x86)\Ipposnif). Edit the value ‘data_source’ with the
SQL server instance source name you want to connect to. Restart the
program and a new Ipposnif database will be created. The user that runs
Ipposnif, must have administrative permissions.
Network
Another important element that affects the overall speed is the quality
of the internet connection. Mainly it consists of the latency (ping
response time) and by the data volume supported. In the default
configuration, Ipposnif generates peaks of data traffic of 200Kbit
second. If your connection does not support easily this volume of
traffic all the system will slow down because the requests made, even
if parallelized, will need more time to be completed.
3.Telemetry
Telemetry is a functionality of Azure Cloud that can
track the activity of an Ipposnif instance installed on a virtual
machine.
You can monitor the virtual machine and the Ipposnif activity with
charts like the following one:
When the option "Instrumental Key" has a value, telemetry is active and Ipposnif sends, every four minutes, the
following information to the telemetry collector:
- Balance (current available balance for
betting)
- Liability (current liability)
- Processes (count of processes in the last minute
excluding external API requests)
- Errors (count of Service Broker errors in the
four minutes)
- API Requests (count of API requests in the last
minute)
- getPrices net ms (average response time of the
getPrices Betfair API)
- getPrices CPU ms (average processing time of the
getPrices Betfair API)
- Main Clock ms (average processing time of the
sp_Main procedure, the heartbeat of Ipposnif)
- TrigBet ms (average processing time of the
betting procedure, where conditions are checked and bet
created)
- IpposnifDB Data Size (size of the Ipposnif
database. It can never overcome 10000 Mb).
- Transactions (count of transactions in the last
hour, when it overcomes 5000 you are subject to extra Betfair
fees)
Telemetry Setup
To get these charts, first, you have to
create a new Azure virtual machine and install Ipposnif on it.
Then in the Azure Cloud Management Console add a new resource of type
"Application Insights".
Once you have created the new resource, copy the Instrumental key
you can find in the properties and paste it into the Ipposnif option.
Wait some minutes (5-10) until Ipposnif has sent some data to the
telemetry collector.
Then in the telemetry property page click the link “Metric
Explorer”, click “edit” on the empty chart that
will appear. Choose the metrics you want to add to this chart. You will
find the Ipposnif ones inside the group "Custom".
The aggregation type to apply is “max” for the metrics
"IpposnifDB Data Size" and "Transactions", the type is "sum" for metric
"Errors", the type is “average” for all the other metrics
4.Customize Ipposnif
Ipposnif is an open system because all the betting logic
and the data is contained unencrypted in the Microsoft SQL Server 2016
local database.
Microsoft SQL Server Management Studio
Using the proper tools, you can connect to the database and
modify or add variables and functions developed by you.
The official tool, for managing SQL Server databases, is
Microsoft SQL Server Management Studio (SSMS). It is free software.
Connect to the database
The server name for the connection is:
(localdb)\IpposnifSql2016Instance
The version of SQL Server used by Ipposnif is the LocalDB 2016. This free version allows only local connections, so you can connect to it, only from the same machine where Ipposnif is installed.
Once you are connected, you can browse SQL Server using Object Explorer. All the Ipposnif procedures and data are contained in the database with name
IpposnifDB380_{yyyyMMddhhmmss}
How to add a new variable
To add a new variable, that can be used from the strategies, simply insert a record in the table [tbl_SysVariables].
All the fields are mandatory:
- Name: a unique combination of the characters: abcdefghijklmnopqrstuvwxyz_0123456789
- Declaration: where to specify the type of the variable.
- Funct: the SQL expression to retrieve and assign the value to the variable.
Example of a new variable that returns the count of runners in the market with and odd between 2 and 7:
The variable
@id_race present in the expression is an index variable resolved automatically. Only the following index variables can be used in the field [Funct]:
- @id_strategy contains the id of the strategy processed in that moment
- @id_race contains the id of the market processed in that moment
- @id_horse contains the id of the selection processed in that moment
- @id_trade contains the id of the trade processed in that moment
- @nbet contains the ordinal number (in the current trade) of the bet processed in that moment
Some of the variables present in the table [tbl_SysVariables] (for ex. @bet_size) are used by the system and by some strategies. If you wish to change an existing variable, don't edit it directly, but instead create a copy of the record with a new variable name.
5.Tipping Service
If you are a tipster, with Ipposnif you can offer to your clients a fully automatic way to place bets on your tips.
All you need to do is to publish your tips on a public web page (website, blog, FB page, etc..) in a specific format, and the Ipposnif clients provided with your URL will download the tips and place bets on them.
Server Configuration
The tips must be inserted into any part of your web page in a text block with the format:
START_OF_TIPS
2022-04-05,Pontefract,Champagne Terri,1
2022-04-05,Pontefract,Peter The Great,1
2022-04-05,Pontefract,Pocket The Profit,1
END_OF_TIPS
The first line has the start tag “START_OF_TIPS”
Each tip must be written on a separate line which contain 4 comma separated values:
- Event Date (yyyy-mm-dd)
- Racecourse Name (match name for Soccer)
- Runner Name (team name for Soccer)
- Tip Type ('1' for LAY tips, '2' for BACK tips.)
The tag “END_OF_TIPS” closes the list of tips
The easiest way to prepare this block of text is to copy the value of each line (one tip) from Ipposnif with a right-click on the runner name → 'Copy Selection Info' and paste it directly into your web page. Complete the line changing the 'Tip Type' value to the correct one.
When you add/remove a tip to your web page, the clients will automatically add/remove it to their list.
Client Configuration
To configure a client to receive your tips, insert the URL of your tips into 'Tipping Service URL' in the Ipposnif Options.
Refresh is the download frequency in minutes. If Refresh equals -1, the tips are not downloaded.
Downloaded tips with Tip Type='1' (LAY) are marked with a green flag.
Downloaded tips with Tip Type='2' (BACK) are marked with a yellow flag.
Ipposnif comes with six strategies ready to bet on the downloaded tips.
Tips - BACK Decimal Fibonacci
Tips - BACK Yankee-4 Win
Tips - BACK
Tips - LAY
Tips - Masa LAY 3-4@5
Tips - LAY Trading
New Strategies
To create a new strategy which plays on LAY tips, simply add this SQL assertion to the Trigger Condition of the bet:
dbo.fn_IsImportedTip(@id_race, @id_horse, '1') = 1
To create a new strategy which plays on BACK tips:
dbo.fn_IsImportedTip(@id_race, @id_horse, '2') = 1
A tip is validated using the combination DATE-RACECOURSE-RUNNERNAME-TIPTYPE. So the same tip is always valid for all the Market Types (WIN, PLACE, ETC..) of an event, and in your strategy you need to specify which market type to bet on.
Client Profiling
If your clients have to pay a subscription to access your tips, you can profile them adding a unique GUID to their URL.
So, for example, client 1 will be provided with the URL:
http://www.mywebsite.com/gettips?guid=7b349fc0-9dbd-47c7-9a35-7e449de6f89c
and client 2 will be provided with the URL:
http://www.mywebsite.com/gettips?guid=496b9591-35ce-4966-9153-eecb6e3e2fea
Your tips must be on a dinamic web page(normally an API), that before returning the tips, checks against a database (or a simple hard-coded list) the validity of the subscription associated to the received GUID.
The GUID must be long enough to work also as a password.
Contact me if you need more info about the tipping service.
6.How to fix a broken SQL instance
Ipposnif relies on SQL Server 2016 LocalDB which is installed on your PC during the Ipposnif installation.
In rare cases, this external program can fail, and this article explains a few solutions to fix this problem.
Before you start applying one of the solutions, give a try restarting your PC, sometimes the SQL instance is not broken but stuck, and simply restarting your PC can solve the problem.
Create from scratch a new SQL instance and database
If you don't mind about the bet history, and you have a backup of the xml of your strategies, you can simply uninstall from your PC the following two programs, and then reinstall Ipposnif.
1) Ipposnif
2) Microsoft SQL Server 2016 LocalDB
Create a new SQL instance and attach the existing database
This will recover all the data.
(work in progress...)