class GpwCurrentStockIntradayDataTest(unittest.TestCase): def setUp(self): ## Called before testfunction is executed self.dataAccess = GpwCurrentStockIntradayData("PLOPTTC00011") def data_path(): return get_data_path("cdr.chart.04-09.txt") self.dataAccess.dao.getDataPath = data_path # type: ignore self.dataAccess.dao.downloadData = lambda filePath: None ## empty lambda function self.dataAccess.dao.storage = WorksheetStorageMock() # self.dataAccess.dao.parseWorksheetFromFile( data_path() ) def tearDown(self): ## Called after testfunction was executed pass def test_getWorksheetData_False(self): currData = self.dataAccess.getWorksheetData(False) self.assertIsNone(currData) def test_getWorksheetData_True(self): currData = self.dataAccess.getWorksheetData(True) dataLen = len(currData) self.assertEqual(dataLen, 3104) def test_getWorksheetForDate(self): date_object = datetime.date(year=2020, month=9, day=21) currData = self.dataAccess.getWorksheetForDate(date_object, True) dataLen = len(currData) self.assertEqual(dataLen, 3104)
def setUp(self): ## Called before testfunction is executed self.dataAccess = GpwCurrentStockIntradayData("PLOPTTC00011") def data_path(): return get_data_path("cdr.chart.04-09.txt") self.dataAccess.dao.getDataPath = data_path # type: ignore self.dataAccess.dao.downloadData = lambda filePath: None ## empty lambda function self.dataAccess.dao.storage = WorksheetStorageMock()
def _calcSingle(self, key): name, isin = key intradayData = GpwCurrentStockIntradayData(isin) dataFrame = intradayData.getWorksheetForDate(self.day) if dataFrame is None: ## no data return (name, 0) dataColumn = dataFrame[self.cName] value = self.func(dataColumn) if math.isnan(value): return (name, 0) return (name, value)
def _loadData(self, isin): # name, isin = paramsList intradayData = GpwCurrentStockIntradayData( "PLOPTTC00011" ) def data_path(): return get_data_path( "cdr.chart.04-09.txt" ) intradayData.dao.getDataPath = data_path # type: ignore intradayData.dao.storage = WorksheetStorageMock() worksheet = intradayData.dao.parseWorksheetFromFile( data_path() ) return worksheet
def prepare_dataobject(): data = DataObject() dataAccess = GpwCurrentStockIntradayData("PLOPTTC00011") def data_path(): return get_data_path("cdr.chart.04-09.txt") dataAccess.dao.getDataPath = data_path # type: ignore dataAccess.dao.downloadData = lambda filePath: None ## empty lambda function dataAccess.dao.storage = WorksheetStorageMock() # data.gpwStockIntradayData.set( "PLOPTTC00011", dataAccess ) # data.gpwStockIntradayData.set( "CRD", dataAccess ) return data
def makeValue(isin, rangeCode): return GpwCurrentStockIntradayData(isin, rangeCode)
def _loadData(self, isin): intradayData = GpwCurrentStockIntradayData(isin) dataFrame = intradayData.getWorksheetForDate(self.accessDate) return dataFrame
def processData(self, params): name, isin = params intradayData = GpwCurrentStockIntradayData(isin) dataFrame = intradayData.getWorksheetForDate(self.day) return (name, dataFrame)