Conversation
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
Karrenbelt
reviewed
Sep 11, 2025
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}") |
Collaborator
There was a problem hiding this comment.
if we update the examples, this method can also be removed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.