def __init__(self) -> None: super().__init__() self.__alpaca_client: AlpacaClient = AlpacaClient() self.__iex_cloud_client: IexCloudClient = IexCloudClient() self.__td_ameritrade_client: TdAmeritradeClient = TdAmeritradeClient() self.__email_client: EmailClient = EmailClient() self.__stock_service: StockService = StockService() self.__calc_service: CalcService = CalcService()
def test_max_profit_period(self): data_rows = [['A', '01-Jan-2012', '100'], ['A', '02-Jan-2012', '95'], ['A', '04-Jan-2012', '100'], ['A', '03-Jan-2012', '96'], ['A', '08-Jan-2012', '8'], ['A', '05-Jan-2012', '0'], ['A', '06-Jan-2012', '3'], ['A', '07-Jan-2012', '5']] s = StockService(data_rows) stock_search = StockSearchFilter('A', datetime.fromisoformat('2012-01-02'), datetime.fromisoformat('2012-02-01')) buy_stock, sell_stock, profit = s.get_max_profit_period(stock_search) self.assertEquals( buy_stock, StockInfo('a', datetime.fromisoformat('2012-01-05'), 0.0)) self.assertEquals( sell_stock, StockInfo('a', datetime.fromisoformat('2012-01-08'), 8.0)) self.assertEqual(profit, 8)
def init(file_name: str) -> StockService: try: csv_util = CSVFile(file_name, True) csv_util.read_file() except FileNotFoundError: print("Please pass a fully qualified path name to the CSV file") sys.exit(2) header = csv_util.get_header() if header != ["StockName", "StockData", "StockPrice"]: print( 'Please provide a valid Stock Input File with "StockName", "StockData" and "StockPrice" as headers' ) sys.exit(2) data_rows = csv_util.get_data_rows() stocks_service = StockService(data_rows) return stocks_service
def __init__(self, *args, **kwargs): super(TestIexCloudClient, self).__init__(*args, **kwargs) self.__iex_cloud_client: IexCloudClient = IexCloudClient() self.__stock_service: StockService = StockService()
def __init__(self) -> None: super().__init__() self.__alpaca_client: AlpacaClient = AlpacaClient() self.__iex_cloud_client: IexCloudClient = IexCloudClient() self.__email_client: EmailClient = EmailClient() self.__stock_service: StockService = StockService()
def __init__(self) -> None: super().__init__() self.__stock_service = StockService() self.__calc_service = CalcService()
def __init__(self, *args, **kwargs): super(TestImportService, self).__init__(*args, **kwargs) self.__import_service: ImportService = ImportService() self.__stock_service: StockService = StockService()
from flask import Blueprint, request from app_utils.model_utils import ModelUtils from app_utils.string_utils import StringUtils from app_utils.log_utils import LogUtils from models.db.symbol_master import SymbolMaster from models.request_models.chart_request import ChartRequest as CR from models.response_models.response_model import ResponseModel from services.stock_service import StockService stock_api: Blueprint = Blueprint('stock_api', __name__) __stock_service = StockService() @stock_api.route('/get_symbols/<instrument>', methods=['GET']) def get_symbols(instrument: str) -> str: return StringUtils.to_json( ResponseModel(__stock_service.get_symbols(instrument))) @stock_api.route('/update_symbol', methods=['POST']) def update_symbol() -> str: req: SymbolMaster = ModelUtils.get_obj(SymbolMaster(), request.get_json()) return StringUtils.to_json( ResponseModel(__stock_service.update_symbol(req))) @stock_api.route('/delete_old_prices', methods=['GET']) def delete_old_prices() -> str: return StringUtils.to_json( ResponseModel(__stock_service.delete_old_prices()))
def __init__(self, *args, **kwargs): super(TestAlpacaClient, self).__init__(*args, **kwargs) self.__alpaca_client: AlpacaClient = AlpacaClient() self.__stock_service: StockService = StockService()
def __init__(self, *args, **kwargs): super(TestStockService, self).__init__(*args, **kwargs) self.__stock_service: StockService = StockService() self.__calc_service: CalcService = CalcService()