alfaaz2011
New Member
Hi All
I am trying to write vba code.. I have a excel with 2 sheets named Current trades and opening position and third sheet i have added just for example of output. I want to create code based on following codition. Can anyone help me...It would be really kind. I generally can read, understand and manupulated the VBA code but lacks in logical coding.
1. if there is new trade "buy" and open position is "Long" then action1 ="Buy" and action2= "Open. For example reliance (2210) -should check in open position and there we have 1 long posiition , so action1 ="Buy" and action2= "Open.
2. if there is new trade "sell" trade and open Position is also "Short", then action1 ="sell" and action2= "Open , Example Wipro (2300") is having 1 "sell" trade and Open postiong is also short, so should be action1 ="sell" and action2= "Open ,
3. if there is new security trade like Tesco 2410 (Sell), - and does not have any open positon it must be action1 ="sell" and action2= "Open and vice versa for APPLE 1564 - for buy security without open postion - action1 ="buy" and action2= "Open ,
4. if there are several new sell trades, and opening position is long and each line of new trade must be subtracted from long position untill get ZERO - for example TCS (2413) is 'having differenct trades let's see first trade row is having 4 units the LONG opening positions are 7 (1+5+1). so mean before opening we gotta close these 7 position first. so we can sell these to close long positions. so this case first row for 4 units action1= "sell", and Action2 = "Close". and next row is having 5 trades and we are left only opening 3 (7-4) and this trade row should be splitted in 2 row something like 3 units with Action1 ="Sell" and Action2 ="Close" and 2 Units with action1 = "Sell" and "Open". Since we are not left with any open positon after this, Rest of the trades should be like Action1=sell and Action2=open
5. if there is buy trade and open position is short, it should be booked on prorata basis, like for IBM ("25000") there are 2 buy trades and one 1 short position in opening position. In this case row must be spliited into 2 -with first row must be 1 unit with action1 =buy and action2=close and other row with 1 unit and action1 =buy and action2 open.
I am trying to write vba code.. I have a excel with 2 sheets named Current trades and opening position and third sheet i have added just for example of output. I want to create code based on following codition. Can anyone help me...It would be really kind. I generally can read, understand and manupulated the VBA code but lacks in logical coding.
1. if there is new trade "buy" and open position is "Long" then action1 ="Buy" and action2= "Open. For example reliance (2210) -should check in open position and there we have 1 long posiition , so action1 ="Buy" and action2= "Open.
2. if there is new trade "sell" trade and open Position is also "Short", then action1 ="sell" and action2= "Open , Example Wipro (2300") is having 1 "sell" trade and Open postiong is also short, so should be action1 ="sell" and action2= "Open ,
3. if there is new security trade like Tesco 2410 (Sell), - and does not have any open positon it must be action1 ="sell" and action2= "Open and vice versa for APPLE 1564 - for buy security without open postion - action1 ="buy" and action2= "Open ,
4. if there are several new sell trades, and opening position is long and each line of new trade must be subtracted from long position untill get ZERO - for example TCS (2413) is 'having differenct trades let's see first trade row is having 4 units the LONG opening positions are 7 (1+5+1). so mean before opening we gotta close these 7 position first. so we can sell these to close long positions. so this case first row for 4 units action1= "sell", and Action2 = "Close". and next row is having 5 trades and we are left only opening 3 (7-4) and this trade row should be splitted in 2 row something like 3 units with Action1 ="Sell" and Action2 ="Close" and 2 Units with action1 = "Sell" and "Open". Since we are not left with any open positon after this, Rest of the trades should be like Action1=sell and Action2=open
5. if there is buy trade and open position is short, it should be booked on prorata basis, like for IBM ("25000") there are 2 buy trades and one 1 short position in opening position. In this case row must be spliited into 2 -with first row must be 1 unit with action1 =buy and action2=close and other row with 1 unit and action1 =buy and action2 open.