Monday, August 9, 2010

Code for Intraday Liquidity Calculation

[sourcecode language="css"]

/*

* UNSW - FINS5566 - Semester 2, 2010

* Group 13 - Stefan Binder, Duk Jang, Tai Tran

* This Ox program calculates liquidity and liquidity percentage from a trading period for a stock

* The intraday pattern assists trading strategies formation

*/


#include


const decl ROWS = 3416;

const decl COLUMNS = 4;

const decl PARCELS = 6;

const decl PRICE = 0;

const decl VOLUME = 1;

const decl DAY = 2;

const decl HOUR = 3;

const decl OPEN = 10;

const decl NUMBEROFPARCELS = 6;

const decl CLOSE = OPEN + NUMBEROFPARCELS - 1;

const decl NUMBEROFDAYS = 5;

const decl FILENAME = “tradedata.csv”;

const decl PARCELOUTPUT = “ParcelLiquidity.csv”;

const decl DAYOUTPUT = “DayLiquidity.csv”;


main()

{

decl m;

decl liquidity=0;

decl parcel;

decl day;

decl parcelPercent;

decl dayPercent;

decl i,j,k;

decl fileParcel,fileDay;


m = new matrix[ROWS][COLUMNS];

m = loadmat(FILENAME);

day = new matrix[1][NUMBEROFDAYS];

dayPercent = new matrix[1][NUMBEROFDAYS];

parcel = new matrix[1][PARCELS];

parcelPercent = new matrix[1][PARCELS];


for (i = 0 ; i < ROWS ; i++)

{

for (j = 0 ; j < NUMBEROFPARCELS ; j++) if (m[i][HOUR] == OPEN+j) parcel[0][j] += m[i][VOLUME];


for (k = 0 ; k < NUMBEROFDAYS ; k++) if (m[i][DAY] == k+1) day[0][k] += m[i][VOLUME];


liquidity += m[i][VOLUME];

}


for (i = 0 ; i < PARCELS ; i++) parcelPercent[0][i] = parcel[0][i] / liquidity;

for (i = 0 ; i < NUMBEROFDAYS ; i++) dayPercent[0][i] = day[0][i] / liquidity;


print(”\nUNSW - FINS5566 S2 2010 - Group 13 - Stefan Binder, Duk Jang, Tai Tran\n”);


fileParcel = fopen(PARCELOUTPUT,”w”);

fileDay = fopen(DAYOUTPUT,”w”);


for (i = 0 ; i < NUMBEROFPARCELS ; i++)

{

print(”\nLiquidity from “, OPEN+i, ” to “, OPEN+i+1, ” is “, parcel[0][i], ” which is “, parcelPercent[0][i]*100, ” percent”);

fprint(fileParcel, “\nLiquidity from “, OPEN+i, ” to “, OPEN+i+1, ” is “, parcel[0][i], “,” ,parcelPercent[0][i]*100);

}


for (i = 0 ; i < NUMBEROFDAYS ; i++)

{

print(”\nLiquidity on day “, i+1, ” is “, day[0][i], ” which is “, dayPercent[0][i]*100, ” percent”);

fprint(fileDay, “\nLiquidity on day “, i+1, ” is,”, day[0][i], “,” ,dayPercent[0][i]*100);

}

}


[/sourcecode]




Xem đầy đủ bài viết tại http://feedproxy.google.com/~r/TaiTran/~3/TfpFcUK7LUQ/code-for-intraday-liquidity-calculation.html

No comments:

Post a Comment

Popular Posts