issue with placing ROBO order using SmartAPI(stoploass and traget in ANGELONE UI shown is different) – is my payload correct?
-
def place_robo_order(
self,
instrument_list: List[Dict[str, Union[str, int]]],
ticker: str,
buy_sell: str,
prices: List[float],
quantity: int,
exchange: str = 'NSE',
) -> Optional[Dict[str, Union[str, int]]]:
"""Place a robo order."""
ltp: Optional[float] = self.get_ltp(instrument_list, ticker, exchange)
if not ltp:
return None
limit_price = ltp + 1 if buy_sell == 'BUY' else ltp - 1
if buy_sell == "SELL":
stop_loss_price = limit_price * 1.01 # 1% above
else: # BUY
stop_loss_price = limit_price * 0.99 # 1% belowcapital = 5000 quantity, target_price = calculate_quantity(capital, limit_price, stop_loss_price, risk_pct=0.01, rr=2) params: Dict[str, Union[str, int, float]] = { 'variety': 'ROBO', 'tradingsymbol': '{}-EQ'.format(ticker), 'symboltoken': token_lookup(ticker, instrument_list), 'transactiontype': buy_sell, 'exchange': exchange, 'ordertype': 'LIMIT', 'producttype': 'BO', 'price': limit_price, 'duration': 'DAY', 'stoploss': round(stop_loss_price, 1), 'squareoff': round(target_price, 1), 'quantity': quantity, } try: print('Payload of robo order:', params) response = self.smart_api.placeOrder(params) return response except Exception as e: print(e) return None
my stoploss and traget should be point diffence to the buy price or actual price?