API Documentation

PriceConvert

Converts an integer price from one price type to another.

    #define cszNxCorePriceConvert "sNxCorePriceConvert"
    typedef int (__stdcall *NxCorePriceConvert) (int lPrice, unsigned char PriceType, unsigned char PriceTypeNew);
    int PriceConvert(
        int                             lPrice,
        unsigned char                   PriceType,
        unsigned char                   PriceTypeNew
        );

Parameters

iPrice

Integer Price to be converted.

PriceType

The Price Type that iPrice is currently using.

PriceTypeNew

The Price Type to convert iPrice into.

Return Value

Returns the value of iPrice as converted into new Price Type.

Example

Here's an example of converting a price/priceType to a different priceType

#define _CRT_SECURE_NO_WARNINGS
#include <windows.h>
#include <stdio.h>
#include "NxCoreAPI.h"
#include "NxCoreAPI_class.h"    
  
NxCoreClass nxCoreClass;    
  
int __stdcall nxCoreCallback(const NxCoreSystem* pNxCoreSys, const NxCoreMessage* pNxCoreMessage)
{
    switch (pNxCoreMessage->MessageType)
    {
        case NxMSG_TRADE:
        {
            const NxCoreTrade& nt = pNxCoreMessage->coreData.Trade;    
  
            unsigned char lessType = nt.PriceType + 1;
            unsigned char moreType = nt.PriceType - 1;    
  
            int lessPrice = nxCoreClass.PriceConvert(nt.Price, nt.PriceType, lessType);
            int morePrice = nxCoreClass.PriceConvert(nt.Price, nt.PriceType, moreType);    
  
            char orig[32];
            char less[32];
            char more[32];    
  
            nxCoreClass.PriceFormat(orig, nt.Price, nt.PriceType);
            nxCoreClass.PriceFormat(less, lessPrice, lessType);
            nxCoreClass.PriceFormat(more, morePrice, moreType);    
  
            printf("Org    = %s\n",orig);
            printf("Less   = %s\n",less);
            printf("More   = %s\n",more);
            printf("\n"); 
            
        }
    }
    return NxCALLBACKRETURN_CONTINUE;
}    
  
int main(int argc, char** argv)
{
    if (!nxCoreClass.LoadNxCore("NxCoreAPI.dll") &&
        !nxCoreClass.LoadNxCore("C:\\Program Files\\Nanex\\NxCoreAPI\\NxCoreAPI.dll"))
    {
        fprintf(stderr, "Can't find NxCoreAPI.dll\n");
        return -1;
    }
    nxCoreClass.ProcessTape(argv[1], 0, NxCF_EXCLUDE_CRC_CHECK, 0, nxCoreCallback);
    return 0;
}