예제 #1
0
    def setUp(self):
        yield super(MatchingEngineTestSuite, self).setUp()
        # Object creation
        self.ask = Ask(
            OrderId(TraderId(b'2' * 20), OrderNumber(1)),
            AssetPair(AssetAmount(3000, 'BTC'), AssetAmount(30, 'MB')),
            Timeout(30), Timestamp.now())
        self.bid = Bid(
            OrderId(TraderId(b'4' * 20), OrderNumber(2)),
            AssetPair(AssetAmount(3000, 'BTC'), AssetAmount(30, 'MB')),
            Timeout(30), Timestamp.now())
        self.ask_order = Order(
            OrderId(TraderId(b'5' * 20), OrderNumber(3)),
            AssetPair(AssetAmount(3000, 'BTC'), AssetAmount(30, 'MB')),
            Timeout(30), Timestamp.now(), True)
        self.bid_order = Order(
            OrderId(TraderId(b'6' * 20), OrderNumber(4)),
            AssetPair(AssetAmount(3000, 'BTC'), AssetAmount(30, 'MB')),
            Timeout(30), Timestamp.now(), False)
        self.order_book = OrderBook()
        self.matching_engine = MatchingEngine(
            PriceTimeStrategy(self.order_book))

        self.ask_count = 2
        self.bid_count = 2
예제 #2
0
 async def setUp(self):
     super(AbstractTestOrderBook, self).setUp()
     # Object creation
     self.ask = Ask(
         OrderId(TraderId(b'0' * 20), OrderNumber(1)),
         AssetPair(AssetAmount(100, 'BTC'), AssetAmount(30, 'MB')),
         Timeout(100), Timestamp.now())
     self.invalid_ask = Ask(
         OrderId(TraderId(b'0' * 20), OrderNumber(1)),
         AssetPair(AssetAmount(100, 'BTC'), AssetAmount(30, 'MB')),
         Timeout(0), Timestamp(0))
     self.ask2 = Ask(
         OrderId(TraderId(b'1' * 20), OrderNumber(1)),
         AssetPair(AssetAmount(400, 'BTC'), AssetAmount(30, 'MB')),
         Timeout(100), Timestamp.now())
     self.bid = Bid(
         OrderId(TraderId(b'2' * 20), OrderNumber(1)),
         AssetPair(AssetAmount(200, 'BTC'), AssetAmount(30, 'MB')),
         Timeout(100), Timestamp.now())
     self.invalid_bid = Bid(
         OrderId(TraderId(b'0' * 20), OrderNumber(1)),
         AssetPair(AssetAmount(100, 'BTC'), AssetAmount(30, 'MB')),
         Timeout(0), Timestamp(0))
     self.bid2 = Bid(
         OrderId(TraderId(b'3' * 20), OrderNumber(1)),
         AssetPair(AssetAmount(300, 'BTC'), AssetAmount(30, 'MB')),
         Timeout(100), Timestamp.now())
     self.trade = Trade.propose(
         TraderId(b'0' * 20), OrderId(TraderId(b'0' * 20), OrderNumber(1)),
         OrderId(TraderId(b'0' * 20), OrderNumber(1)),
         AssetPair(AssetAmount(100, 'BTC'), AssetAmount(30, 'MB')),
         Timestamp(1462224447117))
     self.order_book = OrderBook()
예제 #3
0
    def setUp(self):
        yield super(PriceTimeStrategyTestSuite, self).setUp()
        # Object creation
        self.ask = Ask(
            OrderId(TraderId(b'0' * 20), OrderNumber(1)),
            AssetPair(AssetAmount(3000, 'BTC'), AssetAmount(30, 'MB')),
            Timeout(100), Timestamp.now())
        self.ask2 = Ask(
            OrderId(TraderId(b'1' * 20), OrderNumber(2)),
            AssetPair(AssetAmount(3000, 'BTC'), AssetAmount(30, 'MB')),
            Timeout(100), Timestamp.now())
        self.ask3 = Ask(
            OrderId(TraderId(b'0' * 20), OrderNumber(3)),
            AssetPair(AssetAmount(40000, 'BTC'), AssetAmount(200, 'MB')),
            Timeout(100), Timestamp.now())
        self.ask4 = Ask(
            OrderId(TraderId(b'1' * 20), OrderNumber(4)),
            AssetPair(AssetAmount(3000, 'A'), AssetAmount(3000, 'MB')),
            Timeout(100), Timestamp.now())
        self.ask5 = Ask(
            OrderId(TraderId(b'1' * 20), OrderNumber(4)),
            AssetPair(AssetAmount(3000, 'BTC'), AssetAmount(30, 'C')),
            Timeout(100), Timestamp.now())

        self.bid = Bid(
            OrderId(TraderId(b'0' * 20), OrderNumber(5)),
            AssetPair(AssetAmount(3000, 'BTC'), AssetAmount(30, 'MB')),
            Timeout(100), Timestamp.now())
        self.bid2 = Bid(
            OrderId(TraderId(b'0' * 20), OrderNumber(6)),
            AssetPair(AssetAmount(6000, 'BTC'), AssetAmount(30, 'MB')),
            Timeout(100), Timestamp.now())

        self.ask_order = Order(
            OrderId(TraderId(b'9' * 20), OrderNumber(11)),
            AssetPair(AssetAmount(3000, 'BTC'), AssetAmount(30, 'MB')),
            Timeout(100), Timestamp.now(), True)
        self.ask_order2 = Order(
            OrderId(TraderId(b'9' * 20), OrderNumber(12)),
            AssetPair(AssetAmount(600, 'BTC'), AssetAmount(60, 'MB')),
            Timeout(100), Timestamp.now(), True)

        self.bid_order = Order(
            OrderId(TraderId(b'9' * 20), OrderNumber(13)),
            AssetPair(AssetAmount(3000, 'BTC'), AssetAmount(30, 'MB')),
            Timeout(100), Timestamp.now(), False)
        self.bid_order2 = Order(
            OrderId(TraderId(b'9' * 20), OrderNumber(14)),
            AssetPair(AssetAmount(6000, 'BTC'), AssetAmount(60, 'MB')),
            Timeout(100), Timestamp.now(), False)
        self.order_book = OrderBook()
        self.price_time_strategy = PriceTimeStrategy(self.order_book)
예제 #4
0
async def order_book():
    order_book = OrderBook()
    yield order_book
    await order_book.shutdown_task_manager()