The purpose of this section is to describe the format of the string which will submitted to the Python bet processor strats.py. This string is a series of lines that are Python variable declarative statements. There are a few things that readers not very with familiar with Python should know about:

  1. # starts a comment, so anything after and including # will be ignored, so lines starting with # can help make the intent of the declaration clear
  2. Blank lines are ignored. This may help the readability of the string when printed/debugged
  3. self. included in a variable declaration refers to the variable as a member of the class where it is declared. In our case it will be in a strats.Bet class object.

The rest of this manual will describe what variable to declare and what it means. These variables (attributes) will be introduced in the preferred order of declaration. Generally speaking, there is a default value for each variable, except for strats.Bet.bet_type and (currently) strats.Bet.nraces which must be specified.

[1] I would suggest that we let strats.py define strats.Bet.nraces from strats.Bet.bet_type.

Type of Bet Pool [Mandatory]

This is one of Quinella, Exacta, Trifecta, Pick 4, Pick 6, Quaddie, Superfecta. An example of this part of the string might be:

self.bet_type = "Quaddie"

Number of Races [Mandatory?]

This attribute is the number of races for which information is required. It is

  • 1 for Quinella, Exacta, Trifecta, Pick 4, and Pick 6
  • 4 for Quaddie
  • 6 for Superfecta

An example part of the string would be for the Quaddie:

self.nraces = 4
[2] strats.Bet.nraces should possibly removed from user input: but determined instead from strats.Bet.bet_type instead.

TAB Horse IDs [Mandatory]

Depending on the bet type, we will need either 1, 4, or 6 sets of horse IDs associated with the relevant race(s). To accomodate this the class variable strats.Bet.horse_ids is a list of lists. For a single race bet types this list only has one element: the list of TAB horse IDS for that race. As an example of the string for such a case is:

self.horse_ids.append([1,2,4,5,6,8,9])

Here is an example of the statements required for a Quaddie:

self.horse_ids.append([1,2,3,4,5,6,7,8,9,10,11])
self.horse_ids.append([1,2,3,4,5,6,7])
self.horse_ids.append([1,2,3,4,5,6,7,8,9])
self.horse_ids.append([1,2,3,4,5,6,7])

TAB Odds [Mandatory?]

Either the TAB Odds, User Odds, or both must be specified. Depending on the bet type, we will need either 1, 4, or 6 sets of odds associated with the relevant race(s). To accomodate this the class variable strats.Bet.tab_odds is a list of lists. For a single race bet types this list only has one element: the list of TAB horse IDS for that race. As an example of the string for the single race case is:

self.tab_odds.append([2.0,4.2,4.2,5.5,5.9,"-",11.0])

Any entry of a non-numeric character indicates a scratching for that horse.

Here is an example for a Quaddie:

self.tab_odds.append([5.2,3.2,16.2,5.8,9.3,34.8,6.7,9.7,14.3,10.5,60.])
self.tab_odds.append([1.3,10.0,12.0,3.1,15.1,1.6,2.3])
self.tab_odds.append([8.3,31.0,4.2,10.0,6.0,7.2,3.2,20,42.6])
self.tab_odds.append([31.7,13.7,4.7,22.6,11.7,2.4,11.7])

User Odds [Mandatory?]

Either the TAB Odds, User Odds, or both must be specified. Depending on the bet type, we will need either 1, 4, or 6 sets of odds associated with the relevant race(s). To accomodate this the class variable strats.Bet.user_odds is a list of lists. For a single race bet types this list only has one element: the list of TAB horse IDS for that race. As an example of the string for the single race case is:

self.user_odds.append([2.0,4.2,4.2,5.5,5.9,"-",11.0])

Any entry of a non-numeric character indicates a scratching for that horse.

Here is an example for a Quaddie:

self.user_odds.append([5.2,3.2,16.2,5.8,9.3,34.8,6.7,9.7,14.3,10.5,60.])
self.user_odds.append([1.3,10.0,12.0,3.1,15.1,1.6,2.3])
self.user_odds.append([8.3,31.0,4.2,10.0,6.0,7.2,3.2,20,42.6])
self.user_odds.append([31.7,13.7,4.7,22.6,11.7,2.4,11.7])

Aggregation of IDs and Odds

It may be more convenient (and doesn’t affect the bet logic) if the TAB IDs and odds (user and/or TAB) are grouped together:

self.horse_ids.append([1,2,3,4,5,6,7,8,9,10,11])
self.tab_odds.append([5.2,3.2,16.2,5.8,9.3,34.8,6.7,9.7,14.3,10.5,60.])
self.user_odds.append([4.1, 3.8, 19.1, 8.0, 7.6, 35.8, 7.2, 11.1, 11.6, 10.9, 56.8]) self.horse_ids.append([1,2,3,4,5,6,7])
self.tab_odds.append([1.3,10.0,12.0,3.1,15.1,1.6,2.3])
self.user_odds.append([1.6, 13.0, 7.2, 2.8, 20.8, 2.3, 1.9]) self.horse_ids.append([1,2,3,4,5,6,7,8,9])
self.tab_odds.append([8.3,31.0,4.2,10.0,6.0,7.2,3.2,20,42.6])
self.user_odds.append([5.0, 34.8, 5.3, 14.3, 4.3, 8.5, 3.2, 28.9, 61.3]) self.horse_ids.append([1,2,3,4,5,6,7])
self.tab_odds.append([31.7,13.7,4.7,22.6,11.7,2.4,11.7])
self.user_odds.append([29.3, 13.9, 4.7, 26.1, 15.2, 1.5, 8.9])

Jockeys [Option]

For multi-race betting (Quaddie and Superfecta) jockey information can be input. (Jockey information for single race betting pools is forbidden.) An example input for a Quaddie is kept in strats.Bet.jockey_list which is class attribute of a list of lists:

self.jockey_list.append([1,2,3,4,5,6,7,8,9,10])
self.jockey_list.append([11,21,13,41,51,61,17])
self.jockey_list.append([11,21,13,41,51,61,81])
self.jockey_list.append([431,351,613,137,831])

If jockey info is provided for one race, it needs to be provided for all. If provided, the jockey information needs to be provided for each runner in each race. If jockey information is not provided, then strats.Bet.jockey_list defaults to the empty list, and jockey information plays no part in bet discrimination.

Trainers [Option]

For multi-race betting (Quaddie and Superfecta) trainer information can be input. (trainer information for single race betting pools is forbidden.) An example input for a Quaddie is kept in strats.Bet.trainer_list which is class attribute of a list of lists:

self.trainer_list.append([6,2,3,4,5,6,7,8,7,60])
self.trainer_list.append([66,26,63,46,56,66,67])
self.trainer_list.append([66,26,63,46,56,66,86])
self.trainer_list.append([436,356,663,637,836])

If trainer info is provided for one race, it needs to be provided for all. If provided, the trainer information needs to be provided for each runner in each race. If trainer information is not provided, then strats.Bet.trainer_list defaults to the empty list, and trainer information plays no part in bet discrimination.

Scaling Odds [Option]

The attributes, strats.Bet.scale_tab and strats.Bet.scale_tab, are parameters that are used to scale the odds data. They affect scaling according to:

  • if = -1, the odds are unscaled: the probabilites are the inverse of the win price line
  • if = 0, the odds are normlized: the probabilities of the price line add up to 1
  • if between 0 and 100 (% of normal), the odds are scaled by odds*scale_factor/100

Here is an example:

self.scale_tab = -1 # unscaled
self.scale_user = 85 # scaled by 85% to try to approximate TAB takeout

By default the scaling of the odds is normalized.

Standouts [Option]

For single race pools, the user can stand out any place in the combination The relevant attribute associated with each place is given by standout_x, where x is the place. For example if we wished to stand out horse 1 and 2 for first, 1,2, and 7 for second, and the field for third in a trifecta bet, the string involved would be:

self.standout_1 = [1,2]
self.standout_2 = [1,2,7]
self.standout_3 = []

The third line would not be necessary as the field is the default for the standouts.

For the multi-race pools, the standouts are for the winners of each race, so standout_x is the stadout for the xth race in the Quaddie or Superfecta. An example string standout element for a Quaddie bet might be:

self.standout_1 = [1,4]
self.standout_2 = [2,3,7]
self.standout_3 = [1,5,9,11]
self.standout_4 = [2,8]

Filter Price Line by Interval [Option]

We can filter the win price line by specifying the attributes strats.Bet.taboddsx and/or strats.Bet.useroddsx where x refers to an odds place restriction for a single race bet, or to a odds win odds restriction for a multi race bet. These restriction are expressed as an odds minimum, odds maximum tuple. For example, if one was very confident of the user win price line for a race, one could express the restriction for a trifecta bet as:

self.userodds1 = (1,4)
self.userodds2 = (1,10)
self.userodds3 = (8,20)

As another example, if one had a strong belief that runners were only in the market if the TAB odds wre less than 10, we could put this restriction on a Superfecta bet:

self.tabodds1 = (1,10)
self.tabodds2 = (1,10)
self.tabodds3 = (1,10)
self.tabodds4 = (1,10)
self.tabodds5 = (1,10)
self.tabodds6 = (1,10)

Restriction on Exotic Odds Range [Option]

After the TAB and/or user exotic odds have been calculated from their respective win price lines using the rules above, one may decide to restrict the bets to a particular exotic odds range (min,max). This is done by specifying the attributes strats.Bet.tab_div_range and/or strats.Bet.user_div_range. For example, suppose in trifecta betting we want to restrict the calculated user trifecta odds to less than 50 and the calculated TAB odds to great than 50. We might specify this condition as:

self.user_div_range = (1,50)
self.tab_div_range = (50,1000000)

If there is to be on restriction on the exotic odds range, then these attributes are set to False, which is the default.

Overlay (Option)

If set to True, then the overlay attribute, strats.Bet.overlay, then combinations will be accept only if the TAB exotic odds are at least strats.Bet.overlay_var per cent greater than the user exotic odds. Here is an example where the user odds are required to be 150% better than the TAB odds:

self.overlay = True
self.overlay_var = 150

These attributes are only relevant if both win price lines are specified.

Top Combinations by Probability (Option)

If the attribute strats.Bet.percent_by_number is given, then the top % combinations specified are accepted. If there is only one win price line specified, then the combinations are sorted by that price line. If both price lines are specified, then they are rated by the user price line. For example, suppose we only want the top 25 per cent of combinations for a given set of exotic combination as calculated from the rules above. The relevant string would be:

self.percent_by_number = 25

Top Combinations by Value (Option)

If the attribute strats.Bet.percent_by_value is given, then the top % combinations rated by value are accepted. Value is defined as the ratio of the TAB odds to the user odds. Clearly, both price lines need to be defined for this option to be invoked. For example, suppose we only want the 10 per cent of combinations for a given set of exotic combination as calculated from the rules above. The relevant string would be:

self.percent_by_value = 10

Staking (Option)

One can specify either flat staking or staking based on taking out a specified amount of money. Which scheme is used depends on the Boolean attribute strats.Bet.flat_stakes. If True (the default with stakes/combination of 0.50), then one could specify the flat staking at $1 per combination as:

self.flat_stakes = True
self.stakes = 1.0

Alternative, one could weight the stakes so as to take out a fixed amount of winnings depending upon the odds. If both price lines have been input, it will be necessary to specify which price line will be used for the odds. This is in the attribute strats.Bet.takeout_priceline which can be either “tab” or “user”. Here is an example takeout scheme using the TAB odds to take out $500 per combination:

self.flat_stakes = False
self.takeout_priceline = "tab"
self.takeout = 500

Rounding (Option)

If not flat staking, the individual bet/combination outlay can be rounded in various ways depending upon the strats.Bet.rounding attribute:

  • “Exact” - as calculated
  • “Round Up” - round up to nearest .50 increment (default)
  • “Round Down” - round down to the nearest .50 increment
  • “Nearest” - round to the nearest .50 increment

An example of rounding to the nearest $.50 increment is:

self.rounding = "Nearest"

Total Outlay (Option)

After all of the other rules are in place, the total outlay for the bet can be capped with the attribute strats.Bet.outlay_amount. This is currently set by default to a million dollars. Here is a specification that puts on a more reasonable cap:

self.outlay_amount = 100

How to Construct the Input Bet String的更多相关文章

  1. [LeetCode] Construct Binary Tree from String 从字符串创建二叉树

    You need to construct a binary tree from a string consisting of parenthesis and integers. The whole ...

  2. 536. Construct Binary Tree from String 从括号字符串中构建二叉树

    [抄题]: You need to construct a binary tree from a string consisting of parenthesis and integers. The ...

  3. LeetCode Construct Binary Tree from String

    原题链接在这里:https://leetcode.com/problems/construct-binary-tree-from-string/description/ 题目: You need to ...

  4. [LeetCode] 536. Construct Binary Tree from String 从字符串创建二叉树

    You need to construct a binary tree from a string consisting of parenthesis and integers. The whole ...

  5. 【LeetCode】536. Construct Binary Tree from String 解题报告(C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 统计字符串出现的次数 日期 题目地址:https:// ...

  6. [Angular HTML] Overwrite input value, String.fromCharCode & input.selectionStart

    @HostListener('keydown', ['$event', '$event.keyCode']) onKeyDown($event: KeyboardEvent, keyCode) { i ...

  7. [LeetCode] Construct String from Binary Tree 根据二叉树创建字符串

    You need to construct a string consists of parenthesis and integers from a binary tree with the preo ...

  8. 606. Construct String from Binary Tree 从二叉树中构建字符串

    [抄题]: You need to construct a string consists of parenthesis and integers from a binary tree with th ...

  9. LeetCode Construct String from Binary Tree

    原题链接在这里:https://leetcode.com/problems/construct-string-from-binary-tree/#/description 题目: You need t ...

随机推荐

  1. 可落地的DDD(3)-如何利用DDD进行微服务的划分

    摘要 前面两篇介绍了DDD的目标管理.DDD的工程结构调整.这篇讨论微服务的划分.微服务是目前后端比较流行的架构体系了,那么如何做好一个微服务的划分?一个微服务的粒度应该是多大呢?这篇主要介绍如何结合 ...

  2. .Net Core 获取应用物理路径的常见问题

    如果要得到传统的ASP.Net应用程序中的相对路径或虚拟路径对应的服务器物理路径,只需要使用使用Server.MapPath()方法来取得Asp.Net根目录的物理路径. 但是在Asp.Net Cor ...

  3. c#使用SoundPlayer播放wav格式音频

    1.引用System.Media名称空间下的类SoundPlayer   SoundPlayer player = new SoundPlayer(); 2.方法调用Play(); public vo ...

  4. 运维利器1-supervisor

    supervisor用来管理进程服务很方便 优点: 1.重启方便,无抖动感 2.可以分组管理进程 3.加入系统自动启动后,可以开机自启,程序异常退出能自动启动 操作: 1.在python沙箱环境下操作 ...

  5. 2019 翔通动漫java面试笔试题 (含面试题解析)

      本人5年开发经验.18年年底开始跑路找工作,在互联网寒冬下成功拿到阿里巴巴.今日头条.翔通动漫等公司offer,岗位是Java后端开发,因为发展原因最终选择去了翔通动漫,入职一年时间了,也成为了面 ...

  6. JSP+SpringMVC框架使用WebUploader插件实现注册时候头像图片的异步上传功能

    一.去官网下载webuploader文件上传插件 https://fex.baidu.com/webuploader/ 下载好后把它放到Javaweb项目的文件夹中(我放到了webcontent下面的 ...

  7. js学习之堆栈内存

    **栈内存** >基本数据类型值是直接存放在栈内存中的 栈内存中的变量一般都是已知大小或者有范围上限的,算作一种简单存储.而堆内存存储的对象类型数据对于大小这方面,一般都是未知的.个人认为,这也 ...

  8. 49.react中使用less

    1.安装less:npm install less less-loader --save 2.webpack.config.js中配置: oneOf: [ {   test: /\.less$/,   ...

  9. 英语apyrite红碧玺apyrite单词

    红碧玺(apyrite)是粉红.桃红.玫瑰红.深红.紫红等以红色调为主的碧玺,矿物学上主要属于锂电气石和镁电气石.红色起因可能与微量锰及锂和铯有关. 红色是碧玺中价值最高的,其中以紫红色和玫瑰红色最佳 ...

  10. 没有用到React,为什么我需要import引入React?

    没有用到React,为什么我需要import引入React? 本质上来说JSX是React.createElement(component, props, ...children)方法的语法糖. 所以 ...