Hi,
I need some help with perl code for the below:
Input data:
$Date,$Mod_Time,$Index,$Date_Inst,$Time_Inst,$Reason,$In,$Phase,$Type,$BuyorSell,$Size,$Price
20100611 090009.870000 2 20100611 85954 5 Tes C L -1 16 43.85
20100611 090009.870000 2 20100611 90009 4 Tes C L 1 16 3.85
20100611 090011.630000 2 20100611 85954 4 ASD C L -1 461 23.85
20100611 090012.630000 2 20100611 90011 24 ASD C L -1 800 43.858
20100611 090020.630000 2 20100611 90011 14 Tes C M 1 461 43.85
20100611 090027.770000 2 20100611 85959 4 ASD C L 1 198 13.715
Output required:
I want to calculate the net buy or sell from the above data in every 10 secs interval.The column BuyorSell is -1 for sell and +1 for a buy.
For example in the 1st 2 rows of input data we could say that the net buy_sell was =(-1+1)=0;
So i want to group my data in 10 sec interval and in those 10 sec intervals I want to calculate whether there was a net sell or buy
The output should be something like this:
Time NetBuy/Sell
90000-90010 0
90010-90020 -2
90020-90030 +2
SO it means:
Time NetBuy/Sell
90000-90010 Neither sell nor buy
90010-90020 Net Sell
90020-90030 Net Buy
This is what I am trying:
open(IN)
open(OUT)
while($line=<IN>)
{ chomp ($line);
($Date,$Mod_Time,$Precision,$Date_Inst,$Time_Inst,$Reason,$In,$Phase,$Type,$BuyorSell,$Size,$Price)= split(/ /,$line);
$time = "090000";
until($time == "173001")
{
if($Mod_Time>$time && $Mod_Time< ($time+10))
{
#calculate the net buy_sell->I dont know how to calculate this!
}
$time = $time+10;
}
}
I have no clue how to calculate the net buy and sell for each 10 sec group. It would be great if you could help with this pleasee.
Any help would be great..
Thanks in advance.
I need some help with perl code for the below:
Input data:
$Date,$Mod_Time,$Index,$Date_Inst,$Time_Inst,$Reason,$In,$Phase,$Type,$BuyorSell,$Size,$Price
20100611 090009.870000 2 20100611 85954 5 Tes C L -1 16 43.85
20100611 090009.870000 2 20100611 90009 4 Tes C L 1 16 3.85
20100611 090011.630000 2 20100611 85954 4 ASD C L -1 461 23.85
20100611 090012.630000 2 20100611 90011 24 ASD C L -1 800 43.858
20100611 090020.630000 2 20100611 90011 14 Tes C M 1 461 43.85
20100611 090027.770000 2 20100611 85959 4 ASD C L 1 198 13.715
Output required:
I want to calculate the net buy or sell from the above data in every 10 secs interval.The column BuyorSell is -1 for sell and +1 for a buy.
For example in the 1st 2 rows of input data we could say that the net buy_sell was =(-1+1)=0;
So i want to group my data in 10 sec interval and in those 10 sec intervals I want to calculate whether there was a net sell or buy
The output should be something like this:
Time NetBuy/Sell
90000-90010 0
90010-90020 -2
90020-90030 +2
SO it means:
Time NetBuy/Sell
90000-90010 Neither sell nor buy
90010-90020 Net Sell
90020-90030 Net Buy
This is what I am trying:
open(IN)
open(OUT)
while($line=<IN>)
{ chomp ($line);
($Date,$Mod_Time,$Precision,$Date_Inst,$Time_Inst,$Reason,$In,$Phase,$Type,$BuyorSell,$Size,$Price)= split(/ /,$line);
$time = "090000";
until($time == "173001")
{
if($Mod_Time>$time && $Mod_Time< ($time+10))
{
#calculate the net buy_sell->I dont know how to calculate this!
}
$time = $time+10;
}
}
I have no clue how to calculate the net buy and sell for each 10 sec group. It would be great if you could help with this pleasee.
Any help would be great..
Thanks in advance.