DLL была успешно построена, но она не работает - PullRequest
0 голосов
/ 01 ноября 2019

Я использую пример Plugin.cpp от amibroker ADK. Я делаю каталог 'ASCII' в папке 'amibroker' и помещаю все данные с именем * .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;   
}
...