else: print "not a recognizable order state" if not empty: #sell algorithm currentPrice = robot.getPrice(currentlyOwnedStock) priceDifference = (currentPrice - startingPrice)/startingPrice print "percentage difference between purchasing price and current price: ", priceDifference #price has gone down too much, give up and sell result = "" if priceDifference < 0.05: print "price too low, giving up and selling at a loss" result = robot.ask(stockQuantity, currentPrice, currentlyOwnedStock) print "selling", stockQuantity, "shares at $" , currentPrice, "per share" elif priceDifference > 0.05: "price increased sufficiently, selling for a profit" result = robot.ask(stockQuantity, currentPrice, currentlyOwnedStock) print "selling", stockQuantity, "shares at $" , currentPrice, "per share" if result == 'Accepted': print "trade accepted" elif result == 'Unsuccesful': print "trade declined" elif result == 'Pending': print "trade pending" else: print "not a recognizable order state"
else: print "not a recognizable order state" if not empty: #sell algorithm currentPrice = robot.getPrice(currentlyOwnedStock) priceDifference = (currentPrice - startingPrice) / startingPrice print "percentage difference between purchasing price and current price: ", priceDifference #price has gone down too much, give up and sell result = "" if priceDifference < 0.05: print "price too low, giving up and selling at a loss" result = robot.ask(stockQuantity, currentPrice, currentlyOwnedStock) print "selling", stockQuantity, "shares at $", currentPrice, "per share" elif priceDifference > 0.05: "price increased sufficiently, selling for a profit" result = robot.ask(stockQuantity, currentPrice, currentlyOwnedStock) print "selling", stockQuantity, "shares at $", currentPrice, "per share" if result == 'Accepted': print "trade accepted" elif result == 'Unsuccesful': print "trade declined" elif result == 'Pending': print "trade pending" else: print "not a recognizable order state"
if (portfolio[ticker] != 0): #selling distribution: #25 percent at market price #10 percent at 10 percent above market price #10 percent at 10 percent below market price #5 percent at 5 percent below market price marketFraction = 0.25 aboveMarket = 0.10 tenBelowMarket = 0.10 fiveBelowMarket = 0.05 price = robot.getPrice(ticker) result = robot.ask((int)(portfolio[ticker] * marketFraction), price, ticker) if result == 'Accepted': print "trade accepted" elif result == 'Unsuccesful': print "trade declined" elif result == 'Pending': print "trade pending" else: print "not a recognizable order state" result = robot.ask((int)(portfolio[ticker] * aboveMarket), price * 1.10, ticker) if result == 'Accepted': print "trade accepted" elif result == 'Unsuccesful': print "trade declined" elif result == 'Pending':
if portfolio[ticker] != 0: # selling distribution: # 25 percent at market price # 10 percent at 10 percent above market price # 10 percent at 10 percent below market price # 5 percent at 5 percent below market price marketFraction = 0.25 aboveMarket = 0.10 tenBelowMarket = 0.10 fiveBelowMarket = 0.05 price = robot.getPrice(ticker) result = robot.ask((int)(portfolio[ticker] * marketFraction), price, ticker) if result == "Accepted": print "trade accepted" elif result == "Unsuccesful": print "trade declined" elif result == "Pending": print "trade pending" else: print "not a recognizable order state" result = robot.ask((int)(portfolio[ticker] * aboveMarket), price * 1.10, ticker) if result == "Accepted": print "trade accepted" elif result == "Unsuccesful": print "trade declined" elif result == "Pending": print "trade pending"
print "trade pending" else: print "not a recognizable order state" if not empty: #sell algorithm currentPrice = robot.getPrice(currentlyOwnedStock) priceDifference = (currentPrice - startingPrice)/startingPrice print "percentage difference between purchasing price and current price: ", priceDifference #price has gone down too much, give up and sell result = "" if priceDifference < 0.05: print "price too low, giving up and selling at a loss" result = robot.ask(robot.accountID, stockQuantity, currentPrice, currentlyOwnedStock) print "selling", stockQuantity, "shares at $" , currentPrice, "per share" elif priceDifference > 0.05: "price increased sufficiently, selling for a profit" result = robot.ask(robot.accountID, stockQuantity, currentPrice, currentlyOwnedStock) print "selling", stockQuantity, "shares at $" , currentPrice, "per share" if result == 'Accepted': print "trade accepted" elif result == 'Unsuccesful': print "trade declined" elif result == 'Pending': print "trade pending" else: print "not a recognizable order state"