本文整理匯總了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)