Merge pull request #135 from rybolov/develop

Better buy and sell strategy
This commit is contained in:
Janne Sinivirta 2017-11-23 18:25:56 +02:00 committed by GitHub
commit c6def418cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -61,6 +61,10 @@ def populate_indicators(dataframe: DataFrame) -> DataFrame:
hilbert = ta.HT_SINE(dataframe) hilbert = ta.HT_SINE(dataframe)
dataframe['htsine'] = hilbert['sine'] dataframe['htsine'] = hilbert['sine']
dataframe['htleadsine'] = hilbert['leadsine'] dataframe['htleadsine'] = hilbert['leadsine']
dataframe['plus_dm'] = ta.PLUS_DM(dataframe)
dataframe['plus_di'] = ta.PLUS_DI(dataframe)
dataframe['minus_dm'] = ta.MINUS_DM(dataframe)
dataframe['minus_di'] = ta.MINUS_DI(dataframe)
return dataframe return dataframe
@ -71,10 +75,16 @@ def populate_buy_trend(dataframe: DataFrame) -> DataFrame:
:return: DataFrame with buy column :return: DataFrame with buy column
""" """
dataframe.loc[ dataframe.loc[
(dataframe['tema'] <= dataframe['blower']) & (
(dataframe['rsi'] < 37) & (dataframe['rsi'] < 35) &
(dataframe['fastd'] < 48) & (dataframe['fastd'] < 35) &
(dataframe['adx'] > 31), (dataframe['adx'] > 30) &
(dataframe['plus_di'] > 0.5)
) |
(
(dataframe['adx'] > 65) &
(dataframe['plus_di'] > 0.5)
),
'buy'] = 1 'buy'] = 1
return dataframe return dataframe
@ -87,9 +97,19 @@ def populate_sell_trend(dataframe: DataFrame) -> DataFrame:
:return: DataFrame with buy column :return: DataFrame with buy column
""" """
dataframe.loc[ dataframe.loc[
(crossed_above(dataframe['rsi'], 70)), (
(
(crossed_above(dataframe['rsi'], 70)) |
(crossed_above(dataframe['fastd'], 70))
) &
(dataframe['adx'] > 10) &
(dataframe['minus_di'] > 0)
) |
(
(dataframe['adx'] > 70) &
(dataframe['minus_di'] > 0.5)
),
'sell'] = 1 'sell'] = 1
return dataframe return dataframe