Creating a trading system from scratch

How many lines of code you are comfortable with


  • Total voters
    61

VJAY

Well-Known Member
#41
So, the same system in Python. Instructions for use
  1. Unzip the file to a folder
  2. Navigate to this folder in cmd and run the notebook using jupyter notebook. You can also try jupyter lab if you are adventurous
  3. Follow the instructions in the System notebook
  4. Change only the PARAMETERS
I have included only the files for 20 and 21st, you can test it for any dates. So to do a backtest for the last 5 days, you can change the filename in PARAMETERS and save each results in a separate folder. Post in case of any doubts or clarifications
  • Don't get intimidated by a lot of code in the notebook. Most of them redundant and verbose. It's just to show each of the steps we peform
  • Don't try backtest for longer periods. There are easier methods to do it.
Dear UB ,
I today downloaded bhavcopy and placed in traderji folder ant run it giving errors in all cells except in first 2 cells
 

VJAY

Well-Known Member
#45
Can you post screenshot?
Did you changed the parameters especially the ORDER_FILENAME and RESULT_FILENAME. You need to have 2 files. 21st and 23rd
1535077146716.png


1535077171387.png

1535077199909.png

1535077241172.png

1535077269430.png
 
#46
Wow just reading your code ,small code to download files
Python:
import requests, zipfile, io
# to download specific date like 20 aug change cm21AUG2018bhav.csv.zip in link to cm20AUG2018bhav.csv.zip

r = requests.get('https://www.nseindia.com/content/historical/EQUITIES/2018/AUG/cm21AUG2018bhav.csv.zip')

z = zipfile.ZipFile(io.BytesIO(r.content))

z.extractall()

Python:
import requests, zipfile, io
# to download specific date like 20 aug change cm21AUG2018bhav.csv.zip in link to cm20AUG2018bhav.csv.zip

day = '23' ## ENTER DAY IN TWO DIGITS
month = 'AUG' ## ENTER MONTH IN THREE WORDS
year = '2017' ## ENTER THE YEAR HERE

r = requests.get('https://www.nseindia.com/content/historical/EQUITIES/'+year+'/'+month+'/cm'+day+month+year+'bhav.csv.zip')

z = zipfile.ZipFile(io.BytesIO(r.content))

z.extractall()
Bit Sophisticated version of what you have produced.
 

UberMachine

Well-Known Member
#49
How to use that code.. Does't seem dlike a python code.. Where to run?
Actually, it doesn't provide you a way to download files. But if provides a pattern to consistently download files without adjusting dates each time. It must be used with the download file function you have created. More on this in a later tutorial.

And since NSE doesn't allow distribution of their data, I am a bit hesitant to post the code that downloads all files in a single go (for any number of years)
 

VJAY

Well-Known Member
#50

Similar threads