π Try ChipaEditor - Our AI-Powered Code Editor
donate in paypal: Paypal.me
help us in patreon: Patreon
π Join us on Discord
Get our services here
Let us create your bot here
Contact us in Telegram
pip install BinomoAPI
git clone https://github.com/yourname/BinomoAPI.git
cd BinomoAPI
pip install -e .
Set up your credentials securely using environment variables:
export BINOMO_EMAIL="your_email@example.com"
export BINOMO_PASSWORD="your_password"
export BINOMO_DEMO_MODE="true" # Use demo account by default
Create a binomo_config.json file (optional):
{
"api": {
"demo_mode": true,
"enable_logging": true,
"log_level": "INFO"
},
"trading": {
"default_asset": "EUR/USD",
"min_trade_amount": 1.0,
"max_trade_amount": 100.0,
"risk_percentage": 2.0
}
}
Hereβs a complete example of making your first trade:
import asyncio
from BinomoAPI import BinomoAPI, AuthenticationError, TradeError
async def main():
try:
# Login to get authentication data
login_response = BinomoAPI.login(
"your_email@example.com",
"your_password"
)
print(f"Login successful! User ID: {login_response.user_id}")
# Initialize API client
async with BinomoAPI(
auth_token=login_response.authtoken,
device_id=login_response.user_id,
demo=True, # Use demo account
enable_logging=True
) as api:
# Check balance
balance = await api.get_balance()
print(f"Demo account balance: ${balance.amount}")
# Place a trade
if balance.amount >= 1.0:
result = await api.place_call_option(
asset="EUR/USD",
duration_seconds=60,
amount=1.0
)
print(f"Trade placed successfully: {result}")
else:
print("Insufficient balance for trading")
except AuthenticationError as e:
print(f"Login failed: {e}")
except TradeError as e:
print(f"Trade failed: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
if __name__ == "__main__":
asyncio.run(main())
The login_response object contains:
authtoken: Authentication token for API callsuser_id: Your unique user identifierThe balance object includes:
amount: Current balance amountcurrency: Currency codeaccount_type: βdemoβ or βrealβTrade results contain:
Remember to always use the demo account first when testing new trading strategies!