You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dear all,
i am runnig a code set under while loop but its not working as it working under pycharm
the 'symbols': '{\ added every time in previous value of symbol variable
please guide how to fixed it
code i am using
if tnow > '09:14:00' and symbol_list == 0:
print("donelist")
symbol = []
data = {"symbols":"NSE:NIFTY50-INDEX"}
response = fyersh.quotes(data=data)
#print(response)
ltp = response["d"][0].get("v").get("lp")
ltp = int(round(ltp / 50) * 50)
#symbol.clear()
pe_ce_strik_genarator(ltp, s_diff, striks) (function that generat striks)
print(symbol)
symbol = str(symbol)
symbol = symbol.replace(" ",'').replace("'",'').replace("[","").replace("]","")
#%store symbol
print(symbol)
symbol_list = 1
straddle_position = c.execute(f"SELECT value FROM variables WHERE name = 'straddle_position'").fetchone()[0]
#print(straddle_position)
straddle_tp_sl = c.execute(f"SELECT value FROM variables WHERE name = 'straddle_tp_sl'").fetchone()[0]
#print(straddle_tp_sl)
if(straddle_tp_sl == 0 and straddle_position == 0 and tnow > '09:16:00' and tnow < '23:50:00'):
#%store -r symbol
symbol = {"symbols":f"{symbol}"}
print(symbol)
response = fyersh.quotes(data=symbol)
#print(response)
response = response['d']
data = []
#data.clear()
for i in response:
sym = i['v']
op_type = sym["symbol"][-2:]
op_strik = sym["symbol"][-7:-2]
sym['type'] = op_type
sym['strik'] = op_strik
#print(op_strik)
#print(op_type)
#print(sym)
data.append(sym)
df = pd.DataFrame(data)
#print(data)
df['diff'] = df['strik'].apply(diff)
ndf = df.get(["tt", "symbol", "volume", "lp", "type", "strik", "diff"])
ndfs = ndf.sort_values(by=['diff'])
spsd = ndfs.loc[(ndf['diff'] < 20),['strik']]
fsp = int(spsd.iloc[0]['strik'])
#print(ndf)
print(ndfs)
print(fsp)
#cedf = ndf.loc[(ndf['type'] == 'CE') & (ndf['lp'] >90) & (ndf['lp'] < 110), ['strik', 'diff', 'type','lp']]
#cedf = cedf.sort_values(by=['lp'])
#sp_ce = int(cedf.iloc[0]['strik'])
#print(cedf)
#print(sp_ce)
#pedf = ndf.loc[(ndf['type'] == 'PE') & (ndf['lp'] >90) & (ndf['lp'] < 110), ['strik', 'diff', 'type', 'lp']]
#pedf = pedf.sort_values(by=['lp'])
#sp_pe = int(pedf.iloc[0]['strik'])
#print(pedf)
#print(sp_pe)
if fsp > 1 :
ce = f"{exch}:{underline}{YY}{M}{dd}{fsp}{ce}"[-21:]
pe = f"{exch}:{underline}{YY}{M}{dd}{fsp}{pe}"[-21:]
c.execute(f"update variables SET value = '{pe}' where name = 'straddle_pe_strik'")
c.execute(f"update variables SET value = '{ce}' where name = 'straddle_ce_strik'")
sql.commit()
print(ce)
print(pe)
#sell_straddle(lot=lot)
print("selling done")
time.sleep(10) out of cell
donelist
['NSE:NIFTY2450222600CE', 'NSE:NIFTY2450222600PE', 'NSE:NIFTY2450222650CE', 'NSE:NIFTY2450222650PE', 'NSE:NIFTY2450222700CE', 'NSE:NIFTY2450222700PE', 'NSE:NIFTY2450222750CE', 'NSE:NIFTY2450222750PE', 'NSE:NIFTY2450222800CE', 'NSE:NIFTY2450222800PE', 'NSE:NIFTY2450222550CE', 'NSE:NIFTY2450222550PE', 'NSE:NIFTY2450222500CE', 'NSE:NIFTY2450222500PE', 'NSE:NIFTY2450222450CE', 'NSE:NIFTY2450222450PE', 'NSE:NIFTY2450222400CE', 'NSE:NIFTY2450222400PE', 'NSE:NIFTY2450222350CE', 'NSE:NIFTY2450222350PE']
NSE:NIFTY2450222600CE,NSE:NIFTY2450222600PE,NSE:NIFTY2450222650CE,NSE:NIFTY2450222650PE,NSE:NIFTY2450222700CE,NSE:NIFTY2450222700PE,NSE:NIFTY2450222750CE,NSE:NIFTY2450222750PE,NSE:NIFTY2450222800CE,NSE:NIFTY2450222800PE,NSE:NIFTY2450222550CE,NSE:NIFTY2450222550PE,NSE:NIFTY2450222500CE,NSE:NIFTY2450222500PE,NSE:NIFTY2450222450CE,NSE:NIFTY2450222450PE,NSE:NIFTY2450222400CE,NSE:NIFTY2450222400PE,NSE:NIFTY2450222350CE,NSE:NIFTY2450222350PE
{'symbols': 'NSE:NIFTY2450222600CE,NSE:NIFTY2450222600PE,NSE:NIFTY2450222650CE,NSE:NIFTY2450222650PE,NSE:NIFTY2450222700CE,NSE:NIFTY2450222700PE,NSE:NIFTY2450222750CE,NSE:NIFTY2450222750PE,NSE:NIFTY2450222800CE,NSE:NIFTY2450222800PE,NSE:NIFTY2450222550CE,NSE:NIFTY2450222550PE,NSE:NIFTY2450222500CE,NSE:NIFTY2450222500PE,NSE:NIFTY2450222450CE,NSE:NIFTY2450222450PE,NSE:NIFTY2450222400CE,NSE:NIFTY2450222400PE,NSE:NIFTY2450222350CE,NSE:NIFTY2450222350PE'}
tt symbol volume lp type strik diff
2 1714521600 NSE:NIFTY2450222650CE 54390475 74.40 CE 22650 3.60
3 1714521600 NSE:NIFTY2450222650PE 72032975 78.00 PE 22650 3.60
0 1714521600 NSE:NIFTY2450222600CE 53069325 105.00 CE 22600 44.85
1 1714521600 NSE:NIFTY2450222600PE 105136725 60.15 PE 22600 44.85
4 1714521600 NSE:NIFTY2450222700CE 168286825 47.40 CE 22700 54.60
5 1714521600 NSE:NIFTY2450222700PE 156388550 102.00 PE 22700 54.60
10 1714521600 NSE:NIFTY2450222550CE 9891675 140.95 CE 22550 94.95
11 1714521600 NSE:NIFTY2450222550PE 46309350 46.00 PE 22550 94.95
6 1714521600 NSE:NIFTY2450222750CE 140323100 28.00 CE 22750 106.35
7 1714521600 NSE:NIFTY2450222750PE 92238300 134.35 PE 22750 106.35
13 1714521600 NSE:NIFTY2450222500PE 89741425 35.00 PE 22500 140.80
12 1714521600 NSE:NIFTY2450222500CE 17044375 175.80 CE 22500 140.80
9 1714521600 NSE:NIFTY2450222800PE 76818450 170.65 PE 22800 154.65
8 1714521600 NSE:NIFTY2450222800CE 173021475 16.00 CE 22800 154.65
14 1714521600 NSE:NIFTY2450222450CE 1938725 217.95 CE 22450 191.55
15 1714521600 NSE:NIFTY2450222450PE 41362150 26.40 PE 22450 191.55
16 1714521600 NSE:NIFTY2450222400CE 3200325 260.15 CE 22400 240.75
17 1714521600 NSE:NIFTY2450222400PE 58798475 19.40 PE 22400 240.75
18 1714521600 NSE:NIFTY2450222350CE 363075 305.20 CE 22350 291.85
19 1714521600 NSE:NIFTY2450222350PE 33641900 13.35 PE 22350 291.85
22650
NSE:NIFTY2450222650CE
NSE:NIFTY2450222650PE
selling done
{'symbols': "{'symbols': 'NSE:NIFTY2450222600CE,NSE:NIFTY2450222600PE,NSE:NIFTY2450222650CE,NSE:NIFTY2450222650PE,NSE:NIFTY2450222700CE,NSE:NIFTY2450222700PE,NSE:NIFTY2450222750CE,NSE:NIFTY2450222750PE,NSE:NIFTY2450222800CE,NSE:NIFTY2450222800PE,NSE:NIFTY2450222550CE,NSE:NIFTY2450222550PE,NSE:NIFTY2450222500CE,NSE:NIFTY2450222500PE,NSE:NIFTY2450222450CE,NSE:NIFTY2450222450PE,NSE:NIFTY2450222400CE,NSE:NIFTY2450222400PE,NSE:NIFTY2450222350CE,NSE:NIFTY2450222350PE'}"}
'symbol'
{'symbols': '{'symbols': "{'symbols': 'NSE:NIFTY2450222600CE,NSE:NIFTY2450222600PE,NSE:NIFTY2450222650CE,NSE:NIFTY2450222650PE,NSE:NIFTY2450222700CE,NSE:NIFTY2450222700PE,NSE:NIFTY2450222750CE,NSE:NIFTY2450222750PE,NSE:NIFTY2450222800CE,NSE:NIFTY2450222800PE,NSE:NIFTY2450222550CE,NSE:NIFTY2450222550PE,NSE:NIFTY2450222500CE,NSE:NIFTY2450222500PE,NSE:NIFTY2450222450CE,NSE:NIFTY2450222450PE,NSE:NIFTY2450222400CE,NSE:NIFTY2450222400PE,NSE:NIFTY2450222350CE,NSE:NIFTY2450222350PE'}"}'}
'symbol'
{'symbols': '{'symbols': '{\'symbols\': "{\'symbols\': \'NSE:NIFTY2450222600CE,NSE:NIFTY2450222600PE,NSE:NIFTY2450222650CE,NSE:NIFTY2450222650PE,NSE:NIFTY2450222700CE,NSE:NIFTY2450222700PE,NSE:NIFTY2450222750CE,NSE:NIFTY2450222750PE,NSE:NIFTY2450222800CE,NSE:NIFTY2450222800PE,NSE:NIFTY2450222550CE,NSE:NIFTY2450222550PE,NSE:NIFTY2450222500CE,NSE:NIFTY2450222500PE,NSE:NIFTY2450222450CE,NSE:NIFTY2450222450PE,NSE:NIFTY2450222400CE,NSE:NIFTY2450222400PE,NSE:NIFTY2450222350CE,NSE:NIFTY2450222350PE\'}"}'}'}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Dear all,
i am runnig a code set under while loop but its not working as it working under pycharm
the 'symbols': '{\ added every time in previous value of symbol variable
please guide how to fixed it
code i am using
if tnow > '09:14:00' and symbol_list == 0:
print("donelist")
symbol = []
data = {"symbols":"NSE:NIFTY50-INDEX"}
response = fyersh.quotes(data=data)
#print(response)
ltp = response["d"][0].get("v").get("lp")
ltp = int(round(ltp / 50) * 50)
#symbol.clear()
pe_ce_strik_genarator(ltp, s_diff, striks) (function that generat striks)
print(symbol)
symbol = str(symbol)
symbol = symbol.replace(" ",'').replace("'",'').replace("[","").replace("]","")
#%store symbol
print(symbol)
symbol_list = 1
straddle_position = c.execute(f"SELECT value FROM variables WHERE name = 'straddle_position'").fetchone()[0]
#print(straddle_position)
straddle_tp_sl = c.execute(f"SELECT value FROM variables WHERE name = 'straddle_tp_sl'").fetchone()[0]
#print(straddle_tp_sl)
if(straddle_tp_sl == 0 and straddle_position == 0 and tnow > '09:16:00' and tnow < '23:50:00'):
#%store -r symbol
symbol = {"symbols":f"{symbol}"}
print(symbol)
response = fyersh.quotes(data=symbol)
#print(response)
response = response['d']
data = []
#data.clear()
for i in response:
sym = i['v']
op_type = sym["symbol"][-2:]
op_strik = sym["symbol"][-7:-2]
sym['type'] = op_type
sym['strik'] = op_strik
#print(op_strik)
#print(op_type)
#print(sym)
data.append(sym)
df = pd.DataFrame(data)
#print(data)
df['diff'] = df['strik'].apply(diff)
ndf = df.get(["tt", "symbol", "volume", "lp", "type", "strik", "diff"])
ndfs = ndf.sort_values(by=['diff'])
spsd = ndfs.loc[(ndf['diff'] < 20),['strik']]
fsp = int(spsd.iloc[0]['strik'])
#print(ndf)
print(ndfs)
print(fsp)
#cedf = ndf.loc[(ndf['type'] == 'CE') & (ndf['lp'] >90) & (ndf['lp'] < 110), ['strik', 'diff', 'type','lp']]
#cedf = cedf.sort_values(by=['lp'])
#sp_ce = int(cedf.iloc[0]['strik'])
#print(cedf)
#print(sp_ce)
#pedf = ndf.loc[(ndf['type'] == 'PE') & (ndf['lp'] >90) & (ndf['lp'] < 110), ['strik', 'diff', 'type', 'lp']]
#pedf = pedf.sort_values(by=['lp'])
#sp_pe = int(pedf.iloc[0]['strik'])
#print(pedf)
#print(sp_pe)
if fsp > 1 :
ce = f"{exch}:{underline}{YY}{M}{dd}{fsp}{ce}"[-21:]
pe = f"{exch}:{underline}{YY}{M}{dd}{fsp}{pe}"[-21:]
c.execute(f"update variables SET value = '{pe}' where name = 'straddle_pe_strik'")
c.execute(f"update variables SET value = '{ce}' where name = 'straddle_ce_strik'")
sql.commit()
print(ce)
print(pe)
#sell_straddle(lot=lot)
print("selling done")
time.sleep(10)
out of cell
donelist
['NSE:NIFTY2450222600CE', 'NSE:NIFTY2450222600PE', 'NSE:NIFTY2450222650CE', 'NSE:NIFTY2450222650PE', 'NSE:NIFTY2450222700CE', 'NSE:NIFTY2450222700PE', 'NSE:NIFTY2450222750CE', 'NSE:NIFTY2450222750PE', 'NSE:NIFTY2450222800CE', 'NSE:NIFTY2450222800PE', 'NSE:NIFTY2450222550CE', 'NSE:NIFTY2450222550PE', 'NSE:NIFTY2450222500CE', 'NSE:NIFTY2450222500PE', 'NSE:NIFTY2450222450CE', 'NSE:NIFTY2450222450PE', 'NSE:NIFTY2450222400CE', 'NSE:NIFTY2450222400PE', 'NSE:NIFTY2450222350CE', 'NSE:NIFTY2450222350PE']
NSE:NIFTY2450222600CE,NSE:NIFTY2450222600PE,NSE:NIFTY2450222650CE,NSE:NIFTY2450222650PE,NSE:NIFTY2450222700CE,NSE:NIFTY2450222700PE,NSE:NIFTY2450222750CE,NSE:NIFTY2450222750PE,NSE:NIFTY2450222800CE,NSE:NIFTY2450222800PE,NSE:NIFTY2450222550CE,NSE:NIFTY2450222550PE,NSE:NIFTY2450222500CE,NSE:NIFTY2450222500PE,NSE:NIFTY2450222450CE,NSE:NIFTY2450222450PE,NSE:NIFTY2450222400CE,NSE:NIFTY2450222400PE,NSE:NIFTY2450222350CE,NSE:NIFTY2450222350PE
{'symbols': 'NSE:NIFTY2450222600CE,NSE:NIFTY2450222600PE,NSE:NIFTY2450222650CE,NSE:NIFTY2450222650PE,NSE:NIFTY2450222700CE,NSE:NIFTY2450222700PE,NSE:NIFTY2450222750CE,NSE:NIFTY2450222750PE,NSE:NIFTY2450222800CE,NSE:NIFTY2450222800PE,NSE:NIFTY2450222550CE,NSE:NIFTY2450222550PE,NSE:NIFTY2450222500CE,NSE:NIFTY2450222500PE,NSE:NIFTY2450222450CE,NSE:NIFTY2450222450PE,NSE:NIFTY2450222400CE,NSE:NIFTY2450222400PE,NSE:NIFTY2450222350CE,NSE:NIFTY2450222350PE'}
tt symbol volume lp type strik diff
2 1714521600 NSE:NIFTY2450222650CE 54390475 74.40 CE 22650 3.60
3 1714521600 NSE:NIFTY2450222650PE 72032975 78.00 PE 22650 3.60
0 1714521600 NSE:NIFTY2450222600CE 53069325 105.00 CE 22600 44.85
1 1714521600 NSE:NIFTY2450222600PE 105136725 60.15 PE 22600 44.85
4 1714521600 NSE:NIFTY2450222700CE 168286825 47.40 CE 22700 54.60
5 1714521600 NSE:NIFTY2450222700PE 156388550 102.00 PE 22700 54.60
10 1714521600 NSE:NIFTY2450222550CE 9891675 140.95 CE 22550 94.95
11 1714521600 NSE:NIFTY2450222550PE 46309350 46.00 PE 22550 94.95
6 1714521600 NSE:NIFTY2450222750CE 140323100 28.00 CE 22750 106.35
7 1714521600 NSE:NIFTY2450222750PE 92238300 134.35 PE 22750 106.35
13 1714521600 NSE:NIFTY2450222500PE 89741425 35.00 PE 22500 140.80
12 1714521600 NSE:NIFTY2450222500CE 17044375 175.80 CE 22500 140.80
9 1714521600 NSE:NIFTY2450222800PE 76818450 170.65 PE 22800 154.65
8 1714521600 NSE:NIFTY2450222800CE 173021475 16.00 CE 22800 154.65
14 1714521600 NSE:NIFTY2450222450CE 1938725 217.95 CE 22450 191.55
15 1714521600 NSE:NIFTY2450222450PE 41362150 26.40 PE 22450 191.55
16 1714521600 NSE:NIFTY2450222400CE 3200325 260.15 CE 22400 240.75
17 1714521600 NSE:NIFTY2450222400PE 58798475 19.40 PE 22400 240.75
18 1714521600 NSE:NIFTY2450222350CE 363075 305.20 CE 22350 291.85
19 1714521600 NSE:NIFTY2450222350PE 33641900 13.35 PE 22350 291.85
22650
NSE:NIFTY2450222650CE
NSE:NIFTY2450222650PE
selling done
{'symbols': "{'symbols': 'NSE:NIFTY2450222600CE,NSE:NIFTY2450222600PE,NSE:NIFTY2450222650CE,NSE:NIFTY2450222650PE,NSE:NIFTY2450222700CE,NSE:NIFTY2450222700PE,NSE:NIFTY2450222750CE,NSE:NIFTY2450222750PE,NSE:NIFTY2450222800CE,NSE:NIFTY2450222800PE,NSE:NIFTY2450222550CE,NSE:NIFTY2450222550PE,NSE:NIFTY2450222500CE,NSE:NIFTY2450222500PE,NSE:NIFTY2450222450CE,NSE:NIFTY2450222450PE,NSE:NIFTY2450222400CE,NSE:NIFTY2450222400PE,NSE:NIFTY2450222350CE,NSE:NIFTY2450222350PE'}"}
'symbol'
{'symbols': '{'symbols': "{'symbols': 'NSE:NIFTY2450222600CE,NSE:NIFTY2450222600PE,NSE:NIFTY2450222650CE,NSE:NIFTY2450222650PE,NSE:NIFTY2450222700CE,NSE:NIFTY2450222700PE,NSE:NIFTY2450222750CE,NSE:NIFTY2450222750PE,NSE:NIFTY2450222800CE,NSE:NIFTY2450222800PE,NSE:NIFTY2450222550CE,NSE:NIFTY2450222550PE,NSE:NIFTY2450222500CE,NSE:NIFTY2450222500PE,NSE:NIFTY2450222450CE,NSE:NIFTY2450222450PE,NSE:NIFTY2450222400CE,NSE:NIFTY2450222400PE,NSE:NIFTY2450222350CE,NSE:NIFTY2450222350PE'}"}'}
'symbol'
{'symbols': '{'symbols': '{\'symbols\': "{\'symbols\': \'NSE:NIFTY2450222600CE,NSE:NIFTY2450222600PE,NSE:NIFTY2450222650CE,NSE:NIFTY2450222650PE,NSE:NIFTY2450222700CE,NSE:NIFTY2450222700PE,NSE:NIFTY2450222750CE,NSE:NIFTY2450222750PE,NSE:NIFTY2450222800CE,NSE:NIFTY2450222800PE,NSE:NIFTY2450222550CE,NSE:NIFTY2450222550PE,NSE:NIFTY2450222500CE,NSE:NIFTY2450222500PE,NSE:NIFTY2450222450CE,NSE:NIFTY2450222450PE,NSE:NIFTY2450222400CE,NSE:NIFTY2450222400PE,NSE:NIFTY2450222350CE,NSE:NIFTY2450222350PE\'}"}'}'}
Beta Was this translation helpful? Give feedback.
All reactions