def label_formatter(x, pos): v = int(x) if v <= 9: return ballpark.business(v, precision=1) elif v <= 99: return ballpark.business(v, precision=2) else: return ballpark.business(v, precision=3)
def refresh(self): '''Refresh data and screens''' # fisrt refresh data if necessary now = time.time() since = now - self.lastCheck if since >= self.configuration["refresh_delay"] or since < 0.0: self.checkPrice() self.checkPriceYesterday() self.checkWalletsBalance() self.lastCheck = time.time() # Second refresh the screens self.screen[0] = self.parse_summary() for x in range(len(self.configuration["addresses"])): s1 = self.configuration['addresses'][x]['description'] s2 = '%s BTC = %s %s' % (business(self.walletBalance[x]), business(self.walletBalance[x] * self.priceLast), self.configuration["currency"]) self.screen[ x + 1 ] = [s1, s2]
def convert_to_business(num): if abs(num) < 0.1: return 0 else: num_str = business( abs(num), precision=5, ) if num < 0: return "-" + num_str else: return num_str
COMPANY INTRO: CHICAGO (AP) - {{ company_name }} ({{ ticker }}) on {{ weekday }} reported fiscal third-quarter net income of ${{ net_income }}. {{ company_name }}, {{ state }}-based company said it's earnings, adjusted for non-recurring costs, came to ${{ lastQtrEPS }} per share. The results beat Wall Street expectations. {{ company_name}} also posted revenue of ${{ total_revenue }} Million in the period, also exceeding Street forecasts. The company also posted a dividend rate of {{an_dividend_rate}}% with a divided yeild of {{dividend_yield}}% """) prefixes = {6: ' million'} # ...fill in the rest intro = Introtemplate.render( company_name=company_name, ticker=symbol, weekday=weekday, lastQtrEPS = df["lastQtrEPS"][0], total_revenue = df["annualRevenue"][0], dividend_yield = df["annualDividendYield"][0], an_dividend_rate = df["annualDividendRate"][0], net_income=business(income['netIncome'], prefixes=prefixes), state=states[company['state']] ) print(intro) url3 = "http://ondemand.websol.barchart.com/getQuote.csv" querystring = {"symbols": symbol,"fields":"ask,bid, open, high, low, close,impliedVolatility, numTrades,fiftyTwoWkHigh,fiftyTwoWkLow","mode":"R","apikey":"barcharthackathon"} r = requests.request("GET", url3, params=querystring) df_quotes = pd.read_csv(StringIO(r.text)) Quotetemplate = Template(""" THE STOCKS PERFORMANCE WITH EXPLANATION: CHICAGO (AP)- {{ company_name}} ({{ticker}}) on {{weekday}} has the following results: The ({{ticker}}) stock opened today with ${{opening}} and is currently going at ${{last_price}} which gives a net change of {{percent_change}}%.
def parse_summary(self): s1 = '1BTC = %s %s' % (business(self.priceLast), self.configuration["currency"]) s2 = 'Monit: %s wallets' % (len(self.configuration["addresses"])) return [s1, s2]