How to use the flumine.order.order.OrderStatus.EXECUTABLE function in flumine

To help you get started, we’ve selected a few flumine examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github liampauling / flumine / tests / test_integration.py View on Github external
def process_orders(self, market, orders):
                for order in orders:
                    if order.status == OrderStatus.EXECUTABLE:
                        if order.elapsed_seconds and order.elapsed_seconds > 2:
                            self.cancel_order(market, order)
github liampauling / flumine / tests / test_order.py View on Github external
def test_complete(self):
        self.order.status = None
        self.assertFalse(self.order.complete)
        for s in [
            OrderStatus.PENDING,
            OrderStatus.CANCELLING,
            OrderStatus.UPDATING,
            OrderStatus.REPLACING,
            OrderStatus.EXECUTABLE,
        ]:
            self.order.status = s
            self.assertFalse(self.order.complete)
        for s in [
            OrderStatus.EXECUTION_COMPLETE,
            OrderStatus.EXPIRED,
            OrderStatus.VOIDED,
            OrderStatus.LAPSED,
            OrderStatus.VIOLATION,
        ]:
            self.order.status = s
            self.assertTrue(self.order.complete)
github liampauling / flumine / tests / test_order.py View on Github external
def test_update(self, mock_updating):
        self.order.status = OrderStatus.EXECUTABLE
        with self.assertRaises(OrderUpdateError):
            self.order.update("PERSIST")

        self.mock_order_type.ORDER_TYPE = OrderTypes.LIMIT
        self.mock_order_type.persistence_type = "LAPSE"
        self.order.update("PERSIST")
        self.assertEqual(self.mock_order_type.persistence_type, "PERSIST")
        mock_updating.assert_called_with()

        with self.assertRaises(OrderUpdateError):
            self.order.update("PERSIST")
github liampauling / flumine / examples / strategies / lowestlayer.py View on Github external
def process_orders(self, market, orders):
        # kill order if unmatched in market for greater than 2 seconds
        # this logic is likely to be moved into trade.fill_kill in the future
        for order in orders:
            if order.status == OrderStatus.EXECUTABLE:
                if order.elapsed_seconds and order.elapsed_seconds > 2:
                    self.cancel_order(market, order)
github liampauling / flumine / flumine / order / process.py View on Github external
def process_current_order(order: BaseOrder):
    if order.status == OrderStatus.EXECUTABLE:
        if order.size_voided:
            order.voided()
        elif order.size_lapsed:
            order.lapsed()
        elif order.size_remaining == 0:
            order.execution_complete()

    if order.trade.complete:
        order.trade.complete_trade()
github liampauling / flumine / flumine / order / order.py View on Github external
def complete(self) -> bool:
        """ Returns False if order is
        live or pending in the market"""
        if self.status in [
            OrderStatus.PENDING,
            OrderStatus.CANCELLING,
            OrderStatus.UPDATING,
            OrderStatus.REPLACING,
            OrderStatus.EXECUTABLE,
        ]:
            return False
        elif self.status in [
            OrderStatus.EXECUTION_COMPLETE,
            OrderStatus.EXPIRED,
            OrderStatus.VOIDED,
            OrderStatus.LAPSED,
            OrderStatus.VIOLATION,
        ]:
            return True
        else:
            return False  # default to False
github liampauling / flumine / flumine / order / order.py View on Github external
def executable(self) -> None:
        self._update_status(OrderStatus.EXECUTABLE)
        self.update_data.clear()
github liampauling / flumine / flumine / markets / middleware.py View on Github external
def _process_simulated_orders(market, market_analytics: dict) -> None:
        for order in market.blotter.live_orders:
            if order.simulated and order.status == OrderStatus.EXECUTABLE:
                runner_analytics = market_analytics.get(
                    (order.selection_id, order.handicap)
                )
                order.simulated(market.market_book, runner_analytics)
github liampauling / flumine / examples / example.py View on Github external
def process_orders(self, market, orders):
        for order in orders:
            if order.status == OrderStatus.EXECUTABLE:
                if order.elapsed_seconds and order.elapsed_seconds > 5:
                    # print(order.bet_id, order.average_price_matched, order.size_matched)
                    if order.size_remaining == 2.00:
                        self.cancel_order(market, order, size_reduction=1.51)
                # self.update_order(market, order, "PERSIST")
                # if order.order_type.price == 1.01 and order.size_remaining == 0.49:
                #     self.replace_order(market, order, 1.02)
                # if order.order_type.price == 1.02:
                #     self.replace_order(market, order, 1.03)
                # if order.order_type.price == 1.03:
                #     self.replace_order(market, order, 1.05)
                pass