コード例 #1
0
    def update_item(self):
        transaction_time = datetime.datetime.fromtimestamp(
            int(self.transaction["timestamp"])).strftime('%Y-%m-%d %H:%M:%S')

        self.asset1_amount = prec_div(
            self.transaction["assets"]["first"]["amount"], self.asset1_prec)
        self.asset2_amount = prec_div(
            self.transaction["assets"]["second"]["amount"], self.asset2_prec)
        self.transferred_asset1_amount = prec_div(
            self.transaction["transferred"]["first"]["amount"],
            self.asset1_prec)
        self.transferred_asset2_amount = prec_div(
            self.transaction["transferred"]["second"]["amount"],
            self.asset2_prec)

        self.setText(
            0, "%s.%d" % (self.transaction["trader_id"][:10],
                          self.transaction["transaction_number"]))
        self.setText(
            1, "%g %s" %
            (self.asset1_amount, self.transaction["assets"]["first"]["type"]))
        self.setText(
            2, "%g %s" %
            (self.asset2_amount, self.transaction["assets"]["second"]["type"]))
        self.setText(
            3, "%g %s" % (self.transferred_asset1_amount,
                          self.transaction["assets"]["first"]["type"]))
        self.setText(
            4, "%g %s" % (self.transferred_asset2_amount,
                          self.transaction["assets"]["second"]["type"]))
        self.setText(5, transaction_time)
        self.setText(6, self.transaction["status"])
コード例 #2
0
ファイル: orderwidgetitem.py プロジェクト: hbiyik/tribler
    def __init__(self, parent, order, asset1_prec, asset2_prec):
        QTreeWidgetItem.__init__(self, parent)
        self.order = order

        order_time = datetime.datetime.fromtimestamp(int(order["timestamp"])).strftime('%Y-%m-%d %H:%M:%S')
        self.total_volume = prec_div(order["assets"]["first"]["amount"], asset1_prec)
        self.traded_volume = prec_div(order["traded"], asset1_prec)
        self.price = float(self.total_volume) / float(prec_div(order["assets"]["second"]["amount"], asset2_prec))

        self.setText(0, "%s" % order["order_number"])
        self.setText(1, order_time)
        self.setText(2, "%g %s" % (self.price, order["assets"]["second"]["type"]))
        self.setText(3, "%g %s" % (self.total_volume, order["assets"]["first"]["type"]))
        self.setText(4, "%g %s" % (self.traded_volume, order["assets"]["first"]["type"]))
        self.setText(5, "Sell" if order["is_ask"] else "Buy")
        self.setText(6, "%s" % order["status"])
コード例 #3
0
ファイル: tickwidgetitem.py プロジェクト: hbiyik/tribler
    def __init__(self, parent, tick, asset1_prec, asset2_prec):
        QTreeWidgetItem.__init__(self, parent)
        self.tick = tick

        self.total_volume = prec_div(tick["assets"]["first"]["amount"], asset1_prec)
        self.cur_volume = prec_div(tick["assets"]["first"]["amount"] - tick["traded"], asset1_prec)

        self.price = float(self.total_volume) / float(prec_div(tick["assets"]["second"]["amount"], asset2_prec))

        if self.tick["type"] == "ask":
            self.setText(0, "%g" % self.price)
            self.setText(1, "%g" % self.cur_volume)
            self.setText(2, "%g" % self.total_volume)
        else:
            self.setText(0, "%g" % self.total_volume)
            self.setText(1, "%g" % self.cur_volume)
            self.setText(2, "%g" % self.price)
コード例 #4
0
ファイル: marketpage.py プロジェクト: hbiyik/tribler
    def on_wallets(self, wallets):
        if not wallets:
            return
        wallets = wallets["wallets"]
        self.received_wallets.emit(wallets)

        created_wallets = [
            wallet_id for wallet_id, wallet_info in wallets.items()
            if wallet_info['created']
        ]
        if len(created_wallets) < 2:
            self.window().market_create_wallet_button.show()
        else:
            self.window().create_ask_button.show()
            self.window().create_bid_button.show()

        self.wallets = wallets
        if self.chosen_wallets is None and len(self.wallets.keys()) >= 2:
            self.chosen_wallets = sorted(self.wallets.keys())[0], sorted(
                self.wallets.keys())[1]
            self.update_button_texts()

        for wallet_id, wallet in wallets.items():
            if not wallet['created'] or not wallet['unlocked']:
                continue

            if wallet_id not in self.wallet_widgets:
                wallet_widget = MarketCurrencyBox(
                    self.window().market_header_widget,
                    wallets[wallet_id]['name'])
                self.window().market_header_widget.layout().insertWidget(
                    4, wallet_widget)
                wallet_widget.setFixedWidth(100)
                wallet_widget.setFixedHeight(34)
                wallet_widget.show()
                self.wallet_widgets[wallet_id] = wallet_widget

                spacer = QSpacerItem(10, 20, QSizePolicy.Fixed,
                                     QSizePolicy.Fixed)
                self.window().market_header_widget.layout().insertSpacerItem(
                    5, spacer)

            balance_amount = prec_div(wallet['balance']['available'],
                                      wallet['precision'])
            balance_currency = None

            self.wallet_widgets[wallet_id].update_with_amount(
                balance_amount, balance_currency)

        self.load_asks()
        self.load_bids()
コード例 #5
0
    def add_payment_to_list(self, payment):
        if self.wallets:
            payment["transferred"]["amount"] = prec_div(
                payment["transferred"]["amount"], self.wallets[payment["transferred"]["type"]]["precision"]
            )

            payment_time = datetime.datetime.fromtimestamp(int(payment["timestamp"])).strftime('%Y-%m-%d %H:%M:%S')
            item = QTreeWidgetItem(self.window().market_payments_list)
            item.setText(0, "%g %s" % (payment['transferred']["amount"], payment['transferred']["type"]))
            item.setText(1, payment['address_from'])
            item.setText(2, payment['address_to'])
            item.setText(3, payment_time)
            item.setText(4, "%s" % ('yes' if payment['success'] else 'no'))

            self.window().market_payments_list.addTopLevelItem(item)