根据新的条件进行交易,添加交易规则
This commit is contained in:
@@ -50,7 +50,7 @@ class ChanLun_BTC_30(IStrategy):
|
||||
"240": 0
|
||||
}
|
||||
# 15m and 30m
|
||||
minimal_roi_1 = {
|
||||
minimal_roi = {
|
||||
"0": 0.1,
|
||||
"240": 0.05,
|
||||
"480": 0.03,
|
||||
@@ -220,9 +220,9 @@ class ChanLun_BTC_30(IStrategy):
|
||||
new_entryprice = proposed_rate
|
||||
if trade:
|
||||
if trade.is_short:
|
||||
new_entryprice = proposed_rate - 5
|
||||
new_entryprice = proposed_rate - 50
|
||||
else:
|
||||
new_entryprice = proposed_rate + 5
|
||||
new_entryprice = proposed_rate + 50
|
||||
return new_entryprice
|
||||
|
||||
def custom_exit_price(self, pair: str, trade: Trade,
|
||||
@@ -231,9 +231,9 @@ class ChanLun_BTC_30(IStrategy):
|
||||
new_exitprice = proposed_rate
|
||||
if trade:
|
||||
if trade.is_short:
|
||||
new_exitprice = proposed_rate + 5
|
||||
new_exitprice = proposed_rate + 50
|
||||
else:
|
||||
new_exitprice = proposed_rate - 5
|
||||
new_exitprice = proposed_rate - 50
|
||||
return new_exitprice
|
||||
|
||||
def adjust_trade_position(self, trade: Trade, current_time: datetime,
|
||||
@@ -319,32 +319,36 @@ class ChanLun_BTC_30(IStrategy):
|
||||
#logger.info(f"保存开仓时ATR值: {entry_atr}")
|
||||
return None
|
||||
def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
shift_time = self.time60
|
||||
state_str = 'resample_{}_state'.format(self.get_ticker_indicator()*shift_time)
|
||||
|
||||
shift60 = self.time60
|
||||
state60 = 'resample_{}_state'.format(self.get_ticker_indicator()*shift60)
|
||||
shift30 = self.time30
|
||||
state30 = 'resample_{}_state'.format(self.get_ticker_indicator()*shift30)
|
||||
dataframe.loc[
|
||||
(
|
||||
(dataframe[state_str].shift(shift_time) == "-20")
|
||||
(dataframe[state30].shift(shift30) == "-20")
|
||||
),
|
||||
['enter_long', 'enter_tag']] = (1, 'long_30')
|
||||
dataframe.loc[
|
||||
(
|
||||
(dataframe[state_str].shift(shift_time) == "20")
|
||||
(dataframe[state30].shift(shift30) == "20")
|
||||
),
|
||||
['enter_short', 'enter_tag']] = (1, 'short_30')
|
||||
return dataframe
|
||||
def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
shift_time = self.time60
|
||||
state_str = 'resample_{}_state'.format(self.get_ticker_indicator()*shift_time)
|
||||
|
||||
shift60 = self.time60
|
||||
state60 = 'resample_{}_state'.format(self.get_ticker_indicator()*shift60)
|
||||
shift30 = self.time30
|
||||
state30 = 'resample_{}_state'.format(self.get_ticker_indicator()*shift30)
|
||||
dataframe.loc[
|
||||
(
|
||||
(dataframe[state_str].shift(shift_time) == "20")
|
||||
(dataframe[state30].shift(shift30) == "20") |
|
||||
(dataframe[state30].shift(shift30) == "30")
|
||||
),
|
||||
['exit_long', 'exit_tag']] = (1, 'long_close_30')
|
||||
dataframe.loc[
|
||||
(
|
||||
(dataframe[state_str].shift(shift_time) == "-20")
|
||||
(dataframe[state30].shift(shift30) == "-20") |
|
||||
(dataframe[state30].shift(shift30) == "-30")
|
||||
),
|
||||
['exit_short', 'exit_tag']] = (1, 'short_close_30')
|
||||
return dataframe
|
||||
|
||||
Reference in New Issue
Block a user