207 lines
7.1 KiB
Diff
207 lines
7.1 KiB
Diff
1,4d0
|
|
< import numpy as np # noqa
|
|
< import pandas as pd # noqa
|
|
< from pandas import DataFrame
|
|
<
|
|
6c2,3
|
|
<
|
|
---
|
|
> import pandas as pd
|
|
> import numpy as np
|
|
12,13c9
|
|
<
|
|
< INTERFACE_VERSION = 2
|
|
---
|
|
> INTERFACE_VERSION = 3
|
|
14a11
|
|
> # 基础参数
|
|
16c13
|
|
< "0": 10
|
|
---
|
|
> "0": 10
|
|
36d32
|
|
< plot_config = {
|
|
37a34,35
|
|
> # 绘图配置
|
|
> plot_config = {
|
|
51a50
|
|
>
|
|
65c64
|
|
< def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
|
---
|
|
> def populate_indicators(self, dataframe: pd.DataFrame, metadata: dict) -> pd.DataFrame:
|
|
77,78d75
|
|
<
|
|
<
|
|
85c82
|
|
< macd = ta.MACD(dataframe,12,26,1)
|
|
---
|
|
> macd = ta.MACD(dataframe, 12, 26, 1)
|
|
102,103c99
|
|
<
|
|
<
|
|
---
|
|
>
|
|
106c102
|
|
< def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
|
---
|
|
> def populate_buy_trend(self, dataframe: pd.DataFrame, metadata: dict) -> pd.DataFrame:
|
|
116,130c112,113
|
|
< (
|
|
< ( #Original buy condition
|
|
< (dataframe['slowk'] >= 20) & (dataframe['slowk'] <= 80)
|
|
< &
|
|
< (dataframe['slowd'] >= 20) & (dataframe['slowd'] <= 80)
|
|
< )
|
|
< |
|
|
< ( #V3 added based on SmoothScalp
|
|
< (dataframe['slowk'] < 30) & (dataframe['slowd'] < 30) &
|
|
< (qtpylib.crossed_above(dataframe['slowk'], dataframe['slowd']))
|
|
< )
|
|
< )
|
|
< &
|
|
< ( #Original buy condition #Might need improvement to have better signals
|
|
< (dataframe['macd'] > dataframe['macd'].shift(1))
|
|
---
|
|
> (
|
|
> (dataframe['slowk'] >= 20) & (dataframe['slowk'] <= 80)
|
|
132c115
|
|
< (dataframe['macdsignal'] > dataframe['macdsignal'].shift(1))
|
|
---
|
|
> (dataframe['slowd'] >= 20) & (dataframe['slowd'] <= 80)
|
|
134,149c117,120
|
|
< &
|
|
< ( #Original buy condition
|
|
< (dataframe['close'] > dataframe['close'].shift(1))
|
|
< & #V6 added condition to improve buy's
|
|
< (dataframe['open'] > dataframe['open'].shift(1))
|
|
< )
|
|
< &
|
|
< ( #Original buy condition
|
|
< (dataframe['ema5c'] >= dataframe['ema5o'])
|
|
< |
|
|
< (dataframe['open'] < dataframe['ema5l'])
|
|
< )
|
|
< &
|
|
< (
|
|
<
|
|
< (dataframe['volume'] > dataframe['volvar'])
|
|
---
|
|
> |
|
|
> (
|
|
> (dataframe['slowk'] < 30) & (dataframe['slowd'] < 30) &
|
|
> (qtpylib.crossed_above(dataframe['slowk'], dataframe['slowd']))
|
|
152,154c123,125
|
|
< |
|
|
< ( # V2 Added buy condition w/ Bollingers bands
|
|
< (dataframe['slowk'] >= 20) & (dataframe['slowk'] <= 80)
|
|
---
|
|
> &
|
|
> (
|
|
> (dataframe['macd'] > dataframe['macd'].shift(1))
|
|
156c127,131
|
|
< (dataframe['slowd'] >= 20) & (dataframe['slowd'] <= 80)
|
|
---
|
|
> (dataframe['macdsignal'] > dataframe['macdsignal'].shift(1))
|
|
> )
|
|
> &
|
|
> (
|
|
> (dataframe['close'] > dataframe['close'].shift(1))
|
|
158,162c133
|
|
< (
|
|
< (dataframe['close'] <= dataframe['bb_lowerband'])
|
|
< |
|
|
< (dataframe['open'] <= dataframe['bb_lowerband'])
|
|
< )
|
|
---
|
|
> (dataframe['open'] > dataframe['open'].shift(1))
|
|
164,168c135,143
|
|
< |
|
|
< ( # V5 added Pullback RSI thanks to simoelmou
|
|
< (dataframe['close'] > dataframe['ema200c'])
|
|
< &
|
|
< (dataframe['rsi7'] < 35)
|
|
---
|
|
> &
|
|
> (
|
|
> (dataframe['ema5c'] >= dataframe['ema5o'])
|
|
> |
|
|
> (dataframe['open'] < dataframe['ema5l'])
|
|
> )
|
|
> &
|
|
> (
|
|
> (dataframe['volume'] > dataframe['volvar'])
|
|
175c150
|
|
< def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
|
---
|
|
> def populate_sell_trend(self, dataframe: pd.DataFrame, metadata: dict) -> pd.DataFrame:
|
|
185,200c160,161
|
|
< (
|
|
< ( #Original sell condition
|
|
< (dataframe['slowk'] <= 80) & (dataframe['slowd'] <= 80)
|
|
< )
|
|
< |
|
|
< ( #V3 added based on SmoothScalp
|
|
< (qtpylib.crossed_above(dataframe['slowk'], 70))
|
|
< |
|
|
< (qtpylib.crossed_above(dataframe['slowd'], 70))
|
|
< )
|
|
< )
|
|
< &
|
|
< ( #Original sell condition
|
|
< (dataframe['macd'] < dataframe['macd'].shift(1))
|
|
< &
|
|
< (dataframe['macdsignal'] < dataframe['macdsignal'].shift(1))
|
|
---
|
|
> (
|
|
> (dataframe['slowk'] <= 80) & (dataframe['slowd'] <= 80)
|
|
202,204c163,165
|
|
< &
|
|
< ( #Original sell condition
|
|
< (dataframe['ema5c'] < dataframe['ema5o'])
|
|
---
|
|
> |
|
|
> (
|
|
> (qtpylib.crossed_above(dataframe['slowk'], 70))
|
|
206c167
|
|
< (dataframe['open'] >= dataframe['ema5h']) # V3 added based on SmoothScalp
|
|
---
|
|
> (qtpylib.crossed_above(dataframe['slowd'], 70))
|
|
209,213c170,172
|
|
< |
|
|
< ( # V2 Added sell condition w/ Bollingers bands
|
|
< (dataframe['slowk'] <= 80)
|
|
< &
|
|
< (dataframe['slowd'] <= 80)
|
|
---
|
|
> &
|
|
> (
|
|
> (dataframe['macd'] < dataframe['macd'].shift(1))
|
|
215,219c174
|
|
< (
|
|
< (dataframe['close'] >= dataframe['bb_upperband'])
|
|
< |
|
|
< (dataframe['open'] >= dataframe['bb_upperband'])
|
|
< )
|
|
---
|
|
> (dataframe['macdsignal'] < dataframe['macdsignal'].shift(1))
|
|
221,225c176,180
|
|
< |
|
|
< (# V6 Added sell condition for extra high values
|
|
< (dataframe['high'] > dataframe['bb_upperband'])
|
|
< &
|
|
< (((dataframe['high'] - dataframe['bb_upperband']) * 100 / dataframe['bb_upperband']) > 1)
|
|
---
|
|
> &
|
|
> (
|
|
> (dataframe['ema5c'] < dataframe['ema5o'])
|
|
> |
|
|
> (dataframe['open'] >= dataframe['ema5h'])
|
|
227d181
|
|
<
|
|
230,231c184
|
|
< return dataframe
|
|
<
|
|
---
|
|
>
|