Ejemplo n.º 1
0
def update_labels():

    time = datetime.now()
    timestamp = str(time.time().strftime('%I:%M %p'))

    price = CoinDesk.get_current_price(currency='USD')
    price_USD = '${:,.2f}'.format(price)
    worth = float(price) * owned
    worth_USD = '${:,.2f}'.format(float(price) * owned)
    margin = worth - invested
    margin_USD = '${:,.2f}'.format(margin)

    if margin > 0:
        label2.text_color = 'green'
    else:
        label2.text_color = 'red'

    x_list.append(time)
    y_list.append(price)

    label1.text = price_USD
    label2.text = margin_USD
    label3.text = timestamp

    graph(x_list, y_list)
Ejemplo n.º 2
0
    def current_price(self):
        """
        updates the interval and self.data with current price.

        :return: current price
        :rtype: float
        """
        now = datetime.now()
        self.interval += 1
        self.current_interval = now
        price = float(CoinDesk.get_current_price(currency='USD'))
        self.last_price = price
        self.data.ix[now] = [price, self.interval]
        return price
Ejemplo n.º 3
0
 def _populate_data(self):
     """
     populate the initial interval of data
     :return: dataframe containing the current price
     :rtype: pd.DataFrame
     """
     now = datetime.now()
     price = float(CoinDesk.get_current_price(currency='USD'))
     df = pd.DataFrame(
         [[now, price, self.interval]],
         columns=['date', 'price', 'interval'],
     )
     df = df.set_index('date')
     return df
Ejemplo n.º 4
0
def update_label():
    time = datetime.now()
    timestamp = str(time.time().strftime('%I:%M %p'))
    price = CoinDesk.get_current_price(currency='USD')
    price_USD = '${:,.2f}'.format(price)
    worth = float(price) * owned
    worth_USD = '${:,.2f}'.format(float(price) * owned)
    margin = worth - invested
    margin_USD = '${:,.2f}'.format(margin)

    app.clearLabel('L1')
    app.setLabel('L1', price_USD)

    app.clearLabel('L2')
    app.setLabel('L2', margin_USD)
    if margin > 0:
        app.setLabelFg('L2', 'dark green')
    else:
        app.setLabelFg('L2', 'red')

    app.clearLabel('L3')
    app.setLabel('L3', timestamp)
Ejemplo n.º 5
0
current_ip = socket.gethostbyname(socket.gethostname())

if current_ip == "127.0.1.1":

    gam_input = "ip -4 addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}'"
    result_1 = os.popen(gam_input).read()
    current_ip = result_1

invested = 122.44
owned = .01

time = datetime.now()
timestamp = str(time.time().strftime('%I:%M %p'))

price = CoinDesk.get_current_price(currency='USD')
price_USD = '${:,.2f}'.format(price)
worth = float(price) * owned
worth_USD = '${:,.2f}'.format(float(price) * owned)
margin = worth - invested
margin_USD = '${:,.2f}'.format(margin)


def update_label():
    time = datetime.now()
    timestamp = str(time.time().strftime('%I:%M %p'))
    price = CoinDesk.get_current_price(currency='USD')
    price_USD = '${:,.2f}'.format(price)
    worth = float(price) * owned
    worth_USD = '${:,.2f}'.format(float(price) * owned)
    margin = worth - invested