Strategy Edit

How To Configure Strategies' Criteria

You can open the configuration panel of a strategy with a double click on the corresponding row from Strategies Window, or right click the strategy and select Edit from the context menu.
With the configuration panel you can manage the strategy properties that define the betting behaviour of the strategy.
These properties (called also criteria) can contain SQL expressions and functions, setting no limit to the logic you wish to implement.

How strategies work

Every market update, Ipposnif checks against all the runners of that market, if the bet placement criteria specified in the active strategies are verified.
When all the bet placement conditions of a strategy are verified, the strategy places the bet and creates its container, the trade.
The trade is an instance of the strategy, and it can contain a minimum of one bet (for ex. in betting strategies), or more than one (for ex. in trading strategies).
Every trade has its own accounting, and knows its current profit and loss. There are criteria, described below, dedicated to control the number of active markets and the number of open trades per market at one time.
A trade can have one of the following statuses:
  • O = Open. A trade starts with this status when it is created, and remains open until one of the bets closes it.
  • C = Closed. When a trade is closed it cannot receive more bets. If the strategy can manage more trades on the same runner, but only one open at one time, close the trade to start a new one.
  • X = Deleted. When a bet is deleted, if it was the only present in the trade, the trade is deleted too. A trade containing a matched bet cannot be deleted.
  • S = Settled. All the bets inside the trade have been accounted after market is closed.

Ipposnif uses the following criteria types.
  • SQL Expression: SQL is a language created to manage databases but it is also perfect to define mathematical expressions. You can use these expressions to define for example the bet size, or the bet price. The simplest SQL expression can be a number (for ex.: 10.5). More complex SQL expressions can refer to variables and functions (for ex.: @capital/10).
    SQL used by Ipposnif is the Microsoft SQL Server 2016 TSQL. It is a complete and powerful programming language, capable to access external resources like XLS sheets or Web APIs; there are basically no limits to the strategy logic you can implement with it. The decimal separator in SQL is always the dot (.).
  • SQL Assertion: an SQL expression that can be true or false (for ex.: @base_rate < 8 ).
  • String: a combination of the following characters: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_+-0123456789^*#@.,°[]()!\|/?: $€£%
  • Decimal: a decimal number with two decimals. Plus prefix (+) means that the number must be positive. The decimal separator is always the dot (.).
  • Integer: an integer number. Plus prefix (+) means that the number must be positive.
  • Time: time of the day expressed with the format hh:mi:ss.
  • Timeframe: time frame related to the start time of the event. It is expressed with the format hh:mi:ss. If negative, it is subtracted from the related event start time.

Important Advice (before you start creating your own strategies)

If you input wrong values in the criteria of the strategy, for example you do not set enough conditions for the bet triggering logic, the strategy, as soon as it is activated, could exhaust the capital in a few instants, producing a bunch of unwanted bets.
You can reduce the risk following these advices:

1) Read carefully the current page.
2) Keep the strategy capital as low as possible during the development and testing of a new strategy.
3) When it is possible, use the criteria "Betting Time Frame" to avoid that all the markets are eligible for betting at the same time.
4) If you are new to Ipposnif, spend some time observing the strategies provided with the program. They have been longly tested in all the scenarios. Maybe the strategy you wish to implement is similar to a Ipposnif one, and you can easily start from a clone of it.

Criteria marked with a star (*) are mandatory.

Identification

ID* (+integer): it is automatically assigned to every new strategy. Since it can be different for the same strategy when imported onto different computers, use the strategy name (with function dbo.fn_StrategyId) if you need to refer across strategies.
Name* (string): unique name of the strategy.
Group Name (string): you can group strategies together giving them the same Group Name. This will allow statistics for groups of strategies.
Description (string): description of the strategy.

Capital

Initial Capital* (SQL Expression): maximum amount of money the strategy can lose. If not differently needed, use a number to specify the capital. If you decide to use an SQL expression that uses variables or functions, be careful that the value returned doesn't fluctuate out of your control, or you will put in danger your whole Betfair balance. If you have a group of strategies and you want to use a common multiplier for their stakes, you can use here a reference to one of the global variables. If the strategy works with rounds (read below) and you want to reinvest part of the previous rounds winnings, you can use the variable @last_reset_historical_profit
Max Liability (SQL Expression): maximum responsability the strategy can have.
Daily Stop Loss (SQL Expression): when the strategy has lost in the current day more than this amount, it stops placing bets until the day after. The local timezone is applied. Only settled bets are counted.
Daily Stop Win (SQL Expression): when the strategy has won in the current day more than this amount, it stops placing bets until the day after. The local timezone is applied. Only settled bets are counted.
Max Reset (SQL Expression): maximum number of times the strategy can perform a reset. When the strategy resets, it start a new round with a new capital. Zero means no reset. The total amount of money risked by the strategy is equal to: Capital*(MaxReset+1).
Reset Condition (SQL Assertion): when the SQL assertion is true, and all the trades are settled, the strategy is reset. The reset conditions are checked asyncronously every 15 seconds. If you want to reset a strategy before it has finished its capital, or a progression before it has been completed, in this strategy you need to wait at least 15 seconds before placing a new bet, because the placement of a new bet would prevent the strategy from being reset. @last_check_bet_seconds is a variable that can be used for this scope.
Max Active Markets (+integer): maximum number of markets with open and closed trades. If you are using a progression that requires to know the previous outcome before placing a new bet, this value must be 1.
Trades per Market: can be one of the following options:
  • Single trade per market: maximum one trade per market.
  • Single trade per runner: maximum one trade per runner, for a maximum of Max Runners.
  • Multiple trades one runner: a maximum of Max Trades on only one runner.
  • Multiple trades and runners: multiple trades on a maximum of Max Runners. Only one trade open at one time for the same runner.
  • Unlimited: no limit applied. Use the trig condition criteria to limit the number of bets.
Count Deleted Trades: when this option is checked, deleted trades (that have only deleted bet inside) are considered for the "Trades per Market" limit.

Link To Strategy

Makes the current strategy dependent from another one.
Strategy: linked strategy.
Criteria: when the criteria applied to the linked strategy is true, the current strategy can place bets. The following link criteria can be used:
  • Day PL greater/less than the specified amount
  • Market PL greater/less than the specified amount
  • Market total trades equals to the specified amount
  • Consecutive won trades equals/greater than the specified amount
  • Consecutive lost trades equals/greater than the specified amount
  • Consecutive won reset equals/greater than the specified amount
  • Consecutive lost reset equals/greater than the specified amount
Amount: amount for the criteria.

Manual Input

Manual strategies always require an input from the user before placing bets.
Manual Trigger: the bet placement conditions are checked, immediately and only, after an input from the user. This option speeds up manual strategies and reduces the load of the system. This option cannot be used in manual scheduling strategies (for ex. where the user selects the runners to bet, but the strategy places the bets only at n minutes at the start).
Market Checkbox: shows a checkbox near the Strategy Selector. The checkbox can have a different value for each combination market-strategy. You can read this value from the strategies using the variable @is_market_selected
Strategies - market checkbox

Runner Checkbox: shows a checkbox for each runner. The checkbox can have a different value for each combination market-strategy-runner.
You can read this value from the strategies using the variable @is_horse_selected.
Strategies - runner checkbox

Show All Runners Checkbox: shows a checkbox on the header of the runners grid. When this checkbox is checked, all the runners checkboxes are checked too. This checkbox has no variable associated, instead you have to use the variable @is_horse_selected of each runner.
Strategies - all runners checkbox

Price/Size Controls: activate betting frames. It can be one of the following options:
  • None: no betting frame is shown.
  • Show Betting Frames: show BACK/LAY betting frames when the user clicks on a price of the Runners Grid (for ex. in strategy "Manual - Scalping"). You can read from here how to use the betting frames.
  • Show Price Input Frame: it shows a new column in the Runners Grid where the user can input a decimal value for each horse.
  • Show All Frames: option 2 + option 3.
  • Single Click Price Selection: allows the bet placement with a single click on the prices of the Runners Grid (for ex. strategy "Manual - One Click Bet").
@is_event_selected variable: With a right click on the Events Grid header, you can make visibile the checkboxes column ("Selected").
You can know the value of the checkbox, reading the variable @is_event_selected from the strategies.
The value of the checkbox is the same for all the markets included in the event. So if you check a horse racing event, the variable will be 1 (true) in all its markets, WIN, PLACE, etc...
This allows you to trig multiple strategies, working on different market types, with a single click.

Market Filters

Event Type, Market Types, Countries, and Racecourses: filters applied to the downloaded markets. These filters will not affect the markets download configuration that you can set up from the options. For international events (like for ex. UEFA Champions League) use “International” like country.
Event Start Time (Time): daily time frame (from start time to end time) when the strategy can place bets. The time format is hh:mi:ss. Specify your timezone in Tmz to use your local time.
Status: status of the market when the strategy is allowed to place bets. Pre means pre-race (before the race goes in-play).
Betting Time Frame (Timeframe): time frame relative to the start of the event, when the strategy can place bets. A negative value means before the scheduled start time of the race, a positive value means after the start time. So for example the values -00:00:10 and 00:02:00 mean that the strategy can place bets only from ten seconds at the programmed start time of the race, to two minutes after the programmed start time (the race has no more delay than 2 minutes).
If the previous option (Status) is "In-Play" the bounds are referred to the moment in which the event goes in-play. The "Betting Time" values are not mandatory, but it is strongly recommended to specify them to reduce the computation effort, and to avoid that all the markets are eligible for betting at the same time.
Overround Back (+decimal): min and max back overround allowed. The overround is an indicator on how much fair are the odds in a market. Closer is the overround to 100 better are the odds for the final user. When the overround limits are applied to a market with more than one winner (like the horse race PLACE markets), the limits are multiplied by the number of winners during the check of the strategy's conditions. The overround back is calculated with the formula: SUM_FOR_ALL_RUNNERS(1/runner_best_back_price)*100
Overround Lay (+decimal): min and max lay overround allowed. This indicator is the same of the previous one, but calculated using the best lay price.
Each Bet: if checked, the overround filters are applied to all the bets; if not checked, the overround filters are applied only to the entry bet of the trade.
Only Markets That Go In-Play: only markets that allow betting after the event start.
Only Manually Selected Markets: when this option is checked, the strategy will place bets only on selected markets. To select markets, first you have to show the market checkbox activating the manual input option "Market Checkbox".

Runner Filters

Runner Selection Criteria: criteria used to select the runner/s to bet. If can be one of the following options:
  • None: the selection of the runners is demanded to all the other filters of the strategy (particularly the Entry Bet Condition option).
  • SQL Assertion: the strategy will place bet only when this assertion is true.
  • Red|Black Flag: the strategy can place bets only on runners with a red/black flag.
  • Runner Note (LIKE): the strategy can place bets on a runner if its note contains the text specified in Text to search. To perform a like comparison use the % symbol. For example, inserting "%lead%" as text, the strategy will place bets only if the runner note contains anywhere the text "lead".
  • Recent Form (LIKE): the string of the last results can be used to filter runners. For example, inserting "%1" as Text to search, only the runners that have won the last race can be bet; inserting "%11" only the runners that have won the last two races.
  • Runner|Jockey|Trainer|Owner Name (IN): the strategy can place bets on a runner if its name is one in the comma separated list specified. For example, inserting "The Draw" as text, the strategy will place bets only on selections with name "The Draw".
  • HomeTeam|AwayTeam|Draw If Score (IN): the home team is selected if the actual score is among the specified ones. Multiple score results must be specified using comma. For example "0-0,1-0,1-1". No spaces.
  • Manual Check: The strategy will place bets only on the selected runners. To show the runner checkboxes, activate the option in "Manual Input" section.
Runner Order Criteria: when the strategy criteria produce two or more runners, the runners to bet are ordered by the specified criteria. Desc means "descending order".
Back/Lay Price Range defines the odd bounds within a bet can be placed. These bounds not necessarily set a constraint to the final price of a bet, because the bet price could be updated after the creation (if specified in the strategy). If you need to specify bet price bounds that can never be overcome, use the Price Offset option. If you run several strategies at the same time, the use of this option, together with the option Betting Time Frame, can considerably reduce the load of the system.

Bets

The number of bets present in a trade is specified by the dropdown "Total Bets". A trade can contain a minimum of 1 bet and a maximum of 20 bets. The placement of a bet within a trade can never be repeated. When a bet is deleted, if it was the only present in the trade, the trade is deleted too.
Use the arrow buttons to move between the properties of each bet.

Only Bet 1 Starts Trade If you have more than one bet per trade, you can decide if only the bet 1 can open the trade (when all the strategy criteria and the trigger condition of bet 1 are verified), or every bet can open the trade (when all the strategy criteria and the trigger condition of the bet n are verified)

Trigger Condition: when the SQL assertion specified is true, the strategy can place the bet, when it is false the strategy cannot place the bet. This condition is optional and it is added to all the other criteria of the strategy.

Order Type: order type of the current bet.
  • Limit: this is the standard Betfair order. User can delete unmatched bets. User can hedge matched bets.
  • SP Market On Close: The bet will be matched when the market goes in-play, at the BSP price reconciliation. Size of the bet is expressed as liability. User cannot delete the SP bets after they have been placed on the market. User can hedge a bet only when it is matched after the market goes in-play.
  • SP Limit On Close: like the order above, but in this case the user can specify a limit for the BSP price: if the BSP is under (over for LAY bets) the specified limit, the bet is voided. User can hedge a bet only when it is matched after the market goes in-play.
Bid Type: bid type of the current bet.
  • BACK/LAY: the bet is of the specified type.
  • Size Sign: type depends by the sign of the bet size. If it is positive the bet type is BACK, if it is negative the bet type is LAY. This option is normally used together with the Manual Input option "Show Betting Frames". The Size returned by the Betting Frame is a negative value if the bet type is LAY.
  • Hedge: the bet will perform a "greening up" of the current trade balance and the type of the bet will be set accordingly.
Persistence: behavior of the bet when the event starts, it can be:
  • Lapse: the unmatched bet will be voided
  • Persist: if the market goes in play, the unmatched bet will be kept in-play. 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.
  • Manual Input: the user decides the persistence from the betting frame. This option is present only when the option "Show Betting Frame" is selected in the section "MANUAL INPUT".
Bet Price defines the price of the bet. It can be:
  • A fixed price
  • The best back/lay increased/decreased by a number of Ticks (integer).
  • The best back/lay increased/decreased by a Percentage (integer).
  • The back/lay price at which a specific Stake Amount (+integer) is fully matched.
  • The average price of the bet Ref.Bet. (+integer) plus Ticks (+integer) of gain.
  • Price at which there is a Percentage (+integer) of gain of the size of bet Ref.Bet. (+integer)
  • Price defined by an SQL Expression.
  • Manual Input: the user decides the price from the betting frame. This option is present only when the option "Show Betting Frame" is selected in the section "MANUAL INPUT".
Price Offset Min/Max (SQL Expression): the minimum and maximum price that a bet can have. If the price overcomes one of the bounds, it is offset to the bound.
Bet Size (SQL Expression): size of the bet. It can be simply an amount or a SQL expression. If the size returned by the expression equals to zero, the bet will not be placed. The result of the expression is always rounded to two decimals. Strategies that follow a particular stake progression logic, like for example the strategy Masaniello or D'Alembert, can use SQL Functions and SQL Variables present in the Ipposnif database. You can add new variables and functions developed by you to the Ipposnif database.
Size Offset Min/Max (SQL Expression): the minimum and maximum size that a bet can have. If the size overcomes one of the bounds, it is offset to the bound. The result of the expression is always rounded to two decimals. If the option "Bet Size = Net Win/Liability" is ON, the bounds are applied after the size calculated.
Use Residual Capital: when this option is active and the capital is not enough to place the next bet, the bet will be placed anyway, with the size adjusted to use all the residual capital.
Bet Size = Net Win/Liability: when this option is ON, the amount resulting from the "Bet Size" option, is considered like the target net win (back) or the total liability of the bet (lay). The effective size of the bet is adjusted accordingly.
When the Update option is ON and the bet is unmatched, a new price and a new size are calculated with the same criteria specified for the bet placement, and the bet updated accordingly. The update process is performed until the bet is matched, with an interval in seconds specified in Interval (SQL Expression). This option is usefull, for example, to keep the bet at a certain distance from the front of the market. The use of this option can produce a lot of transactions, expecially if you are placing bets below the minimum size (double the cost in transactions). Ipposnif, in default, will stop placing bets when it has reached the 2000 transactions in the last hour. You can change this limit from the options, but keep in mind that if you overcome the 5000 transactions per hour you will be subject to heavy Betfair fees.
Fill Or Kill - Ticks (+integer): cancel the unmatched part of the bet when the distance in ticks between the best back/lay price and the actual bet price is greater than the specified value
Fill Or Kill - Seconds (+integer): cancel the unmatched part of the bet after a specified amount of seconds.
Delete Condition (SQL Assertion): when the SQL Assertion is true, the bet is deleted. When the only bet present in a trade is deleted, also the trade status is automatically set to Deleted.
Close Trade: change the status of the trade accordingly with a specific event. This is useful, for example, to free slots for new bets when the option "Trades per Market" is set to "Multiple trades and runners". Do not close the trade if the strategy may include other bets in it.
Clear Check: remove the runner check applied by the user when a specific event is fired. In some manual strategies, this option is mandatory to prevent new bets after the first one is triggered.

Expression Watcher

Expression Watcher can help you to debug a strategy.