def createNewPositions(occurencesOfPrice, occurencesOfStrikeDate, occurencesOfTicker, validTickersLength): validPositions = [] length = validTickersLength i = 0 while (i < length): try: newPosition = validPosition(occurencesOfTicker[i], occurencesOfPrice[i], occurencesOfStrikeDate[i]) except ValueError: continue validPositions.append(newPosition) i += 1 return validPositions
def printValidPositions(comment, occurencesOfPrice, occurencesOfStrikeDate, occurencesOfTicker, validTickersLength): validPositions = [] length = validTickersLength i = 0 while (i < length): newPosition = validPosition(occurencesOfTicker[i], occurencesOfPrice[i], occurencesOfStrikeDate[i]) validPositions.append(newPosition) outFile = open("resources/files/commentFileOut", "a") outFile.write("\n\n") outFile.write(comment) outFile.write("\n") outFile.write(newPosition.__str__()) outFile.write("\n\n") outFile.close() i += 1
def createValidPositionObjects(ticker, price, date): return validPositionObject.validPosition(ticker, price, date)
def test_formatDate_ShouldRemoveLeadingZero_When_OneExists(self): position = validPosition("MSFT", "100", "06/19") self.assertEqual("06/19", position.strikeDate)
def test_formatDate_ShouldFormatDate_When_StrikeDateIncludesPutOrCall( self): objects.validPositionObject.datetime.utcnow.return_value = datetime.datetime( 2020, 2, 3) position = validPosition("MSFT", "100", "01/01p") self.assertEqual("01/01p", position.strikeDate)
def test_formatDate_ShouldFormatYearAsNextYear_When_StrikeDateMonthEarlierThanCurrentMonth( self): objects.validPositionObject.datetime.utcnow.return_value = datetime.datetime( 2020, 2, 3) position = validPosition("MSFT", "100", "01/01") self.assertEqual("01/01", position.strikeDate)
def test_formatDate_ShouldAddYearToDate_When_YearNotIncluded(self): objects.validPositionObject.datetime.utcnow.return_value = datetime.datetime( 2020, 2, 3) position = validPosition("MSFT", "100", "06/19") self.assertEqual("06/19", position.strikeDate)