Changeset 1358 for applications/robust
- Timestamp:
- 05/06/11 19:13:05 (14 years ago)
- Location:
- applications/robust
- Files:
-
- 3 added
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/robust/CMakeLists.txt
r976 r1358 15 15 16 16 add_library(robustlib robustlib.cpp robustlib.h) 17 add_library(DDEClient ddeclient.cpp ddeclient.h dcerrors.h) 17 18 18 EXEC(main robustlib )19 EXEC(main robustlib DDEClient) 19 20 20 21 -
applications/robust/main.cpp
r1357 r1358 13 13 #include <fstream> 14 14 #include <itpp/itsignal.h> 15 #include <windows.h> 16 #include "DDEClient.h" 17 #include <conio.h> 18 15 19 16 20 using namespace itpp; … … 25 29 itpp::Laplace_RNG LapRNG = Laplace_RNG(); 26 30 31 WORD wConvNo; 32 char szType[] = "request"; 33 char szData[21]; 34 char szItem[] = "EURUSD"; 35 char szService[] = "MT4"; 36 char szTopic[] = "BID"; 37 char szFormat[] = "CF_TEXT"; 38 DWORD dwTimeout = 0; 39 //char szAccess[] = "string"; 40 41 if(!DCInit()) 42 { 43 cout << "DDE doesn't work." << endl; 44 } 45 else 46 { 47 // The following if-block shows a complete conversation with a 48 // single transaction. You therefore do not need to free any memory 49 // explicitly. 50 51 // connect to server 52 if (!DCConnect(&wConvNo,szService, szTopic)) 53 { 54 cout << "Couldn't connect DDE." << endl; 55 } 56 else 57 { 58 // do synchronous request transaction, wait max. 1000 ms, 59 // return data as string 60 if(!DCRequestString(wConvNo,szItem,100000)) 61 { 62 cout << "No data available." << endl; 63 } 64 else 65 { 66 if(!DCAsynchTransactionCompleted(wConvNo,DCDA[wConvNo]->dwTransID,true)) 67 { 68 cout << "Asynchronous transaction error." << endl; 69 } 70 else 71 { 72 // output data to console if transaction complete 73 // DCDA[wConvNo]->pszData is the pointer to the data string 74 cprintf(DCDA[wConvNo]->pszData); 75 DCFreeDdeMem(wConvNo); 76 } 77 } 78 // end conversation 79 if(!DCDisconnect(wConvNo)) 80 { 81 cout << "Couldn't disconnect DDE." << endl; 82 } 83 } 84 } 85 27 86 /* 28 87 // EXPERIMENT: 100 AR model generated time series of length of 30 from y_t=0.95*y_(t-1)+0.05*y_(t-2)+0.2*e_t, … … 173 232 vector<vec> conditions; 174 233 //emlig* emliga = new emlig(2); 175 RARX* my_rarx = new RARX(2, 8,false);234 RARX* my_rarx = new RARX(2,10,false); 176 235 177 236 … … 224 283 225 284 vec sample_prediction; 285 vec averaged_params = zeros(imp_samples.second.rows()); 226 286 for(int t = 0;t<imp_samples.first.size();t++) 227 287 { … … 232 292 233 293 sample_prediction.ins(0,lap_sample*imp_samples.second.get_col(t)); 234 } 235 236 237 vec sample_pow = sample_prediction; 294 295 averaged_params += imp_samples.first[t]*imp_samples.second.get_col(t); 296 } 297 298 averaged_params = averaged_params*(1/(imp_samples.first*ones(imp_samples.first.size()))); 299 300 // cout << "Averaged estimated parameters: " << averaged_params << endl; 301 302 vec sample_pow = sample_prediction; 238 303 239 304 // cout << sample_prediction << endl;