class Trade(): def __init__(self,funds): self.money = MoneyManage(funds) self.stock = Stock() #購入判定処理 def buyDecision(self,code,day): #始値を取得 startPrice=self.stock.currentStartPrice(code,day) #終値を取得 endPrice=self.stock.currentEndPrice(code,day) #標準偏差(10日間)を取得 std=self.stock.singleStd(code,day,10) #始値から標準偏差を引いた分より終値が下回った場合購入 if (startPrice-std) > endPrice: buyDay = dateTools.dateNext(day) buyCount = 100 buyPrice = self.stock.currentStartPrice(code,buyDay) self.money.buy(buyDay,code,buyPrice,buyCount,1) #売却判定処理 def sellDecision(self,day): #保有銘柄分処理を実施 for key,value in self.money.stockHold().items(): #現在株価を取得 currentStockPrice = self.stock.currentStartPrice(key[1],day) #株価が購入時より10%値上がりした際に売却 if int(value[0])*int(value[1])*1.1 < int(currentStockPrice) * int(value[1]): self.money.sell(key[0],key[1],currentStockPrice) #株価が購入時より10%値下がりした際に売却 elif int(value[0])*int(value[1]) * 0.9 > int(currentStockPrice) * int(value[1]): self.money.sell(key[0],key[1],currentStockPrice)
def __init__(self,funds): self.money = MoneyManage(funds) self.stock = Stock()