Python Pacifica Exchange SDK
Project description
Pacifica SDK
Pacifica SDK is a Python library for interacting with the Pacifica.fi exchange API and WebSocket.
The SDK supports asynchronous requests, convenient order management, account operations, market data retrieval, and real-time data streams.
Installation
pip install pacifica-sdk
Dependencies:
Quick Start
Get Market Information
import asyncio
from pacifica_sdk.async_.info import Info
async def main():
info = Info()
markets = await info.get_market_info()
for market in markets:
print(market.symbol, market.max_leverage)
await info.close()
asyncio.run(main())
Create a Limit Order
import asyncio
from pacifica_sdk.async_.exchange import Exchange
from pacifica_sdk.models.requests import CreateLimitOrder, Side, TIF
PRIVATE_KEY = "YOUR_PRIVATE_KEY"
async def main():
exchange = Exchange(private_key=PRIVATE_KEY)
order = CreateLimitOrder(
symbol="BTCUSDT",
price="30000",
amount="0.01",
side=Side.BID,
tif=TIF.GTC,
)
response = await exchange.create_order(order)
print("Order ID:", response.data.order_id)
await exchange.close()
asyncio.run(main())
Subscribe to Price Stream via WebSocket
import asyncio
from pacifica_sdk.async_.websocket_manager import WebsocketManager
from pacifica_sdk.models.ws_subscribe import WSPricesSubscribe
async def on_prices_update(data):
print("Prices update:", data)
async def main():
ws_manager = WebsocketManager()
params = WSPricesSubscribe()
await ws_manager.subscribe(params, on_prices_update)
await asyncio.sleep(60)
await ws_manager.close()
asyncio.run(main())
Error Handling
The SDK raises custom exceptions:
ApiError— for API errors (4xx)ServerError— for server errors (5xx)
from pacifica_sdk.utils.error import ApiError, ServerError
try:
# Your code here
...
except ApiError as e:
print("API error:", e)
except ServerError as e:
print("Server error:", e)
Package Structure
pacifica_sdk.async_— asynchronous clients (API, Exchange, Info, WebSocket)pacifica_sdk.models— Pydantic models for requests, responses, and streamspacifica_sdk.utils— utilities, error handling, message signingpacifica_sdk.enums— enums for statuses, order types, etc.pacifica_sdk.constants— constants (URLs, etc.)
Documentation
Roadmap / Upcoming Features
The following features are planned for future releases:
-
Trading operations via WebSocket:
Place, modify, and cancel orders in real time using the WebSocket API. -
Comprehensive docstrings:
All public classes and functions will include detailed docstrings for better developer experience and IDE support. -
More usage examples:
The documentation and repository will include more practical code samples for common SDK use cases. -
Price and order size rounding utilities:
Helper functions for correct rounding of prices and order sizes according to market requirements. -
Synchronous client:
(Planned) Support for synchronous (non-async) usage for simpler integration in legacy projects. -
Extensive test coverage:
More unit and integration tests to ensure reliability and stability. -
Type hints and static analysis improvements:
Even stricter type checking and mypy compatibility. -
Logging in all modules:
Consistent and configurable logging will be added across all SDK modules for better debugging and monitoring.
If you have feature requests or suggestions, feel free to open an issue or contact us!
License
MIT License
Contacts
- Telegram: @hedgehog
Pull requests and bug reports are welcome!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pacifica_sdk-0.1.0.tar.gz.
File metadata
- Download URL: pacifica_sdk-0.1.0.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad705c0826359eff2486f03ca22ff3c9f0cb4e7d437b6ccbf4e0d405f066c41c
|
|
| MD5 |
d33a041d1c20073aa71529546431bced
|
|
| BLAKE2b-256 |
0c17369f3adc8b3a343ea84ab6e9f2bbbe40069c39f0dc8169cab865de9bedfc
|
File details
Details for the file pacifica_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pacifica_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c46c733327af5d947a16dbda9da5bfb0b8077550c6715a4478cca1cfd66071aa
|
|
| MD5 |
2b5780dac44e31300abf0a8b97e2015f
|
|
| BLAKE2b-256 |
c257eba48c7739c10cd57b90a85d000d537119e1a0ebd6e0529ee76e976726ec
|