def stockGroupWeightUpdater(weightClass, weightVector):
    stockGroups = getAllStockGroupsByClass(weightClass)
    for stockGroup in stockGroups:
        stockGroup.setPlotBestRewardByRisk((weightClass, weightVector))
        if stockGroup.isThresholdClear():
            notifyExpectants(stockGroup)
        saveStockGroup(stockGroup)
    print stockGroups
def addStock(newStock):
    listOfStocks = getAllStocks()
    saveStock(newStock)
    print "Added stock %s" % newStock
    if len(listOfStocks) is not 0:
        combinationsOfStockGroup = getCombination(newStock, listOfStocks)
        print combinationsOfStockGroup
        for stockGroup in combinationsOfStockGroup.values():
            saveStockGroup(stockGroup)
 def testStockGroupAddingAndRemoving(self):
     stock1 = Stock(str(1),'test1', (0.2+ 0.01), (0.1 + 0.01))
     stock2 = Stock(str(2),'test2', (0.2+ 0.01), (0.1 + 0.01))
     stock3 = Stock(str(3),'test3', (0.2+ 0.01), (0.1 + 0.01))
     assert ( saveStock(stock1) is True)
     assert ( saveStock(stock2) is True)
     assert ( saveStock(stock3) is True)
     stockGroupList = [stock1, stock2, stock3]
     stockGroup = StockGroup(stockGroupList)
     assert( saveStockGroup(stockGroup) is True)
     lookupStockGroup = getStockGroup(stockGroup)
     assert(lookupStockGroup is not None)
     assert(removeStockGroups(lookupStockGroup) is True)
     lookupStockGroup = getStockGroup(stockGroup)
     assert(lookupStockGroup is None)
     assert(removeStock(stock1) is True)
     assert(removeStock(stock2) is True)
     assert(removeStock(stock3) is True)