Skip to content

Commit 8594a63

Browse files
committed
fix: resolve linting and code style issues
1 parent 33dbed7 commit 8594a63

File tree

2 files changed

+48
-49
lines changed

2 files changed

+48
-49
lines changed

hyperliquid/info.py

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -614,45 +614,48 @@ def query_perp_deploy_auction_status(self) -> Any:
614614

615615
def historical_orders(self, user: str) -> Any:
616616
"""Retrieve a user's historical orders.
617-
617+
618618
POST /info
619-
619+
620620
Args:
621621
user (str): Onchain address in 42-character hexadecimal format;
622622
e.g. 0x0000000000000000000000000000000000000000.
623-
623+
624624
Returns:
625-
Returns at most 2000 most recent historical orders with their current
625+
Returns at most 2000 most recent historical orders with their current
626626
status and detailed order information.
627627
"""
628628
return self.post("/info", {"type": "historicalOrders", "user": user})
629629

630630
def user_non_funding_ledger_updates(self, user: str, startTime: int, endTime: Optional[int] = None) -> Any:
631631
"""Retrieve non-funding ledger updates for a user.
632-
632+
633633
POST /info
634-
634+
635635
Args:
636636
user (str): Onchain address in 42-character hexadecimal format.
637637
startTime (int): Start time in milliseconds (epoch timestamp).
638638
endTime (Optional[int]): End time in milliseconds (epoch timestamp).
639-
639+
640640
Returns:
641641
Comprehensive ledger updates including deposits, withdrawals, transfers,
642642
liquidations, and other account activities excluding funding payments.
643643
"""
644644
if endTime is not None:
645-
return self.post("/info", {"type": "userNonFundingLedgerUpdates", "user": user, "startTime": startTime, "endTime": endTime})
645+
return self.post(
646+
"/info",
647+
{"type": "userNonFundingLedgerUpdates", "user": user, "startTime": startTime, "endTime": endTime},
648+
)
646649
return self.post("/info", {"type": "userNonFundingLedgerUpdates", "user": user, "startTime": startTime})
647650

648651
def portfolio(self, user: str) -> Any:
649652
"""Retrieve comprehensive portfolio performance data.
650-
653+
651654
POST /info
652-
655+
653656
Args:
654657
user (str): Onchain address in 42-character hexadecimal format.
655-
658+
656659
Returns:
657660
Comprehensive portfolio performance data across different time periods,
658661
including account value history, PnL history, and volume metrics.
@@ -661,13 +664,13 @@ def portfolio(self, user: str) -> Any:
661664

662665
def batch_clearinghouse_states(self, users: List[str], dex: str = "") -> Any:
663666
"""Retrieve perpetuals account summaries for multiple users.
664-
667+
665668
POST /info
666-
669+
667670
Args:
668671
users (List[str]): List of onchain addresses in 42-character hexadecimal format.
669672
dex (str): Perp dex name. Defaults to empty string (first perp dex).
670-
673+
671674
Returns:
672675
Array where each item matches the clearinghouseState schema with fields like
673676
assetPositions, marginSummary, crossMarginSummary, time, and withdrawable.
@@ -676,26 +679,26 @@ def batch_clearinghouse_states(self, users: List[str], dex: str = "") -> Any:
676679

677680
def user_twap_slice_fills(self, user: str) -> Any:
678681
"""Retrieve a user's TWAP slice fills.
679-
682+
680683
POST /info
681-
684+
682685
Args:
683686
user (str): Onchain address in 42-character hexadecimal format.
684-
687+
685688
Returns:
686-
Returns at most 2000 most recent TWAP slice fills with detailed
689+
Returns at most 2000 most recent TWAP slice fills with detailed
687690
execution information.
688691
"""
689692
return self.post("/info", {"type": "userTwapSliceFills", "user": user})
690693

691694
def user_vault_equities(self, user: str) -> Any:
692695
"""Retrieve user's equity positions across all vaults.
693-
696+
694697
POST /info
695-
698+
696699
Args:
697700
user (str): Onchain address in 42-character hexadecimal format.
698-
701+
699702
Returns:
700703
Detailed information about user's equity positions across all vaults
701704
including current values, profit/loss metrics, and withdrawal details.
@@ -704,12 +707,12 @@ def user_vault_equities(self, user: str) -> Any:
704707

705708
def user_role(self, user: str) -> Any:
706709
"""Retrieve the role and account type information for a user.
707-
710+
708711
POST /info
709-
712+
710713
Args:
711714
user (str): Onchain address in 42-character hexadecimal format.
712-
715+
713716
Returns:
714717
Role and account type information including account structure,
715718
permissions, and relationships within the Hyperliquid ecosystem.
@@ -718,12 +721,12 @@ def user_role(self, user: str) -> Any:
718721

719722
def user_rate_limit(self, user: str) -> Any:
720723
"""Retrieve user's API rate limit configuration and usage.
721-
724+
722725
POST /info
723-
726+
724727
Args:
725728
user (str): Onchain address in 42-character hexadecimal format.
726-
729+
727730
Returns:
728731
Detailed information about user's API rate limit configuration
729732
and current usage for managing API usage and avoiding rate limiting.
@@ -732,12 +735,12 @@ def user_rate_limit(self, user: str) -> Any:
732735

733736
def delegator_history(self, user: str) -> Any:
734737
"""Retrieve comprehensive staking history for a user.
735-
738+
736739
POST /info
737-
740+
738741
Args:
739742
user (str): Onchain address in 42-character hexadecimal format.
740-
743+
741744
Returns:
742745
Comprehensive staking history including delegation and undelegation
743746
events with timestamps, transaction hashes, and detailed delta information.

tests/info_test.py

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,7 @@ def test_historical_orders():
152152
def test_user_non_funding_ledger_updates_with_end_time():
153153
info = Info(skip_ws=True, meta=TEST_META, spot_meta=TEST_SPOT_META)
154154
response = info.user_non_funding_ledger_updates(
155-
user="0x2ba553d9f990a3b66b03b2dc0d030dfc1c061036",
156-
startTime=1681923833000,
157-
endTime=1682010233000
155+
user="0x2ba553d9f990a3b66b03b2dc0d030dfc1c061036", startTime=1681923833000, endTime=1682010233000
158156
)
159157
assert isinstance(response, list), "The response should be a list"
160158
for record in response:
@@ -167,8 +165,7 @@ def test_user_non_funding_ledger_updates_with_end_time():
167165
def test_user_non_funding_ledger_updates_without_end_time():
168166
info = Info(skip_ws=True, meta=TEST_META, spot_meta=TEST_SPOT_META)
169167
response = info.user_non_funding_ledger_updates(
170-
user="0x2ba553d9f990a3b66b03b2dc0d030dfc1c061036",
171-
startTime=1681923833000
168+
user="0x2ba553d9f990a3b66b03b2dc0d030dfc1c061036", startTime=1681923833000
172169
)
173170
assert isinstance(response, list), "The response should be a list"
174171

@@ -182,21 +179,18 @@ def test_portfolio():
182179
if len(response) > 0:
183180
# Each item should be a time period with performance data
184181
period_data = response[0]
185-
assert isinstance(period_data, list) and len(period_data) == 2, \
186-
"Each item should be a [period_name, data] pair"
187-
period_name, data = period_data
182+
assert isinstance(period_data, list) and len(period_data) == 2, "Each item should be a [period_name, data] pair"
183+
_, data = period_data
188184
assert isinstance(data, dict), "Period data should be a dictionary"
189-
assert any(key in data for key in ["accountValueHistory", "pnlHistory", "vlm"]), \
190-
"Portfolio should contain performance metrics"
185+
assert any(
186+
key in data for key in ["accountValueHistory", "pnlHistory", "vlm"]
187+
), "Portfolio should contain performance metrics"
191188

192189

193190
@pytest.mark.vcr()
194191
def test_batch_clearinghouse_states():
195192
info = Info(skip_ws=True, meta=TEST_META, spot_meta=TEST_SPOT_META)
196-
users = [
197-
"0x5e9ee1089755c3435139848e47e6635505d5a13a",
198-
"0xb7b6f3cea3f66bf525f5d8f965f6dbf6d9b017b2"
199-
]
193+
users = ["0x5e9ee1089755c3435139848e47e6635505d5a13a", "0xb7b6f3cea3f66bf525f5d8f965f6dbf6d9b017b2"]
200194
# Note: This endpoint may not be available on all Hyperliquid nodes
201195
# It's only available on the official Hyperliquid public API
202196
try:
@@ -207,7 +201,7 @@ def test_batch_clearinghouse_states():
207201
# Each state should have the same structure as clearinghouseState
208202
assert "assetPositions" in state, "Each state should have assetPositions"
209203
assert "marginSummary" in state, "Each state should have marginSummary"
210-
except Exception as e:
204+
except (ConnectionError, TimeoutError, ValueError) as e:
211205
# This is expected if the endpoint is not available
212206
print(f"batch_clearinghouse_states not available: {e}")
213207

@@ -232,8 +226,9 @@ def test_user_vault_equities():
232226
if len(response) > 0:
233227
vault_equity = response[0]
234228
# Check for expected vault equity fields - actual response has vaultAddress instead of vault
235-
assert "vaultAddress" in vault_equity or "vault" in vault_equity, \
236-
"Each vault equity should have a 'vaultAddress' or 'vault' field"
229+
assert (
230+
"vaultAddress" in vault_equity or "vault" in vault_equity
231+
), "Each vault equity should have a 'vaultAddress' or 'vault' field"
237232
assert "equity" in vault_equity, "Each vault equity should have an 'equity' field"
238233

239234

@@ -243,8 +238,9 @@ def test_user_role():
243238
response = info.user_role(user="0x2ba553d9f990a3b66b03b2dc0d030dfc1c061036")
244239
assert isinstance(response, dict), "The response should be a dictionary"
245240
# User role should contain account type and role information
246-
assert "role" in response or "type" in response or "account" in response, \
247-
"Response should contain role or account type information"
241+
assert (
242+
"role" in response or "type" in response or "account" in response
243+
), "Response should contain role or account type information"
248244

249245

250246
@pytest.mark.vcr()

0 commit comments

Comments
 (0)