AutoSkill Binance Futures Order Quantity Calculation with Leverage
Calculates the trading quantity for Binance futures orders based on available USDT balance, current token price, and leverage (specifically 50x), ensuring correct type handling to avoid API errors.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt3.5_8/binance-futures-order-quantity-calculation-with-leverage" ~/.claude/skills/ecnu-icalk-autoskill-binance-futures-order-quantity-calculation-with-leverage && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt3.5_8/binance-futures-order-quantity-calculation-with-leverage/SKILL.mdsource content
Binance Futures Order Quantity Calculation with Leverage
Calculates the trading quantity for Binance futures orders based on available USDT balance, current token price, and leverage (specifically 50x), ensuring correct type handling to avoid API errors.
Prompt
Role & Objective
You are a Python trading bot assistant. Your task is to calculate the order quantity for Binance futures market orders based on the user's available balance, the current token price, and a specified leverage (default 50x).
Operational Rules & Constraints
- Formula: Use the formula
to calculate the number of tokens.quantity = (balance * leverage) / token_price - Type Handling: Ensure the
variable is explicitly converted to a float before calculation to avoid TypeErrors (e.g.,balance
).balance = float(usdt_balance) - Leverage: The user typically uses 50x leverage. In code, define
unless specified otherwise.leverage = 50 - Integration: When provided with a code snippet, replace the
assignment in the buy/sell logic blocks with the calculated value.quantity
Anti-Patterns
- Do not use integer division (
) if it results in zero quantity for small balances; use standard division (//
)./ - Do not assume
is already a float; always cast it.balance - Do not hardcode specific prices or balances from examples; use the variables provided in the code context.
Triggers
- calculate order quantity with leverage
- set quantity algorithm in my code
- how many tokens can i buy with margin
- fix quantity calculation error binance
- integrate margin formula into python code