Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
class RawDataEvent(BaseEvent):
EVENT_TYPE = EventType.RAW_DATA
QUEUE_TYPE = QueueType.HANDLER
class CurrentOrdersEvent(BaseEvent):
EVENT_TYPE = EventType.CURRENT_ORDERS
QUEUE_TYPE = QueueType.HANDLER
class ClearedMarketsEvent(BaseEvent):
EVENT_TYPE = EventType.CLEARED_MARKETS
QUEUE_TYPE = QueueType.HANDLER
class ClearedOrdersEvent(BaseEvent):
EVENT_TYPE = EventType.CLEARED_ORDERS
QUEUE_TYPE = QueueType.HANDLER
class CloseMarketEvent(BaseEvent):
EVENT_TYPE = EventType.CLOSE_MARKET
QUEUE_TYPE = QueueType.HANDLER
class StrategyResetEvent(BaseEvent):
EVENT_TYPE = EventType.STRATEGY_RESET
QUEUE_TYPE = QueueType.HANDLER
class CustomEvent(BaseEvent):
EVENT_TYPE = EventType.CUSTOM_EVENT
self.event = event
@property
def elapsed_seconds(self):
return (datetime.datetime.utcnow() - self._time_created).total_seconds()
def __str__(self):
return "<{0} [{1}]>".format(self.EVENT_TYPE.name, self.QUEUE_TYPE.name)
class MarketCatalogueEvent(BaseEvent):
EVENT_TYPE = EventType.MARKET_CATALOGUE
QUEUE_TYPE = QueueType.HANDLER
class MarketBookEvent(BaseEvent):
EVENT_TYPE = EventType.MARKET_BOOK
QUEUE_TYPE = QueueType.HANDLER
class RawDataEvent(BaseEvent):
EVENT_TYPE = EventType.RAW_DATA
QUEUE_TYPE = QueueType.HANDLER
class CurrentOrdersEvent(BaseEvent):
EVENT_TYPE = EventType.CURRENT_ORDERS
QUEUE_TYPE = QueueType.HANDLER
class ClearedMarketsEvent(BaseEvent):
EVENT_TYPE = EventType.CLEARED_MARKETS
def __str__(self):
return "<{0} [{1}]>".format(self.EVENT_TYPE.name, self.QUEUE_TYPE.name)
class MarketCatalogueEvent(BaseEvent):
EVENT_TYPE = EventType.MARKET_CATALOGUE
QUEUE_TYPE = QueueType.HANDLER
class MarketBookEvent(BaseEvent):
EVENT_TYPE = EventType.MARKET_BOOK
QUEUE_TYPE = QueueType.HANDLER
class RawDataEvent(BaseEvent):
EVENT_TYPE = EventType.RAW_DATA
QUEUE_TYPE = QueueType.HANDLER
class CurrentOrdersEvent(BaseEvent):
EVENT_TYPE = EventType.CURRENT_ORDERS
QUEUE_TYPE = QueueType.HANDLER
class ClearedMarketsEvent(BaseEvent):
EVENT_TYPE = EventType.CLEARED_MARKETS
QUEUE_TYPE = QueueType.HANDLER
class ClearedOrdersEvent(BaseEvent):
EVENT_TYPE = EventType.CLEARED_ORDERS
class ClearedMarketsEvent(BaseEvent):
EVENT_TYPE = EventType.CLEARED_MARKETS
QUEUE_TYPE = QueueType.HANDLER
class ClearedOrdersEvent(BaseEvent):
EVENT_TYPE = EventType.CLEARED_ORDERS
QUEUE_TYPE = QueueType.HANDLER
class CloseMarketEvent(BaseEvent):
EVENT_TYPE = EventType.CLOSE_MARKET
QUEUE_TYPE = QueueType.HANDLER
class StrategyResetEvent(BaseEvent):
EVENT_TYPE = EventType.STRATEGY_RESET
QUEUE_TYPE = QueueType.HANDLER
class CustomEvent(BaseEvent):
EVENT_TYPE = EventType.CUSTOM_EVENT
QUEUE_TYPE = QueueType.HANDLER
class NewDayEvent(BaseEvent):
EVENT_TYPE = EventType.NEW_DAY
QUEUE_TYPE = QueueType.HANDLER
class CloseMarketEvent(BaseEvent):
EVENT_TYPE = EventType.CLOSE_MARKET
QUEUE_TYPE = QueueType.HANDLER
class StrategyResetEvent(BaseEvent):
EVENT_TYPE = EventType.STRATEGY_RESET
QUEUE_TYPE = QueueType.HANDLER
class CustomEvent(BaseEvent):
EVENT_TYPE = EventType.CUSTOM_EVENT
QUEUE_TYPE = QueueType.HANDLER
class NewDayEvent(BaseEvent):
EVENT_TYPE = EventType.NEW_DAY
QUEUE_TYPE = QueueType.HANDLER
class ClearedOrdersEvent(BaseEvent):
EVENT_TYPE = EventType.CLEARED_ORDERS
QUEUE_TYPE = QueueType.HANDLER
class CloseMarketEvent(BaseEvent):
EVENT_TYPE = EventType.CLOSE_MARKET
QUEUE_TYPE = QueueType.HANDLER
class StrategyResetEvent(BaseEvent):
EVENT_TYPE = EventType.STRATEGY_RESET
QUEUE_TYPE = QueueType.HANDLER
class CustomEvent(BaseEvent):
EVENT_TYPE = EventType.CUSTOM_EVENT
QUEUE_TYPE = QueueType.HANDLER
class NewDayEvent(BaseEvent):
EVENT_TYPE = EventType.NEW_DAY
QUEUE_TYPE = QueueType.HANDLER
from betfairlightweight.metadata import order_limits
from ..events.events import BaseEvent, EventType, QueueType
from ..clients.clients import ExchangeType
from .. import config
from .order import BaseOrder, OrderStatus
class OrderPackageType(Enum):
PLACE = "Place"
CANCEL = "Cancel"
REPLACE = "Replace"
UPDATE = "Update"
class BaseOrderPackage(BaseEvent):
"""
Data structure for multiple orders,
temporary to allow execution
"""
# todo client/retry
EVENT_TYPE = EventType.ORDER_PACKAGE
QUEUE_TYPE = QueueType.HANDLER
EXCHANGE = None
def __init__(
self,
client,
market_id: str,
class MarketCatalogueEvent(BaseEvent):
EVENT_TYPE = EventType.MARKET_CATALOGUE
QUEUE_TYPE = QueueType.HANDLER
class MarketBookEvent(BaseEvent):
EVENT_TYPE = EventType.MARKET_BOOK
QUEUE_TYPE = QueueType.HANDLER
class RawDataEvent(BaseEvent):
EVENT_TYPE = EventType.RAW_DATA
QUEUE_TYPE = QueueType.HANDLER
class CurrentOrdersEvent(BaseEvent):
EVENT_TYPE = EventType.CURRENT_ORDERS
QUEUE_TYPE = QueueType.HANDLER
class ClearedMarketsEvent(BaseEvent):
EVENT_TYPE = EventType.CLEARED_MARKETS
QUEUE_TYPE = QueueType.HANDLER
class ClearedOrdersEvent(BaseEvent):
EVENT_TYPE = EventType.CLEARED_ORDERS
QUEUE_TYPE = QueueType.HANDLER
class CloseMarketEvent(BaseEvent):
EVENT_TYPE = EventType.CLOSE_MARKET
EVENT_TYPE = None
QUEUE_TYPE = None
def __init__(self, event):
self._time_created = datetime.datetime.utcnow()
self.event = event
@property
def elapsed_seconds(self):
return (datetime.datetime.utcnow() - self._time_created).total_seconds()
def __str__(self):
return "<{0} [{1}]>".format(self.EVENT_TYPE.name, self.QUEUE_TYPE.name)
class MarketCatalogueEvent(BaseEvent):
EVENT_TYPE = EventType.MARKET_CATALOGUE
QUEUE_TYPE = QueueType.HANDLER
class MarketBookEvent(BaseEvent):
EVENT_TYPE = EventType.MARKET_BOOK
QUEUE_TYPE = QueueType.HANDLER
class RawDataEvent(BaseEvent):
EVENT_TYPE = EventType.RAW_DATA
QUEUE_TYPE = QueueType.HANDLER
class CurrentOrdersEvent(BaseEvent):
EVENT_TYPE = EventType.CURRENT_ORDERS
class CurrentOrdersEvent(BaseEvent):
EVENT_TYPE = EventType.CURRENT_ORDERS
QUEUE_TYPE = QueueType.HANDLER
class ClearedMarketsEvent(BaseEvent):
EVENT_TYPE = EventType.CLEARED_MARKETS
QUEUE_TYPE = QueueType.HANDLER
class ClearedOrdersEvent(BaseEvent):
EVENT_TYPE = EventType.CLEARED_ORDERS
QUEUE_TYPE = QueueType.HANDLER
class CloseMarketEvent(BaseEvent):
EVENT_TYPE = EventType.CLOSE_MARKET
QUEUE_TYPE = QueueType.HANDLER
class StrategyResetEvent(BaseEvent):
EVENT_TYPE = EventType.STRATEGY_RESET
QUEUE_TYPE = QueueType.HANDLER
class CustomEvent(BaseEvent):
EVENT_TYPE = EventType.CUSTOM_EVENT
QUEUE_TYPE = QueueType.HANDLER
class NewDayEvent(BaseEvent):
EVENT_TYPE = EventType.NEW_DAY