Skip to content

[DSLTradingMode] add and migrate TV trading mode for DSL#3277

Open
GuillaumeDSM wants to merge 2 commits intodevfrom
dsl_TM
Open

[DSLTradingMode] add and migrate TV trading mode for DSL#3277
GuillaumeDSM wants to merge 2 commits intodevfrom
dsl_TM

Conversation

@GuillaumeDSM
Copy link
Member

No description provided.

@GuillaumeDSM GuillaumeDSM self-assigned this Feb 27, 2026
@GuillaumeDSM GuillaumeDSM force-pushed the dsl_TM branch 3 times, most recently from 2e62b7d to ad4f484 Compare March 3, 2026 20:11
@GuillaumeDSM GuillaumeDSM marked this pull request as ready for review March 3, 2026 20:13
@GuillaumeDSM GuillaumeDSM requested a review from Herklos as a code owner March 3, 2026 20:13
@GuillaumeDSM GuillaumeDSM changed the title [DSLTradingMode] init [DSLTradingMode] add and migrate TV trading mode for DSL Mar 3, 2026
@GuillaumeDSM GuillaumeDSM force-pushed the dsl_TM branch 2 times, most recently from a8d6a5d to 9a979d5 Compare March 4, 2026 08:50
Copy link
Member

@Herklos Herklos left a comment

Choose a reason for hiding this comment

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

Great implementation 💯

operands = [self._visit_node(operand) for operand in node.elts]
return operator_class(*operands)

if isinstance(node, ast.Dict):
Copy link
Member

Choose a reason for hiding this comment

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

👍

step = self._visit_node(node.step)
return operator_class(lower, upper, step)

if isinstance(node, ast.Raise):
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 +26 to +29
@dataclasses.dataclass
class SymbolDependency(InterpreterDependency):
symbol: str
time_frame: typing.Optional[str] = None
Copy link
Member

Choose a reason for hiding this comment

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

It seems a bit specific, is it the right place for this dataclass?

Copy link
Member Author

Choose a reason for hiding this comment

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

right, i'll move it to trading

return repr(value)


def resove_operator_params(
Copy link
Member

Choose a reason for hiding this comment

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

👍

operator_class.get_parameters.return_value = [param_a]
operator_class.get_name.return_value = "test_op"
operator_class.get_parameters_description.return_value = "1: a [int] - first"
with pytest.raises(commons_errors.InvalidParametersError, match="test_op supports up to 1 parameters"):
Copy link
Member

Choose a reason for hiding this comment

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

👍

input_quantity_ratio: decimal.Decimal


class _OrderFactory:
Copy link
Member

Choose a reason for hiding this comment

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

There are 2 OrderFactory one for create_order operators and one for order operators?

Copy link
Member Author

Choose a reason for hiding this comment

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

it's fixed

return True


class DSLTradingMode(trading_modes.AbstractTradingMode):
Copy link
Member

Choose a reason for hiding this comment

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

Can this trading mode be selected by a user with the profile building UI? If so what happens if the user choose to use it?

Copy link
Member Author

Choose a reason for hiding this comment

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

it will execute the configured DSL script when evaluator will trigger the strategy
image

)


class TestMapOtherParamsToDsl:
Copy link
Member

Choose a reason for hiding this comment

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

Great tests!

Comment on lines -292 to +301
chained_order = personal_data.create_order_instance(
trader=self.exchange_manager.trader,
order_type=order_type,
symbol=main_order.symbol,
current_price=price,
quantity=quantity or main_order.origin_quantity,
price=price,
side=side,
associated_entry_id=main_order.order_id,
reduce_only=reduce_only,
return await personal_data.create_and_register_chained_order_on_base_order(
main_order,
price,
order_type,
side,
quantity=quantity,
allow_bundling=allow_bundling,
tag=tag,
reduce_only=reduce_only,
update_with_triggering_order_fees=update_with_triggering_order_fees
Copy link
Member

Choose a reason for hiding this comment

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

👍

return get_full_context(trading_mode, None, None, symbol, None, None, None, None, None, init_call=init_call)


def get_base_context_from_exchange_manager(exchange_manager, symbol):
Copy link
Member

Choose a reason for hiding this comment

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

Is it used somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, in create_order_operators where a trading mode might not be available

@GuillaumeDSM GuillaumeDSM force-pushed the dsl_TM branch 2 times, most recently from e4a726e to 78cf051 Compare March 4, 2026 17:32
@GuillaumeDSM
Copy link
Member Author

PR is up !

Copy link
Member

@Herklos Herklos 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