Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions examples/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ async def example_authenticated_endpoints():

# Get lightning deposits (last 5)
deposits = await client.account.get_lightning_deposits(
GetLightningDepositsParams(from_="2022-01-01", limit=5)
GetLightningDepositsParams(from_="1970-01-01T00:00:00.000Z", limit=5)
)
print(f"\n--- Recent Lightning Deposits (Last {len(deposits)}) ---")
for deposit in deposits:
Expand Down Expand Up @@ -136,7 +136,11 @@ async def example_authenticated_endpoints():
try:
print("\n--- Try to open a new cross order ---")
order_params = FuturesCrossOrderLimit(
type="limit", price=1.5, quantity=1, side="b"
type="limit",
price=101000,
quantity=10,
side="s",
client_id="custom-ref-123",
)
new_order = await client.futures.cross.new_order(order_params)
print(f"New order: {new_order}")
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "hatchling.build"
urls = { "Homepage" = "https://github.com/ln-markets/sdk-python", "Repository" = "https://github.com/ln-markets/sdk-python", "Bug Tracker" = "https://github.com/ln-markets/sdk-python/issues" }

name = "lnmarkets-sdk"
version = "0.0.11"
version = "0.0.13"
description = "LN Markets API Python SDK"
readme = "README.md"
license = { text = "MIT" }
Expand Down Expand Up @@ -42,6 +42,8 @@ dev = [
{ include-group = "test" },
"python-dotenv>=1.0.1",
"playwright>=1.40.0",
"faker>=37.12.0",
"faker-crypto>=1.0.1",
]
lint = ["ruff>=0.12.0", "pyright>=1.1.390"]
test = ["pytest", "pytest-asyncio", "pytest-httpx>=0.35.0"]
Expand Down
2 changes: 1 addition & 1 deletion src/lnmarkets_sdk/v3/_internal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async def request(
data = ""
if params_dict:
if method == "GET":
data = f"?{urlencode({k: str(v) for k, v in params_dict.items()})}"
data = f"?{urlencode(params_dict)}"
else:
data = json.dumps(params_dict, separators=(",", ":"))
headers.update({"Content-Type": "application/json"})
Expand Down
2 changes: 1 addition & 1 deletion src/lnmarkets_sdk/v3/_internal/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class BaseConfig:
"""Base configuration for all Pydantic models."""

model_config = ConfigDict(
extra="forbid",
extra="allow",
validate_assignment=True,
str_strip_whitespace=True,
use_enum_values=True,
Expand Down
54 changes: 32 additions & 22 deletions src/lnmarkets_sdk/v3/http/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,40 @@ def __init__(self, config: APIClientConfig | None = None):
Initialize the LN Markets client.

Args:
config: Client configuration. If None, will use environment variables.
config: Client configuration

Example:
>>> from src.lnmarkets_sdk.v3.client import LNMClient
>>> from src.lnmarkets_sdk.v3.types.api.base import APIClientConfig, APIAuthContext
>>>
>>> config = APIClientConfig(
... authentication=APIAuthContext(
... key="your-key",
... secret="your-secret",
... passphrase="your-passphrase",
... ),
... network="mainnet",
... )
>>>
>>> async with LNMClient(config) as client:
... # Get account info
... account = await client.account.get_account()
...
... # Get market ticker
... ticker = await client.futures.get_ticker()
...
... # Place a futures order
... order = await client.futures.isolated.new_trade(params)
```python
from lnmarkets_sdk.v3.http.client import LNMClient, APIClientConfig, APIAuthContext
from lnmarkets_sdk.v3.models.futures_isolated import FuturesOrder

config = APIClientConfig(
authentication=APIAuthContext(
key="your-key",
secret="your-secret",
passphrase="your-passphrase",
),
network="mainnet",
timeout=30,
)

async with LNMClient(config) as client:
# Get account info
account = await client.account.get_account()

# Get market ticker
ticker = await client.futures.get_ticker()

# Place a futures order
params = FuturesOrder(
type="l", # limit order
side="b", # buy
price=100_000,
quantity=1,
leverage=100,
)
order = await client.futures.isolated.new_trade(params)
```
"""
if config is None:
config = APIClientConfig()
Expand Down
Loading
Loading