Frequently Asked Questions (FAQ)
Frequently Asked Questions (FAQ)
Common questions and answers about BinomoAPI.
Authentication
Q: How do I set up authentication?
A: Use the BinomoAPI.login() method:
login_response = BinomoAPI.login(
"your_email@example.com",
"your_password"
)Q: How long do authentication tokens last?
A: Authentication tokens typically last for 24 hours. The API automatically handles token refresh.
Q: Can I use multiple accounts?
A: Yes, you can create multiple API instances with different credentials:
account1 = BinomoAPI(auth_token1, device_id1)
account2 = BinomoAPI(auth_token2, device_id2)Trading
Q: How do I check my balance?
A: Use the get_balance() method:
balance = await api.get_balance()
print(f"Balance: ${balance.amount}")Q: What’s the minimum trade amount?
A: The minimum trade amount is typically $1.00, but this can vary. Check your account settings.
Q: How do I place a trade?
A: Use place_call_option() or place_put_option():
result = await api.place_call_option(
asset="EUR/USD",
duration_seconds=60,
amount=1.0
)Configuration
Q: How do I enable demo mode?
A: Set demo=True when creating the API instance:
api = BinomoAPI(
auth_token=token,
device_id=device_id,
demo=True
)Q: How do I configure logging?
A: Enable logging during initialization:
api = BinomoAPI(
auth_token=token,
device_id=device_id,
enable_logging=True,
log_level="INFO"
)Q: Where are configuration files stored?
A: Configuration files are stored in:
- Unix/macOS:
~/.config/binomo/ - Windows:
%APPDATA%/binomo/
Error Handling
Q: How do I handle connection errors?
A: Use try/except with specific exceptions:
try:
result = await api.place_call_option(...)
except ConnectionError:
logging.error("Connection failed")Q: What does “insufficient balance” mean?
A: This error occurs when your account balance is too low for the trade:
try:
result = await api.place_call_option(...)
except InsufficientBalanceError:
logging.error("Not enough funds")Q: How do I retry failed operations?
A: Implement retry logic:
async def retry_operation(func, max_retries=3):
for attempt in range(max_retries):
try:
return await func()
except ConnectionError:
if attempt == max_retries - 1:
raise
await asyncio.sleep(1)WebSocket
Q: How do I handle WebSocket disconnections?
A: The API automatically handles reconnections. You can also implement custom handling:
api.ws_client.on_disconnect = handle_disconnectQ: How do I subscribe to price updates?
A: Use WebSocket subscriptions:
async def on_price_update(data):
print(f"New price: {data}")
api.ws_client.on_price_update = on_price_update
await api.ws_client.subscribe(["price_feed"])Q: Can I use multiple WebSocket connections?
A: Yes, but it’s recommended to use a single connection for better performance.
Performance
Q: How do I optimize for high-frequency trading?
A: Use these optimization techniques:
- Enable connection pooling
- Implement caching
- Use WebSocket for real-time data
- Batch operations when possible
Q: What are the rate limits?
A: Rate limits vary by account type. Implement rate limiting:
from BinomoAPI.utils import RateLimiter
limiter = RateLimiter(
max_requests=60,
time_window=60
)Q: How do I handle timeouts?
A: Configure timeout settings:
config = get_config()
config.set("api", "timeout_seconds", 30)Debugging
Q: How do I enable debug logging?
A: Set log level to DEBUG:
import logging
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s - %(levelname)s - %(message)s'
)Q: How do I trace API calls?
A: Enable request tracing:
api = BinomoAPI(
auth_token=token,
device_id=device_id,
enable_logging=True,
log_level="DEBUG"
)Q: Where are log files stored?
A: By default, logs are stored in:
trading.logfor general logserrors.logfor error logs
Security
Q: Is my API key safe?
A: Yes, when following these practices:
- Use environment variables
- Never commit credentials
- Rotate keys regularly
- Use HTTPS only
Q: How do I secure my credentials?
A: Use environment variables or secure storage:
from dotenv import load_dotenv
import os
load_dotenv()
email = os.getenv("BINOMO_EMAIL")
password = os.getenv("BINOMO_PASSWORD")Q: Can I use 2FA with the API?
A: Yes, implement 2FA when available in your account settings.
Device Management
Q: What is a device ID?
A: A unique identifier for your API client. Generate it securely:
import uuid
device_id = str(uuid.uuid4())Q: Can I use the same device ID multiple times?
A: It’s recommended to use unique device IDs for each client.
Q: How do I manage multiple devices?
A: Track device IDs and their associated sessions.
Updates
Q: How do I update the library?
A: Use pip to update:
pip install --upgrade BinomoAPIQ: Will updates break my code?
A: Major version updates may include breaking changes. Follow the Migration Guide.
Q: How do I know what version I’m using?
A: Check the version:
import BinomoAPI
print(BinomoAPI.__version__)Support
Q: Where can I get help?
A: Get support through:
Q: How do I report bugs?
A: Open an issue on GitHub with:
- Bug description
- Reproduction steps
- Expected vs actual behavior
- Code example
Q: How can I contribute?
A: See our Contributing Guide for details on:
- Code contributions
- Documentation
- Bug reports
- Feature requests