Strategy Configuration
You can open the configuration panel of a strategy with a double click on the corresponding row from Strategies, 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 refresh, Ipposnif checks against all the runners of that market, if the bet placement criteria specified in the active strategies are verified.
Strategies - Bet Trigger Logic
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, or more than one (for ex. in trading strategies).
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
  • C = Closed. If the strategy can manage more trades on the same runner, but only one open at one time, close the trade to free a new slot.
  • X = Deleted. When a bet is deleted, if it was the only present in the trade, the trade is deleted too.
  • S = Settled. All the bets inside the trade have been accounted after market settlement.

Ipposnif uses the following criteria types. Criteria marked with a star (*) are mandatory.
  • 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 (.) whatever are the local settings of the machine running Ipposnif.
  • 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 (.) whatever are the local settings of the machine running Ipposnif.
  • 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 an 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 new 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.
The only protection against this mistake is the strategy capital: keep the strategy capital as low as possible during the development and testing of a new strategy!
If you are new to Ipposnif, it is better to 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.



Identification
Strategies - Identification
ID* (+integer): it is automatically assigned to every new strategy.
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
Strategies - Identification
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 expressions 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.
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.
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.
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, you need to wait at least 15 seconds before placing a new bet, because 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.
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.



Link To Strategy
Strategies - Identification
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
Strategies - Identification
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 reduce the bet triggering computation effort. 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 near every 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. strategy "Manual - Trading (DOB)"). 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").



Market Filters
Strategies - Identification
Event Type, Market Types, Countries, and Racecourses: filters applied to the downloaded markets. These filters will not affect the download market configuration that you can setup from the options. For international events (like for ex. UEFA Champions League) use “International” like country.
Event Start Time (Time): daily time frame when the strategy can place bets. The time format is hh:mi:ss. Insert your timezone in Tmz to specify a timeframe related to 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, to two minutes after the programmed start time of the race (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
Strategies - Identification
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
Strategies - Identification
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.

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 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 markets 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 to the calculated final size.
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 when it has reached the 4000 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 Betfair extra fees.
Fill Or Kill - Ticks (+integer): when the distance in ticks between the best back/lay price and the actual bet price is greater than the specified value, the bet is deleted (if unmatched).
Fill Or Kill - Seconds (+integer): cancel the bet if it remains unmatched for the 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".
Clear Check: remove the runner check applied by the user when a specific event is fired. In some manual strategies, this option is used to prevent new bets after the first one is placed.



Debug a Strategy
Strategies - Identification
With a right click on the runner name -> Expression Watcher, you will open a debug window that will show all the conditions needed to place the bet of a specific strategy for this runner.
With a right click on a trade you will open the same debug window, but this time it will show all the conditions needed to place/update/delete all the other bets of the selected trade.

You can add variables and custom expressions to the list to watch their values in real time.
The custom expressions can only return numeric values.

If you want to add an SQL assertion, for example @capital>100, you need to use the SQL flow instructions:
case when @capital>100 then 1 else 0 end