예제 #1
0
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
0
 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
0
 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
0
 def test_find_stock_by_ticker(self):
     stock = Stock.find_one({'local_ticker': 'AC'}, test_mode=True)
     self._assert_first_stock(stock)
예제 #5
0
 def test_fuzzy_text_search_name(self):
     stock = Stock.find_one({'name': 'Arca Continental'}, test_mode=True)
     self._assert_first_stock(stock)
예제 #6
0
def get_stock_by_ticker(local_ticker):
    stock = Stock.find_one({'local_ticker': local_ticker}, test_mode=app.testing)
    return jsonify(stock=stock)