I have my data coming back as a cell which looks like this (each trade is underneath each other in the cell ie its a 5 by 4 cell):
sell 50 FTSE 6500
buy 100 Eurostoxx 3300
buy 25 SP 1980
buy 30 FTSE 6490
sell 25 Eurostoxx 3315
Firstly because I have mixed data its coming back from my database query as a cell so not sure if thats a problem
What I'd like to do is mark these to market, so I have closing market price of each of these contracts as a variable lets call them FTSE_CLOSE
, EUROSTOXX_CLOSE
and SP_CLOSE
.
I'd like to be able to do something that goes as follows:
where coloumn 3 = "FTSE" and column 1 = "sell" then column 5 = column2 * (column4 - FTSE_CLOSE)
where column 3 = "FTSE" and column 1 = "buy" then column 5 = column2 * (FTSE_CLOSE - column4)
and so on for the other contracts.
Basically I am struggling with the mixed use of strings and numbers
- Do I need to
cell2mat
everything so I have several vectors and then somehow look into the string vectors and perform the calucaltion on the other relevant vectors i.e.quantity * price - close_price
- Is there a simpler way of doing this
I think you are simply looking for the command
str2num
Here is one idea: