本文整理汇总了Python中models.Status.query_one方法的典型用法代码示例。如果您正苦于以下问题:Python Status.query_one方法的具体用法?Python Status.query_one怎么用?Python Status.query_one使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Status
的用法示例。
在下文中一共展示了Status.query_one方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: summary
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import query_one [as 别名]
def summary():
global symbols
user = request.args.get('user')
if user:
if not current_user.is_admin():
return 'WTF?'
if user:
user = User.query_one({'_id': user})
else:
user = current_user
accounts = list(Account.query({'user_id': user._id}))
ps = [p for p in
Position.query({'user_id': user._id},
sort=[('date', 1)])]
os = [o for o in
Order.query({'user_id': user._id},
sort=[('date', 1)])]
dates = list(reversed([p.date for p in ps]))
total_profit = 0
for o in os:
for oo in o.order_list:
if oo.symbol in symbols:
total_profit += oo.profit
today = request.args.get('today')
if today:
today = datetime.strptime(today, '%Y-%m-%d %H:%M:%S')
else:
d = datetime.utcnow() + timedelta(hours=8)
if d.hour == 9 and 20 <= d.minute <= 40:
return '跌零时间段, 不可查看'
if d.hour < 9:
d -= timedelta(days=1)
today = d.replace(hour=0, minute=0, second=0, microsecond=0)
try:
position_list = Position.query_one({'user_id': user._id,
'date': today}).position_list
status_list = Status.query_one({'user_id': user._id,
'date': today}).status_list
order_list = Order.query_one({'user_id': user._id,
'date': today}).order_list
except:
pass
locals()['symbols'] = symbols
return render_template('summary.html', **locals())