def getTransactionHistory(self, start_datetime, end_datetime): start_timestamp = int(util.dt_to_timestamp(start_datetime) / 1e6) end_timestamp = int(util.dt_to_timestamp(end_datetime) / 1e6) call = "/v1/history" result = [] for currency in ['USD', 'BTC']: data = { 'currency': currency, 'since': start_timestamp, 'until': end_timestamp } result += yield self.post(call, data=data) transactions = [{ 'timestamp': int(transaction['timestamp'] * 1e6), 'contract': transaction['currency'], 'quantity': abs(Decimal(transaction['amount'])), 'direction': 'credit' if transaction['amount'] > 0 else 'debit', 'balance': Decimal(transaction['balance']), 'note': transaction['description'] } for transaction in result] returnValue(transactions)
def to_webserver(self): return {"contract": self.contract.ticker, "price": self.price, "quantity": self.quantity, "id": self.id, "timestamp": util.dt_to_timestamp(self.timestamp) }
def dict(self): return {'id': self.id, 'username': self.username, 'address': self.address, 'contract': self.contract.ticker, 'amount': self.quantity_fmt, 'entered': util.dt_to_timestamp(self.entered)}
def to_matching_engine_order(self): """ :returns: dict """ return {'id': self.id, 'username': self.username, 'contract': self.contract_id, 'quantity': self.quantity, 'timestamp': util.dt_to_timestamp(self.timestamp), 'price': self.price, 'side': (-1 if self.side == "BUY" else 1)}
def getTransactionHistory(self, start_datetime, end_datetime): start_timestamp = int(util.dt_to_timestamp(start_datetime)/1e6) end_timestamp = int(util.dt_to_timestamp(end_datetime)/1e6) call = "/v1/history" result = [] for currency in ['USD', 'BTC']: data = {'currency': currency, 'since': start_timestamp, 'until': end_timestamp} result += yield self.post(call, data=data) transactions = [{'timestamp': int(transaction['timestamp'] * 1e6), 'contract': transaction['currency'], 'quantity': abs(Decimal(transaction['amount'])), 'direction': 'credit' if transaction['amount'] > 0 else 'debit', 'balance': Decimal(transaction['balance']), 'note': transaction['description']} for transaction in result] returnValue(transactions)
def to_webserver(self): return {"id": self.id, "contract": self.contract.ticker, "quantity": self.quantity, "quantity_left": self.quantity_left, "price": self.price, "side": self.side, "is_cancelled": self.is_cancelled, "timestamp": util.dt_to_timestamp(self.timestamp) }
def __init__(self, id=None, contract=None, quantity=None, quantity_left=None, price=None, side=None, username=None, timestamp=None): self.id = id self.contract = contract self.quantity = quantity self.quantity_left = quantity self.price = price self.side = side self.username = username if timestamp is not None: self.timestamp = timestamp else: self.timestamp = util.dt_to_timestamp(datetime.utcnow())
def create_posting(type, username, contract, quantity, direction, note=None, timestamp=None): if timestamp is None: timestamp = util.dt_to_timestamp(datetime.datetime.utcnow()) return { "username": username, "contract": contract, "quantity": quantity, "direction": direction, "note": note, "type": type, "timestamp": timestamp }
def create_posting(type, username, contract, quantity, direction, note=None, timestamp=None): if timestamp is None: timestamp = util.dt_to_timestamp(datetime.datetime.utcnow()) return {"username":username, "contract":contract, "quantity":quantity, "direction":direction, "note": note, "type": type, "timestamp": timestamp}