⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gen_code.c

📁 股票主要技术指标源码
💻 C
📖 第 1 页 / 共 5 页
字号:
   {      forEachGroupFunc( table->string[i],                        i,                        i==0? 1:0,                        i==(table->size-1)? 1:0 );   }      retCode = TA_GroupTableFree( table );   if( retCode != TA_SUCCESS )      return 0;   return i;}/* Replaces reserved xml characters with the appropriate escape sequence. */static void ReplaceReservedXmlCharacters(const char *input, char *output ){	char *currentPosition;	char tempString[8*1024];	if((input == NULL) || (output == NULL))	{		return;	}	strcpy(output, input);	/*Replace '&' with "&amp;"	 *Note1: '&' has to be processed first as otherwise we replace the	 *       '&' in the escaped characters.	 *Note2: We assume that the input string does not have any escaped	 *       characters already.     */	currentPosition = output;	while((currentPosition = strchr(currentPosition, '&')) != NULL)	{		tempString[0] = '\0';		if(strlen(currentPosition) > 1)		{			strcpy(tempString, currentPosition+1);		}		sprintf(currentPosition, "&amp;%s", tempString);	}	/* Replace '<' with "&lt;" */	currentPosition = output;	while((currentPosition = strchr(currentPosition, '<')) != NULL)	{		tempString[0] = '\0';		if(strlen(currentPosition) > 1)		{			strcpy(tempString, currentPosition+1);		}		sprintf(currentPosition, "&lt;%s", tempString);	}	/* Replace '>' with "&gt;" */	currentPosition = output;	while((currentPosition = strchr(currentPosition, '>')) != NULL)	{		tempString[0] = '\0';		if(strlen(currentPosition) > 1)		{			strcpy(tempString, currentPosition+1);		}		sprintf(currentPosition, "&gt;%s", tempString);	}    /* Replace ''' with "&apos;" */	currentPosition = output;	while((currentPosition = strchr(currentPosition, '\'')) != NULL)	{		tempString[0] = '\0';		if(strlen(currentPosition) > 1)		{			strcpy(tempString, currentPosition+1);		}		sprintf(currentPosition, "&apos;%s", tempString);	}	/* Replace '"' with "&quot;" */	currentPosition = output;	while((currentPosition = strchr(currentPosition, '"')) != NULL)	{		tempString[0] = '\0';		if(strlen(currentPosition) > 1)		{			strcpy(tempString, currentPosition+1);		}		sprintf(currentPosition, "&quot;%s", tempString);	}}static void doForEachFunctionXml(const TA_FuncInfo *funcInfo,								 void *opaqueData){	TA_RetCode retCode;	const TA_InputParameterInfo *inputInfo;	const TA_OptInputParameterInfo *optInputInfo;	const TA_OutputParameterInfo *outputInfo;	char tempString[8*1024];	unsigned int i;    (void)opaqueData;	/* General stuff about function */	fprintf(gOutFunc_XML->file, "	<!-- %s -->\n", funcInfo->name);	fprintf(gOutFunc_XML->file, "	<FinancialFunction>\n");    fprintf(gOutFunc_XML->file, "		<Abbreviation>%s</Abbreviation>\n", (funcInfo->name == NULL)? "" : funcInfo->name);    fprintf(gOutFunc_XML->file, "		<CamelCaseName>%s</CamelCaseName>\n", (funcInfo->camelCaseName == NULL)? "" : funcInfo->camelCaseName);	ReplaceReservedXmlCharacters(funcInfo->hint, tempString);    fprintf(gOutFunc_XML->file, "		<ShortDescription>%s</ShortDescription>\n", (funcInfo->hint == NULL)? "" : tempString);    fprintf(gOutFunc_XML->file, "		<GroupId>%s</GroupId>\n", funcInfo->group);	/* Optional function flags */	if(funcInfo->flags & (TA_FUNC_FLG_OVERLAP | TA_FUNC_FLG_VOLUME | TA_FUNC_FLG_CANDLESTICK | TA_FUNC_FLG_UNST_PER))	{	    fprintf(gOutFunc_XML->file, "		<Flags>\n");		if(funcInfo->flags & TA_FUNC_FLG_OVERLAP)		{			fprintf(gOutFunc_XML->file, "			<Flag>Overlap</Flag>\n");		}		if(funcInfo->flags & TA_FUNC_FLG_VOLUME)		{			fprintf(gOutFunc_XML->file, "			<Flag>Volume</Flag>\n");		}		if(funcInfo->flags & TA_FUNC_FLG_CANDLESTICK)		{			fprintf(gOutFunc_XML->file, "			<Flag>Candlestick</Flag>\n");		}		if(funcInfo->flags & TA_FUNC_FLG_UNST_PER)		{			fprintf(gOutFunc_XML->file, "			<Flag>Unstable Period</Flag>\n");		}			    fprintf(gOutFunc_XML->file, "		</Flags>\n");	}	/* Required input arguments */    fprintf(gOutFunc_XML->file, "		<RequiredInputArguments>\n");	for(i=0; i<funcInfo->nbInput; i++)	{		retCode = TA_GetInputParameterInfo( funcInfo->handle, i, &inputInfo);		if(inputInfo->type == TA_Input_Price)		{			if(inputInfo->flags & TA_IN_PRICE_OPEN)			{				fprintf(gOutFunc_XML->file, "			<RequiredInputArgument>\n");				fprintf(gOutFunc_XML->file, "				<Type>Open</Type>\n");				fprintf(gOutFunc_XML->file, "				<Name>Open</Name>\n");				fprintf(gOutFunc_XML->file, "			</RequiredInputArgument>\n");			}			if(inputInfo->flags & TA_IN_PRICE_HIGH)			{				fprintf(gOutFunc_XML->file, "			<RequiredInputArgument>\n");				fprintf(gOutFunc_XML->file, "				<Type>High</Type>\n");				fprintf(gOutFunc_XML->file, "				<Name>High</Name>\n");				fprintf(gOutFunc_XML->file, "			</RequiredInputArgument>\n");			}			if(inputInfo->flags & TA_IN_PRICE_LOW)			{				fprintf(gOutFunc_XML->file, "			<RequiredInputArgument>\n");				fprintf(gOutFunc_XML->file, "				<Type>Low</Type>\n");				fprintf(gOutFunc_XML->file, "				<Name>Low</Name>\n");				fprintf(gOutFunc_XML->file, "			</RequiredInputArgument>\n");			}			if(inputInfo->flags & TA_IN_PRICE_CLOSE)			{				fprintf(gOutFunc_XML->file, "			<RequiredInputArgument>\n");				fprintf(gOutFunc_XML->file, "				<Type>Close</Type>\n");				fprintf(gOutFunc_XML->file, "				<Name>Close</Name>\n");				fprintf(gOutFunc_XML->file, "			</RequiredInputArgument>\n");			}			if(inputInfo->flags & TA_IN_PRICE_VOLUME)			{				fprintf(gOutFunc_XML->file, "			<RequiredInputArgument>\n");				fprintf(gOutFunc_XML->file, "				<Type>Volume</Type>\n");				fprintf(gOutFunc_XML->file, "				<Name>Volume</Name>\n");				fprintf(gOutFunc_XML->file, "			</RequiredInputArgument>\n");			}			if(inputInfo->flags & TA_IN_PRICE_OPENINTEREST)			{				fprintf(gOutFunc_XML->file, "			<RequiredInputArgument>\n");				fprintf(gOutFunc_XML->file, "				<Type>Open Interest</Type>\n");				fprintf(gOutFunc_XML->file, "				<Name>Open Interest</Name>\n");				fprintf(gOutFunc_XML->file, "			</RequiredInputArgument>\n");			}			if(inputInfo->flags & TA_IN_PRICE_TIMESTAMP)			{				fprintf(gOutFunc_XML->file, "			<RequiredInputArgument>\n");				fprintf(gOutFunc_XML->file, "				<Type>Timestamp</Type>\n");				fprintf(gOutFunc_XML->file, "				<Name>Timestamp</Name>\n");				fprintf(gOutFunc_XML->file, "			</RequiredInputArgument>\n");			}		}		else		{			fprintf(gOutFunc_XML->file, "			<RequiredInputArgument>\n");			if(inputInfo->type == TA_Input_Real)			{				fprintf(gOutFunc_XML->file, "				<Type>Double Array</Type>\n");			}			else if(inputInfo->type == TA_Input_Integer)			{				fprintf(gOutFunc_XML->file, "				<Type>Integer Array</Type>\n");			}			else			{				printf("Unknown input type detected.\n");			}			fprintf(gOutFunc_XML->file, "				<Name>%s</Name>\n", inputInfo->paramName);			fprintf(gOutFunc_XML->file, "			</RequiredInputArgument>\n");		}	}    fprintf(gOutFunc_XML->file, "		</RequiredInputArguments>\n");	/* Optional input arguments */	if(funcInfo->nbOptInput > 0)	{		fprintf(gOutFunc_XML->file, "		<OptionalInputArguments>\n");		for(i=0; i<funcInfo->nbOptInput; i++)		{			retCode = TA_GetOptInputParameterInfo( funcInfo->handle, i, &optInputInfo );			fprintf(gOutFunc_XML->file, "			<OptionalInputArgument>\n");			fprintf(gOutFunc_XML->file, "				<Name>%s</Name>\n", optInputInfo->displayName);			ReplaceReservedXmlCharacters(optInputInfo->hint, tempString);			fprintf(gOutFunc_XML->file, "				<ShortDescription>%s</ShortDescription>\n", (optInputInfo->hint == NULL)? "" : tempString);			if(optInputInfo->flags != 0)			{				fprintf(gOutFunc_XML->file, "				<Flags>\n");				if(optInputInfo->flags & TA_OPTIN_IS_PERCENT)				{					fprintf(gOutFunc_XML->file, "					<Flag>Percent</Flag>\n");				}				if(optInputInfo->flags & TA_OPTIN_IS_DEGREE)				{					fprintf(gOutFunc_XML->file, "					<Flag>Degree</Flag>\n");				}				if(optInputInfo->flags & TA_OPTIN_IS_CURRENCY)				{					fprintf(gOutFunc_XML->file, "					<Flag>Currency</Flag>\n");				}				if(optInputInfo->flags & TA_OPTIN_ADVANCED)				{					fprintf(gOutFunc_XML->file, "					<Flag>Advanced</Flag>\n");				}				fprintf(gOutFunc_XML->file, "				</Flags>\n");			}			if(optInputInfo->type == TA_OptInput_RealRange)			{				TA_RealRange *doubleRange;									doubleRange= (TA_RealRange*)optInputInfo->dataSet;				fprintf(gOutFunc_XML->file, "				<Type>Double</Type>\n");				fprintf(gOutFunc_XML->file, "				<Range>\n");				fprintf(gOutFunc_XML->file, "					<Minimum>%s</Minimum>\n", doubleToStr(doubleRange->min));				fprintf(gOutFunc_XML->file, "					<Maximum>%s</Maximum>\n", doubleToStr(doubleRange->max));				fprintf(gOutFunc_XML->file, "					<Precision>%d</Precision>\n", doubleRange->precision);				fprintf(gOutFunc_XML->file, "					<SuggestedStart>%s</SuggestedStart>\n", doubleToStr(doubleRange->suggested_start));				fprintf(gOutFunc_XML->file, "					<SuggestedEnd>%s</SuggestedEnd>\n", doubleToStr(doubleRange->suggested_end));				fprintf(gOutFunc_XML->file, "					<SuggestedIncrement>%s</SuggestedIncrement>\n", doubleToStr(doubleRange->suggested_increment));				fprintf(gOutFunc_XML->file, "				</Range>\n");				fprintf(gOutFunc_XML->file, "				<DefaultValue>%s</DefaultValue>\n", doubleToStr(optInputInfo->defaultValue));			}			else if(optInputInfo->type == TA_OptInput_IntegerRange)			{				TA_IntegerRange *integerRange;								integerRange = (TA_IntegerRange*)optInputInfo->dataSet;				fprintf(gOutFunc_XML->file, "				<Type>Integer</Type>\n");				fprintf(gOutFunc_XML->file, "				<Range>\n");				fprintf(gOutFunc_XML->file, "					<Minimum>%d</Minimum>\n", integerRange->min);				fprintf(gOutFunc_XML->file, "					<Maximum>%d</Maximum>\n", integerRange->max);				fprintf(gOutFunc_XML->file, "					<SuggestedStart>%d</SuggestedStart>\n", integerRange->max);				fprintf(gOutFunc_XML->file, "					<SuggestedEnd>%d</SuggestedEnd>\n", integerRange->max);				fprintf(gOutFunc_XML->file, "					<SuggestedIncrement>%d</SuggestedIncrement>\n", integerRange->max);				fprintf(gOutFunc_XML->file, "				</Range>\n");				fprintf(gOutFunc_XML->file, "				<DefaultValue>%d</DefaultValue>\n", (int)optInputInfo->defaultValue);			}			else if(optInputInfo->type == TA_OptInput_IntegerList)			{				TA_IntegerList *intList;									intList = (TA_IntegerList*) optInputInfo->dataSet;				fprintf(gOutFunc_XML->file, "				<Type>MA Type</Type>\n");				fprintf(gOutFunc_XML->file, "				<DefaultValue>%d</DefaultValue>\n", (int)optInputInfo->defaultValue);				if( intList != (TA_IntegerList*) TA_DEF_UI_MA_Method.dataSet )				{					printf("Integer lists are not supported.\n");				}			}			else			{				printf("Unknown optional input type detected.\n");			}			fprintf(gOutFunc_XML->file, "			</OptionalInputArgument>\n");		}		fprintf(gOutFunc_XML->file, "		</OptionalInputArguments>\n");	}	/* Output arguments */	fprintf(gOutFunc_XML->file, "		<OutputArguments>\n");	for(i=0; i<funcInfo->nbOutput; i++)	{		retCode = TA_GetOutputParameterInfo( funcInfo->handle, i, &outputInfo );		fprintf(gOutFunc_XML->file, "			<OutputArgument>\n");		if(outputInfo->type == TA_Output_Integer)		{			fprintf(gOutFunc_XML->file, "				<Type>Integer Array</Type>\n");		}		else if(outputInfo->type == TA_Output_Real)		{			fprintf(gOutFunc_XML->file, "				<Type>Double Array</Type>\n");		}		else		{			printf("Unknown output type detected.\n");		}		fprintf(gOutFunc_XML->file, "				<Name>%s</Name>\n", outputInfo->paramName);		if(outputInfo->flags != 0)		{			fprintf(gOutFunc_XML->file, "				<Flags>\n");			if(outputInfo->flags & TA_OUT_LINE)			{				fprintf(gOutFunc_XML->file, "					<Flag>Line</Flag>\n");			}			if(outputInfo->flags & TA_OUT_DOT_LINE)			{				fprintf(gOutFunc_XML->file, "					<Flag>Dotted Line</Flag>\n");			}			if(outputInfo->flags & TA_OUT_DASH_LINE)			{				fprintf(gOutFunc_XML->file, "					<Flag>Dashed Line</Flag>\n");			}			if(outputInfo->flags & TA_OUT_DOT)			{				fprintf(gOutFunc_XML->file, "					<Flag>Dots</Flag>\n");			}			if(outputInfo->flags & TA_OUT_HISTO)			{				fprintf(gOutFunc_XML->file, "					<Flag>Histogram</Flag>\n");			}			if(outputInfo->flags & TA_OUT_PATTERN_BOOL)			{				fprintf(gOutFunc_XML->file, "					<Flag>Pattern Bool</Flag>\n");			}			if(outputInfo->flags & TA_OUT_PATTERN_BULL_BEAR)			{				fprintf(gOutFunc_XML->file, "					<Flag>Pattern Bull Bear</Flag>\n");			}			if(outputInfo->flags & TA_OUT_PATTERN_STRENGTH)			{				fprintf(gOutFunc_XML->file, "					<Flag>Pattern Strength</Flag>\n");			}			if(outputInfo->flags & TA_OUT_POSITIVE)			{				fprintf(gOutFunc_XML->file, "					<Flag>Positive</Flag>\n");			}			if(outputInfo->flags & TA_OUT_NEGATIVE)			{				fprintf(gOutFunc_XML->file, "					<Flag>Negative</Flag>\n");			}			if(outputInfo->flags & TA_OUT_ZERO)			{				fprintf(gOutFunc_XML->file, "					<Flag>Zero</Flag>\n");			}			if(outputInfo->flags & TA_OUT_UPPER_LIMIT)			{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -