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