def obtain_flags(self, symbol):
""" This will add attributes to price_result and indicate the results
of a couple testsin the `flags` key
"""
# Test flags
self.price_result[symbol]["flags"] = []
# Check max price change
if fabs(self.price_result[symbol]["priceChange"]) > fabs(self.assetconf(symbol, "min_change")):
self.price_result[symbol]["flags"].append("min_change")
# Check max price change
if fabs(self.price_result[symbol]["priceChange"]) > fabs(self.assetconf(symbol, "warn_change")):
self.price_result[symbol]["flags"].append("over_warn_change")
# Check max price change
if fabs(self.price_result[symbol]["priceChange"]) > fabs(self.assetconf(symbol, "skip_change")):
self.price_result[symbol]["flags"].append("skip_change")
# Feed too old
feed_age = self.price_result[symbol]["current_feed"]["date"] if self.price_result[symbol]["current_feed"] else datetime.min
if (datetime.utcnow() - feed_age).total_seconds() > self.assetconf(symbol, "maxage"):
self.price_result[symbol]["flags"].append("over_max_age")
评论列表
文章目录