Skip to content

Fix/transfer positions#82

Merged
8ball030 merged 37 commits intomainfrom
fix/transfer_positions
Sep 11, 2025
Merged

Fix/transfer positions#82
8ball030 merged 37 commits intomainfrom
fix/transfer_positions

Conversation

@8ball030
Copy link
Owner

No description provided.

Aviksaikat and others added 30 commits August 27, 2025 23:47
feat: implemented logic for transfer_position & transfer_positions in endpoints.py
chore: bumped derive-action-signing version to latest 0.0.13
…and fix position amount issues

- Modified position_setup fixture to fetch instruments dynamically using the API instead of hardcoding
- Fixed position amount being 0 by using proper order pricing that ensures fills
- Added proper price formatting to meet API requirements (1 decimal place)
- Added comprehensive debugging information to help troubleshoot issues
- Created test_position_setup.py to verify the fixture works correctly
…asnfer back to the original account then close it
…e using only the ETH-Perps & transfer_positions was using TRADE_MODULE instead of RFQ
Comment on lines +904 to +927
def get_position_amount(self, instrument_name: str, subaccount_id: int) -> float:
"""
Get the current position amount for a specific instrument in a subaccount.

This is a helper method for getting position amounts to use with transfer_position().

Parameters:
instrument_name (str): The name of the instrument.
subaccount_id (int): The subaccount ID to check.

Returns:
float: The current position amount.

Raises:
ValueError: If no position found for the instrument in the subaccount.
"""
positions = self.get_positions()
# get_positions() returns a list directly
position_list = positions if isinstance(positions, list) else positions.get("positions", [])
for pos in position_list:
if pos["instrument_name"] == instrument_name:
return float(pos["amount"])

raise ValueError(f"No position found for {instrument_name} in subaccount {subaccount_id}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

if we update the examples, this method can also be removed

@8ball030 8ball030 merged commit 1595cab into main Sep 11, 2025
1 check passed
@8ball030 8ball030 deleted the fix/transfer_positions branch September 11, 2025 22:24
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.

3 participants