mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 18:23:55 +00:00
fix coding convention
This commit is contained in:
parent
d55092ff17
commit
45218faeb0
|
@ -26,11 +26,13 @@ class Positions(Enum):
|
|||
def opposite(self):
|
||||
return Positions.Short if self == Positions.Long else Positions.Long
|
||||
|
||||
|
||||
def mean_over_std(x):
|
||||
std = np.std(x, ddof=1)
|
||||
mean = np.mean(x)
|
||||
return mean / std if std > 0 else 0
|
||||
|
||||
|
||||
class Base5ActionRLEnv(gym.Env):
|
||||
"""
|
||||
Base class for a 5 action environment
|
||||
|
@ -250,42 +252,58 @@ class Base5ActionRLEnv(gym.Env):
|
|||
if len(self.close_trade_profit):
|
||||
# aim x2 rw
|
||||
if self.close_trade_profit[-1] > self.profit_aim * self.rr:
|
||||
last_trade_price = self.add_buy_fee(self.prices.iloc[self._last_trade_tick].open)
|
||||
current_price = self.add_sell_fee(self.prices.iloc[self._current_tick].open)
|
||||
last_trade_price = self.add_buy_fee(
|
||||
self.prices.iloc[self._last_trade_tick].open)
|
||||
current_price = self.add_sell_fee(
|
||||
self.prices.iloc[self._current_tick].open)
|
||||
return float((np.log(current_price) - np.log(last_trade_price)) * 2)
|
||||
# less than aim x1 rw
|
||||
elif self.close_trade_profit[-1] < self.profit_aim * self.rr:
|
||||
last_trade_price = self.add_buy_fee(self.prices.iloc[self._last_trade_tick].open)
|
||||
current_price = self.add_sell_fee(self.prices.iloc[self._current_tick].open)
|
||||
last_trade_price = self.add_buy_fee(
|
||||
self.prices.iloc[self._last_trade_tick].open
|
||||
)
|
||||
current_price = self.add_sell_fee(
|
||||
self.prices.iloc[self._current_tick].open
|
||||
)
|
||||
return float(np.log(current_price) - np.log(last_trade_price))
|
||||
# # less than RR SL x2 neg rw
|
||||
# elif self.close_trade_profit[-1] < (self.profit_aim * -1):
|
||||
# last_trade_price = self.add_buy_fee(self.prices.iloc[self._last_trade_tick].open)
|
||||
# current_price = self.add_sell_fee(self.prices.iloc[self._current_tick].open)
|
||||
# last_trade_price = self.add_buy_fee(
|
||||
# self.prices.iloc[self._last_trade_tick].open)
|
||||
# current_price = self.add_sell_fee(
|
||||
# self.prices.iloc[self._current_tick].open)
|
||||
# return float((np.log(current_price) - np.log(last_trade_price)) * 2) * -1
|
||||
|
||||
|
||||
# close short
|
||||
if action == Actions.Short_buy.value and self._position == Positions.Short:
|
||||
if len(self.close_trade_profit):
|
||||
# aim x2 rw
|
||||
if self.close_trade_profit[-1] > self.profit_aim * self.rr:
|
||||
last_trade_price = self.add_sell_fee(self.prices.iloc[self._last_trade_tick].open)
|
||||
current_price = self.add_buy_fee(self.prices.iloc[self._current_tick].open)
|
||||
last_trade_price = self.add_sell_fee(
|
||||
self.prices.iloc[self._last_trade_tick].open
|
||||
)
|
||||
current_price = self.add_buy_fee(
|
||||
self.prices.iloc[self._current_tick].open
|
||||
)
|
||||
return float((np.log(last_trade_price) - np.log(current_price)) * 2)
|
||||
# less than aim x1 rw
|
||||
elif self.close_trade_profit[-1] < self.profit_aim * self.rr:
|
||||
last_trade_price = self.add_sell_fee(self.prices.iloc[self._last_trade_tick].open)
|
||||
current_price = self.add_buy_fee(self.prices.iloc[self._current_tick].open)
|
||||
last_trade_price = self.add_sell_fee(
|
||||
self.prices.iloc[self._last_trade_tick].open
|
||||
)
|
||||
current_price = self.add_buy_fee(
|
||||
self.prices.iloc[self._current_tick].open
|
||||
)
|
||||
return float(np.log(last_trade_price) - np.log(current_price))
|
||||
# # less than RR SL x2 neg rw
|
||||
# elif self.close_trade_profit[-1] > self.profit_aim * self.rr:
|
||||
# last_trade_price = self.add_sell_fee(self.prices.iloc[self._last_trade_tick].open)
|
||||
# current_price = self.add_buy_fee(self.prices.iloc[self._current_tick].open)
|
||||
# last_trade_price = self.add_sell_fee(
|
||||
# self.prices.iloc[self._last_trade_tick].open)
|
||||
# current_price = self.add_buy_fee(
|
||||
# self.prices.iloc[self._current_tick].open)
|
||||
# return float((np.log(last_trade_price) - np.log(current_price)) * 2) * -1
|
||||
return 0.
|
||||
|
||||
|
||||
def _update_profit(self, action):
|
||||
# if self._is_trade(action) or self._done:
|
||||
if self._is_trade(action) or self._done:
|
||||
|
|
Loading…
Reference in New Issue
Block a user