Esempio n. 1
0
 def buy(self,price):
     s = u"%s, 当前价%.2f, 上一个交易价%.2f, 第一次买入价%.2f"%(self.code,price, self.pre_price, self.first_buy_price)
     self.account.log(s)
     #第一次买
     if self.pre_price == 0 and price <= self.first_buy_price:
         if self._Buy(self.code, self.first_buy_num, price):
             self.first_buy_price = price
             self.pre_price = price
             self._genQjPrice()
             self.serial()
         return
     if price-self.pre_price <= -self.qj:
         is_buy = True
         #fire_qj_price = Qjjy_accout._findMatchPrice(price, self.qj_prices, is_buy)
         fire_qj_price = price
         if fire_qj_price > 0 and self.prices_traded.Add(fire_qj_price):
             num = stock.Account().ShouShu(self.first_buy_num*self.qj_num_bilv)
             if self._Buy(self.code, num, price):
                 print("_buy")
                 self.pre_price = price
                 self.serial()
Esempio n. 2
0
 def sell(self,price):
     #全部卖出
     if price > self.end_sell_price :
         if self._Sell(self.code, -1, price):
             self.pre_price = 0
             if os.path.isfile(self.fpath):
                 os.remove(self.fpath)
         return
     #self.log("sell 0 "+str(self.qj) + " "+str(price-self.pre_price))
     if price-self.pre_price >= self.qj :
         is_buy = False
         #一定要匹配到锚点价格
         #fire_qj_price = Qjjy_accout._findMatchPrice(price, self.qj_prices, is_buy)
         fire_qj_price = price
         if fire_qj_price > 0 :
             self.log("sell 2")
             num = stock.Account().ShouShu(self.first_buy_num*self.qj_num_bilv)
             if self._Sell(self.code, num, price):
                 self.log( "_sell")
                 self.prices_traded.Del(price)
                 self.pre_price = price
                 self.serial()