# Path: async_v20/definitions/helpers.py
# def domain_check(value, example=None, possible_values=None):
#     if example:
#         if not len(str(example)) == len(str(value)):
#             msg = f'{value} does not match length of example {example}'
#             logger.error(msg)
#             raise InvalidValue(msg)
# 
#     if possible_values:
#         if not value in possible_values:
#             possible_values = ', '.join(possible_values)
#             msg = f'{value} must be in {possible_values}. Possible values are {possible_values}'
#             logger.error(msg)
#             raise InvalidValue(msg)
# 
#     return True
# 
# Path: async_v20/exceptions.py
# class InvalidValue(AsyncV20Exception):
#     """A supplied value does not meet the specification
#     of valid values"""
#     pass
# 
# class InvalidFormatArguments(AsyncV20Exception):
#     """Arguments to format a DecimalNumber or PriceValue
#     are invalid"""
#     pass


import logging
import pandas as pd
from .helpers import domain_check
from ..exceptions import InvalidValue, InvalidFormatArguments
class PriceStatus(str, Primitive):
    """The status of the Price.
    """

    # Valid values
    values = {
        'tradeable': 'The Instrument’s price is tradeable.',
        'non-tradeable': 'The Instrument’s price is not tradeable.',
        'invalid': 'The Instrument of the price is invalid or there is no valid Price for the Instrument.'
    }

    def __new__(cls, value):
        assert domain_check(value, possible_values=cls.values)
        return super().__new__(cls, value)


class PriceValue(float, Primitive):
    """The string representation of a Price for an Instrument.
    """

    # Correct syntax of value
    format_syntax = 'A decimal number encodes as a string. The amount of precision ' \
                    'provided depends on the Price’s Instrument. Must be positive'

    def __new__(cls, value):
        try:
            assert float(value) >= 0
        except AssertionError:
            msg = f'Cannot create PriceValue from {value}. PriceValues must be positive'
            logger.error(msg)

# Path: async_v20/definitions/helpers.py
# def domain_check(value, example=None, possible_values=None):
#     if example:
#         if not len(str(example)) == len(str(value)):
#             msg = f'{value} does not match length of example {example}'
#             logger.error(msg)
#             raise InvalidValue(msg)
# 
#     if possible_values:
#         if not value in possible_values:
#             possible_values = ', '.join(possible_values)
#             msg = f'{value} must be in {possible_values}. Possible values are {possible_values}'
#             logger.error(msg)
#             raise InvalidValue(msg)
# 
#     return True
# 
# Path: async_v20/exceptions.py
# class InvalidValue(AsyncV20Exception):
#     """A supplied value does not meet the specification
#     of valid values"""
#     pass
# 
# class InvalidFormatArguments(AsyncV20Exception):
#     """Arguments to format a DecimalNumber or PriceValue
#     are invalid"""
#     pass


# Path: async_v20/definitions/primitives.py
import logging
import pandas as pd
from .helpers import domain_check
from ..exceptions import InvalidValue, InvalidFormatArguments

class PriceStatus(str, Primitive):
    """The status of the Price.
    """

    # Valid values
    values = {
        'tradeable': 'The Instrument’s price is tradeable.',
        'non-tradeable': 'The Instrument’s price is not tradeable.',
        'invalid': 'The Instrument of the price is invalid or there is no valid Price for the Instrument.'
    }

    def __new__(cls, value):
        assert domain_check(value, possible_values=cls.values)
        return super().__new__(cls, value)


class PriceValue(float, Primitive):
    """The string representation of a Price for an Instrument.
    """

    # Correct syntax of value
    format_syntax = 'A decimal number encodes as a string. The amount of precision ' \
                    'provided depends on the Price’s Instrument. Must be positive'

    def __new__(cls, value):
        try:
            assert float(value) >= 0
        except AssertionError:
            msg = f'Cannot create PriceValue from {value}. PriceValues must be positive'
            logger.error(msg)

            raise InvalidValue(msg)