def setUp(self, annotate=True): yield super(PriceTimeStrategyTestSuite, self).setUp(annotate=annotate) # Object creation self.ask = Ask(MessageId(TraderId('0'), MessageNumber('1')), OrderId(TraderId('0'), OrderNumber(1)), Price(100, 'BTC'), Quantity(30, 'MC'), Timeout(100), Timestamp.now()) self.ask2 = Ask(MessageId(TraderId('1'), MessageNumber('1')), OrderId(TraderId('1'), OrderNumber(2)), Price(100, 'BTC'), Quantity(30, 'MC'), Timeout(100), Timestamp.now()) self.ask3 = Ask(MessageId(TraderId('3'), MessageNumber('1')), OrderId(TraderId('0'), OrderNumber(3)), Price(200, 'BTC'), Quantity(200, 'MC'), Timeout(100), Timestamp.now()) self.ask4 = Ask(MessageId(TraderId('4'), MessageNumber('1')), OrderId(TraderId('1'), OrderNumber(4)), Price(50, 'BTC'), Quantity(200, 'MC'), Timeout(100), Timestamp.now()) self.ask5 = Ask(MessageId(TraderId('4'), MessageNumber('1')), OrderId(TraderId('1'), OrderNumber(4)), Price(100, 'A'), Quantity(30, 'MC'), Timeout(100), Timestamp.now()) self.ask6 = Ask(MessageId(TraderId('4'), MessageNumber('1')), OrderId(TraderId('1'), OrderNumber(4)), Price(100, 'BTC'), Quantity(30, 'A'), Timeout(100), Timestamp.now()) self.bid = Bid(MessageId(TraderId('5'), MessageNumber('2')), OrderId(TraderId('0'), OrderNumber(5)), Price(100, 'BTC'), Quantity(30, 'MC'), Timeout(100), Timestamp.now()) self.bid2 = Bid(MessageId(TraderId('6'), MessageNumber('2')), OrderId(TraderId('0'), OrderNumber(6)), Price(200, 'BTC'), Quantity(30, 'MC'), Timeout(100), Timestamp.now()) self.bid3 = Bid(MessageId(TraderId('7'), MessageNumber('2')), OrderId(TraderId('0'), OrderNumber(7)), Price(50, 'BTC'), Quantity(200, 'MC'), Timeout(100), Timestamp.now()) self.bid4 = Bid(MessageId(TraderId('8'), MessageNumber('2')), OrderId(TraderId('0'), OrderNumber(8)), Price(100, 'BTC'), Quantity(200, 'MC'), Timeout(100), Timestamp.now()) self.ask_order = Order(OrderId(TraderId('9'), OrderNumber(11)), Price(100, 'BTC'), Quantity(30, 'MC'), Timeout(100), Timestamp.now(), True) self.ask_order2 = Order(OrderId(TraderId('9'), OrderNumber(12)), Price(10, 'BTC'), Quantity(60, 'MC'), Timeout(100), Timestamp.now(), True) self.bid_order = Order(OrderId(TraderId('9'), OrderNumber(13)), Price(100, 'BTC'), Quantity(30, 'MC'), Timeout(100), Timestamp.now(), False) self.bid_order2 = Order(OrderId(TraderId('9'), OrderNumber(14)), Price(100, 'BTC'), Quantity(60, 'MC'), Timeout(100), Timestamp.now(), False) self.order_book = OrderBook(MemoryMessageRepository('0')) self.price_time_strategy = PriceTimeStrategy(self.order_book)
def test_from_network(self): # Test for from network data = StartTransaction.from_network( type( 'Data', (object, ), { "trader_id": TraderId('0'), "message_id": MessageId(TraderId('0'), MessageNumber(1)), "transaction_id": TransactionId(TraderId('0'), TransactionNumber(1)), "order_id": OrderId(TraderId('0'), OrderNumber(1)), "recipient_order_id": OrderId(TraderId('1'), OrderNumber(2)), "proposal_id": 1235, "price": Price(300, 'BTC'), "quantity": Quantity(20, 'MC'), "timestamp": Timestamp(0.0) })) self.assertEquals(MessageId(TraderId("0"), MessageNumber(1)), data.message_id) self.assertEquals(TransactionId(TraderId("0"), TransactionNumber(1)), data.transaction_id) self.assertEquals(OrderId(TraderId('0'), OrderNumber(1)), data.order_id) self.assertEquals(OrderId(TraderId('1'), OrderNumber(2)), data.recipient_order_id) self.assertEquals(1235, data.proposal_id) self.assertEquals(Timestamp(0.0), data.timestamp)
class MessageIdTestSuite(unittest.TestCase): """Message ID test cases.""" def setUp(self): # Object creation self.message_id = MessageId(TraderId('0'), MessageNumber(1)) self.message_id2 = MessageId(TraderId('0'), MessageNumber(1)) self.message_id3 = MessageId(TraderId('0'), MessageNumber(2)) def test_properties(self): # Test for properties self.assertEqual(TraderId('0'), self.message_id.trader_id) def test_conversion(self): # Test for conversions self.assertEqual('0.1', str(self.message_id)) def test_equality(self): # Test for equality self.assertTrue(self.message_id == self.message_id2) self.assertTrue(self.message_id == self.message_id) self.assertTrue(self.message_id != self.message_id3) self.assertFalse(self.message_id == 6) def test_hash(self): # Test for hashes self.assertEqual(self.message_id.__hash__(), self.message_id2.__hash__()) self.assertNotEqual(self.message_id.__hash__(), self.message_id3.__hash__())
def test_from_network(self): # Test for from network data = ProposedTrade.from_network( type( 'Data', (object, ), { "trader_id": TraderId('0'), "message_id": MessageId(TraderId('0'), MessageNumber(1)), "order_number": OrderNumber(1), "recipient_order_id": OrderId(TraderId('1'), OrderNumber(2)), "proposal_id": 1234, "timestamp": Timestamp(1462224447.117), "price": Price(63400, 'BTC'), "quantity": Quantity(30, 'MC') })) self.assertEquals(MessageId(TraderId('0'), MessageNumber(1)), data.message_id) self.assertEquals(OrderId(TraderId('0'), OrderNumber(1)), data.order_id) self.assertEquals(OrderId(TraderId('1'), OrderNumber(2)), data.recipient_order_id) self.assertEquals(1234, data.proposal_id) self.assertEquals(Price(63400, 'BTC'), data.price) self.assertEquals(Quantity(30, 'MC'), data.quantity) self.assertEquals(Timestamp(1462224447.117), data.timestamp)
def test_to_network(self): # Test for to network self.assertEquals( (MessageId(TraderId('0'), MessageNumber(1)), self.tick.timestamp, OrderNumber(1), Price(63400, 'BTC'), Quantity( 30, 'MC'), self.tick.timeout), self.tick.to_network(MessageId(TraderId('0'), MessageNumber(1))))
def test_from_network(self): # Test for from network data = Payment.from_network( type( 'Data', (object, ), { "message_id": MessageId(TraderId("0"), MessageNumber(1)), "transaction_id": TransactionId(TraderId('2'), TransactionNumber(2)), "transferee_quantity": Quantity(3, 'MC'), "transferee_price": Price(2, 'BTC'), "address_from": WalletAddress('a'), "address_to": WalletAddress('b'), "payment_id": PaymentId('aaa'), "timestamp": Timestamp(4.0), "success": True })) self.assertEquals(MessageId(TraderId("0"), MessageNumber(1)), data.message_id) self.assertEquals(TransactionId(TraderId('2'), TransactionNumber(2)), data.transaction_id) self.assertEquals(Quantity(3, 'MC'), data.transferee_quantity) self.assertEquals(Price(2, 'BTC'), data.transferee_price) self.assertEquals(Timestamp(4.0), data.timestamp) self.assertTrue(data.success)
def setUp(self): # Object creation self.transaction_id = TransactionId(TraderId("0"), TransactionNumber(1)) self.transaction = Transaction(self.transaction_id, Price(100, 'BTC'), Quantity(30, 'MC'), OrderId(TraderId('0'), OrderNumber(2)), OrderId(TraderId('1'), OrderNumber(1)), Timestamp(0.0)) self.proposed_trade = Trade.propose( MessageId(TraderId('0'), MessageNumber('1')), OrderId(TraderId('0'), OrderNumber(2)), OrderId(TraderId('1'), OrderNumber(3)), Price(100, 'BTC'), Quantity(30, 'MC'), Timestamp(0.0)) self.tick = Tick( MessageId(TraderId('0'), MessageNumber('message_number')), OrderId(TraderId('0'), OrderNumber(1)), Price(100, 'BTC'), Quantity(5, 'MC'), Timeout(0.0), Timestamp(float("inf")), True) self.tick2 = Tick( MessageId(TraderId('0'), MessageNumber('message_number')), OrderId(TraderId('0'), OrderNumber(2)), Price(100, 'BTC'), Quantity(100, 'MC'), Timeout(0.0), Timestamp(float("inf")), True) self.order = Order(OrderId(TraderId("0"), OrderNumber(3)), Price(100, 'BTC'), Quantity(30, 'MC'), Timeout(5000), Timestamp(time.time()), False) self.order2 = Order(OrderId(TraderId("0"), OrderNumber(4)), Price(100, 'BTC'), Quantity(30, 'MC'), Timeout(5), Timestamp(time.time() - 1000), True)
def setUp(self): # Object creation self.proposed_trade = Trade.propose(MessageId(TraderId('0'), MessageNumber('message_number')), OrderId(TraderId('0'), OrderNumber(1)), OrderId(TraderId('1'), OrderNumber(2)), Price(63400, 'BTC'), Quantity(30, 'MC'), Timestamp(1462224447.117)) self.declined_trade = Trade.decline(MessageId(TraderId('0'), MessageNumber('message_number')), Timestamp(1462224447.117), self.proposed_trade)
def setUp(self): # Object creation tick = Tick(MessageId(TraderId('0'), MessageNumber('message_number')), OrderId(TraderId('0'), OrderNumber(1)), Price(63400, 'BTC'), Quantity(30, 'MC'), Timeout(0.0), Timestamp(0.0), True) tick2 = Tick(MessageId(TraderId('0'), MessageNumber('message_number')), OrderId(TraderId('0'), OrderNumber(2)), Price(63400, 'BTC'), Quantity(30, 'MC'), Timeout(100), Timestamp.now(), True) self.price_level = PriceLevel('MC') self.tick_entry = TickEntry(tick, self.price_level) self.tick_entry2 = TickEntry(tick2, self.price_level)
def setUp(self): # Object creation self.tick = Tick( MessageId(TraderId('0'), MessageNumber('message_number')), OrderId(TraderId('0'), OrderNumber(1)), Price(400, 'BTC'), Quantity(30, 'MC'), Timeout(float("inf")), Timestamp(float("inf")), True) self.tick2 = Tick( MessageId(TraderId('1'), MessageNumber('message_number')), OrderId(TraderId('1'), OrderNumber(2)), Price(800, 'BTC'), Quantity(30, 'MC'), Timeout(float("inf")), Timestamp(float("inf")), True) self.side = Side()
def setUp(self, annotate=True): yield super(CommunityTestSuite, self).setUp(annotate=annotate) dummy1_wallet = DummyWallet1() dummy2_wallet = DummyWallet2() self.market_community = MarketCommunity(self.dispersy, self.master_member, self.member) self.market_community.initialize(wallets={ dummy1_wallet.get_identifier(): dummy1_wallet, dummy2_wallet.get_identifier(): dummy2_wallet }, use_database=False) self.market_community.use_local_address = True self.dispersy._lan_address = ("127.0.0.1", 1234) self.dispersy._endpoint.open(self.dispersy) self.dispersy.attach_community(self.market_community) eccrypto = ECCrypto() ec = eccrypto.generate_key(u"curve25519") member = Member(self.dispersy, ec, 1) trader_id = hashlib.sha1(member.public_key).digest().encode('hex') self.ask = Ask( MessageId(TraderId('0'), MessageNumber('message_number')), OrderId(TraderId(trader_id), OrderNumber(1234)), Price(63400, 'DUM1'), Quantity(30, 'DUM2'), Timeout(3600), Timestamp.now()) self.ask.sign(member) self.bid = Bid( MessageId(TraderId('1'), MessageNumber('message_number')), OrderId(TraderId(trader_id), OrderNumber(1235)), Price(343, 'DUM1'), Quantity(22, 'DUM2'), Timeout(3600), Timestamp.now()) self.bid.sign(member) self.order = Order( OrderId(TraderId(self.market_community.mid), OrderNumber(24)), Price(20, 'DUM1'), Quantity(30, 'DUM2'), Timeout(3600.0), Timestamp.now(), False) self.proposed_trade = Trade.propose( MessageId(TraderId('0'), MessageNumber('message_number')), OrderId(TraderId('0'), OrderNumber(23)), OrderId(TraderId(self.market_community.mid), OrderNumber(24)), Price(20, 'DUM1'), Quantity(30, 'DUM2'), Timestamp.now())
def setUp(self, annotate=True): yield super(TestDatabase, self).setUp(annotate=annotate) path = os.path.join(self.getStateDir(), 'sqlite') if not os.path.exists(path): os.makedirs(path) self.database = MarketDB(self.getStateDir()) self.order_id1 = OrderId(TraderId('3'), OrderNumber(4)) self.order_id2 = OrderId(TraderId('4'), OrderNumber(5)) self.order1 = Order(self.order_id1, Price(5, 'EUR'), Quantity(6, 'BTC'), Timeout(3600), Timestamp.now(), True) self.order2 = Order(self.order_id2, Price(5, 'EUR'), Quantity(6, 'BTC'), Timeout(3600), Timestamp.now(), False) self.transaction_id1 = TransactionId(TraderId("0"), TransactionNumber(4)) self.transaction1 = Transaction(self.transaction_id1, Price(100, 'BTC'), Quantity(30, 'MC'), OrderId(TraderId("0"), OrderNumber(1)), OrderId(TraderId("1"), OrderNumber(2)), Timestamp(20.0)) self.payment1 = Payment(MessageId(TraderId("0"), MessageNumber("4")), self.transaction_id1, Quantity(5, 'MC'), Price(6, 'BTC'), WalletAddress('abc'), WalletAddress('def'), PaymentId("abc"), Timestamp(20.0), False) self.transaction1.add_payment(self.payment1)
def setUp(self): # Object creation self.trade = Trade( MessageId(TraderId('0'), MessageNumber('message_number')), OrderId(TraderId('0'), OrderNumber(3)), OrderId(TraderId('0'), OrderNumber(4)), 1234, Timestamp(1462224447.117))
def from_network(cls, data): """ Restore a bid from the network :param data: OfferPayload :return: Restored bid :rtype: Bid """ assert hasattr(data, 'trader_id'), isinstance(data.trader_id, TraderId) assert hasattr(data, 'message_number'), isinstance(data.message_number, MessageNumber) assert hasattr(data, 'order_number'), isinstance(data.order_number, OrderNumber) assert hasattr(data, 'price'), isinstance(data.price, Price) assert hasattr(data, 'quantity'), isinstance(data.quantity, Quantity) assert hasattr(data, 'timeout'), isinstance(data.timeout, Timeout) assert hasattr(data, 'timestamp'), isinstance(data.timestamp, Timestamp) assert hasattr(data, 'public_key'), isinstance(data.public_key, str) assert hasattr(data, 'signature'), isinstance(data.signature, str) return cls( MessageId(data.trader_id, data.message_number), OrderId(data.trader_id, data.order_number), data.price, data.quantity, data.timeout, data.timestamp, data.public_key, data.signature )
def setUp(self, annotate=True): yield super(AbstractTestOrderBook, self).setUp(annotate=annotate) # Object creation self.ask = Ask(OrderId(TraderId('0'), OrderNumber(1)), Price(100, 'BTC'), Quantity(30, 'MC'), Timeout(1462224447.117), Timestamp(1462224447.117)) self.invalid_ask = Ask(OrderId(TraderId('0'), OrderNumber(1)), Price(100, 'BTC'), Quantity(30, 'MC'), Timeout(0), Timestamp(0.0)) self.ask2 = Ask(OrderId(TraderId('1'), OrderNumber(1)), Price(400, 'BTC'), Quantity(30, 'MC'), Timeout(1462224447.117), Timestamp(1462224447.117)) self.bid = Bid(OrderId(TraderId('2'), OrderNumber(1)), Price(200, 'BTC'), Quantity(30, 'MC'), Timeout(1462224447.117), Timestamp(1462224447.117)) self.invalid_bid = Bid(OrderId(TraderId('0'), OrderNumber(1)), Price(100, 'BTC'), Quantity(30, 'MC'), Timeout(0), Timestamp(0.0)) self.bid2 = Bid(OrderId(TraderId('3'), OrderNumber(1)), Price(300, 'BTC'), Quantity(30, 'MC'), Timeout(1462224447.117), Timestamp(1462224447.117)) self.trade = Trade.propose(MessageId(TraderId('0'), MessageNumber(1)), OrderId(TraderId('0'), OrderNumber(1)), OrderId(TraderId('0'), OrderNumber(1)), Price(100, 'BTC'), Quantity(30, 'MC'), Timestamp(1462224447.117)) self.order_book = OrderBook()
def from_unpack_list(cls, trader_id, message_number, timestamp, order_number, recipient_trader_id, recipient_order_number, proposal_id, price, price_type, quantity, quantity_type, ip, port): return TradePayload(MessageId(TraderId(trader_id), MessageNumber(message_number)), Timestamp(timestamp), OrderNumber(order_number), OrderId(TraderId(recipient_trader_id), OrderNumber(recipient_order_number)), proposal_id, Price(price, price_type), Quantity(quantity, quantity_type), SocketAddress(ip, port))
def from_network(cls, data): """ Restore a payment from the network :param data: PaymentPayload :return: Restored payment :rtype: Payment """ assert hasattr(data, 'trader_id'), isinstance(data.trader_id, TraderId) assert hasattr(data, 'message_number'), isinstance(data.message_number, MessageNumber) assert hasattr(data, 'transaction_trader_id'), isinstance(data.transaction_trader_id, TraderId) assert hasattr(data, 'transaction_number'), isinstance(data.transaction_number, TransactionNumber) assert hasattr(data, 'transferee_quantity'), isinstance(data.transferee_quantity, Quantity) assert hasattr(data, 'transferee_price'), isinstance(data.transferee_price, Price) assert hasattr(data, 'address_from'), isinstance(data.address_from, WalletAddress) assert hasattr(data, 'address_to'), isinstance(data.address_to, WalletAddress) assert hasattr(data, 'payment_id'), isinstance(data.payment_id, PaymentId) assert hasattr(data, 'timestamp'), isinstance(data.timestamp, Timestamp) assert hasattr(data, 'success'), isinstance(data.success, bool) return cls( MessageId(data.trader_id, data.message_number), TransactionId(data.transaction_trader_id, data.transaction_number), data.transferee_quantity, data.transferee_price, data.address_from, data.address_to, data.payment_id, data.timestamp, data.success, )
def to_network(self, message_id): """ Return network representation of the order """ return (MessageId(self._order_id.trader_id, message_id.message_number), self._timestamp, self._order_id.order_number, self._price, self._quantity, self._timeout, self._traded_quantity)
def from_network(cls, data): """ Restore a counter trade from the network :param data: TradePayload :return: Restored counter trade :rtype: CounterTrade """ assert hasattr(data, 'trader_id'), isinstance(data.trader_id, TraderId) assert hasattr(data, 'message_number'), isinstance(data.message_number, MessageNumber) assert hasattr(data, 'order_number'), isinstance(data.order_number, OrderNumber) assert hasattr(data, 'recipient_trader_id'), isinstance(data.recipient_trader_id, TraderId) assert hasattr(data, 'recipient_order_number'), isinstance(data.recipient_order_number, OrderNumber) assert hasattr(data, 'proposal_id'), isinstance(data.proposal_id, int) assert hasattr(data, 'price'), isinstance(data.price, Price) assert hasattr(data, 'quantity'), isinstance(data.quantity, Quantity) assert hasattr(data, 'timestamp'), isinstance(data.timestamp, Timestamp) return cls( MessageId(data.trader_id, data.message_number), OrderId(data.trader_id, data.order_number), OrderId(data.recipient_trader_id, data.recipient_order_number), data.proposal_id, data.price, data.quantity, data.timestamp )
def from_network(cls, data): """ Restore a declined trade from the network :param data: DeclinedTradePayload :return: Restored declined trade :rtype: DeclinedTrade """ assert hasattr(data, 'trader_id'), isinstance(data.trader_id, TraderId) assert hasattr(data, 'message_number'), isinstance(data.message_number, MessageNumber) assert hasattr(data, 'order_number'), isinstance(data.order_number, OrderNumber) assert hasattr(data, 'recipient_trader_id'), isinstance(data.recipient_trader_id, TraderId) assert hasattr(data, 'recipient_order_number'), isinstance(data.recipient_order_number, OrderNumber) assert hasattr(data, 'proposal_id'), isinstance(data.proposal_id, int) assert hasattr(data, 'timestamp'), isinstance(data.timestamp, Timestamp) assert hasattr(data, 'decline_reason'), isinstance(data.decline_reason, int) return cls( MessageId(data.trader_id, data.message_number), OrderId(data.trader_id, data.order_number), OrderId(data.recipient_trader_id, data.recipient_order_number), data.proposal_id, data.timestamp, data.decline_reason )
def test_from_network(self): # Test for from network now = Timestamp.now() data = Bid.from_network( type( 'Data', (object, ), { "trader_id": TraderId('0'), "order_number": OrderNumber(2), "message_number": MessageNumber('message_number'), "price": Price(63400, 'BTC'), "quantity": Quantity(40, 'MC'), "timeout": Timeout(30), "timestamp": now, "public_key": 'a', "signature": 'b' })) self.assertEquals( MessageId(TraderId('0'), MessageNumber('message_number')), data.message_id) self.assertEquals(Price(63400, 'BTC'), data.price) self.assertEquals(Quantity(40, 'MC'), data.quantity) self.assertEquals(float(Timeout(30)), float(data.timeout)) self.assertEquals(now, data.timestamp) self.assertEquals('a', data._public_key) self.assertEquals('b', data._signature)
def setUp(self): # Object creation self.payment = Payment( MessageId(TraderId("0"), MessageNumber(1)), TransactionId(TraderId('2'), TransactionNumber(2)), Quantity(3, 'MC'), Price(2, 'BTC'), WalletAddress('a'), WalletAddress('b'), PaymentId('aaa'), Timestamp(4.0), True)
def test_add_remove_tick(self): """ Test addition, retrieval and deletion of ticks in the database """ ask = Tick.from_order( self.order1, MessageId(TraderId('0'), MessageNumber('message_number'))) self.database.add_tick(ask) bid = Tick.from_order( self.order2, MessageId(TraderId('0'), MessageNumber('message_number'))) self.database.add_tick(bid) self.assertEqual(len(self.database.get_ticks()), 2) self.database.delete_all_ticks() self.assertEqual(len(self.database.get_ticks()), 0)
def setUp(self): # Object creation self.start_transaction = StartTransaction( MessageId(TraderId('0'), MessageNumber('1')), TransactionId(TraderId("0"), TransactionNumber(1)), OrderId(TraderId('0'), OrderNumber(1)), OrderId(TraderId('1'), OrderNumber(1)), 1234, Price(30, 'BTC'), Quantity(40, 'MC'), Timestamp(0.0))
def from_unpack_list(cls, trader_id, message_number, timestamp, order_number, price, price_type, quantity, quantity_type, timeout, ip, port, recipient_order_number, match_quantity, match_quantity_type, match_trader_id, matchmaker_trader_id, match_id): return MatchPayload(MessageId(TraderId(trader_id), MessageNumber(message_number)), Timestamp(timestamp), OrderNumber(order_number), Price(price, price_type), Quantity(quantity, quantity_type), Timeout(timeout), SocketAddress(ip, port), OrderNumber(recipient_order_number), Quantity(match_quantity, match_quantity_type), TraderId(match_trader_id), TraderId(matchmaker_trader_id), match_id)
def test_to_network(self): # Test for to network self.assertEquals((MessageId(TraderId('0'), MessageNumber(1)), Timestamp(1462224447.117), OrderNumber(1), OrderId(TraderId('1'), OrderNumber(2)), self.proposed_trade.proposal_id, Price( 63400, 'BTC'), Quantity(30, 'MC')), self.proposed_trade.to_network())
def add_transaction_and_payment(self): """ Add a transaction and a payment to the market """ proposed_trade = Trade.propose(MessageId(TraderId('0'), MessageNumber('message_number')), OrderId(TraderId('0'), OrderNumber(1)), OrderId(TraderId('1'), OrderNumber(2)), Price(63400, 'BTC'), Quantity(30, 'MC'), Timestamp(1462224447.117)) transaction = self.session.lm.market_community.transaction_manager.create_from_proposed_trade(proposed_trade) payment = Payment(MessageId(TraderId("0"), MessageNumber("1")), transaction.transaction_id, Quantity(0, 'MC'), Price(20, 'BTC'), WalletAddress('a'), WalletAddress('b'), PaymentId('aaa'), Timestamp(4.0), True) transaction.add_payment(payment) self.session.lm.market_community.transaction_manager.transaction_repository.update(transaction) return transaction
def from_unpack_list(cls, trader_id, message_number, timestamp, transaction_trader_id, transaction_number, order_trader_id, order_number, recipient_trader_id, recipient_order_number, proposal_id, price, price_type, quantity, quantity_type): return StartTransactionPayload(MessageId(TraderId(trader_id), MessageNumber(message_number)), Timestamp(timestamp), TransactionId(TraderId(transaction_trader_id), TransactionNumber(transaction_number)), OrderId(TraderId(order_trader_id), OrderNumber(order_number)), OrderId(TraderId(recipient_trader_id), OrderNumber(recipient_order_number)), proposal_id, Price(price, price_type), Quantity(quantity, quantity_type))
def from_unpack_list(cls, trader_id, message_number, timestamp, transaction_trader_id, transaction_number, transferee_quantity, transferee_quantity_type, transferee_price, transferee_price_type, address_from, address_to, payment_id, success): return PaymentPayload(MessageId(TraderId(trader_id), MessageNumber(message_number)), Timestamp(timestamp), TransactionId(TraderId(transaction_trader_id), TransactionNumber(transaction_number)), Quantity(transferee_quantity, transferee_quantity_type), Price(transferee_price, transferee_price_type), WalletAddress(address_from), WalletAddress(address_to), PaymentId(payment_id), success)
def setUp(self): # Object creation self.timestamp_now = Timestamp.now() self.tick = Tick( MessageId(TraderId('0'), MessageNumber('message_number')), OrderId(TraderId('0'), OrderNumber(1)), Price(63400, 'BTC'), Quantity(30, 'MC'), Timeout(30), self.timestamp_now, True, 'a', 'b') self.tick2 = Tick( MessageId(TraderId('0'), MessageNumber('message_number')), OrderId(TraderId('0'), OrderNumber(2)), Price(63400, 'BTC'), Quantity(30, 'MC'), Timeout(0.0), Timestamp(0.0), False, 'a', 'b') self.order_ask = Order(OrderId(TraderId('0'), OrderNumber(2)), Price(63400, 'BTC'), Quantity(30, 'MC'), Timeout(0.0), Timestamp(0.0), True) self.order_bid = Order(OrderId(TraderId('0'), OrderNumber(2)), Price(63400, 'BTC'), Quantity(30, 'MC'), Timeout(0.0), Timestamp(0.0), False)