remove all the empty comments
This commit is contained in:
@@ -77,10 +77,6 @@ class DynamicNumpyArray:
|
||||
self.array[self.index] = item
|
||||
|
||||
def get_last_item(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
# validation
|
||||
if self.index == -1:
|
||||
raise IndexError('list assignment index out of range')
|
||||
@@ -103,9 +99,6 @@ class DynamicNumpyArray:
|
||||
return self.array[self.index - past_index]
|
||||
|
||||
def flush(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
self.index = -1
|
||||
self.array = np.zeros(self.shape)
|
||||
self.bucket_size = self.shape[0]
|
||||
|
||||
@@ -35,10 +35,6 @@ class CompletedTrade:
|
||||
setattr(self, a, attributes[a])
|
||||
|
||||
def toJSON(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
orders = []
|
||||
for o in self.orders:
|
||||
orders.append(o.__dict__)
|
||||
@@ -70,10 +66,6 @@ class CompletedTrade:
|
||||
}
|
||||
|
||||
def to_dict(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return {
|
||||
'id': self.id,
|
||||
'strategy_name': self.strategy_name,
|
||||
@@ -102,51 +94,27 @@ class CompletedTrade:
|
||||
|
||||
@property
|
||||
def fee(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
trading_fee = config['env']['exchanges'][self.exchange]['fee']
|
||||
return trading_fee * self.qty * (self.entry_price + self.exit_price)
|
||||
|
||||
@property
|
||||
def reward(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return abs(self.take_profit_at - self.entry_price) * self.qty
|
||||
|
||||
@property
|
||||
def size(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.qty * self.entry_price
|
||||
|
||||
@property
|
||||
def risk(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return abs(self.stop_loss_at - self.entry_price) * self.qty
|
||||
|
||||
@property
|
||||
def risk_percentage(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return round((self.risk / self.size) * 100, 2)
|
||||
|
||||
@property
|
||||
def risk_reward_ratio(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.reward / self.risk
|
||||
|
||||
@property
|
||||
|
||||
@@ -54,9 +54,6 @@ class Order():
|
||||
)
|
||||
|
||||
def notify_submission(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
notify(
|
||||
'{} order: {}, {}, {}, {}, ${}'.format(
|
||||
'QUEUED' if self.is_queued else 'SUBMITTED',
|
||||
@@ -67,18 +64,10 @@ class Order():
|
||||
|
||||
@property
|
||||
def is_canceled(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.status == order_statuses.CANCELED
|
||||
|
||||
@property
|
||||
def is_active(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.status == order_statuses.ACTIVE
|
||||
|
||||
@property
|
||||
@@ -94,49 +83,25 @@ class Order():
|
||||
|
||||
@property
|
||||
def is_new(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.is_active
|
||||
|
||||
@property
|
||||
def is_executed(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.status == order_statuses.EXECUTED
|
||||
|
||||
@property
|
||||
def is_filled(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.is_executed
|
||||
|
||||
@property
|
||||
def is_reduce_only(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.flag == order_flags.REDUCE_ONLY
|
||||
|
||||
@property
|
||||
def is_close(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.flag == order_flags.CLOSE
|
||||
|
||||
def cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
if self.is_canceled or self.is_executed:
|
||||
return
|
||||
|
||||
@@ -163,10 +128,6 @@ class Order():
|
||||
p._on_canceled_order(self)
|
||||
|
||||
def execute(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
if self.is_canceled or self.is_executed:
|
||||
return
|
||||
|
||||
|
||||
@@ -26,9 +26,6 @@ def store_candle_into_db(exchange: str, symbol: str, candle: np.ndarray):
|
||||
}
|
||||
|
||||
def async_save():
|
||||
"""
|
||||
|
||||
"""
|
||||
Candle.insert(**d).on_conflict_ignore().execute()
|
||||
print(
|
||||
jh.color(
|
||||
@@ -60,9 +57,6 @@ def store_ticker_into_db(exchange: str, symbol: str, ticker: np.ndarray):
|
||||
}
|
||||
|
||||
def async_save():
|
||||
"""
|
||||
|
||||
"""
|
||||
Ticker.insert(**d).on_conflict_ignore().execute()
|
||||
print(
|
||||
jh.color('ticker: {}-{}-{}: {}'.format(
|
||||
@@ -94,9 +88,6 @@ def store_trade_into_db(exchange: str, symbol: str, trade: np.ndarray):
|
||||
}
|
||||
|
||||
def async_save():
|
||||
"""
|
||||
|
||||
"""
|
||||
Trade.insert(**d).on_conflict_ignore().execute()
|
||||
print(
|
||||
jh.color(
|
||||
@@ -127,9 +118,6 @@ def store_orderbook_into_db(exchange: str, symbol: str, orderbook: np.ndarray):
|
||||
}
|
||||
|
||||
def async_save():
|
||||
"""
|
||||
|
||||
"""
|
||||
Orderbook.insert(**d).on_conflict_ignore().execute()
|
||||
print(
|
||||
jh.color(
|
||||
|
||||
@@ -14,9 +14,6 @@ class Binance(CandleExchange):
|
||||
self.endpoint = 'https://www.binance.com/api/v1/klines'
|
||||
|
||||
def init_backup_exchange(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
self.backup_exchange = None
|
||||
|
||||
def get_starting_time(self, symbol):
|
||||
|
||||
@@ -14,9 +14,6 @@ class BinanceFutures(CandleExchange):
|
||||
self.endpoint = 'https://fapi.binance.com/fapi/v1/klines'
|
||||
|
||||
def init_backup_exchange(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
from .binance import Binance
|
||||
self.backup_exchange = Binance()
|
||||
|
||||
|
||||
@@ -14,9 +14,6 @@ class Bitfinex(CandleExchange):
|
||||
self.endpoint = 'https://api-pub.bitfinex.com/v2/candles'
|
||||
|
||||
def init_backup_exchange(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
from .coinbase import Coinbase
|
||||
self.backup_exchange = Coinbase()
|
||||
|
||||
|
||||
@@ -14,9 +14,6 @@ class Coinbase(CandleExchange):
|
||||
self.endpoint = 'https://api.pro.coinbase.com/products'
|
||||
|
||||
def init_backup_exchange(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
from .bitfinex import Bitfinex
|
||||
self.backup_exchange = Bitfinex()
|
||||
|
||||
|
||||
@@ -13,9 +13,6 @@ class CandleExchange(ABC):
|
||||
|
||||
@abstractmethod
|
||||
def init_backup_exchange(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
|
||||
@@ -14,9 +14,6 @@ class TestnetBinanceFutures(CandleExchange):
|
||||
self.endpoint = 'https://testnet.binancefuture.com/fapi/v1/klines'
|
||||
|
||||
def init_backup_exchange(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
from .binance import Binance
|
||||
self.backup_exchange = Binance()
|
||||
|
||||
|
||||
@@ -160,10 +160,6 @@ class Genetics(ABC):
|
||||
}
|
||||
|
||||
def make_love(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
mommy = self.select_person()
|
||||
daddy = self.select_person()
|
||||
|
||||
@@ -184,10 +180,6 @@ class Genetics(ABC):
|
||||
}
|
||||
|
||||
def select_person(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
random_index = np.random.choice(self.population_size, int(self.population_size / 100), replace=False)
|
||||
chosen_ones = []
|
||||
|
||||
@@ -304,10 +296,6 @@ class Genetics(ABC):
|
||||
return self.population
|
||||
|
||||
def run(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.evolve()
|
||||
|
||||
def save_progress(self, iterations_index):
|
||||
|
||||
@@ -14,9 +14,6 @@ class API:
|
||||
self.initiate_drivers()
|
||||
|
||||
def initiate_drivers(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
for e in jh.get_config('app.considering_exchanges'):
|
||||
if jh.is_live():
|
||||
def initiate_ws(exchange_name: str):
|
||||
|
||||
@@ -252,10 +252,6 @@ class Broker:
|
||||
)
|
||||
|
||||
def cancel_all_orders(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.api.cancel_all_orders(self.exchange, self.symbol)
|
||||
|
||||
def cancel_order(self, order_id: str):
|
||||
|
||||
@@ -74,9 +74,6 @@ class Cache:
|
||||
pickle.dump(self.db, f, protocol=pickle.HIGHEST_PROTOCOL)
|
||||
|
||||
def flush(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
for key, item in self.db.items():
|
||||
os.remove(item['path'])
|
||||
self.db = {}
|
||||
|
||||
@@ -13,9 +13,6 @@ if not jh.is_unit_testing():
|
||||
|
||||
|
||||
def close_connection():
|
||||
"""
|
||||
|
||||
"""
|
||||
db.close()
|
||||
|
||||
|
||||
|
||||
@@ -3,34 +3,16 @@ from jesse.strategies import Strategy
|
||||
|
||||
class ExampleStrategy(Strategy):
|
||||
def should_long(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def should_short(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def should_cancel(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -5,34 +5,16 @@ import jesse.indicators as ta
|
||||
|
||||
class ExampleStrategy(Strategy):
|
||||
def should_long(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def should_short(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def should_cancel(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return True
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -14,8 +14,4 @@ class CompletedTrades:
|
||||
|
||||
@property
|
||||
def count(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return len(self.trades)
|
||||
|
||||
@@ -15,9 +15,6 @@ class OrderbookState:
|
||||
self.temp_storage = {}
|
||||
|
||||
def init_storage(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
for c in config['app']['considering_candles']:
|
||||
key = jh.key(c[0], c[1])
|
||||
self.temp_storage[key] = {
|
||||
|
||||
@@ -22,9 +22,6 @@ class OrdersState:
|
||||
self.storage[key] = []
|
||||
|
||||
def reset(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
for key in self.storage:
|
||||
self.storage[key].clear()
|
||||
|
||||
@@ -48,10 +45,6 @@ class OrdersState:
|
||||
return self.storage.get(key, [])
|
||||
|
||||
def count_all_active_orders(self) -> int:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
c = 0
|
||||
for key in self.storage:
|
||||
if len(self.storage[key]):
|
||||
@@ -101,10 +94,6 @@ class OrdersState:
|
||||
return pydash.find(self.storage[key], lambda o: o.id == id)
|
||||
|
||||
def execute_pending_market_orders(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
if not self.to_execute:
|
||||
return
|
||||
|
||||
|
||||
@@ -15,10 +15,6 @@ class PositionsState:
|
||||
self.storage[key] = Position(exchange, symbol)
|
||||
|
||||
def count_open_positions(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
c = 0
|
||||
for key in self.storage:
|
||||
p = self.storage[key]
|
||||
|
||||
@@ -14,9 +14,6 @@ class TickersState:
|
||||
self.storage = {}
|
||||
|
||||
def init_storage(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
for c in config['app']['considering_candles']:
|
||||
key = jh.key(c[0], c[1])
|
||||
self.storage[key] = DynamicNumpyArray((60, 5), drop_at=120)
|
||||
|
||||
@@ -15,9 +15,6 @@ class TradesState:
|
||||
self.temp_storage = {}
|
||||
|
||||
def init_storage(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
for c in config['app']['considering_candles']:
|
||||
key = jh.key(c[0], c[1])
|
||||
self.storage[key] = DynamicNumpyArray((60, 6), drop_at=120)
|
||||
|
||||
@@ -76,10 +76,6 @@ class Strategy(ABC):
|
||||
|
||||
@property
|
||||
def is_increased(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
if self.position.is_close:
|
||||
return None
|
||||
|
||||
@@ -145,18 +141,10 @@ class Strategy(ABC):
|
||||
self._on_reduced_position()
|
||||
|
||||
def filters(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return []
|
||||
|
||||
@staticmethod
|
||||
def hyper_parameters():
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return []
|
||||
|
||||
def _execute_long(self):
|
||||
@@ -359,16 +347,10 @@ class Strategy(ABC):
|
||||
|
||||
@abstractmethod
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def _execute_cancel(self):
|
||||
@@ -428,9 +410,6 @@ class Strategy(ABC):
|
||||
|
||||
@abstractmethod
|
||||
def should_cancel(self) -> bool:
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def prepare(self):
|
||||
@@ -616,9 +595,6 @@ class Strategy(ABC):
|
||||
'stop-loss and take-profit should not be exactly the same. Just use either one of them and it will do.')
|
||||
|
||||
def update_position(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def _check(self):
|
||||
@@ -919,9 +895,6 @@ class Strategy(ABC):
|
||||
logger.info('Canceled open-position orders because we reached the end of the backtest session.')
|
||||
|
||||
def terminate(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def watch_list(self):
|
||||
@@ -1047,10 +1020,6 @@ class Strategy(ABC):
|
||||
|
||||
@property
|
||||
def fee_rate(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return selectors.get_exchange(self.exchange).fee_rate
|
||||
|
||||
def _log_position_update(self, order: Order, role: str):
|
||||
@@ -1144,42 +1113,22 @@ class Strategy(ABC):
|
||||
|
||||
@property
|
||||
def is_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.position.type == 'long'
|
||||
|
||||
@property
|
||||
def is_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.position.type == 'short'
|
||||
|
||||
@property
|
||||
def is_open(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.position.is_open
|
||||
|
||||
@property
|
||||
def is_close(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.position.is_close
|
||||
|
||||
@property
|
||||
def average_stop_loss(self) -> float:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
if self._stop_loss is None:
|
||||
raise exceptions.InvalidStrategy('You cannot access self.average_stop_loss before setting self.stop_loss')
|
||||
|
||||
@@ -1188,10 +1137,6 @@ class Strategy(ABC):
|
||||
|
||||
@property
|
||||
def average_take_profit(self) -> float:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
if self._take_profit is None:
|
||||
raise exceptions.InvalidStrategy(
|
||||
'You cannot access self.average_take_profit before setting self.take_profit')
|
||||
@@ -1201,10 +1146,6 @@ class Strategy(ABC):
|
||||
|
||||
@property
|
||||
def average_entry_price(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
if self.is_long:
|
||||
arr = self._buy
|
||||
elif self.is_short:
|
||||
@@ -1232,8 +1173,4 @@ class Strategy(ABC):
|
||||
|
||||
@property
|
||||
def shared_vars(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return store.vars
|
||||
|
||||
@@ -4,44 +4,22 @@ from jesse.strategies import Strategy
|
||||
# test_should_buy_and_execute_buy
|
||||
class Test01(Strategy):
|
||||
def should_long(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.index == 0
|
||||
|
||||
def should_short(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 1
|
||||
self.buy = qty, self.price
|
||||
self.stop_loss = qty, self.price - 10
|
||||
self.take_profit = qty, self.price + 10
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def filters(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return []
|
||||
|
||||
@@ -4,45 +4,23 @@ from jesse.strategies import Strategy
|
||||
# test_should_sell_and_execute_sell
|
||||
class Test02(Strategy):
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
# sell on market at first candle, and sell on the third candle
|
||||
return len(self.candles) == 1
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 1
|
||||
self.sell = qty, self.price
|
||||
self.stop_loss = qty, self.price + 10
|
||||
self.take_profit = qty, self.price - 10
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def filters(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return []
|
||||
|
||||
@@ -4,29 +4,15 @@ from jesse.strategies import Strategy
|
||||
# test_multiple_routes_can_communicate_with_each_other
|
||||
class Test03(Strategy):
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return len(self.candles) == 1
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 1
|
||||
sell_price = self.price + 5
|
||||
|
||||
@@ -35,10 +21,6 @@ class Test03(Strategy):
|
||||
self.take_profit = qty, sell_price - 10
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def on_route_open_position(self, strategy):
|
||||
@@ -49,8 +31,4 @@ class Test03(Strategy):
|
||||
self._execute_cancel()
|
||||
|
||||
def filters(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return []
|
||||
|
||||
@@ -4,23 +4,12 @@ from jesse.strategies import Strategy
|
||||
# test_conflicting_orders
|
||||
class Test04(Strategy):
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.index == 0
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
# print(self.open, self.close, self.high, self.low)
|
||||
# 0.5, 1.0, 1.0, 0.5
|
||||
|
||||
@@ -53,21 +42,10 @@ class Test04(Strategy):
|
||||
# when this is all over, we then add(update) the candle we had in the first place which is 1, 2, 2, 1
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def filters(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return []
|
||||
|
||||
@@ -4,53 +4,28 @@ from jesse.strategies import Strategy
|
||||
# test_is_smart_enough_to_open_positions_via_market_orders
|
||||
class Test05(Strategy):
|
||||
def update(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.time == 1547201100000 + 60_000
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.time == 1547203560000 + 60_000
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 10.204
|
||||
self.buy = qty, self.price
|
||||
self.stop_loss = qty, 128.35
|
||||
self.take_profit = qty, 131.29
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 10
|
||||
self.sell = qty, self.price
|
||||
self.stop_loss = qty, 129.52
|
||||
self.take_profit = qty, 126.58
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def filters(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return []
|
||||
|
||||
@@ -18,33 +18,19 @@ class Test06(Strategy):
|
||||
return self.time == 1547203500000 + 60_000
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 10.204
|
||||
self.buy = qty, 129.33
|
||||
self.stop_loss = qty, 128.35
|
||||
self.take_profit = qty, 131.29
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 10
|
||||
self.sell = qty, 128.05
|
||||
self.stop_loss = qty, 129.52
|
||||
self.take_profit = qty, 126.58
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def filters(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return []
|
||||
|
||||
@@ -4,16 +4,9 @@ from jesse.strategies import Strategy
|
||||
# test_updating_stop_loss_and_take_profit_after_opening_the_position
|
||||
class Test07(Strategy):
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.time == 1547201100000 + 60_000
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 10.204
|
||||
|
||||
self.buy = qty, self.price
|
||||
@@ -21,16 +14,9 @@ class Test07(Strategy):
|
||||
self.take_profit = qty, 131.29
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.time == 1547203560000 + 60_000
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 10
|
||||
|
||||
self.sell = qty, self.price
|
||||
@@ -38,23 +24,12 @@ class Test07(Strategy):
|
||||
self.take_profit = qty, 126.58
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def filters(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return []
|
||||
|
||||
def update_position(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
# early take-profit for short trade
|
||||
if self.time == 1547203680000 + 60_000:
|
||||
self.take_profit = self.position.qty, 127.66
|
||||
|
||||
@@ -4,10 +4,6 @@ from jesse.strategies import Strategy
|
||||
# test_stats_for_a_strategy_without_losing_trades
|
||||
class Test08(Strategy):
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def should_short(self):
|
||||
@@ -21,9 +17,6 @@ class Test08(Strategy):
|
||||
return self.time == 1547203500000 + 60_000
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 10.2041
|
||||
|
||||
self.buy = qty, 129.33
|
||||
@@ -31,9 +24,6 @@ class Test08(Strategy):
|
||||
self.take_profit = 131.29
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 10
|
||||
|
||||
self.sell = qty, 128.05
|
||||
@@ -41,15 +31,7 @@ class Test08(Strategy):
|
||||
self.take_profit = qty, 126.58
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def filters(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return []
|
||||
|
||||
@@ -4,41 +4,19 @@ from jesse.strategies import Strategy
|
||||
# test_stats_for_a_strategy_without_any_trades
|
||||
class Test09(Strategy):
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def filters(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return []
|
||||
|
||||
@@ -4,23 +4,12 @@ from jesse.strategies import Strategy
|
||||
# test_taking_profit_at_multiple_points
|
||||
class Test10(Strategy):
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.price < 7
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 1.5
|
||||
self.buy = qty, 7
|
||||
self.stop_loss = qty, 5
|
||||
@@ -31,21 +20,10 @@ class Test10(Strategy):
|
||||
]
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def filters(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return []
|
||||
|
||||
@@ -4,29 +4,15 @@ from jesse.strategies import Strategy
|
||||
# test_stop_loss_at_multiple_points
|
||||
class Test11(Strategy):
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.index == 0
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 1.5
|
||||
self.sell = qty, 3
|
||||
self.stop_loss = [
|
||||
@@ -37,15 +23,7 @@ class Test11(Strategy):
|
||||
self.take_profit = qty, 1
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def filters(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return []
|
||||
|
||||
@@ -4,23 +4,12 @@ from jesse.strategies import Strategy
|
||||
# test_modifying_take_profit_after_opening_position
|
||||
class Test12(Strategy):
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.price < 7
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 1.5
|
||||
self.buy = qty, 7
|
||||
self.stop_loss = qty, 5
|
||||
@@ -31,28 +20,14 @@ class Test12(Strategy):
|
||||
]
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def filters(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return []
|
||||
|
||||
def update_position(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
if self.price == 10:
|
||||
self.take_profit = self.position.qty, 16
|
||||
|
||||
@@ -4,23 +4,12 @@ from jesse.strategies import Strategy
|
||||
# test_modifying_take_profit_after_part_of_position_is_already_reduced_with_profit
|
||||
class Test13(Strategy):
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.price < 7
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 1.5
|
||||
self.buy = qty, 7
|
||||
self.stop_loss = qty, 5
|
||||
@@ -31,28 +20,14 @@ class Test13(Strategy):
|
||||
]
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def filters(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return []
|
||||
|
||||
def update_position(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
if self.is_reduced:
|
||||
self.take_profit = self.position.qty, 16
|
||||
|
||||
@@ -4,23 +4,12 @@ from jesse.strategies import Strategy
|
||||
# test_modifying_stop_loss_after_part_of_position_is_already_reduced_with_stop_loss
|
||||
class Test14(Strategy):
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.price < 7
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 1.5
|
||||
self.buy = qty, 7
|
||||
self.stop_loss = [
|
||||
@@ -31,28 +20,14 @@ class Test14(Strategy):
|
||||
self.take_profit = qty, 13
|
||||
|
||||
def update_position(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
if self.is_reduced:
|
||||
self.stop_loss = self.position.qty, 4
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def filters(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return []
|
||||
|
||||
@@ -4,23 +4,12 @@ from jesse.strategies import Strategy
|
||||
# test_opening_position_in_multiple_points
|
||||
class Test15(Strategy):
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.price < 7
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
self.buy = [
|
||||
(.5, 7),
|
||||
(.5, 9),
|
||||
@@ -30,21 +19,10 @@ class Test15(Strategy):
|
||||
self.take_profit = 1.5, 15
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def filters(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return []
|
||||
|
||||
@@ -4,16 +4,9 @@ from jesse.strategies import Strategy
|
||||
# test_increasing_position_size_after_opening
|
||||
class Test16(Strategy):
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.price < 7
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 1
|
||||
|
||||
self.buy = qty, 7
|
||||
@@ -21,9 +14,6 @@ class Test16(Strategy):
|
||||
self.take_profit = qty, 15
|
||||
|
||||
def update_position(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
# buy 1 more at current price
|
||||
if self.price == 10:
|
||||
self.buy = 1, 10
|
||||
@@ -31,28 +21,13 @@ class Test16(Strategy):
|
||||
self.stop_loss = 2, 5
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def filters(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return []
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
@@ -4,16 +4,9 @@ from jesse.strategies import Strategy
|
||||
# test_reducing_position_size_after_opening
|
||||
class Test17(Strategy):
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.price < 7
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 2
|
||||
|
||||
self.buy = qty, 7
|
||||
@@ -21,9 +14,6 @@ class Test17(Strategy):
|
||||
self.take_profit = qty, 15
|
||||
|
||||
def update_position(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
# reduce the size of position for 1 at current price
|
||||
if self.price == 10:
|
||||
# should work even without resetting take_profit and stop_loss
|
||||
@@ -33,28 +23,13 @@ class Test17(Strategy):
|
||||
]
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def filters(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return []
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
@@ -4,16 +4,9 @@ from jesse.strategies import Strategy
|
||||
# test_on_reduced_position
|
||||
class Test18(Strategy):
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.price < 7
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 2
|
||||
|
||||
self.buy = qty, 7
|
||||
@@ -24,34 +17,16 @@ class Test18(Strategy):
|
||||
]
|
||||
|
||||
def on_reduced_position(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
self.take_profit = abs(self.position.qty), self.price
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def filters(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return []
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
@@ -3,23 +3,12 @@ from jesse.strategies import Strategy
|
||||
|
||||
class Test19(Strategy):
|
||||
def should_long(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def should_short(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
# qty = 1
|
||||
# self.buy = qty, self.price
|
||||
# self.take_profit = qty, self.price + .1
|
||||
@@ -27,9 +16,6 @@ class Test19(Strategy):
|
||||
pass
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
# qty = 1
|
||||
# self.buy = qty, self.price
|
||||
# self.take_profit = qty, self.price + .1
|
||||
@@ -37,8 +23,4 @@ class Test19(Strategy):
|
||||
pass
|
||||
|
||||
def should_cancel(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
@@ -4,23 +4,12 @@ from jesse.strategies import Strategy
|
||||
# test_conflicting_orders_2
|
||||
class Test20(Strategy):
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.index == 1
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
# self.price = 2
|
||||
qty = 1
|
||||
|
||||
@@ -29,21 +18,10 @@ class Test20(Strategy):
|
||||
self.take_profit = qty, self.price + .6
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def filters(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return []
|
||||
|
||||
@@ -4,38 +4,20 @@ from jesse.strategies import Strategy
|
||||
# test_on_route_open_position part 1 - BTCUSD
|
||||
class Test21(Strategy):
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
# buy on market at first candle, close when on_route_open_position event is fired
|
||||
return self.index == 0
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 1
|
||||
self.buy = qty, self.price
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def on_route_open_position(self, strategy):
|
||||
|
||||
@@ -4,35 +4,17 @@ from jesse.strategies import Strategy
|
||||
# test_on_route_open_position part 2 - ETHUSD
|
||||
class Test22(Strategy):
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.price == 10
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
self.buy = 1, self.price
|
||||
self.take_profit = 1, 20
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
@@ -4,38 +4,20 @@ from jesse.strategies import Strategy
|
||||
# test_on_route_take_profit part 1 - BTCUSD
|
||||
class Test23(Strategy):
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
# buy on market at first candle, close when on_route_take_profit event is fired
|
||||
return self.index == 0
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 1
|
||||
self.buy = qty, self.price
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def on_route_take_profit(self, strategy):
|
||||
|
||||
@@ -4,35 +4,17 @@ from jesse.strategies import Strategy
|
||||
# test_on_route_take_profit part 2 - ETHUSD
|
||||
class Test24(Strategy):
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.price == 10
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
self.buy = 1, self.price
|
||||
self.take_profit = 1, 20
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
@@ -4,38 +4,20 @@ from jesse.strategies import Strategy
|
||||
# test_on_route_stop_loss part 1 - BTCUSD
|
||||
class Test25(Strategy):
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
# buy on market at first candle, close when on_route_stop_loss event is fired
|
||||
return self.index == 0
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 1
|
||||
self.buy = qty, self.price
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def on_route_stop_loss(self, strategy):
|
||||
|
||||
@@ -4,35 +4,17 @@ from jesse.strategies import Strategy
|
||||
# test_on_route_stop_loss part 2 - ETHUSD
|
||||
class Test26(Strategy):
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.price == 10
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
self.sell = 1, self.price
|
||||
self.stop_loss = 1, 20
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
@@ -4,38 +4,20 @@ from jesse.strategies import Strategy
|
||||
# test_on_route_canceled part 1 - BTCUSD
|
||||
class Test27(Strategy):
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
# buy on market at first candle, close when on_route_stop_loss event is fired
|
||||
return self.index == 0
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 1
|
||||
self.buy = qty, self.price
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def on_route_canceled(self, strategy):
|
||||
|
||||
@@ -4,35 +4,17 @@ from jesse.strategies import Strategy
|
||||
# test_on_route_canceled part 2 - ETHUSD
|
||||
class Test28(Strategy):
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.price == 10
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
# because we know the price is going up, this order will never get filled
|
||||
self.buy = 1, self.price - 10
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.price == 20
|
||||
|
||||
@@ -13,30 +13,16 @@ class Test29(Strategy):
|
||||
self.vars['should_long'] = False
|
||||
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.vars['should_long']
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.vars['should_short']
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
self.buy = 1, self.price
|
||||
self.take_profit = 1, self.price + 10
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
self.sell = 1, self.price
|
||||
self.stop_loss = 1, self.price + 10
|
||||
|
||||
@@ -57,22 +43,12 @@ class Test29(Strategy):
|
||||
self.vars['should_short'] = True
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def on_take_profit(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
self.vars['should_long'] = False
|
||||
self.vars['should_short'] = False
|
||||
|
||||
def on_stop_loss(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
self.vars['should_long'] = False
|
||||
self.vars['should_short'] = False
|
||||
|
||||
@@ -4,9 +4,6 @@ from jesse.strategies import Strategy
|
||||
# test_on_route_increased_position_and_on_route_reduced_position_and_strategy_vars part 2 - ETHUSD
|
||||
class Test30(Strategy):
|
||||
def update_position(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
# increase position size
|
||||
if self.price == 20:
|
||||
self.buy = 1, self.price
|
||||
@@ -20,34 +17,16 @@ class Test30(Strategy):
|
||||
self.take_profit = self.position.qty, self.price
|
||||
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.price == 10
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
self.buy = 1, self.price
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
@@ -4,9 +4,6 @@ from jesse.strategies import Strategy
|
||||
# test_liquidate
|
||||
class Test31(Strategy):
|
||||
def update_position(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
# for long trade (first)
|
||||
if self.index == 10:
|
||||
self.liquidate()
|
||||
@@ -16,34 +13,16 @@ class Test31(Strategy):
|
||||
self.liquidate()
|
||||
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.index == 0
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.index == 20
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
self.buy = 1, self.price
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
self.sell = 1, self.price
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
@@ -12,41 +12,20 @@ class Test32(Strategy):
|
||||
self.shared_vars['buy-eth'] = False
|
||||
|
||||
def prepare(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
if self.index == 10:
|
||||
self.shared_vars['buy-eth'] = True
|
||||
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
@@ -4,35 +4,17 @@ from jesse.strategies import Strategy
|
||||
# test_shared_vars [part 2]
|
||||
class Test33(Strategy):
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.trades_count == 0 and self.shared_vars['buy-eth'] is True
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
self.buy = 1, self.price
|
||||
self.take_profit = 1, self.price + 10
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
@@ -4,23 +4,12 @@ from jesse.strategies import Strategy
|
||||
# test_can_handle_multiple_entry_orders_too_close_to_each_other
|
||||
class Test34(Strategy):
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.index == 0
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
entry = 1
|
||||
self.buy = [
|
||||
(1, entry + 0.1),
|
||||
@@ -32,21 +21,10 @@ class Test34(Strategy):
|
||||
self.take_profit = 4, 3
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def filters(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return []
|
||||
|
||||
@@ -4,24 +4,13 @@ from jesse.strategies import Strategy
|
||||
# test_average_take_profit_and_average_stop_loss
|
||||
class Test36(Strategy):
|
||||
def should_long(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
# filter_1 will pass 0, but not 8
|
||||
return self.index in [0, 8]
|
||||
|
||||
def should_short(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.index == 10
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
entry = self.price
|
||||
self.buy = 2, entry
|
||||
self.take_profit = [
|
||||
@@ -30,9 +19,6 @@ class Test36(Strategy):
|
||||
]
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
entry = self.price
|
||||
self.sell = 2, entry
|
||||
self.stop_loss = [
|
||||
@@ -41,26 +27,14 @@ class Test36(Strategy):
|
||||
]
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return True
|
||||
|
||||
def filters(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return [
|
||||
self.filter_1
|
||||
]
|
||||
|
||||
def filter_1(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
if self.index == 0 and self.average_take_profit == 3.5:
|
||||
return True
|
||||
|
||||
|
||||
@@ -10,56 +10,30 @@ class Test37(Strategy):
|
||||
assert self.stop_loss is None
|
||||
|
||||
def should_long(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.index == 0
|
||||
|
||||
def should_short(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.index == 10
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 1
|
||||
self.buy = qty, self.price
|
||||
self.stop_loss = qty, self.price - .10
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 1
|
||||
self.sell = qty, self.price
|
||||
self.take_profit = qty, self.price + .10
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def filters(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return [
|
||||
self.filter_1
|
||||
]
|
||||
|
||||
def filter_1(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
if self.index == 0:
|
||||
return False
|
||||
|
||||
|
||||
@@ -4,51 +4,25 @@ from jesse.strategies import Strategy
|
||||
# test_average_take_profit_exception
|
||||
class Test38(Strategy):
|
||||
def should_long(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.index == 0
|
||||
|
||||
def should_short(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 1
|
||||
self.buy = qty, 2
|
||||
self.stop_loss = qty, 1
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def filters(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return [self.filter_1]
|
||||
|
||||
def filter_1(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
# trying to access average_take_profit without setting it first
|
||||
return self.average_take_profit > 1
|
||||
|
||||
@@ -4,51 +4,25 @@ from jesse.strategies import Strategy
|
||||
# test_average_stop_loss_exception
|
||||
class Test39(Strategy):
|
||||
def should_long(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.index == 0
|
||||
|
||||
def should_short(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 1
|
||||
self.buy = qty, 2
|
||||
self.take_profit = qty, 10
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def filters(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return [self.filter_1]
|
||||
|
||||
def filter_1(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
# trying to access average_take_profit without setting it first
|
||||
return self.average_stop_loss > 1
|
||||
|
||||
@@ -4,35 +4,17 @@ from jesse.strategies import Strategy
|
||||
# test_open_pl_and_total_open_trades
|
||||
class Test40(Strategy):
|
||||
def should_long(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.index == 0
|
||||
|
||||
def should_short(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 1
|
||||
self.buy = qty, 2
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
@@ -5,43 +5,22 @@ from jesse.strategies import Strategy
|
||||
# test_end
|
||||
class Test41(Strategy):
|
||||
def should_long(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.index == 0
|
||||
|
||||
def should_short(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 1
|
||||
self.buy = qty, 2
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def terminate(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
# log, so we can check this block was executed in the first place
|
||||
logger.info('executed terminate successfully')
|
||||
|
||||
|
||||
@@ -4,23 +4,12 @@ from jesse.strategies import Strategy
|
||||
# test_is_increased
|
||||
class Test42(Strategy):
|
||||
def should_long(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.index == 0
|
||||
|
||||
def should_short(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
self.buy = [
|
||||
(.5, 2),
|
||||
(.5, 4),
|
||||
@@ -31,9 +20,6 @@ class Test42(Strategy):
|
||||
]
|
||||
|
||||
def update_position(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
if self.price < 4 and self.position.qty == .5:
|
||||
assert not self.is_increased
|
||||
assert not self.is_reduced
|
||||
@@ -43,14 +29,7 @@ class Test42(Strategy):
|
||||
assert not self.is_reduced
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
@@ -4,23 +4,12 @@ from jesse.strategies import Strategy
|
||||
# test_is_reduced
|
||||
class Test43(Strategy):
|
||||
def should_long(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.index == 0
|
||||
|
||||
def should_short(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
self.buy = 1, 2
|
||||
self.take_profit = [
|
||||
(.5, 6),
|
||||
@@ -28,9 +17,6 @@ class Test43(Strategy):
|
||||
]
|
||||
|
||||
def update_position(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
if self.position.qty == 1:
|
||||
assert not self.is_increased
|
||||
assert not self.is_reduced
|
||||
@@ -39,14 +25,7 @@ class Test43(Strategy):
|
||||
assert self.is_reduced
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
@@ -4,36 +4,18 @@ from jesse.strategies import Strategy
|
||||
# test_inputs_get_rounded_behind_the_scene
|
||||
class Test44(Strategy):
|
||||
def should_long(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.index == 2
|
||||
|
||||
def should_short(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
self.buy = 1.54, 5.1234
|
||||
self.take_profit = 1.54, 10.1234
|
||||
self.stop_loss = 1.54, 1.1234
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
@@ -4,44 +4,23 @@ from jesse.strategies import Strategy
|
||||
# test_can_close_a_long_position_and_go_short_at_the_same_candle
|
||||
class Test45(Strategy):
|
||||
def should_long(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.index == 0
|
||||
|
||||
def should_short(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.index != 0
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 1
|
||||
self.buy = qty, self.price
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 1
|
||||
self.sell = qty, self.price
|
||||
assert self.index == 1
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def update_position(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
if self.index == 1:
|
||||
self.liquidate()
|
||||
|
||||
@@ -4,42 +4,21 @@ from jesse.strategies import Strategy
|
||||
# test_validation_for_equal_stop_loss_and_take_profit
|
||||
class Test46(Strategy):
|
||||
def should_long(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.index == 0
|
||||
|
||||
def should_short(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
self.buy = 1, 2
|
||||
|
||||
def update_position(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
if self.index == 5:
|
||||
self.stop_loss = 1, 3
|
||||
self.take_profit = 1, 3
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
@@ -4,54 +4,28 @@ from jesse.strategies import Strategy
|
||||
# test_filter_readable_exception
|
||||
class Test47(Strategy):
|
||||
def should_long(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return True
|
||||
|
||||
def should_short(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
qty = 1
|
||||
self.buy = qty, self.price
|
||||
self.stop_loss = qty, self.price - .10
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
def filters(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return [
|
||||
self.filter_1()
|
||||
]
|
||||
|
||||
def filter_1(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
if self.index == 0:
|
||||
return False
|
||||
|
||||
|
||||
@@ -4,38 +4,20 @@ from jesse.strategies import Strategy
|
||||
# test_fee_rate_property
|
||||
class Test48(Strategy):
|
||||
def should_long(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
# default fee for unit tests is set to 0, so:
|
||||
assert self.fee_rate == 0
|
||||
return False
|
||||
|
||||
def should_short(self) -> bool:
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
# default fee for unit tests is set to 0, so:
|
||||
assert self.fee_rate == 0
|
||||
return False
|
||||
|
||||
def go_long(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def go_short(self):
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def should_cancel(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user