API Documentation

Syntax

    #define cszNxCorePriceToDouble "sNxCorePriceToDouble"
    typedef double (__stdcall *NxCorePriceToDouble) (int lPrice, unsigned char PriceType);
    double PriceToDouble(int           Price,
                         unsigned char PriceType);

Parameters

Price

Integer representing the Price to format.

PriceType

The Price Type that Price is using.

Return Value

Returns a double that represents the Price and PriceType combination.

Example

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

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include "NxCoreAPI.h"
#include "NxCoreAPI_Wrapper_C++.h"              
              
NxCoreClass NxCore;              

int __stdcall nxCoreCallback(const NxCoreSystem* pNxCoreSys, const NxCoreMessage* pNxCoreMessage)
{
    switch (pNxCoreMessage->MessageType)
    {
        case NxMSG_TRADE:
        {
            const NxCoreTrade& nt = pNxCoreMessage->coreData.Trade;    
            
            double lastTradePrice = NxCore.PriceToDouble(nt.Price, nt.PriceType);    
            
            printf("Last Trade = %0.2f\n",lastTradePrice);    
            
            break;
        }
    } 
    return NxCALLBACKRETURN_CONTINUE;
}

int main(int argc, char** argv)
{
    if (!NxCore.LoadNxCore("NxCoreAPI64.dll") &&
        !NxCore.LoadNxCore("NxCoreAPI.dll"))
    {
        printf("loading library failed\n");
        return -1;
    }
    NxCore.ProcessTape(argv[1], 0, NxCF_EXCLUDE_CRC_CHECK, 0, nxCoreCallback);
    return 0;
}
import net.nanex.NxCoreClass;
class PriceToDoubleSample extends NxCoreClass{
    
    
    @Override
    public int OnNxCoreCallback(NxCoreSystem nxCoreSys, NxCoreMessage nxCoreMsg) {
        switch (nxCoreMsg.MessageType)
        {
            case defines.NxMSG_TRADE:
            {
                NxCoreTrade nt = nxCoreMsg.coreData.Trade;    
                
                double lastTradePrice = PriceToDouble(nt.Price, nt.PriceType);
                
                System.out.println(String.format("Last Trade = %.02f",lastTradePrice));
                break;
            }
        }
        return defines.NxCALLBACKRETURN_CONTINUE;
    }

    public static void main(String args[]) {
        PriceToDoubleSample nxCore = new PriceToDoubleSample();

        if (nxCore.LoadNxCore("NxCoreAPI64.dll") != 0){
            nxCore.ProcessTape(args[0], 0, defines.NxCF_EXCLUDE_CRC_CHECK, 0);
        }
        else
            System.out.println("loading library failed");
    }
}
import NxCore

tapePath = ""

def OnNxCoreCallback(NxCoreSys, NxCoreMsg):
    if NxCoreMsg.MessageType == NxCore.NxMSG_TRADE:
        nt = NxCoreMsg.coreData.Trade;    
        
        lastTradePrice = NxCore.PriceToDouble(nt.Price, nt.PriceType)
        
        #PriceToFloat is identical to PriceToDouble. The only difference is function name corresponds to the Python floating point type name.
        #lastTradePrice = NxCore.PriceToFloat(nt.Price, nt.PriceType)
        
        print("Last Trade = {:.02f}".format(lastTradePrice))
    return NxCore.NxCALLBACKRETURN_CONTINUE

if NxCore.LoadNxCore("NxCoreAPI64.dll"):
    returnValue = NxCore.ProcessTape(tapePath, 0, NxCore.NxCF_EXCLUDE_CRC_CHECK, 0, OnNxCoreCallback)
else:
    print("loading library failed")