def tradeXLFBundle(prices, trade_sz, XFLprice, BONDprice, GSprice, MSprice, WFCprice): m3_utils.buy(prices, "BOND", trade_sz*3, BONDprice) m3_utils.buy(prices, "GS", trade_sz*2, GSprice) m3_utils.buy(prices, "MS", trade_sz*3, MSprice) m3_utils.buy(prices, "WFC", trade_sz*2, WFCprice) m3_utils.convert(prices, "XLF", True, trade_sz*10) #True = BUY m3_utils.sell(prices, "XLF", trade_sz*10, XFLprice)
def liquidate(prices, name): sellPrice = prices.getStockBuy(name) buyPrice = prices.getStockSell(name) if prices.portfolio.shouldSellBasedOnPrice(name, sellPrice[0]): m3_utils.sell(prices, name, sellPrice[1], sellPrice[0]) if prices.portfolio.shouldBuyBasedOnPrice(name, buyPrice[0]): m3_utils.buy(prices, name, buyPrice[1], buyPrice[0])
def tradeVALEforVALBZ(prices, trade_sz, VALEprice, VALBZprice): m3_utils.buy(prices, "VALE", trade_sz, VALEprice) m3_utils.convert(prices, "VALE", False, trade_sz) m3_utils.sell(prices, "VALBZ", trade_sz, VALBZprice)