本文整理汇总了Python中models.Stock.find_one方法的典型用法代码示例。如果您正苦于以下问题:Python Stock.find_one方法的具体用法?Python Stock.find_one怎么用?Python Stock.find_one使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Stock
的用法示例。
在下文中一共展示了Stock.find_one方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_all_stocks
# 需要导入模块: from models import Stock [as 别名]
# 或者: from models.Stock import find_one [as 别名]
def get_all_stocks(name=None):
search_name = request.args.get('name')
if search_name:
stock = Stock.find_one({'name': search_name}, test_mode=app.testing)
return jsonify(stock=stock)
industry = request.args.get('industry')
if industry:
stocks = Stock.find({'industry': industry}, test_mode=app.testing)
return jsonify(stocks=stocks)
# Get all stocks
stocks = Stock.find_all(test_mode=app.testing)
return jsonify(stocks=stocks['stocks'])
示例2: test_find_stock_by_ticker_ticket_not_found
# 需要导入模块: from models import Stock [as 别名]
# 或者: from models.Stock import find_one [as 别名]
def test_find_stock_by_ticker_ticket_not_found(self):
stock = Stock.find_one({'local_ticker': 'NONO'}, test_mode=True)
self.assertEqual(stock['error'], 'Stock not found')
示例3: test_single_stock_by_name
# 需要导入模块: from models import Stock [as 别名]
# 或者: from models.Stock import find_one [as 别名]
def test_single_stock_by_name(self):
stock = Stock.find_one({'name': 'ARCA CONTINENTAL, S.A.B. DE C.V.'}, test_mode=True)
self._assert_first_stock(stock)
示例4: test_find_stock_by_ticker
# 需要导入模块: from models import Stock [as 别名]
# 或者: from models.Stock import find_one [as 别名]
def test_find_stock_by_ticker(self):
stock = Stock.find_one({'local_ticker': 'AC'}, test_mode=True)
self._assert_first_stock(stock)
示例5: test_fuzzy_text_search_name
# 需要导入模块: from models import Stock [as 别名]
# 或者: from models.Stock import find_one [as 别名]
def test_fuzzy_text_search_name(self):
stock = Stock.find_one({'name': 'Arca Continental'}, test_mode=True)
self._assert_first_stock(stock)
示例6: get_stock_by_ticker
# 需要导入模块: from models import Stock [as 别名]
# 或者: from models.Stock import find_one [as 别名]
def get_stock_by_ticker(local_ticker):
stock = Stock.find_one({'local_ticker': local_ticker}, test_mode=app.testing)
return jsonify(stock=stock)