make should_short and go_short optional

This commit is contained in:
Saleh Mir
2022-02-06 08:54:17 +01:00
parent d7cf800122
commit 6299fdca96
3 changed files with 18 additions and 6 deletions

View File

@@ -383,7 +383,6 @@ class Strategy(ABC):
def go_long(self) -> None:
pass
@abstractmethod
def go_short(self) -> None:
pass
@@ -432,13 +431,10 @@ class Strategy(ABC):
@abstractmethod
def should_long(self) -> bool:
"""are all filters good to execute buy"""
pass
@abstractmethod
def should_short(self) -> bool:
"""are all filters good to execute sell"""
pass
return False
@abstractmethod
def should_cancel(self) -> bool:

View File

@@ -0,0 +1,12 @@
from jesse.strategies import Strategy
class TestCanRunWithoutShorting(Strategy):
def should_long(self):
return False
def should_cancel(self):
return False
def go_long(self):
pass

View File

@@ -874,6 +874,10 @@ def test_stop_loss_price_is_replaced_with_market_order():
def test_take_profit_price_is_replaced_with_market_order():
# long position
single_route_backtest('TestTakeProfitPriceIsReplacedWithMarketOrderWhenMoreConvenientLongPosition')
single_route_backtest('TestTakeProfitPriceIsReplacedWithMarketOrderWhenMoreConvenientLongPTestCanRunWithoutShortingsition')
# # short position
single_route_backtest('TestTakeProfitPriceIsReplacedWithMarketOrderWhenMoreConvenientShortPosition')
def test_can_run_without_shorting():
single_route_backtest('TestCanRunWithoutShorting')