当前位置: 首页>>代码示例>>C++>>正文


C++ Asset::getDateColumnPtr方法代码示例

本文整理汇总了C++中Asset::getDateColumnPtr方法的典型用法代码示例。如果您正苦于以下问题:C++ Asset::getDateColumnPtr方法的具体用法?C++ Asset::getDateColumnPtr怎么用?C++ Asset::getDateColumnPtr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Asset的用法示例。


在下文中一共展示了Asset::getDateColumnPtr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: outOfMoneyOption


//.........这里部分代码省略.........
	while (calls->getDate(callsPos) == currDate){

		callsDailyVol += calls->getVolume(callsPos);
		callsDailyOoi += calls->getOoi(callsPos);
		++callsPos;
		if(callsPos == calls->getNbrRows()) break;
	}

	//get puts daily volume and open interest for all options on given day.
	while (puts->getDate(putsPos) == currDate){ //while I am on one date
		putsDailyVol += puts->getVolume(putsPos);
		putsDailyOoi += puts->getOoi(putsPos);
		++putsPos;
		if(putsPos == puts->getNbrRows()) break;
	}

	prevPcVolRatio = putsDailyVol/(callsDailyVol + putsDailyVol);
	prevPcOoiRatio = putsDailyOoi/(callsDailyOoi + putsDailyOoi);

	//////////////////////// get first day data on volumes /////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////


	while(++equityIndex < underlyer->getNbrRows()){ //increment before comparing, to start comparing from row 1.

		currDate = underlyer->getDate(equityIndex);

		if (nbrToLong - currLongPos > 0){ //I have to buy some stock

			if(currCash - (1+tCRatio)*(nbrToLong-currLongPos)*underlyer->getOpen(equityIndex) >= 0){ // I've go enough cash to commit
				currCash -= (1+tCRatio)*(nbrToLong-currLongPos)*underlyer->getOpen(equityIndex);
				currLongPos = nbrToLong;
			}
			else{
				nbrToLong = currLongPos + floor(currCash/((1+tCRatio)*underlyer->getOpen(equityIndex))); //buy as much as I can
				currCash -= (1+tCRatio)*(nbrToLong-currLongPos)*underlyer->getOpen(equityIndex);
				currLongPos = nbrToLong;
			}

		}
		else if (nbrToLong - currLongPos < 0){ // I have to sell some stock, currently only doing long only.
			currCash += (1-tCRatio)*(currLongPos - nbrToLong)*underlyer->getOpen(equityIndex);
			currLongPos = nbrToLong;
		}
		else{} // do nothing.

		//re-initialize values on new date
		callsDailyVol = 0;
		callsDailyOoi = 0;
		putsDailyVol = 0;
		putsDailyOoi = 0;
		//get calls daily volume and open interest for all options on given day.
		while (calls->getDate(callsPos) == currDate){ //while I am on one date
			callsDailyVol += calls->getVolume(callsPos);
			callsDailyOoi += calls->getOoi(callsPos);
			++callsPos;
			if(callsPos == calls->getNbrRows()) break;
		}

		//get puts daily volume and open interest for all options on given day.
		while (puts->getDate(putsPos) == currDate){ //while I am on one date
			putsDailyVol += puts->getVolume(putsPos);
			putsDailyOoi += puts->getOoi(putsPos);
			++putsPos;
			if(putsPos == puts->getNbrRows()) break;
		}

		currPcVolRatio = putsDailyVol/(callsDailyVol + putsDailyVol); //update pcVolRatio, wrong, actually want difference in volumes from one day to the other.
		currPcOoiRatio = putsDailyOoi/(callsDailyOoi + putsDailyOoi);

		//make trade decision based on pcVolRatio
		//start easy, only long, cannot short.

		if (currPcVolRatio - prevPcVolRatio < RATIODIFF){
			nbrToLong += floor((1-currPcVolRatio)*(currCash/((1+tCRatio)*underlyer->getClose(equityIndex))));
		}
		else if (currPcVolRatio - prevPcVolRatio > RATIODIFF)
			if(currLongPos > 0)
				nbrToLong = floor((currPcVolRatio)*currLongPos); //diminish part of stocks
			else{}
		else{
			if(currLongPos*underlyer->getClose(equityIndex) > currCash) //no clear sign and lots of cash in stocks
				nbrToLong = nbrToLong * 0.9; //diminish part of equity. 0.9 picked random
			else{} //do nothing.
		}


		results.push_back(currCash + currLongPos * underlyer->getClose(equityIndex));
		dataOut << currDate << "," << currCash + currLongPos* underlyer->getClose(equityIndex)
				<< "," << currCash << "," << currLongPos << "," << 0 << endl;
	}

	plotResults(underlyer->getDateColumnPtr(), &results);
	plotLogResults(underlyer->getDateColumnPtr(), &results);
	return 0;


	return 0;
}
开发者ID:jdwuarin,项目名称:algoRobot,代码行数:101,代码来源:volForecasting.cpp

示例2: optionsVolumeComp1


//.........这里部分代码省略.........

	////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////
	//////////////////////// get first day data on volumes /////////////////////////////
	while (calls->getDate(callsPos) == currDate){
		callsDailyVol += calls->getVolume(callsPos);
		callsDailyOoi += calls->getOoi(callsPos);
		++callsPos;
		if(callsPos == calls->getNbrRows()) break;
	}

	//get puts daily volume and open interest for all options on given day.
	while (puts->getDate(putsPos) == currDate){ //while I am on one date
		putsDailyVol += puts->getVolume(putsPos);
		putsDailyOoi += puts->getOoi(putsPos);
		++putsPos;
		if(putsPos == puts->getNbrRows()) break;
	}

	prevPcVolRatio = putsDailyVol/(callsDailyVol + putsDailyVol);
	prevPcOoiRatio = putsDailyOoi/(callsDailyOoi + putsDailyOoi);

	//////////////////////// get first day data on volumes /////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////


	while(++equityIndex < underlyer->getNbrRows()){ //increment before comparing, to start comparing from row 1.

		currDate = underlyer->getDate(equityIndex);

		if (nbrToLong - currLongPos > 0){ //I have to buy some stock

			if(currCash - (1+tCRatio)*(nbrToLong-currLongPos)*underlyer->getOpen(equityIndex) >= 0){ // I've go enough cash to commit
				currCash -= (1+tCRatio)*(nbrToLong-currLongPos)*underlyer->getOpen(equityIndex);
				currLongPos = nbrToLong;
			}
			else{
				nbrToLong = currLongPos + floor(currCash/((1+tCRatio)*underlyer->getOpen(equityIndex))); //buy as much as I can
				currCash -= (1+tCRatio)*(nbrToLong-currLongPos)*underlyer->getOpen(equityIndex);
				currLongPos = nbrToLong;
			}

		}
		else if (nbrToLong - currLongPos < 0){ // I have to sell some stock, currently only doing long only.
			currCash += (1-tCRatio)*(currLongPos - nbrToLong)*underlyer->getOpen(equityIndex);
			currLongPos = nbrToLong;
		}
		else{} // do nothing.

		//re-initialize values on new date
		callsDailyVol = 0;
		callsDailyOoi = 0;
		putsDailyVol = 0;
		putsDailyOoi = 0;
		//get calls daily volume and open interest for all options on given day.
		while (calls->getDate(callsPos) == currDate){ //while I am on one date
			callsDailyVol += calls->getVolume(callsPos);
			callsDailyOoi += calls->getOoi(callsPos);
			++callsPos;
			if(callsPos == calls->getNbrRows()) break;
		}

		//get puts daily volume and open interest for all options on given day.
		while (puts->getDate(putsPos) == currDate){ //while I am on one date
			putsDailyVol += puts->getVolume(putsPos);
			putsDailyOoi += puts->getOoi(putsPos);
			++putsPos;
			if(putsPos == puts->getNbrRows()) break;
		}

		currPcVolRatio = putsDailyVol/(callsDailyVol + putsDailyVol); //update pcVolRatio, wrong, actually want difference in volumes from one day to the other.
		currPcOoiRatio = putsDailyOoi/(callsDailyOoi + putsDailyOoi);

		//make trade decision based on pcVolRatio
		//start easy, only long, cannot short.

		if (currPcVolRatio - prevPcVolRatio < RATIODIFF){
			nbrToLong += floor((1-currPcVolRatio)*(currCash/((1+tCRatio)*underlyer->getClose(equityIndex))));
		}
		else if (currPcVolRatio - prevPcVolRatio > RATIODIFF)
			if(currLongPos > 0)
				nbrToLong = floor((currPcVolRatio)*currLongPos); //diminish part of stocks
			else{}
		else{
			if(currLongPos*underlyer->getClose(equityIndex) > currCash) //no clear sign and lots of cash in stocks
				nbrToLong = nbrToLong * 0.9; //diminish part of equity. 0.9 picked random
			else{} //do nothing.
		}


		results.push_back(currCash + currLongPos * underlyer->getClose(equityIndex));
		dataOut << currDate << "," << currCash + currLongPos* underlyer->getClose(equityIndex)
				<< "," << currCash << "," << currLongPos << "," << 0 << endl;
	}

	plotResults(underlyer->getDateColumnPtr(), &results);
	plotLogResults(underlyer->getDateColumnPtr(), &results);
	return 0;
}
开发者ID:jdwuarin,项目名称:algoRobot,代码行数:101,代码来源:optionsVolumeComp1.cpp


注:本文中的Asset::getDateColumnPtr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。