Add some check now
This commit is contained in:
@@ -288,7 +288,7 @@ class ChanPY():
|
||||
#print(zs.begin.time, zs.end.time)
|
||||
return bsps, updown, bi_sure
|
||||
|
||||
def get_bsp_state(self, dataframe:DataFrame):
|
||||
def get_bsp_state1(self, dataframe:DataFrame):
|
||||
fields = "time,open,high,low,close,volume"
|
||||
bsps = []
|
||||
if self.chanIn:
|
||||
@@ -302,7 +302,7 @@ class ChanPY():
|
||||
bsp = bsp_list[bsp_index]
|
||||
if klu.idx == bsp.klu.idx:
|
||||
bsp_type = self.get_bsp_type(bsp.type[0], bsp.is_buy)
|
||||
if abs(bsp_type) == 1 or abs(bsp_type) == 2:
|
||||
if abs(bsp_type) == 1 or abs(bsp_type) == 10:
|
||||
bsps.append(1)
|
||||
else:
|
||||
bsps.append(0)
|
||||
@@ -316,7 +316,7 @@ class ChanPY():
|
||||
self.chan.trigger_load({self.k_type: [klu]}) # 喂给CChan新增k线
|
||||
self.last_kline = klu
|
||||
return bsps
|
||||
def get_bsp_state1(self, dataframe:DataFrame):
|
||||
def get_bsp_state(self, dataframe:DataFrame):
|
||||
fields = "time,open,high,low,close,volume"
|
||||
bsps = []
|
||||
if self.chanIn:
|
||||
@@ -324,6 +324,7 @@ class ChanPY():
|
||||
bsp_list = []
|
||||
bsp_list_pre_len = 0
|
||||
last_bsp_value = 0
|
||||
last_bsp_index = 0
|
||||
for klu in kl_data: # 获取单根K线
|
||||
self.chan.trigger_load({self.k_type: [klu]}) # 喂给CChan新增k线
|
||||
self.last_kline = klu
|
||||
@@ -335,7 +336,7 @@ class ChanPY():
|
||||
last_bsp = bsp_list[-1]
|
||||
#print(klu.time, klu.idx, last_bsp.klu.time, last_bsp.klu.idx, last_bsp_value, lst[-2].fx, bi_list[-1].dir, bi_list[-1].is_sure,klu.close)
|
||||
if bsp_list_pre_len > len(bsp_list):
|
||||
if abs(last_bsp_value) == 1 or abs(last_bsp_value) == 2:
|
||||
if abs(last_bsp_value) == 1:
|
||||
bsps.append(1)
|
||||
#print(klu.time, klu.idx, last_bsp.klu.time, last_bsp.klu.idx, last_bsp_value, 98)
|
||||
else:
|
||||
@@ -343,17 +344,28 @@ class ChanPY():
|
||||
else:
|
||||
if bsp_list_pre_len == len(bsp_list):
|
||||
if klu.idx == last_bsp.klu.idx:
|
||||
last_bsp_value = self.get_bsp_type(last_bsp.type[0], last_bsp.is_buy)
|
||||
bsps.append(last_bsp_value)
|
||||
#if abs(last_bsp_value) == 1 or abs(last_bsp_value) == 2:
|
||||
#print(klu.time, klu.idx, last_bsp.klu.time, last_bsp.klu.idx, last_bsp_value, "Knonw")
|
||||
if last_bsp.klu.idx - last_bsp_index > 3:
|
||||
last_bsp_value = self.get_bsp_type(last_bsp.type[0], last_bsp.is_buy)
|
||||
bsps.append(last_bsp_value)
|
||||
else:
|
||||
bsps.append(0)
|
||||
last_bsp_index = last_bsp.klu.idx
|
||||
#if abs(last_bsp_value) == 1 or abs(last_bsp_value) == 2:
|
||||
#print(klu.time, klu.idx, last_bsp.klu.time, last_bsp.klu.idx, last_bsp_value, "Knonw")
|
||||
else:
|
||||
bsps.append(0)
|
||||
else:
|
||||
last_bsp_value = self.get_bsp_type(last_bsp.type[0], last_bsp.is_buy)
|
||||
bsps.append(last_bsp_value)
|
||||
#if abs(last_bsp_value) == 1 or abs(last_bsp_value) == 2:
|
||||
#print(klu.time, klu.idx, last_bsp.klu.time, last_bsp.klu.idx, last_bsp_value, "Unknow")
|
||||
if klu.idx == last_bsp.klu.idx:
|
||||
if last_bsp.klu.idx - last_bsp_index > 3:
|
||||
last_bsp_value = self.get_bsp_type(last_bsp.type[0], last_bsp.is_buy)
|
||||
bsps.append(last_bsp_value)
|
||||
else:
|
||||
bsps.append(0)
|
||||
last_bsp_index = last_bsp.klu.idx
|
||||
#if abs(last_bsp_value) == 1 or abs(last_bsp_value) == 2:
|
||||
#print(klu.time, klu.idx, last_bsp.klu.time, last_bsp.klu.idx, last_bsp_value, "Knonw")
|
||||
else:
|
||||
bsps.append(0)
|
||||
else:
|
||||
bsps.append(0)
|
||||
bsp_list_pre_len = len(bsp_list)
|
||||
@@ -374,11 +386,17 @@ class ChanPY():
|
||||
bsps[index] = 0
|
||||
else:
|
||||
if bsps[index] == 2:
|
||||
bsps[index] = 1
|
||||
bsps[index] = 10
|
||||
else:
|
||||
if bsps[index] == -2:
|
||||
bsps[index] = -1
|
||||
bsps[index] = -10
|
||||
else:
|
||||
bsps[index] = 0
|
||||
if bsps[index] == 1:
|
||||
bsps[index] = 1
|
||||
else:
|
||||
if bsps[index] == -1:
|
||||
bsps[index] = -1
|
||||
else:
|
||||
bsps[index] = 0
|
||||
return bsps
|
||||
|
||||
|
||||
@@ -55,19 +55,19 @@ class ChanLun_BTC_30(IStrategy):
|
||||
"480": 0.03,
|
||||
"600": 0
|
||||
}
|
||||
minimal_roi_2 = {
|
||||
minimal_roi_1 = {
|
||||
"0": 0.10,
|
||||
"1200": 0.05,
|
||||
"2400": 0.025,
|
||||
"3600": 0
|
||||
}
|
||||
can_short = True
|
||||
lev = 2.0
|
||||
lev = 1.0
|
||||
stoploss = -0.3
|
||||
trailing_stop = True
|
||||
trailing_stop = False
|
||||
trailing_stop_positive = 0.025
|
||||
trailing_stop_positive_offset = 0.045
|
||||
trailing_only_offset_is_reached = True
|
||||
trailing_only_offset_is_reached = False
|
||||
|
||||
position_adjustment_enable = True
|
||||
startup_candle_count = 600
|
||||
@@ -198,12 +198,12 @@ class ChanLun_BTC_30(IStrategy):
|
||||
if trade.is_short:
|
||||
last_high = trade.get_custom_data(key="entry_candle_high")
|
||||
if current_rate > last_high:
|
||||
print(trade.open_date, last_high, current_rate, "Relay Top FX exit")
|
||||
#print(trade.open_date, last_high, current_rate, "Relay Top FX exit")
|
||||
return "Relay Top FX exit"
|
||||
else:
|
||||
last_low = trade.get_custom_data(key="entry_candle_low")
|
||||
if current_rate < last_low:
|
||||
print(trade.open_date, last_low, current_rate, "Relay Bottom FX exit")
|
||||
#print(trade.open_date, last_low, current_rate, "Relay Bottom FX exit")
|
||||
return "Relay Bottom FX exit"
|
||||
def order_filled(self, pair: str, trade: Trade, order: Order, current_time: datetime, **kwargs) -> None:
|
||||
"""
|
||||
@@ -228,7 +228,7 @@ class ChanLun_BTC_30(IStrategy):
|
||||
else:
|
||||
if (trade.nr_of_successful_entries == 1) and (order.ft_order_side == trade.entry_side):
|
||||
trade.set_custom_data(key="entry_candle_low", value=last_low)
|
||||
print(trade.open_date, trade.close_date, last_high, last_low, order.ft_order_side, klc_list[-2].start_time, klc_list[-2].end_time)
|
||||
#print(trade.open_date, trade.close_date, last_high, last_low, order.ft_order_side, klc_list[-2].start_time, klc_list[-2].end_time)
|
||||
self.last_trade = trade
|
||||
return None
|
||||
def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
|
||||
Reference in New Issue
Block a user