pysonar_demo/models.pyStatic analysis
1 """Domain models used by the demo application.""" 2 3 4 class Market: 5 def __init__(self, question, yes_price, volume): 6 self.question = question 7 self.yes_price = yes_price 8 self.volume = volume 9 10 def liquidity_label(self): 11 if self.volume >= 100000: 12 return "deep" 13 if self.volume >= 50000: 14 return "active" 15 return "emerging" 16 17 18 class Prediction: 19 def __init__(self, market, score, confidence): 20 self.market = market 21 self.score = score 22 self.confidence = confidence 23 24 def summary(self): 25 direction = "YES" if self.score >= 0.5 else "NO" 26 return direction + " · " + self.confidence + " · " + self.market.question 27 28 29 class Report: 30 def __init__(self, title, predictions): 31 self.title = title 32 self.predictions = predictions 33 34 def strongest(self): 35 best = self.predictions[0] 36 for prediction in self.predictions[1:]: 37 if prediction.score > best.score: 38 best = prediction 39 return best