Skip to content
This repository was archived by the owner on Feb 21, 2026. It is now read-only.

[IndexTrading] Fix futures trading#1695

Merged
Herklos merged 2 commits intodevfrom
fix/futures-profile-copy-trading
Jan 30, 2026
Merged

[IndexTrading] Fix futures trading#1695
Herklos merged 2 commits intodevfrom
fix/futures-profile-copy-trading

Conversation

@Herklos
Copy link
Copy Markdown
Member

@Herklos Herklos commented Jan 29, 2026

No description provided.

@Herklos Herklos requested a review from GuillaumeDSM January 29, 2026 22:17
@Herklos Herklos self-assigned this Jan 29, 2026
@Herklos Herklos force-pushed the fix/futures-profile-copy-trading branch 2 times, most recently from b6ae4b3 to 3a6530b Compare January 29, 2026 22:55
@@ -1,5 +1,5 @@
{
"version": "1.0.0",
"version": "1.2.0",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

Comment on lines +361 to +413
async def _wait_for_positions_init(self, timeout) -> bool:
"""
Wait for positions to be initialized for futures/options trading.
This ensures that existing positions are loaded from the exchange before
calculating holdings ratios.
"""
if not (self.exchange_manager.is_future or self.exchange_manager.is_option):
return True
try:
full_symbols = self._get_full_traded_pairs()
if full_symbols:
self.logger.debug(
f"Waiting for positions initialization for symbols: {full_symbols}"
)
await trading_util.wait_for_topic_init(
self.exchange_manager, timeout,
commons_enums.InitializationEventExchangeTopics.POSITIONS.value,
symbols=full_symbols
)
self.logger.debug("Positions initialization completed")
return True
except (asyncio.TimeoutError,):
self.logger.warning(
f"Positions initialization took more than {timeout} seconds. "
f"Existing positions might not be reflected in holdings calculations."
)
return False

async def _wait_for_orders_init(self, timeout) -> bool:
"""
Wait for orders to be initialized.
This ensures that existing open orders are loaded from the exchange before
calculating holdings ratios.
"""
try:
full_symbols = self._get_full_traded_pairs()
if full_symbols:
self.logger.debug(
f"Waiting for orders initialization for symbols: {full_symbols}"
)
await trading_util.wait_for_topic_init(
self.exchange_manager, timeout,
commons_enums.InitializationEventExchangeTopics.ORDERS.value,
symbols=full_symbols
)
self.logger.debug("Orders initialization completed")
return True
except (asyncio.TimeoutError,):
self.logger.warning(
f"Orders initialization took more than {timeout} seconds. "
f"Existing open orders might not be reflected in holdings calculations."
)
return False
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should factorize those calls

commons_enums.InitializationEventExchangeTopics.ORDERS.value,
symbols=full_symbols
)
self.logger.debug("Orders initialization completed")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should we log everytime we execute this ? I understand it will be called everytime the index producer triggers

@Herklos Herklos force-pushed the fix/futures-profile-copy-trading branch from 3a6530b to 9f65d85 Compare January 30, 2026 08:32
@Herklos
Copy link
Copy Markdown
Member Author

Herklos commented Jan 30, 2026

Right, it's up

Comment on lines +369 to +371
self.logger.debug(
f"Waiting for {topic_name} initialization for symbols: {full_symbols}"
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should also remove this log, to avoid spamming

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Right, it's up

@Herklos Herklos force-pushed the fix/futures-profile-copy-trading branch from 9f65d85 to 661f30e Compare January 30, 2026 08:38
@Herklos Herklos enabled auto-merge (rebase) January 30, 2026 08:39
@Herklos Herklos merged commit 5746996 into dev Jan 30, 2026
4 checks passed
@Herklos Herklos deleted the fix/futures-profile-copy-trading branch January 30, 2026 08:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants