Creating a trading system from scratch

How many lines of code you are comfortable with


  • Total voters
    61

VJAY

Well-Known Member
Zerodha provides an offline basket order execution so that I can place an order via browser. Since browsers can operate anywhere, you can place orders from any platform.

I currently use google compute for auto placing orders at 9:15:00 even when not available


I run only on Linux :)
Just use any broker who provides you an interface with browser.
Zerodha provides them (Upstox should also provide it but got to check)
Else you need to use an API but API's are costly for retail traders, in my opinion. If you have an extremely well tested scalping strategy, you can use it.
You could run a scheduled task by converting the notebook into a python file (so that you get the output).
For now, just export the notebook as python script to enable this and try it out
Dear UB can you please explain bold part?
 
This might reduce some effort of downloading csv and changing dates
Edit-Forgot Holidays now must work fine
still needs to consider if two holiday are together except SAT,SUN maybe creating local file having holiday dates was less messy
Python:
import os.path
import requests,zipfile,io
import datetime
today = datetime.date.today()
yesterday = today - datetime.timedelta(days = 10)
PREVDAY=yesterday.strftime("%a")

if PREVDAY=='Sun':
    yesterday -= datetime.timedelta(days = 2)

DATE=yesterday.strftime("%d%b%Y").upper()
YEAR=yesterday.strftime("%Y")
MON=yesterday.strftime('%b').upper()

LINK= f"https://www.nseindia.com/content/historical/EQUITIES/{YEAR}/{MON}/cm{DATE}bhav.csv.zip"

print(f'Downloading -{DATE} csv')

r = requests.get(LINK)

if len(r.content)<300:
    print('Yesterday was holiday')
    yesterday -= datetime.timedelta(days = 1)
    DATE=yesterday.strftime("%d%b%Y").upper()
    YEAR=yesterday.strftime("%Y")
    MON=yesterday.strftime('%b').upper()
    LINK=f"https://www.nseindia.com/content/historical/EQUITIES/{YEAR}/{MON}/cm{DATE}bhav.csv.zip"
    r = requests.get(LINK)
    z = zipfile.ZipFile(io.BytesIO(r.content))
    z.extractall(path='C:\\tradingsystem\\data')
    print (f"Check if ORDERFILE {DATE} date is correct, File downloaded")

else:
    z = zipfile.ZipFile(io.BytesIO(r.content))
    z.extractall(path='C:\\tradingsystem\\data')
    print ("File downloaded")

ORDER_FILENAME = f'data/cm{DATE}bhav.csv'
 
Last edited:
This might reduce some effort of downloading csv and changing dates
Python:
import os.path
import requests,zipfile,io
import datetime
today = datetime.date.today()
yesterday = today - datetime.timedelta(days = 1)
DATE=yesterday.strftime("%d%b%Y").upper()
YEAR=yesterday.strftime("%Y")
MON=yesterday.strftime('%b').upper()
LINK= f"https://www.nseindia.com/content/historical/EQUITIES/{YEAR}/{MON}/cm{DATE}bhav.csv.zip"
print(f'Downloading -{DATE} csv')
if os.path.isfile(f"data/cm{DATE}bhav.csv")
    print ("File exists and is readable")
else:
    r = requests.get(LINK)
    z = zipfile.ZipFile(io.BytesIO(r.content))
    z.extractall(path='C:\\tradingsystem\\data')
    print ("File downloaded")

ORDER_FILENAME = f'data/cm{DATE}bhav.csv'
why download yesterday's bhavcopy any specific reason??
And should i change the systemnew orderfile as well..will it work?
 
Last edited:
why download yesterday's bhavcopy any specific reason??
And should i change the systemnew orderfile as well..will it work?
hain
we are using 10oct csv result on 11 oct to trade if i'm correct
so if you use this on 12 it will download 11oct csvo_O
orderfile will have yesterday date in filename if you use this automaticallyo_Oo_O
 
Last edited:
hain
we are using 10oct csv result on 11 oct to trade if i'm correct
so if you use this on 12 it will download 11oct csvo_O
orderfile will have yesterday date in filename if you use this automaticallyo_Oo_O
Got it...it is schedule for tommorrow 9:12 right...
tried it on python works like a charm...hope the scheduler works tomorrow
 

Similar threads