def is_trend_close_time(self): # this is used to jude the time to close return bool # first base band, if the sd is too small ,wo need to bigger # current the close signal is only band if self._now_interest <=0: return False # base the max draw down # 达到最大盈利之后,或者最大亏损之后,就开始平仓。这个是系统自带的。 # 现在根据李总的说法,添加了maxdrawdown的功能。!!!!! if self._direction ==LONG: tmp_profit = self._now_md_price[LASTPRICE] - self._open_lastprice elif self._direction ==SHORT: tmp_profit = self._open_lastprice - self._now_md_price[LASTPRICE] else: return False if tmp_profit < (0 - self._limit_max_loss) or tmp_profit > self._limit_max_profit: # print "the profit is bigger or loss" return True is_drawdown = bf.is_max_draw_down(self._direction,self._now_md_price[LASTPRICE],self._open_lastprice ,self._multiple,self._max_profit,self._limit_max_draw_down) self._max_profit = is_drawdown[1] if is_drawdown[0]: mesg= 'this is the max draw down ' + str(self._max_profit) self._file.write(mesg +"\n") return True loss_val = self._param_loss_edge close_val = self._param_close_edge is_band_close = bf.is_band_close_time(self._direction,self._now_md_price[LASTPRICE], self._now_middle_value,self._now_sd_val,loss_val,close_val ,self._ris_data,self._limit_rsi_data,self._limit_sd,self._limit_sd_close_edge) return is_band_close
def is_trend_close_time(self): # this is used to jude the time to close return bool # first base band, if the sd is too small ,wo need to bigger # current the close signal is only band if self._now_interest <= 0: return False tmp_time = self._time.split(":") tmp_time_str = tmp_time[0] + ":" + tmp_time[1] if "14:58" in tmp_time_str: return True # base the max loss if self._open_lastprice != 0: if self._direction == LONG: tmp = self._lastprice - self._open_lastprice elif self._direction == SHORT: tmp = self._open_lastprice - self._lastprice if tmp < 0 and ((0 - tmp) > self._limit_max_loss): return True # base the max profit to decide leave.if the max profit is too small,we don't need to leave if self._max_profit < tmp: self._max_profit = tmp is_band_close = bf.is_band_close_time( self._direction, self._lastprice, self._now_middle_value_60, self._now_sd_val, self._param_loss_edge, self._param_profit_edge, self._ris_data, self._limit_rsi_data) if is_band_close == True: return True is_middle_cross_close = self.is_middle_cross_close_time( self._direction, self._lastprice, self._now_middle_value_5) return is_middle_cross_close
def is_trend_close_time(self): # this is used to jude the time to close return bool # first base band, if the sd is too small ,wo need to bigger # current the close signal is only band if self._now_interest <= 0: return False # base the max draw down # 达到最大盈利之后,或者最大亏损之后,就开始平仓。这个是系统自带的。 # if self._direction ==LONG: # tmp_profit = self._lastprice - self._open_lastprice # elif self._direction ==SHORT: # tmp_profit = self._open_lastprice - self._lastprice # else: # return False # if tmp_profit < (0 - self._limit_max_loss) or tmp_profit > self._limit_max_profit: # # print "the profit is bigger or loss" # return True loss_val = self._param_loss_edge close_val = self._param_close_edge if self._now_sd_val < self._limit_sd: close_val = self._limit_sd_close_edge is_band_close = bf.is_band_close_time(self._direction, self._lastprice, self._now_middle_value, self._now_sd_val, loss_val, close_val, self._ris_data, self._limit_rsi_data) return is_band_close
def is_trend_close_time(self): # this is used to jude the time to close return bool # first base band, if the sd is too small ,wo need to bigger # current the close signal is only band if self._now_interest <=0: return False tmp_time =self._time.split(":") tmp_time_str = tmp_time[0]+":"+tmp_time[1] if "14:58" in tmp_time_str: return True # exit when profit profit_close_val = self._profit_close_edge is_band_close = bf.is_band_close_time(self._direction,self._lastprice, self._now_middle_value,self._now_sd_val,self._close_edge,profit_close_val ,self._rsi_data,self._limit_rsi_data) if is_band_close == True: return True # base the max loss to leave and close if self._open_lastprice != 0: if self._direction ==LONG: tmp = self._lastprice - self._open_lastprice elif self._direction ==SHORT: tmp = self._open_lastprice - self._lastprice if tmp <0 and ((0 - tmp) > self._limit_max_loss): return True # if tmp > self._limit_max_profit: # return True return False
def is_trend_close_time(self): # this is used to jude the time to close return bool if self._now_interest <= 0: return False tmp_time = self._time.split(":") tmp_time_str = tmp_time[0] + ":" + tmp_time[1] if "14:58" in tmp_time_str: return True # base the max loss if self._open_lastprice != 0: if self._direction == LONG: tmp = self._lastprice - self._open_lastprice elif self._direction == SHORT: tmp = self._open_lastprice - self._lastprice if tmp < 0 and ((0 - tmp) > self._limit_max_loss): return True if self._max_profit < tmp: self._max_profit = tmp is_band_close = bf.is_band_close_time( self._direction, self._lastprice, self._now_middle_value_60, self._now_sd_val, self._param_loss_edge, self._param_profit_edge, self._ris_data, self._limit_rsi_data) if is_band_close == True: return True is_middle_cross_close = self.is_middle_cross_close_time( self._direction, self._lastprice, self._now_middle_value_5) # print self._max_profit return is_middle_cross_close