Skip to content

Commit 9347ef2

Browse files
committed
Enhance RobinhoodDataReader with configurable base URL and expand documentation
- Made the base URL configurable for testing purposes. - Added detailed options, error handling, and partitioning information to the documentation. - Updated notes to clarify requirements and references for the Robinhood API.
1 parent 6d6c2f9 commit 9347ef2

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

pyspark_datasources/robinhood.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ def __init__(self, schema: StructType, options: Dict[str, str]) -> None:
5353

5454

5555

56-
# Crypto API base URL
57-
self.base_url = "https://trading.robinhood.com"
56+
# Crypto API base URL (configurable for testing)
57+
self.base_url = options.get("base_url", "https://trading.robinhood.com")
5858

5959
def _get_current_timestamp(self) -> int:
6060
"""Get current UTC timestamp."""
@@ -226,15 +226,29 @@ class RobinhoodDataSource(DataSource):
226226
227227
228228
229+
Options
230+
-------
231+
- api_key: string (required) — Robinhood Crypto API key.
232+
- private_key: string (required) — Base64-encoded Ed25519 private key seed.
233+
- base_url: string (optional, default "https://trading.robinhood.com") — Override for sandbox/testing.
234+
235+
Errors
236+
------
237+
- Raises ValueError when required options are missing or private_key is invalid.
238+
- Network/API errors are logged and skipped per symbol; no rows are emitted for failed symbols.
239+
240+
Partitioning
241+
------------
242+
- One partition per requested trading pair (e.g., "BTC-USD,ETH-USD"). Symbols are uppercased and auto-appended with "-USD" if missing pair format.
243+
244+
Arrow
245+
-----
246+
- Rows are yielded directly; Arrow-based batches can be added in future for improved performance.
247+
229248
Notes
230249
-----
231-
- Requires valid Robinhood Crypto API credentials (API key and base64-encoded private key)
232-
- Supports all major cryptocurrencies available on Robinhood
233-
- Implements proper API authentication with NaCl (Sodium) signing
234-
- Rate limiting is handled automatically
235-
- Based on official Robinhood Crypto Trading API documentation
236-
- Requires 'pynacl' library for cryptographic signing: pip install pynacl
237-
- Reference: https://docs.robinhood.com/crypto/trading/
250+
- Requires 'pynacl' for Ed25519 signing: pip install pynacl
251+
- Refer to official Robinhood documentation for authentication details.
238252
"""
239253

240254
@classmethod

0 commit comments

Comments
 (0)