def get_staking_cutoff(self, round_num=0, tournament=1): """Compute staking cutoff for the given round and tournament. Args: round_num (int, optional): The round you are interested in, defaults to current round. tournament (int, optional): ID of the tournament, defaults to 1 Returns: decimal.Decimal: cutoff probability Raises: ValueError: in case of missing prize pool information """ query = ''' query($number: Int! $tournament: Int!) { rounds(number: $number tournament: $tournament) { selection { outcome pCutoff bCutoff } } } ''' arguments = {'number': round_num, 'tournament': tournament} result = self.raw_query(query, arguments) result = result['data']['rounds'][0]['selection'] key = 'bCutoff' if round_num >= 154 or round_num == 0 else 'pCutoff' return utils.parse_float_string(result[key])
def test_parse_float_string(): assert utils.parse_float_string(None) is None assert utils.parse_float_string("") is None assert utils.parse_float_string("1.23") == decimal.Decimal("1.23") assert utils.parse_float_string("12") == decimal.Decimal("12.0") assert utils.parse_float_string("1,000.0") == decimal.Decimal("1000.0") assert utils.parse_float_string("0.4") == decimal.Decimal("0.4")
def test_parse_float_string(): assert utils.parse_float_string(None) is None assert utils.parse_float_string("") is None assert utils.parse_float_string("1.23") == 1.23 assert utils.parse_float_string("12") == 12.0 assert utils.parse_float_string("1,000.0") == 1000.0