Exemple #1
0
TA_RetCode TA_SetInputParamPricePtr( TA_ParamHolder     *param,
                                     const TA_Timestamp *timestamp,
                                     const TA_Real      *open,
                                     const TA_Real      *high,
                                     const TA_Real      *low,
                                     const TA_Real      *close,
                                     const TA_Integer   *volume,
                                     const TA_Integer   *openInterest )
{
   /* The following code is fundamentaly the same as
    * the SET_INPUT_PARAMETER.
    */
   TA_ParamHolderPriv *paramHolderPriv;
   const TA_InputParameterInfo *paramInfo;

   if( param == NULL )
      return TA_BAD_PARAM;

   /* Validate the TA_ParamHolderPriv. */
   paramHolderPriv = (TA_ParamHolderPriv *)param;

   if( paramHolderPriv->magicNumber != TA_PARAM_HOLDER_PRIV_MAGIC_NB )
      return TA_INVALID_PARAM_HOLDER;

   /* Check correct function is used with correct type of parameter. */
   if( paramHolderPriv->type != TA_PARAM_HOLDER_INPUT )
      return TA_INVALID_PARAM_HOLDER_TYPE;

   paramInfo = paramHolderPriv->p.in.inputInfo;

   if( paramInfo->type != TA_Input_Price )
      return TA_INVALID_PARAM_HOLDER_TYPE;

   /* Validate that the needed parameter are provided. */
   #define SET_PARAM_INFO(lowerParam,upperParam) \
   { \
      if( paramInfo->flags & TA_IN_PRICE_##upperParam ) \
      { \
         if( lowerParam == NULL ) \
            return TA_BAD_PARAM; \
         paramHolderPriv->p.in.data.inPrice.lowerParam = lowerParam; \
      } \
   }

   SET_PARAM_INFO(open, OPEN );
   SET_PARAM_INFO(high, HIGH );
   SET_PARAM_INFO(low, LOW );
   SET_PARAM_INFO(close, CLOSE );
   SET_PARAM_INFO(volume, VOLUME );
   SET_PARAM_INFO(openInterest, OPENINTEREST );
   SET_PARAM_INFO(timestamp, TIMESTAMP );

   #undef SET_PARAM_INFO

   /* Got/validate all the information required for this parameter. */
   paramHolderPriv->valueInitialize = 1;
   return TA_SUCCESS;
}
Exemple #2
0
TA_RetCode TA_SetInputParamPricePtr( TA_ParamHolder     *param,
                                     unsigned int        paramIndex,
                                     const TA_Real      *open,
                                     const TA_Real      *high,
                                     const TA_Real      *low,
                                     const TA_Real      *close,
                                     const TA_Real      *volume,
                                     const TA_Real      *openInterest )
{
   
   TA_ParamHolderPriv *paramHolderPriv;
   const TA_InputParameterInfo *paramInfo;
   const TA_FuncInfo *funcInfo;

   if( param == NULL )
   {
      return TA_BAD_PARAM;
   }

   paramHolderPriv = (TA_ParamHolderPriv *)(param->hiddenData);
   if( paramHolderPriv->magicNumber != TA_PARAM_HOLDER_PRIV_MAGIC_NB )
   {
      return TA_INVALID_PARAM_HOLDER;
   }

   /* Make sure this index really exist. */
   funcInfo = paramHolderPriv->funcInfo;
   if( !funcInfo ) return TA_INVALID_HANDLE;
   if( paramIndex >= funcInfo->nbInput )
   {
      return TA_BAD_PARAM;
   }   

   /* Verify the type of the parameter. */
   paramInfo = paramHolderPriv->in[paramIndex].inputInfo;
   if( !paramInfo ) return TA_INTERNAL_ERROR(2);
   if( paramInfo->type != TA_Input_Price )
   {
      return TA_INVALID_PARAM_HOLDER_TYPE;
   }

   /* keep a copy of the provided parameter. */
   #define SET_PARAM_INFO(lowerParam,upperParam) \
   { \
      if( paramInfo->flags & TA_IN_PRICE_##upperParam ) \
      { \
         if( lowerParam == NULL ) \
         { \
            return TA_BAD_PARAM; \
         } \
         paramHolderPriv->in[paramIndex].data.inPrice.lowerParam = lowerParam; \
      } \
   }

   SET_PARAM_INFO(open, OPEN );
   SET_PARAM_INFO(high, HIGH );
   SET_PARAM_INFO(low, LOW );
   SET_PARAM_INFO(close, CLOSE );
   SET_PARAM_INFO(volume, VOLUME );
   SET_PARAM_INFO(openInterest, OPENINTEREST );

   #undef SET_PARAM_INFO

   /* This parameter is now initialized, clear the corresponding bit. */
   paramHolderPriv->inBitmap &= ~(1<<paramIndex);

   return TA_SUCCESS;
}
Exemple #3
0
TA_RetCode TA_SetInputParamPricePtr( TA_ParamHolder     *param,
                                     unsigned int        paramIndex,
                                     const TA_Timestamp *timestamp,
                                     const TA_Real      *open,
                                     const TA_Real      *high,
                                     const TA_Real      *low,
                                     const TA_Real      *close,
                                     const TA_Integer   *volume,
                                     const TA_Integer   *openInterest )
{
   TA_PROLOG
   TA_ParamHolderPriv *paramHolderPriv;
   const TA_InputParameterInfo *paramInfo;
   const TA_FuncInfo *funcInfo;

   TA_TRACE_BEGIN( TA_SetInputParamIntegerPtr );

   if( param == NULL )
   {
      TA_TRACE_RETURN( TA_BAD_PARAM );
   }

   paramHolderPriv = (TA_ParamHolderPriv *)(param->hiddenData);
   if( paramHolderPriv->magicNumber != TA_PARAM_HOLDER_PRIV_MAGIC_NB )
   {
      TA_TRACE_RETURN( TA_INVALID_PARAM_HOLDER );
   }

   /* Make sure this index really exist. */
   funcInfo = paramHolderPriv->funcInfo;
   TA_DEBUG_ASSERT( funcInfo != NULL );
   if( paramIndex >= funcInfo->nbInput )
   {
      TA_TRACE_RETURN( TA_BAD_PARAM );
   }   

   /* Verify the type of the parameter. */
   paramInfo = paramHolderPriv->in[paramIndex].inputInfo;
   TA_DEBUG_ASSERT( paramInfo != NULL );
   if( paramInfo->type != TA_Input_Price )
   {
      TA_TRACE_RETURN( TA_INVALID_PARAM_HOLDER_TYPE );
   }

   /* keep a copy of the provided parameter. */
   #define SET_PARAM_INFO(lowerParam,upperParam) \
   { \
      if( paramInfo->flags & TA_IN_PRICE_##upperParam ) \
      { \
         if( lowerParam == NULL ) \
         { \
            TA_TRACE_RETURN( TA_BAD_PARAM ); \
         } \
         paramHolderPriv->in[paramIndex].data.inPrice.lowerParam = lowerParam; \
      } \
   }

   SET_PARAM_INFO(open, OPEN );
   SET_PARAM_INFO(high, HIGH );
   SET_PARAM_INFO(low, LOW );
   SET_PARAM_INFO(close, CLOSE );
   SET_PARAM_INFO(volume, VOLUME );
   SET_PARAM_INFO(openInterest, OPENINTEREST );
   SET_PARAM_INFO(timestamp, TIMESTAMP );

   #undef SET_PARAM_INFO

   /* This parameter is now initialized, clear the corresponding bit. */
   paramHolderPriv->inBitmap &= ~(1<<paramIndex);

   TA_TRACE_RETURN( TA_SUCCESS );
}