Usage
Methods
openPerpTrade
Open a new perpetual trading position using Ranger SOR API.Parameters
Example
closePerpTrade
Close an existing perpetual trading position.Parameters
Example
increasePerpPosition
Increase the size of an existing perpetual position.Parameters
Example
decreasePerpPosition
Decrease the size of an existing perpetual position.Parameters
Example
withdrawBalance
Withdraw available balance from Ranger.Parameters
Example
withdrawCollateral
Withdraw collateral from an existing position.Parameters
Example
Example Implementation
Implementation Details
- Smart Order Router (SOR): Ranger’s SOR optimizes trade execution across multiple venues.
- Multiple Venues: Supports trading across various platforms including Flash, Jupiter, Drift, and Adrena.
- Position Management: Complete toolkit for opening, closing, increasing, and decreasing perpetual positions.
- Collateral Management: Functions for adding and withdrawing collateral from positions.
- Data Access: Comprehensive data access for positions, quotes, trade history, and market metrics.
About Ranger Protocol
Ranger is a protocol designed to provide optimized perpetual trading on Solana. It offers a Smart Order Router (SOR) that routes orders across various trading venues to achieve the best execution. Key features include:- Cross-venue execution: Trade across multiple venues with a single API
- Capital efficiency: Optimize collateral usage across positions
- Low slippage: Smart routing to minimize price impact
- Advanced position management: Sophisticated tools for managing perpetual positions
- Rich market data: Access to funding rates, liquidation data, and other market metrics
Error Handling
Best Practices
-
API Key Management
- Securely store and manage your Ranger API key
- Never expose your API key in client-side code
- Implement proper scoping and permissions for API keys
-
Position Sizing
- Use appropriate position sizes relative to your capital
- Consider market volatility when determining leverage
- Monitor positions regularly to manage risk
-
Collateral Management
- Maintain sufficient collateral to avoid liquidations
- Use the withdrawCollateral function judiciously
- Monitor health factors for positions
-
Error Handling
- Implement robust error handling for all API calls
- Include retry logic for temporary failures
- Monitor transaction status until confirmed
Common Market Symbols
- SOL-PERP
- BTC-PERP
- ETH-PERP
- BONK-PERP
- JTO-PERP
Response Format
Related Functions
getBalance: Check token balancesgetFundingRateArbs: Get funding rate arbitrage opportunitiesgetLiquidationsLatest: Get the latest liquidation eventsgetFundingRatesAccumulated: Get accumulated funding ratesgetBorrowRatesAccumulated: Get accumulated borrow rates