Closed AnthonyVince closed 1 year ago
Example:
CryptoPerpetual(id=ETCUSDT-PERP.BINANCE, raw_symbol=ETCUSDT, asset_class=CRYPTOCURRENCY, asset_type=SWAP, quote_currency=USDT, is_inverse=False, price_precision=3, price_increment=0.001, size_precision=2, size_increment=0.01, multiplier=1, lot_size=1, margin_init=0.0500, margin_maint=0.0250, maker_fee=0.0200, taker_fee=0.0180, info={'symbol': 'ETCUSDT', 'pair': 'ETCUSDT', 'contractType': 'PERPETUAL', 'deliveryDate': 4133404800000, 'onboardDate': 1569398400000, 'status': 'TRADING', 'maintMarginPercent': '2.5000', 'requiredMarginPercent': '5.0000', 'baseAsset': 'ETC', 'quoteAsset': 'USDT', 'marginAsset': 'USDT', 'pricePrecision': 3, 'quantityPrecision': 2, 'baseAssetPrecision': 8, 'quotePrecision': 8, 'underlyingType': 'COIN', 'underlyingSubType': [], 'settlePlan': 0, 'triggerProtect': '0.0800', 'liquidationFee': '0.015000', 'marketTakeBound': '0.10', 'filters': [{'filterType': 'PRICE_FILTER', 'minPrice': '0.567', 'maxPrice': '946.547', 'tickSize': '0.001', 'multiplierUp': None, 'multiplierDown': None, 'multiplierDecimal': None, 'avgPriceMins': None, 'minQty': None, 'maxQty': None, 'stepSize': None, 'limit': None, 'maxNumOrders': None, 'notional': None, 'minNotional': None, 'maxNumAlgoOrders': None, 'bidMultiplierUp': None, 'bidMultiplierDown': None, 'askMultiplierUp': None, 'askMultiplierDown': None, 'applyMinToMarket': None, 'maxNotional': None, 'applyMaxToMarket': None, 'maxNumIcebergOrders': None, 'maxPosition': None, 'minTrailingAboveDelta': None, 'maxTrailingAboveDelta': None, 'minTrailingBelowDelta': None, 'maxTrailingBelowDelta': None}, {'filterType': 'LOT_SIZE', 'minPrice': None, 'maxPrice': None, 'tickSize': None, 'multiplierUp': None, 'multiplierDown': None, 'multiplierDecimal': None, 'avgPriceMins': None, 'minQty': '0.01', 'maxQty': '100000', 'stepSize': '0.01', 'limit': None, 'maxNumOrders': None, 'notional': None, 'minNotional': None, 'maxNumAlgoOrders': None, 'bidMultiplierUp': None, 'bidMultiplierDown': None, 'askMultiplierUp': None, 'askMultiplierDown': None, 'applyMinToMarket': None, 'maxNotional': None, 'applyMaxToMarket': None, 'maxNumIcebergOrders': None, 'maxPosition': None, 'minTrailingAboveDelta': None, 'maxTrailingAboveDelta': None, 'minTrailingBelowDelta': None, 'maxTrailingBelowDelta': None}, {'filterType': 'MARKET_LOT_SIZE', 'minPrice': None, 'maxPrice': None, 'tickSize': None, 'multiplierUp': None, 'multiplierDown': None, 'multiplierDecimal': None, 'avgPriceMins': None, 'minQty': '0.01', 'maxQty': '100000', 'stepSize': '0.01', 'limit': None, 'maxNumOrders': None, 'notional': None, 'minNotional': None, 'maxNumAlgoOrders': None, 'bidMultiplierUp': None, 'bidMultiplierDown': None, 'askMultiplierUp': None, 'askMultiplierDown': None, 'applyMinToMarket': None, 'maxNotional': None, 'applyMaxToMarket': None, 'maxNumIcebergOrders': None, 'maxPosition': None, 'minTrailingAboveDelta': None, 'maxTrailingAboveDelta': None, 'minTrailingBelowDelta': None, 'maxTrailingBelowDelta': None}, {'filterType': 'MAX_NUM_ORDERS', 'minPrice': None, 'maxPrice': None, 'tickSize': None, 'multiplierUp': None, 'multiplierDown': None, 'multiplierDecimal': None, 'avgPriceMins': None, 'minQty': None, 'maxQty': None, 'stepSize': None, 'limit': 200, 'maxNumOrders': None, 'notional': None, 'minNotional': None, 'maxNumAlgoOrders': None, 'bidMultiplierUp': None, 'bidMultiplierDown': None, 'askMultiplierUp': None, 'askMultiplierDown': None, 'applyMinToMarket': None, 'maxNotional': None, 'applyMaxToMarket': None, 'maxNumIcebergOrders': None, 'maxPosition': None, 'minTrailingAboveDelta': None, 'maxTrailingAboveDelta': None, 'minTrailingBelowDelta': None, 'maxTrailingBelowDelta': None}, {'filterType': 'MAX_NUM_ALGO_ORDERS', 'minPrice': None, 'maxPrice': None, 'tickSize': None, 'multiplierUp': None, 'multiplierDown': None, 'multiplierDecimal': None, 'avgPriceMins': None, 'minQty': None, 'maxQty': None, 'stepSize': None, 'limit': 10, 'maxNumOrders': None, 'notional': None, 'minNotional': None, 'maxNumAlgoOrders': None, 'bidMultiplierUp': None, 'bidMultiplierDown': None, 'askMultiplierUp': None, 'askMultiplierDown': None, 'applyMinToMarket': None, 'maxNotional': None, 'applyMaxToMarket': None, 'maxNumIcebergOrders': None, 'maxPosition': None, 'minTrailingAboveDelta': None, 'maxTrailingAboveDelta': None, 'minTrailingBelowDelta': None, 'maxTrailingBelowDelta': None}, {'filterType': 'MIN_NOTIONAL', 'minPrice': None, 'maxPrice': None, 'tickSize': None, 'multiplierUp': None, 'multiplierDown': None, 'multiplierDecimal': None, 'avgPriceMins': None, 'minQty': None, 'maxQty': None, 'stepSize': None, 'limit': None, 'maxNumOrders': None, 'notional': '5.0', 'minNotional': None, 'maxNumAlgoOrders': None, 'bidMultiplierUp': None, 'bidMultiplierDown': None, 'askMultiplierUp': None, 'askMultiplierDown': None, 'applyMinToMarket': None, 'maxNotional': None, 'applyMaxToMarket': None, 'maxNumIcebergOrders': None, 'maxPosition': None, 'minTrailingAboveDelta': None, 'maxTrailingAboveDelta': None, 'minTrailingBelowDelta': None, 'maxTrailingBelowDelta': None}, {'filterType': 'PERCENT_PRICE', 'minPrice': None, 'maxPrice': None, 'tickSize': None, 'multiplierUp': '1.1000', 'multiplierDown': '0.9000', 'multiplierDecimal': '4', 'avgPriceMins': None, 'minQty': None, 'maxQty': None, 'stepSize': None, 'limit': None, 'maxNumOrders': None, 'notional': None, 'minNotional': None, 'maxNumAlgoOrders': None, 'bidMultiplierUp': None, 'bidMultiplierDown': None, 'askMultiplierUp': None, 'askMultiplierDown': None, 'applyMinToMarket': None, 'maxNotional': None, 'applyMaxToMarket': None, 'maxNumIcebergOrders': None, 'maxPosition': None, 'minTrailingAboveDelta': None, 'maxTrailingAboveDelta': None, 'minTrailingBelowDelta': None, 'maxTrailingBelowDelta': None}], 'orderTypes': ['LIMIT', 'MARKET', 'STOP', 'STOP_MARKET', 'TAKE_PROFIT', 'TAKE_PROFIT_MARKET', 'TRAILING_STOP_MARKET'], 'timeInForce': ['GTC', 'IOC', 'FOK', 'GTX']})
The solution was to get maxNotionalValue
from the position risk endpoint. So after that we are capped at zero and max notional, and I am ok with that. PR is created for this bug https://github.com/nautechsystems/nautilus_trader/pull/1239 @cjdsellers
Hi @AnthonyVince thanks for the report here!
Thanks for the solution @filipmacek, from what I could see from the Binance API this is the correct way to determine the max notional.
I also went ahead and added instrument min/max notional risk limit checks per order into the RiskEngine
58e80067286c6b69fd1ccf61c93ba6de5be326ef.
Bug Report
Expected Behaviour
The following code should return values in the strategy. Binance pre-trade checks verify orders against the notional. Nautilus Risk engine checs against max_notional (not checked yet)
self.cache.instrument(self.instrument_id).min_notional
self.cache.instrument(self.instrument_id).max_notional
Actual Behaviour
Currently when connecting to Binance testnet for USDt margined perpetuals I get Zero or None.
Steps to Reproduce the Problem
Specifications
nautilus_trader
version: 1.178 with a fix for the GTD Binance enum