def __init__(self, sim_env, api_wrapper, name, cash): self.sim_env = sim_env self.api_wrapper = api_wrapper self.name = name self.portfolios = [] self.info_obj = YAFIObjects.YAFIObjectDepotInfo([0]) self.starting_cash = cash self.loadStuff()
def save(self): info_filename = Util.getDepotInfoFile(self.name) fileh = open(info_filename, "w") self.info_obj = YAFIObjects.YAFIObjectDepotInfo([self.starting_cash]) fileh.write(self.info_obj.getAsString()) for portfolio in self.portfolios: portfolio.save()
def loadDepotInfo(depot_name): filename = getDepotInfoFile(depot_name) if os.path.exists(filename): fileh = open(filename, "r") csv_dict = getDictFromCsvString(fileh.read()) info_obj = YAFIObjects.YAFIObjectDepotInfo(csv_dict[0]) return info_obj return None