Creating a trading system from scratch

How many lines of code you are comfortable with


  • Total voters
    61

UberMachine

Well-Known Member
Dear UB,
Today just played with your code for getting daily profit and open-high profits ...i got daily profit...also I got daily open-high figure but one error showing on it...can you please give solution for this error?
View attachment 28803
This is just a warning.
Put orders.tail() in one line and the other code in next line and the warning would go away
View attachment 28752
This is todays 3 scrip output...here all are banking stocks so i want to skip 2 and will check next scrips using 5 scrips in system ...now I get these scrips in order file
View attachment 28754
So I use HDFC,SUNPHARMA & Maruthi...but when using like this its alocationgoes like for 5 scrips I want only 3 scrips and correct alocation like which I get when using 3 scrips system....need to manully remove scrips which is from same sector but alocation not change
We must adjust all our entries before allocation so that allocation is automatically made.
To diversify among sectors
  1. Create a sectors file with symbol and sectors
  2. Now we pick the top from each sector and then leave out the next
 

VJAY

Well-Known Member
This is just a warning.
Put orders.tail() in one line and the other code in next line and the warning would go away


We must adjust all our entries before allocation so that allocation is automatically made.
To diversify among sectors
  1. Create a sectors file with symbol and sectors
  2. Now we pick the top from each sector and then leave out the next
Dear UB,
Am not getting what you said (marked in bold)....I think you not getting what my problem ...eg...I trade in 3 scrips....when I run system file I get top 3 scrips and its orders in CSV for NEST....but when these scrips are from same sector ....then I use 5scrips in system and run again ..now I get 5 top scrips ...i pick or place orders ticking 3 scrips only ....but now alocation goes wrong as system take it as 5 scrip and given orders as per 5scrip alocation ...where I want only 3 scrips and fully alocated in 3 scrips...hope you got my point,,,,

Ok now if creating sectors in file then we need to run every sector and manually pick each one from each sector? I think its time consuming and error creating work as alocation all things do manually in each sector????!!!!Or am missing something?:confusedd::confusedd::confusedd::confusedd:
 

UberMachine

Well-Known Member
Dear UB,
Am not getting what you said (marked in bold)....I think you not getting what my problem ...eg...I trade in 3 scrips....when I run system file I get top 3 scrips and its orders in CSV for NEST....but when these scrips are from same sector ....then I use 5scrips in system and run again ..now I get 5 top scrips ...i pick or place orders ticking 3 scrips only ....but now alocation goes wrong as system take it as 5 scrip and given orders as per 5scrip alocation ...where I want only 3 scrips and fully alocated in 3 scrips...hope you got my point,,,,

Ok now if creating sectors in file then we need to run every sector and manually pick each one from each sector? I think its time consuming and error creating work as alocation all things do manually in each sector????!!!!Or am missing something?:confusedd::confusedd::confusedd::confusedd:
Say, we run the script and 3 stocks show up with 2 banking stocks. We run for 5 and remove the 2 but allocations get changed. The system doesn't no how many stocks we are going to remove so it allocates based on result. What you need is allocation for 3 stocks only.
Let's do with an example

Capital = 30000, 3 stocks , 10000 each.
2 of them in banking so we run 5 stocks and remove the 2
But allocation is now made for 30000, 5 stocks, 6000 each.

If we create a sectors file, then the system would automatically remove stocks if they are from the same sector no need to change manually daily. This is permanent solution.

Now for a quick fix.
We save the orders file intermediately, open and delete the stocks and then continue with it. To do this
Before pricing logic goes here caption, add this line
Python:
orders.to_csv('temporary_order_file.csv')
After it, add this line
Python:
orders = pd.read_csv('temporary_order_file.csv')
num_stock = len(orders)
Create a copy of the notebook before doing this
 

VJAY

Well-Known Member
Say, we run the script and 3 stocks show up with 2 banking stocks. We run for 5 and remove the 2 but allocations get changed. The system doesn't no how many stocks we are going to remove so it allocates based on result. What you need is allocation for 3 stocks only.
Let's do with an example

Capital = 30000, 3 stocks , 10000 each.
2 of them in banking so we run 5 stocks and remove the 2
But allocation is now made for 30000, 5 stocks, 6000 each.

If we create a sectors file, then the system would automatically remove stocks if they are from the same sector no need to change manually daily. This is permanent solution.

Now for a quick fix.
We save the orders file intermediately, open and delete the stocks and then continue with it. To do this
Before pricing logic goes here caption, add this line
Python:
orders.to_csv('temporary_order_file.csv')
After it, add this line
Python:
orders = pd.read_csv('temporary_order_file.csv')
num_stock = len(orders)
Create a copy of the notebook before doing this
Ok I made one sectorial file ...now where I put this file?
 

Similar threads