def testStockGroupWeightGenerationWithRiskAndReward(self):
        listSize = 5
        stockList = []
        for i in range(0,listSize):
            stockList.append(Stock(str(i),'test'+str(i), (0.2+ 0.01*i), (0.1 + 0.01*i)))
        assert(len(stockList)==listSize)
        StockCoRelation.resetMatrix()
        for i in range(0,listSize):
            for j in range(i,listSize):
                StockCoRelation.addCorelation(stockList[i].uid, stockList[j].uid, 0)

        stockGroup = StockGroup(stockList)
        w = WeightVectorGenerator(100, listSize, 0, 65-listSize*3)
        weightCount = 0
        for i in range(0, 100):
            (weightClass, weightVector) = w.getWeightVectorAndClassTuple()
            while weightClass is not len(stockList):
                (weightClass, weightVector) = w.getWeightVectorAndClassTuple()
            weightCount += 1

            stockGroup.setPlotBestRewardByRisk( (weightClass, weightVector) )

        #print "%s" % (" \n".join([",".join([str(stock.uid), str(stock.reward), str(stock.risk)]) for stock in stockList]))
        #print "Weights created %s" % weightCount
        graphPlot = stockGroup.getPlotBestRewardByRisk()
        graphIndex = graphPlot.keys()
        graphIndex = sorted(graphIndex)
        for i in range(0, len(graphIndex)):
            print "%s %s" % (graphIndex[i], graphPlot[graphIndex[i]])
        assert('01234'== stockGroup.getGroupId())
def getCombination(newStock, listOfStocks):
    combinationStockGroupList = {}
    queue = []
    currentStockList = []
    queue.append((0,[newStock]))
    count = 0
    while len(queue) is not 0:
        (startPoint, currentStockList) = queue.pop()
        stockGroup = StockGroup(currentStockList)
        print "Got combination of size: %d" % len(currentStockList)
        combinationStockGroupList[stockGroup.getGroupId()] = stockGroup
        newStockGroupList = []

        for i in range(startPoint, len(listOfStocks)):
            newStockGroupList = currentStockList[:]
            newStockGroupList.append(listOfStocks[i])
            queue.append((i+1,newStockGroupList,))
        count += 1
    print "********* Count of total combinations %d for length %d" % (count, len(combinationStockGroupList))
    return combinationStockGroupList