Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_init(self):
assert self.unmatched_order.bet_id == 1
assert self.unmatched_order.price == 2
assert self.unmatched_order.size == 3
assert self.unmatched_order.side == 'L'
assert self.unmatched_order.status == 'E'
assert self.unmatched_order.persistence_type == 'L'
assert self.unmatched_order.order_type == 'L'
assert self.unmatched_order.placed_date == BaseResource.strip_datetime(8)
assert self.unmatched_order.size_matched == 9
assert self.unmatched_order.size_remaining == 10
assert self.unmatched_order.size_lapsed == 11
assert self.unmatched_order.size_cancelled == 12
assert self.unmatched_order.size_voided == 13
assert self.unmatched_order.reference_order == 14
assert self.unmatched_order.reference_strategy == 15
assert self.unmatched_order.lapsed_date == 16
assert self.unmatched_order.lapse_status_reason_code == 17
def test_matched_date_string(self):
now = BaseResource.strip_datetime(4)
assert self.unmatched_order.matched_date_string == now.strftime('%Y-%m-%dT%H:%M:%S.%fZ')
def __init__(self, **kwargs):
self.bet_id = kwargs.get("betId")
self.bet_count = kwargs.get("betCount")
self.bet_outcome = kwargs.get("betOutcome")
self.event_id = kwargs.get("eventId")
self.event_type_id = kwargs.get("eventTypeId")
self.handicap = kwargs.get("handicap")
self.last_matched_date = BaseResource.strip_datetime(kwargs.get("lastMatchedDate"))
self.market_id = kwargs.get("marketId")
self.order_type = kwargs.get("orderType")
self.persistence_type = kwargs.get("persistenceType")
self.placed_date = BaseResource.strip_datetime(kwargs.get("placedDate"))
self.price_matched = kwargs.get("priceMatched")
self.price_reduced = kwargs.get("priceReduced")
self.price_requested = kwargs.get("priceRequested")
self.profit = kwargs.get("profit")
self.commission = kwargs.get("commission")
self.selection_id = kwargs.get("selectionId")
self.settled_date = BaseResource.strip_datetime(kwargs.get("settledDate"))
self.side = kwargs.get("side")
self.size_settled = kwargs.get("sizeSettled")
self.size_cancelled = kwargs.get("sizeCancelled")
self.customer_strategy_ref = kwargs.get("customerStrategyRef")
self.customer_order_ref = kwargs.get("customerOrderRef")
self.item_description = ItemDescription(**kwargs.get("itemDescription")
) if 'itemDescription' in kwargs else None
def __init__(self, **kwargs):
self._from = BaseResource.strip_datetime(kwargs.get('from'))
self.to = BaseResource.strip_datetime(kwargs.get('to'))
self.event_id = eventId
self.event_type_id = eventTypeId
self.in_play = inPlay
self.market_base_rate = marketBaseRate
self.market_time = BaseResource.strip_datetime(marketTime)
self.market_type = marketType
self.number_of_active_runners = numberOfActiveRunners
self.number_of_winners = numberOfWinners
self.open_date = BaseResource.strip_datetime(openDate) if openDate else None
self.persistence_enabled = persistenceEnabled
self.regulators = regulators
self.runners_voidable = runnersVoidable
self.settled_time = BaseResource.strip_datetime(settledTime)
self.status = status
self.each_way_divisor = eachWayDivisor
self.suspend_time = BaseResource.strip_datetime(suspendTime)
self.timezone = timezone
self.turn_in_play_enabled = turnInPlayEnabled
self.venue = venue
self.version = version
self.line_max_unit = lineMaxUnit
self.line_min_unit = lineMinUnit
self.line_interval = lineInterval
self.runners = [
MarketDefinitionRunner(**i) for i in runners
]
self.price_ladder_definition = PriceLadderDescription(
**priceLadderDefinition
) if priceLadderDefinition else None
self.key_line_definitions = MarketDefinitionKeyLine(**keyLineDefinition) if keyLineDefinition else None
self.race_type = raceType
def snap(self, market_ids: list = None) -> list:
market_books = []
for cache in list(self._caches.values()):
if market_ids and cache.market_id not in market_ids:
continue
# if market has closed send regardless
if cache.market_definition["status"] != "CLOSED":
if self._listener.inplay:
if not cache.market_definition["inPlay"]:
continue
elif self._listener.seconds_to_start:
_now = datetime.datetime.utcfromtimestamp(cache.publish_time / 1e3)
_market_time = BaseResource.strip_datetime(
cache.market_definition["marketTime"]
)
seconds_to_start = (_market_time - _now).total_seconds()
if seconds_to_start > self._listener.seconds_to_start:
continue
if self._listener.inplay is False:
if cache.market_definition["inPlay"]:
continue
market_books.append(
cache.create_resource(self.unique_id, None, self._lightweight)
)
return market_books
def __init__(self, id, sortPriority, status, hc=0, bsp=None, adjustmentFactor=None, removalDate=None, name=None):
self.selection_id = id
self.sort_priority = sortPriority
self.status = status
self.handicap = hc
self.bsp = bsp
self.adjustment_factor = adjustmentFactor
self.removal_date = BaseResource.strip_datetime(removalDate)
self.name = name # historic data only
def __init__(self, betId, averagePriceMatched, bspLiability, handicap, marketId, orderType, persistenceType,
placedDate, regulatorCode, selectionId, side, sizeCancelled, sizeLapsed, sizeMatched, sizeRemaining,
sizeVoided, status, priceSize, matchedDate=None, customerStrategyRef=None, customerOrderRef=None):
self.bet_id = betId
self.average_price_matched = averagePriceMatched
self.bsp_liability = bspLiability
self.handicap = handicap
self.market_id = marketId
self.matched_date = BaseResource.strip_datetime(matchedDate)
self.order_type = orderType
self.persistence_type = persistenceType
self.placed_date = BaseResource.strip_datetime(placedDate)
self.regulator_code = regulatorCode
self.selection_id = selectionId
self.side = side
self.size_cancelled = sizeCancelled
self.size_lapsed = sizeLapsed
self.size_matched = sizeMatched
self.size_remaining = sizeRemaining
self.size_voided = sizeVoided
self.status = status
self.customer_strategy_ref = customerStrategyRef
self.customer_order_ref = customerOrderRef
self.price_size = PriceSize(**priceSize)
def __init__(self, status, instruction, sizeCancelled=None, cancelledDate=None, errorCode=None):
self.status = status
self.size_cancelled = sizeCancelled
self.cancelled_date = BaseResource.strip_datetime(cancelledDate)
self.instruction = CancelOrderInstruction(**instruction)
self.error_code = errorCode
def __init__(self, **kwargs):
self._from = BaseResource.strip_datetime(kwargs.get('from'))
self.to = BaseResource.strip_datetime(kwargs.get('to'))