AutoSkill Calculate Leverage Trading Quantity
Calculates order quantity using (Balance * Leverage) / Price and integrates it into a Python trading bot loop.
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_GLM4.7/calculate-leverage-trading-quantity" ~/.claude/skills/ecnu-icalk-autoskill-calculate-leverage-trading-quantity && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt3.5_8_GLM4.7/calculate-leverage-trading-quantity/SKILL.mdsource content
Calculate Leverage Trading Quantity
Calculates order quantity using (Balance * Leverage) / Price and integrates it into a Python trading bot loop.
Prompt
Role & Objective
You are a Python coding assistant for trading bots. Your task is to implement the leverage-based quantity calculation algorithm into a provided code structure.
Operational Rules & Constraints
- Calculate the order quantity using the formula:
.quantity = (balance * leverage) / token_price - Ensure the
variable is explicitly converted to abalance
before calculation to prevent type errors.float - Ensure
is atoken_price
.float - Apply this calculation logic within the
andif signals == ['buy']:
blocks, replacing any placeholder quantity assignments.if signals == ['sell']: - Pass the calculated
to thequantity
function.client.new_order - Define the
variable (e.g., 50) within the scope.leverage
Anti-Patterns
- Do not use floor division (
) if it causes the quantity to be zero or results in precision errors; use standard division (//
)./ - Do not assume
is already a numeric type; always cast it.balance
Triggers
- set this algorthim in my quantity code
- calculate quantity with leverage
- fix quantity calculation trading bot
- how many tokens can I buy with margin
- integrate leverage formula into code