def custom_message(msg) :
#print("...new msg...")
script = msg[0]['symbol']
ltp = msg[0]['ltp']
high = msg[0]['high_price']
low = msg[0]['low_price']
ltt = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(msg[0]['timestamp']))
print(f"Script: {script}, Ltp:{ltp}, High:{high}, Low:{low}, Ltt:{ltt}")
time.sleep()
def signal (script,ltp,high,low,ltt):
if (ltp = high) and (script not in open_position) and (ltt[-8:] < "15:10:00"):
open_position.append(script)
placeOrder("BUY",script,ltp)
def placeOrder(order, script, ltp):
if order == "BUY":
quantity = int(10)
target_price = int(ltp*0.02)
stoploss_price = int(ltp*0.01)
order = fyers.place_order(data={"symbol":script,"qty":quantity,"type":2,"side":1,"productType":"BO","limitPrice":0,"stopPrice":0,"disclosedQty":0,"validity":"DAY","offlineOrder":"False","stopLoss":stoploss_price,"takeProfit":target_price})
print(f"Buy Order Pleaced for {script}, at Price: {ltp} for Quantity: {quantity},with order_id:{order['id']} at time: {getTime()}")
print(open_position)
else:
quantity = int(10)
target_price = int(ltp*0.02)
stoploss_price = int(ltp*0.01)
order = fyers.place_order(data={"symbol":script,"qty":quantity,"type":2,"side":-1,"productType":"BO","limitPrice":0,"stopPrice":0,"disclosedQty":0,"validity":"DAY","offlineOrder":"False","stopLoss":stoploss_price,"takeProfit":target_price})
print(f"Sell Order Pleaced for {script}, at Price: {ltp} for Quantity: {quantity},with order_id:{order['id']} at time: {getTime()}")
print(open_position)
Hi @akOMEaqfAb ,
Before placing the order , can you check that signal is generating or not for your algo.
You can just print statement for it. Is your code coming on that line or not
If yes it is coming then try place outside of the this code , with same parameters if any parameters error comes then resolve it .
Hope it will help.
Thanks
Hello @akOMEaqfAb
Check for typecasting while assigning. I was also facing the same error but after proper typecasting, it’s working now.
You can take the reference below.
data = {
"symbol": EntrySymbol,
"qty": int(quantity),
"type": int(TypeOfOrder),
"side": int(act_order_side),
"productType": product_type,
"limitPrice": float(limit_Price),
"stopPrice": float(stop_Price),
"validity": validity,
"disclosedQty":0,
"offlineOrder":False,
"stopLoss": float(stop_Loss),
"takeProfit":float(take_profit),
}
print(data)
response = [fyers.place](http://fyers.place)_order(data = data)
print(response)
it is working now thanks for support