Exemplo n.º 1
0
    def get_position_pnl(self):
        if get_position()['quantity'] < 0:
            pnl_percent = ((get_position()['entry'] - self.get_last_price()) / get_position()['entry']) * 100
        if get_position()['quantity'] > 0:
            pnl_percent = ((self.get_last_price() - get_position()['entry']) / self.get_last_price()) * 100

        try:
            return round(pnl_percent, 2)
        except:
            return 0
Exemplo n.º 2
0
    def update_labels(self):

        # update all labels via tk StringVar()
        self.last_price_value.set(str(self.get_last_price()))
        self.current_position_pnl.set(str(self.get_position_pnl()) + '%')
        self.account_value_pnl.set(
            str(
                round(
                    percent_change(get_account_value(),
                                   float(config.initial_amount)), 2)) + '%')
        self.current_position_value.set(
            str(get_position()['quantity']) + " @ " +
            str(get_position()['entry']))
        self.account_value_text.set(
            locale.currency(get_account_value(), grouping=True))
        self.ticker_value.set(self.get_ticker())

        # Update trade history box
        self.trade_history_list.delete(0, 'end')
        for trade in read_all():
            self.trade_history_list.insert(0, trade)