Official Python SDK for STRIGIVAL Trading Strategies Marketplace
Project description
STRIGIVAL Python SDK
Official Python SDK for the STRIGIVAL Trading Strategies Marketplace.
Installation
pip install strigival
Quick Start
from strigival import StrigivalClient, Protocol, TradeAction
# Initialize client
client = StrigivalClient(
api_url="https://api.strigival.com",
private_key="0x..." # Your private key
)
# List available strategies
strategies = client.list_strategies(sort_by="sharpe", limit=10)
for strategy in strategies:
print(f"{strategy['name']}: Sharpe {strategy['sharpe_ratio']}")
# Get a quote for a swap
quote = client.get_quote(
vault_address="0x...",
token_in="0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", # USDC
token_out="0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", # WETH
amount=1000_000000, # 1000 USDC (6 decimals)
protocol=Protocol.UNISWAP_V3,
slippage_bps=50, # 0.5%
)
print(f"Quote: {quote.amount_out} WETH")
print(f"Price impact: {quote.price_impact_bps} bps")
print(f"Gas cost: ${quote.gas_cost_usd}")
# Execute the trade
trade = client.execute_trade(quote, vault_address="0x...")
print(f"Trade executed: {trade.tx_hash}")
Features
- Authentication: Web3 signature-based authentication
- Quotes: Get real-time quotes from multiple protocols
- Trading: Execute trades via your vault
- Analytics: Access institutional-grade KPIs
- History: Query trade history and performance
API Reference
StrigivalClient
client = StrigivalClient(
api_url: str, # API base URL
private_key: str, # Ethereum private key
timeout: float = 30.0, # Request timeout
)
Methods
Quotes
# Get a quote
quote = client.get_quote(
vault_address: str,
token_in: str,
token_out: str,
amount: int,
protocol: Protocol = Protocol.UNISWAP_V3,
action: TradeAction = TradeAction.SWAP,
slippage_bps: int = 50,
)
# List supported protocols
protocols = client.get_protocols()
Trading
# Execute a trade
trade = client.execute_trade(quote, vault_address)
# Get trade history
history = client.get_trade_history(vault_address, limit=50)
# Get trade details
trade = client.get_trade(vault_address, tx_hash)
Vault
# Get vault status
status = client.get_vault_status(vault_address)
# Get authorized tokens
tokens = client.get_authorized_tokens(vault_address)
Analytics
# Get all KPIs
kpis = client.get_kpis(vault_address)
print(f"Sharpe: {kpis.sharpe_ratio}")
print(f"Max DD: {kpis.drawdown.max_drawdown}")
# Get Sharpe ratio
sharpe = client.get_sharpe_ratio(vault_address, period_days=365)
Types
Quote
@dataclass
class Quote:
quote_id: str
expires_at: datetime
amount_in: int
amount_out: int
amount_out_min: int
price: float
price_impact_bps: int
estimated_gas: int
gas_price_gwei: float
gas_cost_usd: float
protocol: str
route: List[str]
Trade
@dataclass
class Trade:
tx_hash: str
success: bool
gas_used: Optional[int]
amount_in: Optional[int]
amount_out: Optional[int]
slippage_actual_bps: Optional[int]
error: Optional[str]
KPIs
@dataclass
class KPIs:
sharpe_ratio: float
sortino_ratio: float
calmar_ratio: float
volatility_annual: float
drawdown: DrawdownInfo
win_rate: WinRateInfo
alpha: float
beta: float
Error Handling
from strigival import (
StrigivalError,
AuthenticationError,
QuoteError,
TradeError,
RateLimitError,
)
try:
quote = client.get_quote(...)
except RateLimitError as e:
print(f"Rate limited, retry after {e.retry_after}s")
except QuoteError as e:
print(f"Quote failed: {e.message}")
except StrigivalError as e:
print(f"Error [{e.code}]: {e.message}")
License
Proprietary License - see LICENSE file for details.
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
strigival-1.0.2.tar.gz
(20.3 kB
view details)
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
strigival-1.0.2-py3-none-any.whl
(18.5 kB
view details)
File details
Details for the file strigival-1.0.2.tar.gz.
File metadata
- Download URL: strigival-1.0.2.tar.gz
- Upload date:
- Size: 20.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fcaecf65dd5d436c63e0a3e61c7db3bb557865fefecac0e42767133f3918d593
|
|
| MD5 |
1ceeee300675b2317d138337359b6e61
|
|
| BLAKE2b-256 |
c8ae3c6450972f5e86adabb2cd102c03e074dbef77732d4d4bacda0e9f9f6c25
|
File details
Details for the file strigival-1.0.2-py3-none-any.whl.
File metadata
- Download URL: strigival-1.0.2-py3-none-any.whl
- Upload date:
- Size: 18.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6af5f263e65448827e34d842b620ec76636b4c93cd7511135d7b8df6f64911a
|
|
| MD5 |
8dc73e458b16ef4e200173e200e79e0f
|
|
| BLAKE2b-256 |
d2a129e692294b28b0c299b9697b85e78202f5ff24482a7a4daa34586434a6a5
|