
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Python library for the Coinbase Advanced Trade API.
from coinbaseadvanced.client import CoinbaseAdvancedTradeAPIClient
# Creating the client using Clould API Keys.
client = CoinbaseAdvancedTradeAPIClient.from_cloud_api_keys(API_KEY_NAME, PRIVATE_KEY)
# Listing accounts.
accounts_page = client.list_accounts()
print(accounts_page.size)
# Creating a limit order.
order_created = client.create_limit_order(client_order_id="lknalksdj89asdkl", product_id="ALGO-USD", side=Side.BUY, limit_price=".19", base_size=5)
Here is a basic example of how to use the CoinbaseWebSocketClient:
import asyncio
import time
from client_websocket import CoinbaseWebSocketClient
def handle_candle_event(event):
print(f"Received event candle: {event}")
async def main():
api_key = "your-api-key"
private_key = "-----BEGIN EC PRIVATE KEY-----\n\n-----END EC PRIVATE KEY-----"
client = CoinbaseWebSocketClient(api_key, private_key)
client.subscribe(["BTC-EUR"], "candles", callback=handle_candle_event)
while True:
time.sleep(1)
if __name__ == "__main__":
asyncio.run(main())
You can define your own callback functions to handle different types of events. The callback function will receive an event object that you can process as needed.
For each subscription to a market data channel, a separate heartbeat subscription is automatically created. This helps to ensure that the connection remains open and active.
Each subscription runs in a separate thread to ensure that multiple subscriptions can operate concurrently without blocking each other.
Before using this library, it is highly recommended to read the Coinbase API rate limits (https://docs.cdp.coinbase.com/advanced-trade/docs/ws-best-practices/) to understand the constraints and avoid exceeding the limits.
It is also recommended to follow the WebSocket best practices (https://docs.cdp.coinbase.com/advanced-trade/docs/ws-best-practices/) provided by Coinbase for optimal performance and reliability.
If possible, subscribe to one symbol per subscription to help balance the load on the Coinbase server and improve the reliability of your data stream.
pip install coinbaseadvanced
Any and all contributions are welcome! The process is simple:
pip install -r requirements.txt
.python -m unittest -v
.FAQs
Coinbase Advanced Trade API client library.
We found that coinbaseadvanced demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.