// 根据指定的父节点获取其对应的子节点数组 BOOL CLayerTreeDef::GetChildrenAliasName(CStringArray& ChildrenAliasNames, CStringArray& saNeed, const CString FatherAliasName) { ChildrenAliasNames.RemoveAll(); saNeed.RemoveAll(); CString sFatherId; if (GetIdByAliasName(sFatherId, FatherAliasName)==FALSE) return FALSE; CStringArray saOrder;//辅助数组(排序) int nCount = m_LayerTreeArray.GetSize(); for (int i = 0; i <nCount; i++) { if (m_LayerTreeArray.GetAt(i).FatherId.CollateNoCase(sFatherId) == 0) //判断ID是否相等 { //根据排序确定插入位置 int nOrder1 = atoi(m_LayerTreeArray.GetAt(i).OrderNum); int nNum = saOrder.GetSize(); int nPos = 0; for (int j =nNum-1; j >= 0; j--){ int nOrder2 = atoi(saOrder.GetAt(j)); if (nOrder1 >= nOrder2) { nPos = j; break; //记录插入位置 } } //插入数据 ChildrenAliasNames.InsertAt(nPos, m_LayerTreeArray.GetAt(i).AliasName); saNeed.InsertAt(nPos, m_LayerTreeArray.GetAt(i).NeedInf); saOrder.InsertAt(nPos, m_LayerTreeArray.GetAt(i).OrderNum); } } return (ChildrenAliasNames.GetSize() > 0); }
void CFavorite::getFavUrl(CStringArray &arrayUrl) { int size = arrayUrl.GetSize(); for (int i=0; i<m_favString.GetSize(); ++i) { arrayUrl.InsertAt(size+i, m_favString.GetAt(i)); } }
void CTaiKlineDlgHistorySelect::GetFileNameArray(CStringArray &sArry) { CString sPath = "data\\historysh\\"; CFileFind finder; int n = 0; BOOL bWorking = finder.FindFile(sPath+"*.hst"); while(bWorking) { bWorking = finder.FindNextFile(); CString filename = finder.GetFileTitle(); int nSize = sArry.GetSize (); for(int j=0;j<nSize;j++) { if(filename <sArry[j]) { sArry.InsertAt (j,filename); break; } if(j==nSize-1) sArry.Add (filename); } if(nSize == 0) sArry.Add (filename); n++; } sPath = "data\\historysz\\"; n = 0; bWorking = finder.FindFile(sPath+"*.hst"); while(bWorking) { bWorking = finder.FindNextFile(); CString filename = finder.GetFileTitle(); int nSize = sArry.GetSize (); BOOL bf; bf=false; for(int j=0;j<nSize;j++) { if(filename ==sArry[j]) { bf=true; break; } else { bf=false; continue; } if(j==nSize-1) sArry.Add (filename); } if((nSize == 0)||(!bf)) sArry.Add (filename); n++; } }
/****************************************************************************** Function Name : nFillMessageList Input(s) : CStringArray& omstrEntryList BOOL bEmptyString Output : INT Functionality : Fills The Message List Into String Array Member of : CDataBaseMsgList Friend of : - Author(s) : Venkatanarayana Makam Date Created : 06/04/2011 Modifications : ******************************************************************************/ INT CDataBaseMsgList::nFillMessageList(CStringArray& omstrEntryList, BOOL bEmptyString) { if ( nullptr == mCurrentCluster ) { return ERR_INVALID_DATABASE; } std::map<UID_ELEMENT, IElement*> frameList; mCurrentCluster->GetElementList( eFrameElement, frameList ); std::string frameName; for ( auto frame : frameList ) { frame.second->GetName( frameName ); omstrEntryList.Add( frameName.c_str() ); } if ( bEmptyString == TRUE ) { omstrEntryList.InsertAt( 0, _( defDELETE_MSG_SYMBOL ) ); } return frameList.size(); }
int CTradeStatistic2::Statistic(CString day,bool show) { CStringArray list; list.Add("序号,合约,日期,开仓时,数量,价格,方向,开平,盈亏,手续费,权益,"); CStringArray arDirection; arDirection.Add("买"); arDirection.Add("卖"); CStringArray arOpenClose; arOpenClose.Add("开"); arOpenClose.Add("平"); CStringArray arTempPrice; CStringArray arTempCount; double maxquanyi=0; double maxhuiche=0; //CString strMaxHuicheTime; CString str; int yearbegin=0; CTradeStaYear * pStaYear=0; double beginQuanyi=0; CPtrArray arYear; double sum_yk=0; int countyingli = 0; int countkuisun=0; double allyingli=0; double allkuisun=0; double HuicheMax=0; CString HuicheTime; double HuicheMaxAll=0; CString HuicheTimeAll; m_nTradeCount = m_arListTrade.GetSize(); for(int i=0;i<m_arListTrade.GetSize();i++) { double yingkui=0; double shouxufei= 0; CTradeRecord2 * pt = (CTradeRecord2 *)m_arListTrade[i]; CString time(pt->day); int year = atoi(time.Mid(0,4)); shouxufei = pt->price * pt->count * m_jiazhi * m_feilv; CString row; if( pt->openorclose == 0 ) { m_beginquanyi = m_beginquanyi - shouxufei; row.Format("%d,%s,%s,%s,%d,%.2f,%s,%s,%.2f,%.2f,%.2f,",i,pt->heyue, pt->day,pt->time1,pt->count,pt->price,arDirection[pt->direction],arOpenClose[pt->openorclose],yingkui,shouxufei,m_beginquanyi); list.Add(row); str.Format("%.2f",pt->price); arTempPrice.Add(str); str.Format("%d",pt->count); arTempCount.Add(str); } else { yingkui = 0; for(int j=0;j<arTempPrice.GetSize();j++) { if( pt->direction ==0 )//BP { yingkui += atoi(arTempCount[j]) * (atof(arTempPrice[j])-pt->price) *m_jiazhi ; } else { yingkui += atoi(arTempCount[j]) * ( pt->price -atof(arTempPrice[j]) ) *m_jiazhi ; } } arTempPrice.RemoveAll(); arTempCount.RemoveAll(); m_beginquanyi += yingkui - shouxufei; if( m_beginquanyi > maxquanyi ) maxquanyi = m_beginquanyi; pt->huiche = maxquanyi - m_beginquanyi ; if( pt->huiche > HuicheMaxAll ) { HuicheMaxAll = pt->huiche; HuicheTimeAll.Format("%s %s",pt->day, pt->time1); } //统计平均盈利和亏损 if( yingkui > 0 ) { allyingli += yingkui ; countyingli++; } else { allkuisun += yingkui; countkuisun++; } row.Format("%d,%s,%s,%s,%d,%.2f,%s,%s,%.2f,%.2f,%.2f,",i,pt->heyue,pt->day,pt->time1,pt->count,pt->price,arDirection[pt->direction],arOpenClose[pt->openorclose],yingkui,shouxufei,m_beginquanyi); list.Add(row); sum_yk += yingkui- shouxufei * 2; if( sum_yk>m_sum_max) { m_sum_max = sum_yk; } pt->huiche = m_sum_max-sum_yk; if( pt->huiche > HuicheMax ) { HuicheMax = pt->huiche; HuicheTime.Format("%s %s",pt->day,pt->time1); } } //分年统计 if(yearbegin==0 ) { pStaYear = new CTradeStaYear; arYear.Add(pStaYear); yearbegin = year; pStaYear->year = yearbegin; beginQuanyi = m_beginquanyi; } else if (pStaYear && year != pStaYear->year) { //对前一年进行统计 pStaYear->shouyi = m_beginquanyi-beginQuanyi; pStaYear->maxhuiche = HuicheMax; strcpy_s(pStaYear->szMaxHuicheTime,HuicheTime); sum_yk = 0; m_sum_max = 0; HuicheMax = 0; pStaYear = new CTradeStaYear; arYear.Add(pStaYear); yearbegin = year; pStaYear->year = yearbegin; beginQuanyi = m_beginquanyi; } } //对前一年进行统计 if( pStaYear) { pStaYear->shouyi = m_beginquanyi-beginQuanyi; pStaYear->maxhuiche = HuicheMax; strcpy_s(pStaYear->szMaxHuicheTime,HuicheTime); } double avgYingli = allyingli /countyingli; double avgKuisun = allkuisun/countkuisun; double shenglv = 1.0* countyingli /(countyingli+countkuisun); double avgYingli2 = (allyingli+allkuisun)/(countyingli+countkuisun); CString row; row = ",,,,,,"; list.Add(row); row = "测试统计,,,,,,"; list.Add(row); row.Format("最大回撤,%.2f,",HuicheMaxAll); list.Add(row); row.Format("最大回撤时间,%s,",HuicheTimeAll); list.Add(row); row.Format("平均盈利,%.2f,",avgYingli); list.Add(row); row.Format("平均亏损,%.2f,",avgKuisun); list.Add(row); row.Format("胜率,%.2f,",shenglv); list.Add(row); row.Format("每手平均盈利,%.2f,",avgYingli2); list.Add(row); m_shenglv = shenglv; m_HuicheMax = HuicheMaxAll; m_avgYingli2 = avgYingli2; m_avgYingli = avgYingli; m_avgKuisun = avgKuisun; list.Add(",,,,,,,,"); list.Add("分年统计,"); list.Add("年份,收益,最大回撤,回撤时间,交易次数,平均盈利,平均亏损,每手盈利,胜率,"); for(int i=0;i<arYear.GetSize();i++) { CTradeStaYear * pYear = (CTradeStaYear *)arYear[i]; CString row; row.Format("%d,%.2f,%.2f,%s,",pYear->year,pYear->shouyi,pYear->maxhuiche,pYear->szMaxHuicheTime); list.Add(row); } row.Format("耗时,%s", CalculateElapseTime()); list.Add(row); list.InsertAt(0,day); if( show ) { ::SendMessage(m_hMsgWnd,WM_MODEL_RESULT_MSG,0,(long)&list); StatisticEquity(); } return 0; }
int CMainFrame::BuildFavoritesMenu(LPCTSTR pszPath, int nStartPos, CMenu* pMenu) { CString strPath(pszPath); CString strPath2; CString str; WIN32_FIND_DATA wfd; HANDLE h; int nPos = 0; int nEndPos = 0; int nNewEndPos = 0; int nLastDir = 0; TCHAR buf[INTERNET_MAX_PATH_LENGTH]; CStringArray astrFavorites; CStringArray astrDirs; CMenu* pSubMenu; // make sure there's a trailing backslash if(strPath[strPath.GetLength() - 1] != _T('\\')) strPath += _T('\\'); strPath2 = strPath; strPath += "*.*"; // now scan the directory, first for .URL files and then for subdirectories // that may also contain .URL files h = FindFirstFile(strPath, &wfd); if(h != INVALID_HANDLE_VALUE) { nEndPos = nStartPos; do { if((wfd.dwFileAttributes & (FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM))==0) { str = wfd.cFileName; if(str.Right(4) == _T(".url")) { // an .URL file is formatted just like an .INI file, so we can // use GetPrivateProfileString() to get the information we want ::GetPrivateProfileString(_T("InternetShortcut"), _T("URL"), _T(""), buf, INTERNET_MAX_PATH_LENGTH, strPath2 + str); str = str.Left(str.GetLength() - 4); // scan through the array and perform an insertion sort // to make sure the menu ends up in alphabetic order for(nPos = nStartPos ; nPos < nEndPos ; ++nPos) { if(str.CompareNoCase(astrFavorites[nPos]) < 0) break; } astrFavorites.InsertAt(nPos, str); m_astrFavoriteURLs.InsertAt(nPos, buf); ++nEndPos; } } } while(FindNextFile(h, &wfd)); FindClose(h); // Now add these items to the menu for(nPos = nStartPos ; nPos < nEndPos ; ++nPos) { pMenu->AppendMenu(MF_STRING | MF_ENABLED, 0xe00 + nPos, astrFavorites[nPos]); } // now that we've got all the .URL files, check the subdirectories for more nLastDir = 0; h = FindFirstFile(strPath, &wfd); ASSERT(h != INVALID_HANDLE_VALUE); do { if(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { // ignore the current and parent directory entries if(lstrcmp(wfd.cFileName, _T(".")) == 0 || lstrcmp(wfd.cFileName, _T("..")) == 0) continue; for(nPos = 0 ; nPos < nLastDir ; ++nPos) { if(astrDirs[nPos].CompareNoCase(wfd.cFileName) > 0) break; } pSubMenu = new CMenu; pSubMenu->CreatePopupMenu(); // call this function recursively. nNewEndPos = BuildFavoritesMenu(strPath2 + wfd.cFileName, nEndPos, pSubMenu); if(nNewEndPos != nEndPos) { // only intert a submenu if there are in fact .URL files in the subdirectory nEndPos = nNewEndPos; pMenu->InsertMenu(nPos, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR)pSubMenu->m_hMenu, wfd.cFileName); pSubMenu->Detach(); astrDirs.InsertAt(nPos, wfd.cFileName); ++nLastDir; } delete pSubMenu; } } while(FindNextFile(h, &wfd)); FindClose(h); } return nEndPos; }