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.
Here's an example of converting a price/priceType to a different priceType
#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; unsigned char lessType = nt.PriceType + 1; unsigned char moreType = nt.PriceType - 1; int lessPrice = NxCore.PriceConvert(nt.Price, nt.PriceType, lessType); int morePrice = NxCore.PriceConvert(nt.Price, nt.PriceType, moreType); char orig[32]; char less[32]; char more[32]; NxCore.PriceFormat(orig, nt.Price, nt.PriceType); NxCore.PriceFormat(less, lessPrice, lessType); NxCore.PriceFormat(more, morePrice, moreType); printf("Org = %s\n",orig); printf("Less = %s\n",less); printf("More = %s\n",more); printf("\n"); break; } } return NxCALLBACKRETURN_CONTINUE; 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 PriceConvertSample extends NxCoreClass{ @Override public int OnNxCoreCallback(NxCoreSystem nxCoreSys, NxCoreMessage nxCoreMsg) { switch (nxCoreMsg.MessageType) { case defines.NxMSG_TRADE: { NxCoreTrade nt = nxCoreMsg.coreData.Trade; int lessType = nt.PriceType + 1; int moreType = nt.PriceType - 1; int lessPrice = PriceConvert(nt.Price, nt.PriceType, lessType); int morePrice = PriceConvert(nt.Price, nt.PriceType, moreType); String orig = PriceFormat(nt.Price, nt.PriceType); String less = PriceFormat(lessPrice, lessType); String more = PriceFormat(morePrice, moreType); System.out.println(String.format("Org = %s",orig)); System.out.println(String.format("Less = %s",less)); System.out.println(String.format("More = %s\n",more)); break; } } return defines.NxCALLBACKRETURN_CONTINUE; } public static void main(String args[]) { PriceConvertSample nxCore = new PriceConvertSample(); 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; lessType = nt.PriceType + 1; moreType = nt.PriceType - 1; lessPrice = NxCore.PriceConvert(nt.Price, nt.PriceType, lessType); morePrice = NxCore.PriceConvert(nt.Price, nt.PriceType, moreType); orig = NxCore.PriceFormat(nt.Price, nt.PriceType); less = NxCore.PriceFormat(lessPrice, lessType); more = NxCore.PriceFormat(morePrice, moreType); print("Org = "+orig) print("Less = "+less) print("More = "+more+"\n") 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") |