create a linux script to output a price file from two input files
$30-5000 USD
Завершено
Опублікований over 11 years ago
$30-5000 USD
Оплачується при отриманні
Project: create a linux script to output a price file from two input files.
A linux script to create (output) a spread file given two financial markets price series (inputs). This should be either a perl or shell (bash) script.
## Deliverables
Project: create a linux script to output a price file from two input files.
A linux script to create (output) a spread file given two financial markets price series (inputs).
This should be either a perl or shell (bash) script.
Command line options:
1- spread_method (1,2) # subtraction or ratio
2- starting_value (10000) # for spread method 1, amount to add to every result, for example, 10,000
3- list\_of\_spreads (/home/mt/lists/[login to view URL]) # text file with 2 markets per line seperated by a comma
4- input_dir (/data/input/files) # (full path directory of input files)
5- output_dir (/data/output/files) # (full path where to write output files)
output name format: [login to view URL]
Example: The Corn-Wheat spread (input is [login to view URL], [login to view URL]; output as [login to view URL]).
(In some cases the input extension could be .TXT or .txt)
6- high\_low\_check (bool, 0,1) # check that the highest price is output as high, lowest price is output as low
Spread Method 1 (choose via a command line option):
1-Take the price field in each file for a given date and subtract one from the other.
The format of the file is:
Date Open High Low Close Volume OpenInterest TotVolume TotOpenInterest
The prices are Open, High, Low, Close. There are sometimes other fields (as shown above) but they are not used.
In spread method 1, to prevent the result from going negative pass a number via a command line option as the starting value.
For example, in the sample files below (C20 = Corn, W20 = Wheat) the first date using the opening field, 777-1532 = -755 (negative).
The first day (before adding the starting value) would look like this:
19820112 -755 -755.25 -748 -752.25
Then adding the starting value of 10,000 would look like this:
19820112 (10000+ -755) (10000+ -755.25) (10000+ -748) (10000+ - 752.25)
Final result for the three days:
19820112 9245 9244.75 9252 9247.75
19820113 9247.75 9245.75 9249.75 9248.5
19820114 9248 9247 9250.5 9247.5
Spread Method 2 (choose via a command line option)
2-Take the price field in each file for a given date and divide one by the other.
19820112 778.25/1531 778.75/1535 776.25/1528.5 777.5/1530.25
19820113 777/1529 778.25/1532.5 775.75/1525.5 778/1530.5
19820114 780.5/1532.5 782/1542 779.25/1532 781.5/1541
Final result for the three days:
19820112 0.50718015665796 0.50717781402936 0.50894469062859 0.50801177240026
19820113 0.50833333333333 0.50783034257749 0.50835517693316 0.50818062827225
19820114 0.50825568088932 0.50800392028749 0.50868567682727 0.50792872323034
There are usually 4 price fields in each file.
The typical layout of the price file is like this below (but no header is actually in the file, below header is for explanation purposes):
File 1 (C20)
Date Open High Low Close Volume OpenInterest TotVolume TotOpenInterest
19820112 777.00000000 777.25000000 775.25000000 776.75000000 19977 65500 30383 132945
19820113 777.75000000 778.25000000 775.75000000 776.50000000 18526 64149 28388 133138
19820114 777.25000000 777.50000000 776.00000000 776.75000000 12571 64451 19071 134194
File 2 (W20)
Date Open High Low Close Volume OpenInterest TotVolume TotOpenInterest
19820112 1532.00000000 1532.50000000 1523.25000000 1529.00000000 14079 31637 23037 66369
19820113 1530.00000000 1532.50000000 1526.00000000 1528.00000000 11333 31846 16613 67068
19820114 1529.25000000 1530.50000000 1525.50000000 1529.25000000 7115 32319 11176 67747
Additional requirements:
1- default values #default values for each command line option
Explanations:
1- for option 6, before writing the output file there should be a check for high low consistency. Due to the nature of the data construction the low could be the high of the series, or the close could be the low, etc. A check should be made before writing the output that the highest price amongst the four fields becomes the high in the output file, and the lowest price amongs the four fields is the low in the output file.
2- test price files will be supplied so you can test the script.