desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
':type bid: Bid'
| def insert_bid(self, bid):
| assert isinstance(bid, Bid), type(bid)
if ((not self._bids.tick_exists(bid.order_id)) and bid.is_valid()):
self._bids.insert_tick(bid)
timeout_delay = ((float(bid.timestamp) + float(bid.timeout)) - time.time())
task = deferLater(reactor, timeout_delay, self.timeout_bid, bid.order_id)
... |
':type order_id: OrderId'
| def remove_bid(self, order_id):
| assert isinstance(order_id, OrderId), type(order_id)
if self._bids.tick_exists(order_id):
self.cancel_pending_task(('bid_%s_timeout' % order_id))
self._bids.remove_tick(order_id)
|
':type order_id: OrderId
:type recipient_order_id: OrderId
:type quantity: Quantity
:type end_transaction_timestamp: Timestamp'
| def trade_tick(self, order_id, recipient_order_id, quantity, end_transaction_timestamp):
| assert isinstance(order_id, OrderId), type(order_id)
assert isinstance(recipient_order_id, OrderId), type(recipient_order_id)
assert isinstance(quantity, Quantity), type(quantity)
self._logger.debug('Trading tick in order book for own order %s vs order %s (quantity: ... |
':param order_id: The order id to search for
:type order_id: OrderId
:return: True if the tick exists, False otherwise
:rtype: bool'
| def tick_exists(self, order_id):
| assert isinstance(order_id, OrderId), type(order_id)
is_ask = self._asks.tick_exists(order_id)
is_bid = self._bids.tick_exists(order_id)
return (is_ask or is_bid)
|
':param order_id: The order id to search for
:type order_id: OrderId
:rtype: TickEntry'
| def get_ask(self, order_id):
| assert isinstance(order_id, OrderId), type(order_id)
return self._asks.get_tick(order_id)
|
':param order_id: The order id to search for
:type order_id: OrderId
:rtype: TickEntry'
| def get_bid(self, order_id):
| assert isinstance(order_id, OrderId), type(order_id)
return self._bids.get_tick(order_id)
|
'Return a tick with the specified order id.
:param order_id: The order id to search for
:type order_id: OrderId
:rtype: TickEntry'
| def get_tick(self, order_id):
| assert isinstance(order_id, OrderId), type(order_id)
return (self._bids.get_tick(order_id) or self._asks.get_tick(order_id))
|
':param order_id: The order id to search for
:type order_id: OrderId
:return: True if the ask exists, False otherwise
:rtype: bool'
| def ask_exists(self, order_id):
| assert isinstance(order_id, OrderId), type(order_id)
return self._asks.tick_exists(order_id)
|
':param order_id: The order id to search for
:type order_id: OrderId
:return: True if the bid exists, False otherwise
:rtype: bool'
| def bid_exists(self, order_id):
| assert isinstance(order_id, OrderId), type(order_id)
return self._bids.tick_exists(order_id)
|
':type order_id: OrderId'
| def remove_tick(self, order_id):
| assert isinstance(order_id, OrderId), type(order_id)
self.remove_ask(order_id)
self.remove_bid(order_id)
|
'Return the asks side
:rtype: Side'
| @property
def asks(self):
| return self._asks
|
'Return the bids side
:rtype: Side'
| @property
def bids(self):
| return self._bids
|
'Return the price an ask needs to have to make a trade
:rtype: Price'
| def get_bid_price(self, price_wallet_id, quantity_wallet_id):
| return self._bids.get_max_price(price_wallet_id, quantity_wallet_id)
|
'Return the price a bid needs to have to make a trade
:rtype: Price'
| def get_ask_price(self, price_wallet_id, quantity_wallet_id):
| return self._asks.get_min_price(price_wallet_id, quantity_wallet_id)
|
'Return the spread between the bid and the ask price
:rtype: Price'
| def get_bid_ask_spread(self, price_wallet_id, quantity_wallet_id):
| return (self.get_ask_price(price_wallet_id, quantity_wallet_id) - self.get_bid_price(price_wallet_id, quantity_wallet_id))
|
'Return the price in between the bid and the ask price
:rtype: Price'
| def get_mid_price(self, price_wallet_id, quantity_wallet_id):
| ask_price = int(self.get_ask_price(price_wallet_id, quantity_wallet_id))
bid_price = int(self.get_bid_price(price_wallet_id, quantity_wallet_id))
return Price(((ask_price + bid_price) / 2), price_wallet_id)
|
'Return the depth of the price level with the given price on the bid side
:param price: The price for the price level
:type price: Price
:return: The depth at that price level
:rtype: Quantity'
| def bid_side_depth(self, price):
| assert isinstance(price, Price), type(price)
return self._bids.get_price_level(price).depth
|
'Return the depth of the price level with the given price on the ask side
:param price: The price for the price level
:type price: Price
:return: The depth at that price level
:rtype: Quantity'
| def ask_side_depth(self, price):
| assert isinstance(price, Price), type(price)
return self._asks.get_price_level(price).depth
|
'format: [(<price>, <depth>), (<price>, <depth>), ...]
:return: The depth profile
:rtype: list'
| def get_bid_side_depth_profile(self, price_wallet_id, quantity_wallet_id):
| profile = []
for (key, value) in self._bids.get_price_level_list(price_wallet_id, quantity_wallet_id).items():
profile.append((key, value.depth))
return profile
|
'format: [(<price>, <depth>), (<price>, <depth>), ...]
:return: The depth profile
:rtype: list'
| def get_ask_side_depth_profile(self, price_wallet_id, quantity_wallet_id):
| profile = []
for (key, value) in self._asks.get_price_level_list(price_wallet_id, quantity_wallet_id).items():
profile.append((key, value.depth))
return profile
|
':param price: The price to be relative to
:type price: Price
:return: The relative price
:rtype: Price'
| def bid_relative_price(self, price):
| assert isinstance(price, Price), type(price)
return (self.get_bid_price('BTC', 'MC') - price)
|
':param price: The price to be relative to
:type price: Price
:return: The relative price
:rtype: Price'
| def ask_relative_price(self, price):
| assert isinstance(price, Price), type(price)
return (self.get_ask_price('BTC', 'MC') - price)
|
':param tick: The tick with the price to be relative to
:type tick: Tick
:return: The relative price
:rtype: Price'
| def relative_tick_price(self, tick):
| assert isinstance(tick, Tick), type(tick)
if tick.is_ask():
return self.ask_relative_price(tick.price)
else:
return self.bid_relative_price(tick.price)
|
'Return the price level that an ask has to match to make a trade
:rtype: PriceLevel'
| def get_bid_price_level(self, price_wallet_id, quantity_wallet_id):
| return self._bids.get_max_price_list(price_wallet_id, quantity_wallet_id)
|
'Return the price level that a bid has to match to make a trade
:rtype: PriceLevel'
| def get_ask_price_level(self, price_wallet_id, quantity_wallet_id):
| return self._asks.get_min_price_list(price_wallet_id, quantity_wallet_id)
|
'Return all IDs of the orders in the orderbook, both asks and bids. The returned list is sorted.
:rtype: [OrderId]'
| def get_order_ids(self):
| ids = []
for (price_wallet_id, quantity_wallet_id) in self.asks.get_price_level_list_wallets():
for (_, price_level) in self.asks.get_price_level_list(price_wallet_id, quantity_wallet_id).items():
for ask in price_level:
ids.append(ask.tick.order_id)
for (price_wallet_id,... |
'Write all ticks to the database'
| def save_to_database(self):
| self.database.delete_all_ticks()
for order_id in self.get_order_ids():
tick = self.get_tick(order_id)
if tick.is_valid():
self.database.add_tick(tick.tick)
|
'Restore ticks from the database'
| def restore_from_database(self):
| for tick in self.database.get_ticks():
if ((not self.tick_exists(tick.order_id)) and tick.is_valid()):
(self.insert_ask(tick) if tick.is_ask() else self.insert_bid(tick))
|
':param ttl: Integer representation of a time to live
:type ttl: int
:raises ValueError: Thrown when one of the arguments are invalid'
| def __init__(self, ttl):
| super(Ttl, self).__init__()
if (not isinstance(ttl, int)):
raise ValueError('Time to live must be an int')
if (ttl < 0):
raise ValueError('Time to live must be greater than zero')
self._ttl = ttl
|
'Create a time to live with the default value
:return: The ttl
:rtype: Ttl'
| @classmethod
def default(cls):
| return cls(cls.DEFAULT)
|
'Check if the ttl is still hig enough to be send on
:return: True if it is alive, False otherwise
:rtype: bool'
| def is_alive(self):
| return (self._ttl > 0)
|
'Makes a hop by reducing the ttl by 1, to simulate the message being relayed through a node'
| def make_hop(self):
| self._ttl -= 1
|
':rtype: TickEntry'
| @property
def first_tick(self):
| return self._head_tick
|
'Return the length of the amount of ticks contained in the price level
:rtype: integer'
| @property
def length(self):
| return self._length
|
'The depth is equal to the total amount of volume contained in this price level
:rtype: Quantity'
| @property
def depth(self):
| return self._depth
|
':param new_depth: The new depth
:type new_depth: Quantity'
| @depth.setter
def depth(self, new_depth):
| assert isinstance(new_depth, Quantity), type(new_depth)
self._depth = new_depth
|
'Return the length of the amount of ticks contained in the price level'
| def __len__(self):
| return self.length
|
'Return the next tick in the price level for the iterator'
| def next(self):
| if (self._last is None):
raise StopIteration
else:
return_value = self._last
self._last = self._last.next_tick
return return_value
|
':type tick: TickEntry'
| def append_tick(self, tick):
| assert isinstance(tick, TickEntry), type(tick)
assert (tick.quantity.wallet_id == self._quantity_wallet_id)
if (self._length == 0):
tick.prev_tick = None
tick.next_tick = None
self._head_tick = tick
self._tail_tick = tick
else:
tick.prev_tick = self._tail_tick
... |
':type tick: TickEntry'
| def remove_tick(self, tick):
| assert isinstance(tick, TickEntry), type(tick)
self._depth -= tick.quantity
self._length -= 1
if (self._length == 0):
return
prev_tick = tick.prev_tick
next_tick = tick.next_tick
if ((prev_tick is not None) and (next_tick is not None)):
prev_tick.next_tick = next_tick
... |
':type transaction_repository: TransactionRepository'
| def __init__(self, transaction_repository):
| super(TransactionManager, self).__init__()
self._logger = logging.getLogger(self.__class__.__name__)
self._logger.info('Transaction Manager initialized')
assert isinstance(transaction_repository, TransactionRepository), type(transaction_repository)
self.transaction_repository = transaction_rep... |
':type proposed_trade: ProposedTrade
:rtype: Transaction'
| def create_from_proposed_trade(self, proposed_trade):
| assert isinstance(proposed_trade, ProposedTrade), type(proposed_trade)
transaction = Transaction.from_proposed_trade(proposed_trade, self.transaction_repository.next_identity())
self.transaction_repository.add(transaction)
self._logger.info('Transaction created with id: %s, quantity: %... |
':type start_transaction: StartTransaction
:rtype: Transaction'
| def create_from_start_transaction(self, start_transaction):
| assert isinstance(start_transaction, StartTransaction), type(start_transaction)
transaction = Transaction(start_transaction.transaction_id, start_transaction.price, start_transaction.quantity, start_transaction.recipient_order_id, start_transaction.order_id, Timestamp.now())
self.transaction_repository.add(... |
':param transaction_id: The transaction id to look for
:type transaction_id: TransactionId
:return: The transaction or null if it cannot be found
:rtype: Transaction'
| def find_by_id(self, transaction_id):
| assert isinstance(transaction_id, TransactionId), type(transaction_id)
return self.transaction_repository.find_by_id(transaction_id)
|
':rtype: [Transaction]'
| def find_all(self):
| return self.transaction_repository.find_all()
|
':type transaction_number: int
:raises ValueError: Thrown when one of the arguments are invalid'
| def __init__(self, transaction_number):
| super(TransactionNumber, self).__init__()
if (not isinstance(transaction_number, int)):
raise ValueError('Transaction number must be an integer')
self._transaction_number = transaction_number
|
':param trader_id: The trader id who created the order
:param transaction_number: The number of the transaction created
:type trader_id: TraderId
:type transaction_number: TransactionNumber'
| def __init__(self, trader_id, transaction_number):
| super(TransactionId, self).__init__()
assert isinstance(trader_id, TraderId), type(trader_id)
assert isinstance(transaction_number, TransactionNumber), type(transaction_number)
self._trader_id = trader_id
self._transaction_number = transaction_number
|
':rtype: TraderId'
| @property
def trader_id(self):
| return self._trader_id
|
':rtype: TransactionNumber'
| @property
def transaction_number(self):
| return self._transaction_number
|
'format: <trader_id>.<transaction_number>'
| def __str__(self):
| return ('%s.%s' % (self.trader_id, self.transaction_number))
|
':param transaction_id: An transaction id to identify the order
:param price: A price to indicate for which amount to sell or buy
:param quantity: A quantity to indicate how much to sell or buy
:param order_id: The id of your order for this transaction
:param partner_order_id: The id of the order of the other party
:pa... | def __init__(self, transaction_id, price, quantity, order_id, partner_order_id, timestamp):
| super(Transaction, self).__init__()
self._logger = logging.getLogger(self.__class__.__name__)
assert isinstance(transaction_id, TransactionId), type(transaction_id)
assert isinstance(price, Price), type(price)
assert isinstance(quantity, Quantity), type(quantity)
assert isinstance(order_id, Orde... |
'Create a Transaction object based on information in the database.'
| @classmethod
def from_database(cls, data, payments):
| (trader_id, transaction_number, order_trader_id, order_number, partner_trader_id, partner_order_number, price, price_type, transferred_price, quantity, quantity_type, transferred_quantity, transaction_timestamp, sent_wallet_info, received_wallet_info, incoming_address, outgoing_address, partner_incoming_address, pa... |
'Returns a database representation of a Transaction object.
:rtype: tuple'
| def to_database(self):
| return (unicode(self.transaction_id.trader_id), int(self.transaction_id.transaction_number), unicode(self.order_id.trader_id), int(self.order_id.order_number), unicode(self.partner_order_id.trader_id), int(self.partner_order_id.order_number), float(self.price), unicode(self.price.wallet_id), float(self.transferred_... |
':param proposed_trade: The proposed trade to create the transaction for
:param transaction_id: The transaction id to use for this transaction
:type proposed_trade: ProposedTrade
:type transaction_id: TransactionId
:return: The created transaction
:rtype: Transaction'
| @classmethod
def from_proposed_trade(cls, proposed_trade, transaction_id):
| assert isinstance(proposed_trade, ProposedTrade), type(proposed_trade)
assert isinstance(transaction_id, TransactionId), type(transaction_id)
return cls(transaction_id, proposed_trade.price, proposed_trade.quantity, proposed_trade.recipient_order_id, proposed_trade.order_id, proposed_trade.timestamp)
|
':rtype: TransactionId'
| @property
def transaction_id(self):
| return self._transaction_id
|
':rtype: Price'
| @property
def price(self):
| return self._price
|
':rtype: Price'
| @property
def total_price(self):
| return self._total_price
|
':rtype: Price'
| @property
def transferred_price(self):
| return self._transferred_price
|
':rtype: Quantity'
| @property
def total_quantity(self):
| return self._quantity
|
':rtype: Quantity'
| @property
def transferred_quantity(self):
| return self._transferred_quantity
|
'Return the id of your order
:rtype: OrderId'
| @property
def order_id(self):
| return self._order_id
|
':rtype: OrderId'
| @property
def partner_order_id(self):
| return self._partner_order_id
|
':rtype: [Payment]'
| @property
def payments(self):
| return self._payments
|
':rtype: Timestamp'
| @property
def timestamp(self):
| return self._timestamp
|
'Return the status of this transaction, can be one of these: "pending", "completed", "error".
:rtype: str'
| @property
def status(self):
| if len([payment for payment in self.payments if (not payment.success)]):
return 'error'
return ('completed' if self.is_payment_complete() else 'pending')
|
'Return an a amount that is a multiple of min_unit.'
| @staticmethod
def unitize(amount, min_unit):
| if ((Decimal(str(amount)) % Decimal(str(min_unit))) == Decimal(0)):
return amount
return ((int((amount / min_unit)) + 1) * min_unit)
|
'Return a dictionary with a representation of this transaction.'
| def to_dictionary(self):
| return {'trader_id': str(self.transaction_id.trader_id), 'order_number': int(self.order_id.order_number), 'partner_trader_id': str(self.partner_order_id.trader_id), 'partner_order_number': int(self.partner_order_id.order_number), 'transaction_number': int(self.transaction_id.transaction_number), 'price': float(self... |
':param message_id: A message id to identify the message
:param transaction_id: A transaction id to identify the transaction
:param order_id: My order id
:param recipient_order_id: The order id of the recipient of this message
:param proposal_id: The proposal ID associated with this start transaction message
:param pri... | def __init__(self, message_id, transaction_id, order_id, recipient_order_id, proposal_id, price, quantity, timestamp):
| super(StartTransaction, self).__init__(message_id, timestamp)
assert isinstance(transaction_id, TransactionId), type(transaction_id)
assert isinstance(order_id, OrderId), type(order_id)
assert isinstance(recipient_order_id, OrderId), type(order_id)
assert isinstance(proposal_id, int), type(proposal_... |
':rtype: TransactionId'
| @property
def transaction_id(self):
| return self._transaction_id
|
':rtype: OrderId'
| @property
def order_id(self):
| return self._order_id
|
':rtype: OrderId'
| @property
def recipient_order_id(self):
| return self._recipient_order_id
|
':return: The proposal id
:rtype: int'
| @property
def proposal_id(self):
| return self._proposal_id
|
':return: The price
:rtype: Price'
| @property
def price(self):
| return self._price
|
':return: The quantity
:rtype: Quantity'
| @property
def quantity(self):
| return self._quantity
|
'Restore a start transaction message from the network
:param data: StartTransactionPayload
:return: Restored start transaction
:rtype: StartTransaction'
| @classmethod
def from_network(cls, data):
| 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'), isins... |
'Return network representation of the start transaction message'
| def to_network(self):
| return (self._message_id.trader_id, self._message_id.message_number, self._transaction_id.trader_id, self._transaction_id.transaction_number, self._order_id.trader_id, self._order_id.order_number, self._recipient_order_id.trader_id, self._recipient_order_id.order_number, self._proposal_id, self._price, self._quanti... |
'Don\'t use this method directly, use one of the class methods.
:param message_id: A message id to identify the trade
:param order_id: A order id to identify the order
:param recipient_order_id: A order id to identify the traded party
:param proposal_id: The ID of the trade proposal
:param timestamp: A timestamp wen th... | def __init__(self, message_id, order_id, recipient_order_id, proposal_id, timestamp):
| super(Trade, self).__init__(message_id, timestamp)
assert isinstance(order_id, OrderId), type(order_id)
assert isinstance(recipient_order_id, OrderId), type(recipient_order_id)
assert isinstance(proposal_id, int), type(proposal_id)
self._order_id = order_id
self._recipient_order_id = recipient_o... |
'Propose a trade to another node
:param message_id: A message id to identify the trade
:param order_id: A order id to identify the order
:param recipient_order_id: A order id to identify the traded party
:param price: A price for the trade
:param quantity: A quantity to be traded
:param timestamp: A timestamp wen this ... | @classmethod
def propose(cls, message_id, order_id, recipient_order_id, price, quantity, timestamp):
| return ProposedTrade(message_id, order_id, recipient_order_id, random.randint(0, 100000000), price, quantity, timestamp)
|
'Decline a trade from another node
:param message_id: A message id to identify the trade
:param timestamp: A timestamp when the trade was declined
:param proposed_trade: A proposed trade that needs to be declined
:type message_id: MessageId
:type timestamp: Timestamp
:type proposed_trade: ProposedTrade
:return: A decli... | @classmethod
def decline(cls, message_id, timestamp, proposed_trade):
| assert isinstance(proposed_trade, ProposedTrade), type(proposed_trade)
return DeclinedTrade(message_id, proposed_trade.recipient_order_id, proposed_trade.order_id, proposed_trade.proposal_id, timestamp)
|
'Counter a trade from another node
:param message_id: A message id to identify the trade
:param quantity: The quantity to use for the counter offer
:param timestamp: A timestamp when the trade was countered
:param proposed_trade: A proposed trade that needs to be countered
:type message_id: MessageId
:type quantity: Qu... | @classmethod
def counter(cls, message_id, quantity, timestamp, proposed_trade):
| assert isinstance(proposed_trade, ProposedTrade), type(proposed_trade)
return CounterTrade(message_id, proposed_trade.recipient_order_id, proposed_trade.order_id, proposed_trade.proposal_id, proposed_trade.price, quantity, timestamp)
|
':return: The order id
:rtype: OrderId'
| @property
def order_id(self):
| return self._order_id
|
':return: The order id
:rtype: OrderId'
| @property
def recipient_order_id(self):
| return self._recipient_order_id
|
':return: The proposal id
:rtype: int'
| @property
def proposal_id(self):
| return self._proposal_id
|
'Don\'t use this method directly, use the class methods from Trade or use the from_network
:param message_id: A message id to identify the trade
:param order_id: A order id to identify the order
:param recipient_order_id: A order id to identify the traded party
:param proposal_id: The ID of the trade proposal
:param pr... | def __init__(self, message_id, order_id, recipient_order_id, proposal_id, price, quantity, timestamp):
| super(ProposedTrade, self).__init__(message_id, order_id, recipient_order_id, proposal_id, timestamp)
assert isinstance(price, Price), type(price)
assert isinstance(quantity, Quantity), type(quantity)
self._price = price
self._quantity = quantity
|
'Restore a proposed trade from the network
:param data: TradePayload
:return: Restored proposed trade
:rtype: ProposedTrade'
| @classmethod
def from_network(cls, data):
| 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.rec... |
':return: The price
:rtype: Price'
| @property
def price(self):
| return self._price
|
':return: The quantity
:rtype: Quantity'
| @property
def quantity(self):
| return self._quantity
|
'Return whether this trade proposal has an acceptable price.
:rtype: bool'
| def has_acceptable_price(self, is_ask, order_price):
| return ((is_ask and (self.price >= order_price)) or ((not is_ask) and (self.price <= order_price)))
|
'Return network representation of a proposed trade'
| def to_network(self):
| return (self._recipient_order_id.trader_id, (self._order_id.trader_id, self._message_id.message_number, self._order_id.order_number, self._recipient_order_id.trader_id, self._recipient_order_id.order_number, self._proposal_id, self._price, self._quantity, self._timestamp))
|
'Don\'t use this method directly, use one of the class methods of Trade or use from_network
:param message_id: A message id to identify the trade
:param order_id: A order id to identify the order
:param recipient_order_id: A order id to identify the traded party
:param proposal_id: The ID of the trade proposal
:param p... | def __init__(self, message_id, order_id, recipient_order_id, proposal_id, price, quantity, timestamp):
| super(CounterTrade, self).__init__(message_id, order_id, recipient_order_id, proposal_id, price, quantity, timestamp)
|
'Restore a counter trade from the network
:param data: TradePayload
:return: Restored counter trade
:rtype: CounterTrade'
| @classmethod
def from_network(cls, data):
| 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.rec... |
'Return network representation of a counter trade'
| def to_network(self):
| return (self._recipient_order_id.trader_id, (self._order_id.trader_id, self._message_id.message_number, self._order_id.order_number, self._recipient_order_id.trader_id, self._recipient_order_id.order_number, self._proposal_id, self._price, self._quantity, self._timestamp))
|
'Don\'t use this method directly, use one of the class methods from Trade or the from_network
:param message_id: A message id to identify the trade
:param order_id: A order id to identify the order
:param recipient_order_id: A order id to identify the order
:param proposal_id: The ID of the trade proposal
:param timest... | def __init__(self, message_id, order_id, recipient_order_id, proposal_id, timestamp):
| super(DeclinedTrade, self).__init__(message_id, order_id, recipient_order_id, proposal_id, timestamp)
|
'Restore a declined trade from the network
:param data: DeclinedTradePayload
:return: Restored declined trade
:rtype: DeclinedTrade'
| @classmethod
def from_network(cls, data):
| 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.rec... |
'Return network representation of a declined trade'
| def to_network(self):
| return (self._recipient_order_id.trader_id, (self._order_id.trader_id, self._message_id.message_number, self._order_id.order_number, self._recipient_order_id.trader_id, self._recipient_order_id.order_number, self._proposal_id, self._timestamp))
|
':param ip: String representation of an ipv4 address
:type ip: str
:param port: Integer representation of a port
:type port: int
:raises ValueError: Thrown when one of the arguments are invalid'
| def __init__(self, ip, port):
| super(SocketAddress, self).__init__()
assert isinstance(ip, str), type(ip)
assert isinstance(port, int), type(port)
if (not is_valid_address((ip, port))):
raise ValueError('Address is not valid')
self._ip = ip
self._port = port
|
':return: The ip
:rtype: str'
| @property
def ip(self):
| return self._ip
|
':return: The port
:rtype: int'
| @property
def port(self):
| return self._port
|
':param price: Integer representation of a price that is positive or zero
:param wallet_id: Identifier of the wallet type of this price
:type price: float
:type wallet_id: str
:raises ValueError: Thrown when one of the arguments are invalid'
| def __init__(self, price, wallet_id):
| super(Price, self).__init__()
if (not isinstance(price, (int, float))):
raise ValueError('Price must be an int or a float')
if (not isinstance(wallet_id, str)):
raise ValueError('Wallet id must be a string')
if (price < 0):
raise ValueError('Pr... |
':rtype: str'
| @property
def wallet_id(self):
| return self._wallet_id
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.