Learn Algo Trading with Python | Codes | Youtube Series

Thank you Sir !

1 Like

Tagging @Hardik and @Dhan , please look into it.

chaged to 4 days… its close now… but still not giving exact same value… may be -5 or -6 days will work… i tried to change to -5 and -6 options but code is throwing OHCL data error. please suggest.

sir when i check my success order , in order i place one limit order and one stoploss order. i see that in both order , order type is limit. and transaction type is diffrent, one is sell and one is buy. should i do this in code. in stoploss order order type will be limit.

Hi @rahulcse56 ,

Do refer the below code to get the accurate ema:

chart = tsl.get_historical_data('ZYDUSLIFE', 'NSE', '5') 
chart['ema'] = chart['close'].ewm(span=200, adjust=False).mean()
chart.to_csv("ema.csv")

Here’s the screenshot of the output:

Hi @Ganesh ,

We are unable to fully understand your query, but at a high level, you can place orders via an algo in the same way you do manually.

@Tradehull_Imran sir,

after using code base3.1, getting following error-

Codebase Version 2.8 : Solved - Strike Selection Issue
-----Logged into Dhan-----
reading existing file all_instrument 2025-02-11.csv
Got the instrument file
Getting Error at Option Chain as '<' not supported between instances of 'int' and 'str'
Empty DataFrame
Columns: []
Index: []

@Tradehull_Imran sir,

In the source folder I am getting old CSV file and when I am running the file getting in the console that data reading from current_day.CSV file.
But there no current_day.CSV generated in source folder

Although not creating any issue.

As you mentioned now we are not creating .csv file for data read

I am thinking in defination file due existing console it is showing

Let me check that I will let you know my feedback

Thank you sir :pray: :blush:

@Tradehull_Imran SIR,

also got error in the running algo, after using new Dhan_Tradehull_V2 from code base 3.1… unabel to fetch ltp of atm strikes

Codebase Version 2.8 : Solved - Strike Selection Issue
-----Logged into Dhan-----
reading existing file all_instrument 2025-02-12.csv
Got the instrument file
[2025-02-12 09:21:15] Fetched NIFTY data
[2025-02-12 09:21:15] NIFTY Open Price at 9:15 AM: 23050.8
............
........
exception got in ce_pe_option_df '<' not supported between instances of 'int' and 'str'
[2025-02-12 09:21:15] Selected ATM Strikes - CE: None, PE: None
Exception in Getting OHLC data as 'NoneType' object has no attribute 'upper'
Exception in Getting OHLC data as 'NoneType' object has no attribute 'upper'
[2025-02-12 09:21:15] Error: No data for options.

pls solve this issue…

have a nice day

Simple I want to place stop loss order by algo. My algo code is given and also error too. When I placing stoploss order what will market type . GIVE A SAMPLE CODE FOR STOPLOSS ORDER AFTER A SUCCESSFUL LIMIT ORDER.

@Tradehull_Imran Just wanted to check on hosting the script on server. any idea, how to do it?

@Tradehull_Imran

tsl.get_historical_data('NIFTY FEB FUT', 'NFO', "5")
tsl.get_historical_data('BANKNIFTY FEB FUT', 'NFO’ "5")
tsl.get_historical_data('FINNIFTY FEB FUT', 'NFO', "5")
tsl.get_historical_data('MIDCPNIFTY FEB FUT', 'NFO', "5")
tsl.get_historical_data('SENSEX FEB FUT', 'BFO', "5")
tsl.get_historical_data('BANKEX FEB FUT', 'BFO', "5")

Can you confirm whether above ones are correct, please? :crossed_fingers:

@Rajashekhar_Rangappa Sir
Try this

tsl.get_historical_data(tradingsymbol='NIFTY FEB FUT',tradingsymbol='NFO',timeframe= "5")
tsl.get_historical_data(tradingsymbol='BANKNIFTY FEB FUT',tradingsymbol='NFO',timeframe= "5")
tsl.get_historical_data(tradingsymbol='FINNIFTY FEB FUT',tradingsymbol='NFO',timeframe= "5")
tsl.get_historical_data(tradingsymbol='MIDCPNIFTY FEB FUT', tradingsymbol='NFO',timeframe= "5")
tsl.get_historical_data(tradingsymbol='SENSEX FEB FUT', tradingsymbol='BFO', timeframe="5")
tsl.get_historical_data(tradingsymbol='BANKEX FEB FUT', tradingsymbol='BFO',timeframe= "5")
3 Likes

@Rajashekhar_Rangappa G
@Tradehull_Imran Sir ne jo padhaya hai uske hisab se to incorrect lagta hai

sir please provide CCI indicator code.

@s_nandi G
Use this

chart_5['cci'] = talib.CCI(chart_5['high'], chart_5['low'], chart_5['close'], timeperiod=14)

2 Likes

i want live cci data in daily chart. can it possible using this code

Hi @anandc ,

There seems to be no issue in getting the option chain:

To get the option chain refer the below code:

option_chain = tsl.get_option_chain(Underlying="NIFTY", exchange="INDEX", expiry=0, num_strikes=10)
1 Like

@s_nandi G

chart        = tsl.get_historical_data(tradingsymbol='NIFTY',exchange='INDEX', timeframe="DAY")
chart['cci'] = talib.CCI(chart['high'], chart['low'], chart['close'], timeperiod=14)

1 Like

there seems to be no issue while fetching the historical data as well.

To fetch the historical data use the below code:

data = tsl.get_historical_data('NIFTY', 'INDEX', '5')

If still you are facing any issues send us your complete code .