Skip to content

[Polymarket] Add ITM profile#3333

Open
Herklos wants to merge 1 commit intodevfrom
feature/add-itm-evaluator
Open

[Polymarket] Add ITM profile#3333
Herklos wants to merge 1 commit intodevfrom
feature/add-itm-evaluator

Conversation

@Herklos
Copy link
Member

@Herklos Herklos commented Mar 23, 2026

Requires #3332

@Herklos Herklos self-assigned this Mar 23, 2026
@Herklos Herklos force-pushed the feature/add-itm-evaluator branch 23 times, most recently from 64c469c to 0225be1 Compare March 24, 2026 22:00
@Herklos Herklos marked this pull request as ready for review March 24, 2026 22:00
@Herklos Herklos requested a review from GuillaumeDSM as a code owner March 24, 2026 22:00
@Herklos
Copy link
Member Author

Herklos commented Mar 24, 2026

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

Copy link
Member

@GuillaumeDSM GuillaumeDSM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love the implementation !

Comment on lines +35 to +36
_triggered_symbol_operator(host),
_market_expiry_operator(host),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add tests for those operators please?

tickers_by_symbol: dict[str, dict],
) -> list[type[exchange_operator.ExchangeOperator]]:

class _TickerOperator(exchange_operator.ExchangeOperator):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add tests for those operators please?

import octobot_commons.dsl_interpreter as dsl_interpreter


class NowMsOperator(dsl_interpreter.CallOperator):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

Comment on lines +314 to +321
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why duplicating the code of _ensure_supported_order_type ?

@Herklos Herklos force-pushed the feature/add-itm-evaluator branch 2 times, most recently from 5cf3447 to edf9c0d Compare March 25, 2026 09:46
@Herklos
Copy link
Member Author

Herklos commented Mar 25, 2026

Thanks! It's up

Comment on lines +52 to +80
@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}')")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Herklos Herklos force-pushed the feature/add-itm-evaluator branch from edf9c0d to 1226314 Compare March 25, 2026 16:01
@Herklos
Copy link
Member Author

Herklos commented Mar 25, 2026

It's up with the fix on simulated trading

Comment on lines +314 to +319
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,
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can revert it ?

Signed-off-by: Herklos <herklos@drakkar.software>
@Herklos Herklos force-pushed the feature/add-itm-evaluator branch from 1226314 to e2c3d3d Compare March 25, 2026 16:18
Copy link
Member

@GuillaumeDSM GuillaumeDSM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants