def test1(self): p = Portfolio(100000) p.buy("TEL.OL", 100) #p.buy("NHY.OL", 100) #p.buy("XXL.OL", 100) #p.buy("NHY.OL", 100) #p.buy("AKSO.OL", 100) p.sell("TEL.OL") d = p.cash assert(d==100000)
def create_portfolio(method, ticker): try: name = request.json['name'] cash = request.json['cash'] p = Portfolio(name, int(cash)); jsonstring = jsonpickle.encode(p) resp = jsonify({'Success':True, 'result':jsonstring}) resp.status_code = 200 return resp except: exc_type, exc_obj, exc_tb = sys.exc_info() error = str(exc_type)[18:-2] + ": " + str(exc_obj)[1:-1] resp = jsonify({'Success':False, 'error':error}) resp.status_code = 500 return resp
def serializetest(self): import json as j p = Portfolio("Test", 10000); p.buy("TEL.OL", 100) d = j.dumps(p.open_positions) assert (1==1)