Sponsored Content
Full Discussion: Calculate Beta or Slope !
Top Forums Shell Programming and Scripting Calculate Beta or Slope ! Post 302707537 by csierra on Friday 28th of September 2012 10:55:30 PM
Old 09-28-2012
Question Calculate Beta or Slope !

Hello Group,

I would request your help to build a shell script that can calculate the beta or slope between a two series of investment instruments (i.e S&P 500 and Silver).
I have a source files of data (First - Date, Second (Value1) and Third (Value 2) columns)
Code:
Date    S&P 500    S&P 500    Silver    Silver
9/4/2012    140.28        31.36    
9/5/2012    140.16    -0.085616438    31.27    -0.287815798
9/6/2012    143.01    1.992867632    31.67    1.263024945
9/7/2012    143.56    0.383115074    32.64    2.971813725
9/10/2012    142.75    -0.567425569    32.29    -1.083926912
9/11/2012    143.15    0.279427174    32.41    0.370256094
9/12/2012    143.62    0.327252472    32.21    -0.620925179
9/13/2012    145.81    1.501954598    33.61    4.165426956
9/14/2012    146.46    0.443807183    33.6    -0.029761905
9/17/2012    145.96    -0.342559605    32.99    -1.849045165
9/18/2012    145.84    -0.082281953    33.71    2.135864729
9/19/2012    145.92    0.054824561    33.57    -0.417039023
9/20/2012    145.93    0.006852601    33.58    0.029779631
9/21/2012    145.87    -0.041132515    33.48    -0.298685783
9/24/2012    145.65    -0.151047031    32.93    -1.670209535
9/25/2012    144.1    -1.075641915    32.68    -0.76499388
9/26/2012    143.29    -0.56528718    32.87    0.578034682
9/27/2012    144.64    0.93335177    33.58    2.114353782
9/28/2012    143.97    -0.465374731    33.48    -0.298685783
                
        Slope or Beta        0.293057926


Attached you will find the spreadsheet of this example

Thanks in advance

Last edited by csierra; 09-29-2012 at 12:01 AM..
 

We Also Found This Discussion For You

1. Shell Programming and Scripting

Calculate age of a file | calculate time difference

Hello, I'm trying to create a shell script (#!/bin/sh) which should tell me the age of a file in minutes... I have a process, which delivers me all 15 minutes a new file and I want to have a monitoring script, which sends me an email, if the present file is older than 20 minutes. To do... (10 Replies)
Discussion started by: worm
10 Replies
DATEPERIOD.__CONSTRUCT(3)						 1						 DATEPERIOD.__CONSTRUCT(3)

DatePeriod::__construct - Creates a new DatePeriod object

SYNOPSIS
public DatePeriod::__construct (DateTimeInterface $start, DateInterval $interval, int $recurrences, [int $options]) DESCRIPTION
DatePeriod::__construct (DateTimeInterface $start, DateInterval $interval, DateTimeInterface $end, [int $options]) DatePeriod::__con- struct (string $isostr, [int $options]) Creates a new DatePeriod object. PARAMETERS
o $start - The start date of the period. o $interval - The interval between recurrences within the period. o $recurrences - The number of recurrences. o $end - The end date of the period. o $isostr - An ISO 8601 repeating interval specification. o $options - Can be set to DatePeriod::EXCLUDE_START_DATE to exclude the start date from the set of recurring dates within the period. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.5.8 | | | | | | | $end type changed to DateTimeImmutable. Previ- | | | ously, DateTime. | | | | | 5.5.0 | | | | | | | $start type changed to DateTimeImmutable. Previ- | | | ously, DateTime. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 DatePeriod example <?php $start = new DateTime('2012-07-01'); $interval = new DateInterval('P7D'); $end = new DateTime('2012-07-31'); $recurrences = 4; $iso = 'R4/2012-07-01T00:00:00Z/P7D'; // All of these periods are equivalent. $period = new DatePeriod($start, $interval, $recurrences); $period = new DatePeriod($start, $interval, $end); $period = new DatePeriod($iso); // By iterating over the DatePeriod object, all of the // recurring dates within that period are printed. foreach ($period as $date) { echo $date->format('Y-m-d')." "; } ?> The above example will output: 2012-07-01 2012-07-08 2012-07-15 2012-07-22 2012-07-29 Example #2 DatePeriod example with DatePeriod::EXCLUDE_START_DATE <?php $start = new DateTime('2012-07-01'); $interval = new DateInterval('P7D'); $end = new DateTime('2012-07-31'); $period = new DatePeriod($start, $interval, $end, DatePeriod::EXCLUDE_START_DATE); // By iterating over the DatePeriod object, all of the // recurring dates within that period are printed. // Note that, in this case, 2012-07-01 is not printed. foreach ($period as $date) { echo $date->format('Y-m-d')." "; } ?> The above example will output: 2012-07-08 2012-07-15 2012-07-22 2012-07-29 PHP Documentation Group DATEPERIOD.__CONSTRUCT(3)
All times are GMT -4. The time now is 10:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy