Example #1
0
 def on_awake(self):
   try:
     current_price = self.data_source.query()
     if utils.format_dollars(self.last_price) != utils.format_dollars(current_price):
       self.on_price_change(current_price)
   except ValueError:
     print "Error querying Bitstamp API"
   except requests.ConnectionError:
     print "Error querying Bitstamp API"
Example #2
0
 def print_status(self, current_bitcoin_price):
   print "=============================================================================="
   print "Account value: {value}".format(value = utils.format_dollars(self.get_account_value(current_bitcoin_price)))
   print "------------------------------------------------------------------------------"
   print "Bitcoin value: {value}".format(value=utils.format_dollars(current_bitcoin_price))
   print "------------------------------------------------------------------------------"
   print "Cash: {cash}".format(cash=utils.format_dollars(self.dollars))
   print "------------------------------------------------------------------------------"
   for index, record in self.bitcoin_records.items():
     print record
   print "==============================================================================\n"
Example #3
0
 def __str__(self):
   return "index={index}, qty={qty}, price={price}, purchase_time={purchase_time}".format(index = self.index, qty = self.qty, price = utils.format_dollars(self.price), purchase_time = self.purchase_time)
Example #4
0
 def print_db_results(self, db_results):
   for row in db_results:
     date_string = datetime.datetime.fromtimestamp(row[0]).strftime('%Y-%m-%d %H:%M:%S')
     self.last_price = row[1]
     print date_string + "\t" + utils.format_dollars(self.last_price) + "\t" + utils.format_slope(row[2])
Example #5
0
 def print_price_data(self, price, time, slope, recommendation):
   date_string = datetime.datetime.fromtimestamp(time).strftime('%Y-%m-%d %H:%M:%S')
   print date_string + "\t" + utils.format_dollars(price)  + "\t" + utils.format_slope(slope) + "\t" + str(recommendation)