Ejemplo n.º 1
0
 def setUp(self):
     # Object creation
     self.proposed_trade = Trade.propose(
         TraderId(b'0' * 20), OrderId(TraderId(b'0' * 20), OrderNumber(1)),
         OrderId(TraderId(b'1' * 20), OrderNumber(2)),
         AssetPair(AssetAmount(60, 'BTC'), AssetAmount(30, 'MB')),
         Timestamp(1462224447117))
     self.declined_trade = Trade.decline(
         TraderId(b'0' * 20), Timestamp(1462224447117), self.proposed_trade,
         DeclinedTradeReason.ORDER_COMPLETED)
Ejemplo n.º 2
0
 def setUp(self):
     # Object creation
     self.proposed_trade = Trade.propose(
         TraderId(b'0' * 20), OrderId(TraderId(b'0' * 20), OrderNumber(1)),
         OrderId(TraderId(b'1' * 20), OrderNumber(2)),
         AssetPair(AssetAmount(60, 'BTC'), AssetAmount(30, 'MB')),
         Timestamp(1462224447117))
     self.counter_trade = Trade.counter(
         TraderId(b'0' * 20),
         AssetPair(AssetAmount(60, 'BTC'), AssetAmount(30, 'MB')),
         Timestamp(1462224447117), self.proposed_trade)
Ejemplo n.º 3
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()
Ejemplo n.º 4
0
    def setUp(self):
        # Object creation
        self.transaction_id = TransactionId(b'a' * 32)
        self.transaction = Transaction(
            self.transaction_id,
            AssetPair(AssetAmount(100, 'BTC'), AssetAmount(30, 'MC')),
            OrderId(TraderId(b'0' * 20), OrderNumber(2)),
            OrderId(TraderId(b'1' * 20), OrderNumber(1)), Timestamp(0))
        self.proposed_trade = Trade.propose(
            TraderId(b'0' * 20), OrderId(TraderId(b'0' * 20), OrderNumber(2)),
            OrderId(TraderId(b'1' * 20), OrderNumber(3)),
            AssetPair(AssetAmount(100, 'BTC'), AssetAmount(30, 'MC')),
            Timestamp(0))

        self.tick = Tick(
            OrderId(TraderId(b'0' * 20), OrderNumber(1)),
            AssetPair(AssetAmount(5, 'BTC'), AssetAmount(5, 'MC')), Timeout(0),
            Timestamp(00), True)
        self.tick2 = Tick(
            OrderId(TraderId(b'0' * 20), OrderNumber(2)),
            AssetPair(AssetAmount(500, 'BTC'), AssetAmount(5, 'MC')),
            Timeout(0), Timestamp(0), True)

        self.order_timestamp = Timestamp.now()
        self.order = Order(
            OrderId(TraderId(b'0' * 20), OrderNumber(3)),
            AssetPair(AssetAmount(50, 'BTC'), AssetAmount(40, 'MC')),
            Timeout(5000), self.order_timestamp, False)
        self.order.set_verified()
        self.order2 = Order(
            OrderId(TraderId(b'0' * 20), OrderNumber(4)),
            AssetPair(AssetAmount(50, 'BTC'), AssetAmount(10, 'MC')),
            Timeout(5), Timestamp(int(time.time() * 1000) - 1000 * 1000), True)
        self.order2.set_verified()
Ejemplo n.º 5
0
class TradeTestSuite(unittest.TestCase):
    """Trade test cases."""
    def setUp(self):
        # Object creation
        self.trade = Trade(TraderId(b'0' * 20),
                           OrderId(TraderId(b'0' * 20), OrderNumber(3)),
                           OrderId(TraderId(b'0' * 20), OrderNumber(4)), 1234,
                           Timestamp(1462224447117))

    def test_to_network(self):
        # Test for to network
        self.assertEquals(NotImplemented, self.trade.to_network())
Ejemplo n.º 6
0
 def setUp(self):
     # Object creation
     self.transaction_id = TransactionId(TraderId(b'0' * 20),
                                         TransactionNumber(1))
     self.transaction = Transaction(
         self.transaction_id,
         AssetPair(AssetAmount(100, 'BTC'), AssetAmount(100, 'MB')),
         OrderId(TraderId(b'3' * 20), OrderNumber(2)),
         OrderId(TraderId(b'2' * 20), OrderNumber(1)), Timestamp(0))
     self.proposed_trade = Trade.propose(
         TraderId(b'0' * 20), OrderId(TraderId(b'0' * 20), OrderNumber(2)),
         OrderId(TraderId(b'1' * 20), OrderNumber(3)),
         AssetPair(AssetAmount(100, 'BTC'), AssetAmount(100, 'MB')),
         Timestamp(0))
     self.payment = Payment(
         TraderId(b'0' * 20),
         TransactionId(TraderId(b'2' * 20), TransactionNumber(2)),
         AssetAmount(3, 'MB'), WalletAddress('a'), WalletAddress('b'),
         PaymentId('aaa'), Timestamp(4), True)
Ejemplo n.º 7
0
 def setUp(self):
     # Object creation
     self.trade = Trade(TraderId(b'0' * 20),
                        OrderId(TraderId(b'0' * 20), OrderNumber(3)),
                        OrderId(TraderId(b'0' * 20), OrderNumber(4)), 1234,
                        Timestamp(1462224447117))