DLL已成功构建,但无法正常工作

时间:2019-11-01 06:52:34

标签: c++ amibroker

我使用来自amibroker ADK的示例Plugin.cpp。我在文件夹“ amibroker”下创建一个目录“ ASCII”,并将所有数据放入名为* .AQI的内部。但是在amibroker中没有发现数据。我在函数GetQuotesEx中进行了更改是否导致了问题?

PLUGINAPI int GetQuotesEx( LPCTSTR pszTicker, int nPeriodicity, int nLastValid, int nSize, struct Quotation *pQuotes, GQEContext *pContext  )
{
    char filename[256];
    FILE* fh;
    int  iLines = 0;

    // format path to the file (we are using relative path)
    sprintf_s(filename, "ASCII\\%s.AQI", pszTicker);

    // open file for reading
    fopen_s(&fh, filename, "r");

    // if file is successfully opened read it and fill quotation array
    if (fh)
    {
        char line[ 256 ];

        // read the line of text until the end of text
        // but not more than array size provided by AmiBroker
        while( fgets( line, sizeof( line ), fh ) && iLines < nSize )
        {
            // get array entry
            struct Quotation *qt = &pQuotes[ iLines ];
            char* pTmp = NULL;

            // parse line contents: divide tokens separated by comma (strtok) and interpret values

            // date and time first
            int datenum = atoi( strtok_s( line, ",", &pTmp) );  // YYMMDD
            int timenum = atoi( strtok_s( NULL, ",", &pTmp) );  // HHMM

            // unpack datenum and timenum and store date/time 
            qt->DateTime.Date = 0; // make sure that date structure is intialized with zero
            qt->DateTime.PackDate.Minute = timenum % 100;
            qt->DateTime.PackDate.Hour = timenum / 100;
            qt->DateTime.PackDate.Year = 2000 + datenum / 10000;
            qt->DateTime.PackDate.Month = ( datenum / 100 ) % 100;
            qt->DateTime.PackDate.Day = datenum % 100;

            // now OHLC price fields
            qt->Open = (float) atof( strtok_s( NULL, ",", &pTmp) );
            qt->High = (float) atof( strtok_s( NULL, ",", &pTmp) );
            qt->Low  = (float) atof( strtok_s( NULL, ",", &pTmp) );
            qt->Price = (float) atof( strtok_s( NULL, ",", &pTmp) ); // close price

            // ... and Volume
            qt->Volume = (float) atof( strtok_s( NULL, ",\n", &pTmp) );

            iLines++;
        }

        // close the file once we are done
        fclose( fh );

    }

    // return number of lines read which is equal to
    // number of quotes
    return iLines;   
}

0 个答案:

没有答案