/
fgtmenow
/
tb
Обзор
Документация
Войти
/
fgtmenow
/
tb
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
_common/domain/util/PositionCalc.py
20 строк
575 B
Azarev Artem
add base bot sources
25 мар 2025, 20:11
25 мар 2025, 20:11
184b0c6
Код
Авторство
О чём код?
import math from _common.domain.model.Instrument import Instrument def floor_with_precision(quantity, step_size=0.001): factor = 1 / step_size return math.floor(quantity * factor) / factor def calculate_qty(instrument: Instrument, trade_amount: float, close: float) -> float: quantity_raw = trade_amount / close quantity = floor_with_precision(quantity_raw, instrument.qtyStep) if quantity > instrument.maxOrderQty: return instrument.maxOrderQty elif quantity < instrument.minOrderQty: return 0 else: return quantity