Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from functools import reduce
- class LiveBetDataFactory:
- handicap_codes = {'471', '489', '501', '539', '541'}
- game_codes_with_checks = {
- '501': 'md_bt_45', '502': 'md_bt_45', '412': 'md_bt_45', '413': 'md_bt_45',
- '414': 'md_bt_45', '406': 'md_lte_45', '407': 'md_lte_45', '408': 'md_lte_45', '489': 'md_lte_45',
- '490': 'md_lte_45', '418': [8, 13], '419': [8, 13], '420': [8, 13], '421': [9, 14], '422': [9, 14],
- '423': [9, 14], '424': [10, 15], '425': [10, 15], '426': [10, 15], '427': [11, 16], '428': [11, 16],
- '429': [11, 16], '430': [12], '432': [12], '539': [8], '540': [8], '541': [9], '542': [9],
- }
- game_codes_and_dict_paths = {
- 'current_half_result.home': ['412', '406', '418', '421', '424', '427', '430'],
- 'current_half_result.draw': ['413', '407', '419', '422', '425', '428'],
- 'current_half_result.away': ['414', '408', '420', '423', '426', '429', '432'],
- 'current_half_over_under.$1_5.under': ['489', '501', '539', '541'],
- 'current_half_over_under.$1_5.over': ['490', '502', '540', '542'],
- 'next_goal.home': ['607', ], 'next_goal.no_goal': ['608', ], 'next_goal.away': ['609', ],
- 'full_time_result.home': ['400', ], 'full_time_result.draw': ['401', ], 'full_time_result.away': ['402', ],
- 'full_time_over_under.$2_5.under': ['471', ], 'full_time_over_under.$2_5.over': ['472', ]
- }
- def __init__(self, game_data_db, ignored_bets, min_diff, game_inst):
- """
- :param game_data_db:
- :param ignored_bets:
- :param min_diff:
- :param game_inst: game_instance
- """
- self.gd_db, self.ignored_bets = game_data_db, ignored_bets
- self.min_diff, self.game_instance = min_diff, game_inst
- template_dict = {
- "value": "",
- "isIncreased": False,
- "isDecreased": False
- }
- self.dict = {
- "current_half_result": {},
- "current_half_over_under": {
- "$1_5": {
- "over": template_dict,
- "under": template_dict
- },
- "handicap": ""
- },
- "full_time_over_under": {
- "$2_5": {
- "over": template_dict,
- "under": template_dict
- },
- "handicap": ""
- },
- "next_goal": {
- "home": template_dict,
- "no_goal": template_dict,
- "away": template_dict
- }
- }
- def set_game_data_values(self, path_str, game_code):
- if game_code in self.gd_db['odds'] and self.gd_db['odds'][game_code]['odd'] not in self.ignored_bets:
- if game_code in self.game_codes_with_checks.keys():
- # t.run('cp2')
- check = self.game_codes_with_checks[game_code]
- if (check == 'md_bt_45' and not self.min_diff > 45) or (
- check == 'md_lte_45' and not self.min_diff <= 45):
- return
- if self.game_instance.betradar_status not in check:
- return
- path_list = path_str.split('.')
- path = path_list
- update_dict = {
- 'value': self.gd_db['odds'][game_code].get('odd', ''),
- 'isIncreased': self.gd_db['odds'][game_code].get('is_increased', False),
- 'isDecreased': self.gd_db['odds'][game_code].get('is_decreased', False)
- }
- reduce(dict.setdefault, path, self.dict).update(update_dict)
- if game_code in self.handicap_codes and 'handicap_value' in self.gd_db['odds'][game_code]:
- self.dict[path_list[0]]['handicap'] = self.gd_db['odds'][game_code]['handicap_value']
- def set_game_data_db(self):
- for key in self.game_codes_and_dict_paths.keys():
- for game_code in self.game_codes_and_dict_paths[key]:
- self.set_game_data_values(key, game_code)
- return self.dict
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement