Conversation
64c469c to
0225be1
Compare
|
It's ready and it works (tested in simulated trading). It catches markets that are closed to expiration and buy the almost won outcome and try to sell it at a better price before market closes |
GuillaumeDSM
left a comment
There was a problem hiding this comment.
love the implementation !
| _triggered_symbol_operator(host), | ||
| _market_expiry_operator(host), |
There was a problem hiding this comment.
can we add tests for those operators please?
| tickers_by_symbol: dict[str, dict], | ||
| ) -> list[type[exchange_operator.ExchangeOperator]]: | ||
|
|
||
| class _TickerOperator(exchange_operator.ExchangeOperator): |
There was a problem hiding this comment.
can we add tests for those operators please?
| import octobot_commons.dsl_interpreter as dsl_interpreter | ||
|
|
||
|
|
||
| class NowMsOperator(dsl_interpreter.CallOperator): |
There was a problem hiding this comment.
can we add tests for this operator please?
| "auto_update": false, | ||
| "avatar": "default_profile.png", | ||
| "complexity": 2, | ||
| "description": "ITM Predictions Market profile: buys in-the-money binary options on predictions markets (e.g. Polymarket) using limit orders with stop loss and take profit.", |
| if not self.exchange_manager.exchange.is_supported_order_type(enums.TraderOrderType.STOP_LOSS): | ||
| if self.exchange_manager.is_trader_simulated: | ||
| logging.get_logger(__name__).warning( | ||
| f"STOP_LOSS orders are not supported on {self.exchange_manager.exchange_name}, " | ||
| f"skipping stop loss creation in simulated mode" | ||
| ) | ||
| return | ||
| self._ensure_supported_order_type(enums.TraderOrderType.STOP_LOSS) |
There was a problem hiding this comment.
why duplicating the code of _ensure_supported_order_type ?
5cf3447 to
edf9c0d
Compare
|
Thanks! It's up |
| @pytest.mark.asyncio | ||
| @pytest.mark.parametrize("operator, field", [ | ||
| ("ticker_close", "close"), | ||
| ("ticker_open", "open"), | ||
| ("ticker_high", "high"), | ||
| ("ticker_low", "low"), | ||
| ("ticker_volume", "baseVolume"), | ||
| ("ticker_last", "last"), | ||
| ]) | ||
| async def test_ticker_operators(interpreter, operator, field): | ||
| assert await interpreter.interprete(f"{operator}('{SYMBOL}')") == TICKERS[SYMBOL][field] | ||
| assert await interpreter.interprete(f"{operator}('ETH/USDT')") == TICKERS["ETH/USDT"][field] | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_ticker_unknown_symbol(interpreter): | ||
| with pytest.raises(octobot_commons.errors.DSLInterpreterError, match="No ticker data"): | ||
| await interpreter.interprete("ticker_close('UNKNOWN/PAIR')") | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_ticker_none_field(): | ||
| tickers_with_none = {SYMBOL: {"close": None}} | ||
| interp = dsl_interpreter.Interpreter( | ||
| dsl_interpreter.get_all_operators() | ||
| + exchange_operators.create_ticker_operators(tickers_with_none) | ||
| ) | ||
| with pytest.raises(octobot_commons.errors.DSLInterpreterError, match="is None"): | ||
| await interp.interprete(f"ticker_close('{SYMBOL}')") |
edf9c0d to
1226314
Compare
|
It's up with the fix on simulated trading |
| self._ensure_supported_order_type(enums.TraderOrderType.STOP_LOSS) | ||
| if not self.exchange_manager.exchange.is_supported_order_type(enums.TraderOrderType.STOP_LOSS): | ||
| raise trading_errors.NotSupportedOrderTypeError( | ||
| f"{enums.TraderOrderType.STOP_LOSS.name} orders are not supported on " | ||
| f"{self.exchange_manager.exchange_name}", | ||
| enums.TraderOrderType.STOP_LOSS, | ||
| ) |
There was a problem hiding this comment.
I think we can simply use self._ensure_supported_order_type(enums.TraderOrderType.STOP_LOSS) here, it does the same thing unless I'm missing something
There was a problem hiding this comment.
Indeed, we have reached the equivalent of this function.
| f"stop_loss_price='{stop_loss_price}')" | ||
| ) | ||
| finally: | ||
| exchange_manager.is_trader_simulated = original_is_trader_simulated |
There was a problem hiding this comment.
I think we can revert it ?
Signed-off-by: Herklos <herklos@drakkar.software>
1226314 to
e2c3d3d
Compare
Requires #3332