unit PascalNxCoreAPI; // TODO - This is getting a bit ugly with TI specific code. I should probably // move the TI specifc stuff into a helper unit, // Version 0.91 of this translation of NXCOREAPI.H. Not to be used in a production // environment. Partially translated by Hugh Van Dyke and a helper unknown :) //Feb 9, 2006 - Fixed TNxCoreCategory to properly reflect the fact that the // pnxFields record is actually a poiner to an array of // TNxCoreCategoryField types. This is done through the addition // of the new PNxCategoryFieldArray pointer type and the // TNxCategoryFieldArray array type. interface uses SysUtils, TwoDLookup, {$IFDEF WIN32} Windows; {$ELSE} Wintypes, WinProcs; {$ENDIF} var SymbolTranslations: TTwoDArray; ////////////////////////////////////////////////////////////////////// /// NxDate.DSTIndicator Daylight Savings Time Indicator (DST) types.// ////////////////////////////////////////////////////////////////////// const NxDATE_DST_UNKNOWN = 0; // DST is unknown. NxDATE_DST_ON = 1; // DST is on. From 1st Sunday (2am) in April, to Last Sunday (2am) in October, clock is ahead 1 hour from Standard Time. NxDATE_DST_OFF = 2; // DST is on. From Last Sunday (2am) in October, to 1st Sunday (2am) in April, clock is at Standard Time. NxDATE_DST_ONTODAY = 3; // DST on at 2am today. Must be 1st Sunday in April NxDATE_DST_OFFTODAY = 4; // DST off at 2am today. Must be last Sunday in October ////////////////////////////////////////////////////////////////////// ///////////// NxDate.DayOfWeek Day of week /////////////////////////// ////////////////////////////////////////////////////////////////////// NxDOW_SUNDAY = 0; NxDOW_MONDAY = 1; NxDOW_TUESDAY = 2; NxDOW_WEDNESDAY = 3; NxDOW_THURSDAY = 4; NxDOW_FRIDAY = 5; NxDOW_SATURDAY = 6; ////////////////////////////////////////////////////////////////////// ///////// NxCoreSystem.ClockUpdateInterval definitions /////////////// ////////////////////////////////////////////////////////////////////// const NxCLOCK_NOCHANGE = 0; // clock has not changed since last message. NxCLOCK_CLOCK = 1; // NxCoreSystem.nxTime.Millisecond is longest interval that changed. NxCLOCK_SECOND = 2; // NxCoreSystem.nxTime.Second is longest interval that changed. NxCLOCK_MINUTE = 3; // NxCoreSystem.nxTime.Minute is longest interval that changed. NxCLOCK_HOUR = 4; // NxCoreSystem.nxTime.Hour is longest interval that changed. ////////////////////////////////////////////////////////////////////// /////////// NxCoreSystem.Status definitions ////////////////////////// ////////////////////////////////////////////////////////////////////// const NxCORESTATUS_RUNNING = 0; // system is running. NxCORESTATUS_INITIALIZING = 1; // first message sent when processing a tape. NxCORESTATUS_COMPLETE = 2; // last message sent when processing a tape, unless user aborts by returning a non-zero value (NxCALLBACKRETURN_STOP) from callback. NxCORESTATUS_SYNCHRONIZING = 3; // synchronization reset detected in the tape, continuing processing NxCORESTATUS_ERROR = 4; // an error has occurred and processing halted. NxCORESTATUS_COMPLETE message will follow NxCORESTATUS_WAITFORCOREACCESS = 5; // NxCoreAPI.dll is waiting for NxCore Access to connect. NxCORESTATUS_RESTARTING_TAPE = 6; // NxCoreAPI.dll is restarting the same tape from the beginning at users request NxCORESTATUS_LOADED_STATE = 7; // NxCoreAPI.dll initialized from state NxCORESTATUS_SAVING_STATE = 8; // NxCoreAPI.dll will begin state save after this message ////////////////////////////////////////////////////////////////////// ///////// StatusData member may be set to one of the following /////// ////////////////////////////////////////////////////////////////////// const NxCSRUNMODE_SRC_DISK_FILE = 0; // processing from a tape on disk NxCSRUNMODE_SRC_ACCESS_FILE = 1; // processing from NxCoreAccess's file -- dll has not yet reached memory buffers NxCSRUNMODE_SRC_ACCESS_MEMORY = 2; // processing from NxCoreAccess's memory buffers NxCSRUNMODE_SRC_ACCESS_MB_OLDEST = 2; // processing oldest of NxCoreAccess's memory buffers NxCSRUNMODE_SRC_ACCESS_MB_LOWER = 3; // processing older half of NxCoreAccess's memory buffers NxCSRUNMODE_SRC_ACCESS_MB_UPPER = 4; // processing most recent half of NxCoreAccess's memory buffers NxCSRUNMODE_SRC_ACCESS_MB_SECOND = 5; // processing 2nd most recent. NxCSRUNMODE_SRC_ACCESS_MB_CURRENT = 6; // processing most recent of NxCoreAccess's memory buffers ////////////////////////////////////////////////////////////////////// //////////////////////// NxCoreData Members ////////////////////////// ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// ////////// NxCoreQuote.NasdaqBidTick definitions ///////////////////// ////////////////////////////////////////////////////////////////////// const NxQTE_NASDBIDTICK_NA = 0; // bid tick is not applicable for symbol. NxQTE_NASDBIDTICK_UP = 1; // set when bid tick is up. NxQTE_NASDBIDTICK_DN = 2; // set when bid tick is down. NxQTE_NASDBIDTICK_NO = 3; // NASDAQ stock that does not carry a bid tick (small caps, etc) ////////////////////////////////////////////////////////////////////// /////////// NxCoreQuote.Refresh definitions ////////////////////////// ////////////////////////////////////////////////////////////////////// const NxQTE_REFRESH_SOURCE = 1; // The source of the data has refreshed quote. Only seen for Market Makers in morning reset NxQTE_REFRESH_MISMATCH = 2; // A mismatch detected in NxCore processors from last received quote information. NxQTE_REFRESH_SYNCHRONIZE = 3; // NxCore processors are resending last known quotes to ensure synchronization. Rare. ////////////////////////////////////////////////////////////////////// ///////// NxCoreExgQuote.BBOChangeFlags definitions. ///////////////// ////////////////////////////////////////////////////////////////////// const NxBBOCHANGE_BIDEXG = $01; // BestBidExg != PrevBestBidExg NxBBOCHANGE_BIDPRICE = $02; // BestBidPriceChange != 0 NxBBOCHANGE_BIDSIZE = $04; // BestBidSizeChange != 0 NxBBOCHANGE_ASKEXG = $10; // BestAskExg != PrevBestAskExg NxBBOCHANGE_ASKPRICE = $20; // BestAskPriceChange != 0 NxBBOCHANGE_ASKSIZE = $40; // BestAskSizeChange != 0 ////////////////////////////////////////////////////////////////////// ///////// Exchange constants////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// const NxEXCH_NQEX = 1; NxEXCH_NQAD = 2; NxEXCH_NYSE = 3; NxEXCH_AMEX = 4; NxEXCH_CBOE = 5; NxEXCH_ISEX = 6; NxEXCH_PACF = 7; NxEXCH_CINC = 8; NxEXCH_PHIL = 9; NxEXCH_OPRA = 10; NxEXCH_BOST = 11; NxEXCH_NQNM = 12; NxEXCH_NQSC = 13; NxEXCH_NQBB = 14; NxEXCH_NQPK = 15; NxEXCH_NQAG = 16; NxEXCH_CHIC = 17; NxEXCH_TSE = 18; NxEXCH_CDNX = 19; NxEXCH_CME = 20; NxEXCH_NYBT = 21; NxEXCH_NYBA = 22; NxEXCH_COMX = 23; NxEXCH_CBOT = 24; NxEXCH_NYMX = 25; NxEXCH_KCBT = 26; NxEXCH_MGEX = 27; NxEXCH_WCE = 28; NxEXCH_ONEC = 29; NxEXCH_DOWJ = 30; NxEXCH_NNEX = 31; NxEXCH_SIMX = 32; NxEXCH_FTSE = 33; NxEXCH_EURX = 34; NxEXCH_ENXT = 35; NxEXCH_DTN = 36; NxEXCH_LMT = 37; NxEXCH_LME = 38; NxEXCH_IPEX = 39; NxEXCH_MSE = 40; NxEXCH_WSE = 41; NxEXCH_ISLD = 42; NxEXCH_MDAM = 43; NxEXCH_CLRP = 44; NxEXCH_BARK = 45; NxEXCH_TULL = 46; NxEXCH_CQTS = 47; NxEXCH_HOTS = 48; NxEXCH_EUUS = 49; NxEXCH_EUEU = 50; NxEXCH_ENCM = 51; NxEXCH_ENID = 52; NxEXCH_ENIR = 53; NxEXCH_CFE = 54; NxEXCH_PBOT = 55; NxEXCH_HWTB = 56; NxEXCH_NQNX = 57; NxEXCH_BTRF = 58; NxEXCH_NTRF = 59; NxEXCH_BATS = 60; NxEXCH_NYLF = 61; NxEXCH_PINK = 62; NxEXCH_BATY = 63; NxEXCH_EDGE = 64; NxEXCH_EDGX = 65; ////////////////////////////////////////////////////////////////////// /////////////////////////// NxDate /////////////////////////////////// ////////////////////////////////////////////////////////////////////// type TNxDate = record NDays: Cardinal; Year: Word; Month: Byte; Day: Byte; DSTIndicator: Byte; DayOfWeek: Byte; DayOfYear: Word; Alignment: Array[0..3] of Byte; // aligns NxDate to 16 bytes. end; ////////////////////////////////////////////////////////////////////// /////////////////////////// NxTime /////////////////////////////////// ////////////////////////////////////////////////////////////////////// type TNxTime = record MsOfDay: Cardinal; Millisecond: Word; Second: Byte; Minute: Byte; Hour: Byte; TimeZone: Char; MsResolution: Word; Alignment: Array[0..3] of Byte; // aligns NxTime to 16 bytes. end; ////////////////////////////////////////////////////////////////////// ////////////////////////// NxString ////////////////////////////////// ////////////////////////////////////////////////////////////////////// type TNxString = record UserData1: Integer; UserData2: Integer; Atom: Word; Str: Array[0..0] of char ; end; PNxString = ^TNxString ; //added by me //Added by MF type TNxAStatus = record Version: Cardinal; AcctExpireDays: Integer; Status: Byte; AttnLevel: Byte; StatusMCS: Byte; AttnLevelMCS: Byte; UDPPingTime: Word; UDPPktLossPct: Word; NxClockDiff: Integer; NxClockReceived: Cardinal; SysClockDrift: Integer; SecondsRunning: Cardinal; RecvBytes: Cardinal; SendBytes: Cardinal; MCClients: Word; MCCLicenses: Word; ChatMsgIndc: Byte; end; PNxAStatus = ^TNxAStatus ; type TNxCoreSystem = record UserData: Integer; DLLVersion: Integer; NxDate: TNxDate; NxTime: TNxTime; ClockUpdateInterval: Integer; Status: Integer; StatusData: Integer; StatusDisplay: PChar; TapeDisplay: PChar; Module: Pointer; ThreadInstance: Pointer; PermissionSet: PChar; NxAccessStatus: PNxAStatus; end; PNxCoreSystem = ^TNxCoreSystem ; ////////////////////////////////////////////////////////////////////// /////////////////// NxCoreQuote ////////////////////////////////////// ////////////////////////////////////////////////////////////////////// type TNxCoreQuote = record AskSize: Integer; BidSize: Integer; AskSizeChange: Integer; BidSizeChange: Integer; AskPrice: Integer; BidPrice: Integer; AskPriceChange: Integer; BidPriceChange: Integer; PriceType: Byte; Refresh: Byte; QuoteCondition: Byte; NasdaqBidTick: Byte; Alignment: Array[0..3] of Byte; end; type TNxCoreExgQuote = record CoreQuote: TNxCoreQuote; BestAskPrice: Integer; BestBidPrice: Integer; BestAskPriceChange: Integer; BestBidPriceChange: Integer; BestAskSize: Integer; BestBidSize: Integer; BestAskSizeChange: Integer; BestBidSizeChange: Integer; BestAskExg: Word; BestBidExg: Word; PrevBestAskExg: Word; PrevBestBidExg: Word; BestAskCondition: Byte; BestBidCondition: Byte; BBOChangeFlags: Byte; ClosingQuoteFlag: Byte; Alignment: Array[0..3] of Byte; end; ////////////////////////////////////////////////////////////////////// /////////// NxCoreMMQuote.MarketMakerType definitions //////////////// ////////////////////////////////////////////////////////////////////// const NxMMT_UNKNOWN = 0; // not set, not applicable NxMMT_REGULAR = 1; // regular market maker -- not primary, not passive. NxMMT_PRIMARY = 2; // primary market maker. NxMMT_PASSIVE = 3; // passive market maker. ////////////////////////////////////////////////////////////////////// /////////// NxCoreMMQuote.QuoteType definitions ////////////////////// ////////////////////////////////////////////////////////////////////// const NxMMQT_UNKNOWN = 0; NxMMQT_REGULAR = 1; NxMMQT_PASSIVE = 2; // passive quote. (not same thing as MMT_PASSIVE which is a type of market maker) NxMMQT_SYNDICATE = 3; // Syndicate BID ONLY NxMMQT_PRESYNDICATE = 4; // Presyndicate BID ONLY NxMMQT_PENALTY = 5; // Penalty. BID ONLY type TNxCoreMMQuote = record coreQuote: TNxCoreQuote; pnxStringMarketMaker: PNxString; MarketMakerType: Byte; QuoteType: Byte; end; ////////////////////////////////////////////////////////////////////// /////////////// NxCoreTrade.PriceFlags definitions. ////////////////// ////////////////////////////////////////////////////////////////////// const NxTPF_SETLAST = $01; // Set if this trade report is a type of opening report. For snapshot indicies, this is the 'open' field. See TradeConditions for the types that update this flag. NxTPF_SETHIGH = $02; // Set if this trade report had the highest price at the time the report was sent NxTPF_SETLOW = $04; // Set if this trade report had the lowest price at the time the report was sent NxTPF_SETOPEN = $08; // Set if this trade report is a type of opening report. For snapshot indicies, this is the 'open' field. See TradeConditions for the types that update this flag. NxTPF_EXGINSERT = $10; // trade reported inserted, not real-time. Often follows EXGCANCEL for trade report corrections. NxTPF_EXGCANCEL = $20; // Cancel message. The data in this trade report reflects the state of the report when first sent, including the SETLAST/increment volume, etc flags. ////////////////////////////////////////////////////////////////////// ////////////// NxCoreTrade.ConditionFlags definitions. /////////////// ////////////////////////////////////////////////////////////////////// const NxTCF_NOLAST = $01; // not eligible to update last price. NxTCF_NOHIGH = $02; // not eligible to update high price. NxTCF_NOLOW = $04; // not eligible to update low price. ////////////////////////////////////////////////////////////////////// /////////////// NxCoreTrade.VolumeType definitions. ////////////////// ////////////////////////////////////////////////////////////////////// const NxTVT_INCRVOL = 0; // incremental volume. UNSIGNED, increments total volume. NxTVT_NONINCRVOL = 1; // non-incremental volume. Rarely used outside of indexes. Intraday and Open detail in NYSE stocks. NxTVT_TOTALVOL = 2; // dwSize*is* the total volume -- used mainly in a few indexes NxTVT_TOTALVOLx100 = 3; // dwSize*is* the total volume/100. multiply by 100 for current total volume. RARE -- in DOW indexes ////////////////////////////////////////////////////////////////////// /////////////// NxCoreTrade.nxAnalysis.SigHiLoType definitions. ////// ////////////////////////////////////////////////////////////////////// const NxRTA_SIGHL_EQ = 0; NxRTA_SIGHL_LOWEST = 1; NxRTA_SIGHL_LOW = 2; NxRTA_SIGHL_HIGH = 3; NxRTA_SIGHL_HIGHEST = 4; ////////////////////////////////////////////////////////////////////// ////////// NxCoreTrade.nxAnalysis.QteMatchTypeRGN and //////////////// ////////// NxCoreTrade.nxAnalysis.QteMatchTypeBBO definitions. /////// ////////////////////////////////////////////////////////////////////// const NxRTA_QMTYPE_NONE = 0; // no recent quotes. NxRTA_QMTYPE_BID = 1; // at bid or higher. NxRTA_QMTYPE_ASK = 2; // at ask or lower NxRTA_QMTYPE_INSIDE = 3; // exactly between bid/ask. 0 dist means locked. NxRTA_QMTYPE_BELOWBID = 4; // lower than bid NxRTA_QMTYPE_ABOVEASK = 5; // higher than ask ////////////////////////////////////////////////////////////////////// ////////// NxCoreTrade.nxAnalysis.QteMatchFlagsRGN and /////////////// ////////// NxCoreTrade.nxAnalysis.QteMatchFlagsBBO definitions. ////// ////////////////////////////////////////////////////////////////////// const NxRTA_QTEMATCHFLAG_OLDER = $01; // matched a quote older than a previously matched quote, possible indication of staleness NxRTA_QTEMATCHFLAG_CROSSED = $02; ////////////////////////////////////////////////////////////////////// //////////////////// NxCoreTrade.nxAnalysis ////////////////////////// ////////////////////////////////////////////////////////////////////// type TNxCTAnalysis = record FilterThreshold: Integer; Filtered: Byte; FilterLevel: Byte; SigHiLoType: Byte; Alignment: Byte; SigHiLoSeconds: Cardinal; QteMatchDistanceRGN: Integer; QteMatchDistanceBBO: Integer; QteMatchTypeRGN: Byte; QteMatchTypeBBO: Byte; QteMatchFlagsRGN: Byte; QteMatchFlagsBBO: Byte; end; ////////////////////////////////////////////////////////////////////// ////////////////////// NxCoreTrade /////////////////////////////////// ////////////////////////////////////////////////////////////////////// type TNxCoreTrade = record Price: Integer; PriceType: Byte; PriceFlags: Byte; TradeCondition: Byte; ConditionFlags: Byte; VolumeType: Byte; alignment: Array[0..2] of Byte; Size: Cardinal; ExgSequence: Cardinal; RecordsBack: Cardinal; nxAnalysis: TNxCtAnalysis; TotalVolume: INT64; //int64 is signed, this should be defined as unsigned TickVolume: Cardinal; Open: Integer; High: Integer; Low: Integer; Last: Integer; Tick: Integer; NetChange: Integer; end; ////////////////////////////////////////////////////////////////////// ///////////// NxCategoryField.FieldType definitions. ///////////////// ////////////////////////////////////////////////////////////////////// const NxCFT_UNKNOWN = 0; NxCFT_64BIT = 1; NxCFT_32BIT = 2; NxCFT_STRINGZ = 3; NxCFT_DOUBLE = 4; NxCFT_PRICE = 5; NxCFT_DATE = 6; NxCFT_TIME = 7; NxCFT_NxSTRING = 8; NxCFT_STRING_IDX = 9; NxCFT_STRING_MAP = 10; type TNxPrice = record Price: Integer; PriceType: Byte; end; type TStringTableItem = record ixTable: Cardinal; idString: Cardinal; end; type TNxCategoryField = record FieldName: PChar; FieldInfo: PChar; _Set: Byte; //I changed from Set to _Set FieldType: Byte; alignment: array[0..5] of Byte; case Word of 1: (i64Bit: INT64;); 2: (i32Bit: Integer;); 3: (StringZ: PChar;); 4: (Double: Double;); 5: (NxPrice: TNxPrice;); 6: (NxDate: TNxDate;); 7: (NxTime: TNxTime;); 8: (PNxString: PNxString;); 9: (StringTableItem: TStringTableItem;); end; PNxCategoryField = ^TNxCategoryField ; //added by EK TNxCategoryFieldArray = array[0..27] of TNxCategoryField; //hard coded to 28 fields for now...MUST CHECK NFields value and never overrun index!!! PNxCategoryFieldArray = ^TNxCategoryFieldArray; type TNxCoreCategory = record pnxStringCategory: PNxString; pnxFields: PNxCategoryFieldArray; NFields: Word; end; type TNxOptionHdr = record DateAndStrike: PNxString; Underlying: PNxString; SeriesChain: PNxString; SpecialSettle: PNxString; ExgUnderlying: Word; ContractUnit: Word; StrikePrice: Integer; StrikePriceEst: Integer; PutCall: Byte; ExpirationCycle: Byte; OICStrikeAge: Byte; NxStrikeMatch: Byte; NxExpirationDate: TNxDate; end; PNxOptionHdr = ^TNxOptionHdr; //added by EK ////////////////////////////////////////////////////////////////////// ////////////// NxCoreSymbolChange.Status values ////////////////////// ////////////////////////////////////////////////////////////////////// const NxSS_ADD = 0; // symbol has been added effective immediately. NxSS_DEL = 1; // symbol marked for deletion at end of session. NxSS_MOD = 2; // symbol changed, or moved from one ListedExg to another. pnxsSymbolOld, pnxOptionHdrOld, and ListedExgOld are set. type TNxCoreSymbolChange = record Status: Byte; StatusChar: Char; alignment: Word; pnxsSymbolOld: PNxString; pnxOptionHdrOld: PNxOptionHdr; ListedExgOld: Word; end; // Every SymbolSpin contains the current iteration zero-based count (index) and the total number of symbols that will be iterated. // only options contracts use the "sub" count and limit fields. type TNxCoreSymbolSpin = record SpinID: Cardinal; IterLimit: Cardinal; SubIterLimit: Cardinal; IterCount: Cardinal; SubIterCount: Cardinal; end; const NxSPIN_ALL_EXGS = 65534 ; //((unsigned short)-1) Changed to 65534 by EK const NxSPIN_OPTIONS = 0 ; // (0x00000001) Not Sure Hanged to 0 by EK ////////////////////////////////////////////////////////////////////// //////////////// NxCoreMessage.MessageType /////////////////////////// ////////////////////////////////////////////////////////////////////// const NxMSG_STATUS = 0; NxMSG_EXGQUOTE = 1; NxMSG_MMQUOTE = 2; NxMSG_TRADE = 3; NxMSG_CATEGORY = 4; NxMSG_SYMBOLCHANGE = 5; NxMSG_SYMBOLSPIN = 6; type TNxCoreData = record case Word of 1: (ExgQuote: TNXCOREEXGQUOTE;); 2: (MMQuote: TNXCOREMMQUOTE;); 3: (Trade: TNXCORETRADE;); 4: (Category: TNXCORECATEGORY;); 5: (SymbolChange: TNXCORESYMBOLCHANGE;); 6: (SymbolSpin: TNXCORESYMBOLSPIN;); end; ////////////////////////////////////////////////////////////////////// ////////////////////////// NxCoreHeader ////////////////////////////// ////////////////////////////////////////////////////////////////////// type TNxCoreHeader = record pnxStringSymbol: PNxString; pnxOptionHdr: PNxOptionHdr; nxSessionDate: TNxDate; nxExgTimestamp: TNxTime; ListedExg: Word; ReportingExg: Word; SessionID: Byte; alignment: Byte; PermissionID: Word; end; ////////////////////////////////////////////////////////////////////// ////////////////////////// NxCoreMessage////////////////////////////// ////////////////////////////////////////////////////////////////////// type TNxCoreMessage = record coreHeader: TNxCoreHeader; coreData: TNxCoreData; MessageType: Cardinal; end; PNxCoreMessage = ^TNxCoreMessage ; //****************************************************************** //******************* NxCoreState data ***************************** //****************************************************************** type TNxCoreStateExgQuote = record AskPrice: Integer; BidPrice: Integer; AskSize: Integer; BidSize: Integer; ReportingExg: Word; QuoteCondition: Byte; end; type TNxCoreStateMMQuote = record AskPrice: Integer; BidPrice: Integer; AskSize: Integer; BidSize: Integer; pnxStringMarketMaker: PNxString; MarketMakerType: Byte; QuoteType: Byte; end; type TNxCoreStateExgQuotes = record StateQuoteCount: Word; PriceType: Byte; NasdaqBidTick: Byte; BestAskExg: Word; BestBidExg: Word; StateExgQuotes: Array[0..11] of TNxCoreStateExgQuote; end; type TNxCoreStateMMQuotes = record StateQuoteCount: Word; PriceType: Byte; NasdaqBidTick: Byte; StateMMQuotes: Array[0..511] of TNxCoreStateMMQuote; end; type TNxCoreStateTrade = record TotalVolume: Int64 ; //UNSIGNED __INT64 changed by EK TickVolume: Cardinal; PriceType: Byte; PriceFlags: Byte; ConditionFlags: Byte; VolumeType: Byte; Open: Integer; High: Integer; Low: Integer; Last: Integer; NetChange: Integer; Price: Integer; Threshold: Integer; Tick: Integer; end; const NxSTATETYPE_OHLCTRADE = 1; type TNxCoreStateOHLCTrade = record TotalVolume: Int64 ; //UNSIGNED __INT64 changed by EK TickVolume: Cardinal; PriceType: Byte; PriceFlags: Byte; ConditionFlags: Byte; VolumeType: Byte; Open: Integer; High: Integer; Low: Integer; Last: Integer; NetChange: Integer; Price: Integer; Threshold: Integer; Tick: Integer; TradeSize: Integer; end; ////////////////////////////////////////////////////////////////////// //////////// NxCoreTapeFile used with NxCoreListTapes //////////////// ////////////////////////////////////////////////////////////////////// type TNxCoreTapeFile = record PathnameStrZ: Array[0..259] of Char; PathnameLen: Integer; FilenameLen: Integer; FileAttributes: Cardinal; FileSize: Int64 ; //UNSIGNED __INT64 changed by EK TapeDate: TNxDate; PermSet: Array[0..7] of Char; end; ////////////////////////////////////////////////////////////////////// ////////// NxCoreAPIDLLFile used with NxCoreListAPIDlls ////////////// ////////////////////////////////////////////////////////////////////// type TNxCoreAPIDLLFile = record PathnameStrZ: Array[0..259] of Char; PathnameLen: Integer; FilenameLen: Integer; FileAttributes: Cardinal; FileSize: Int64; //UNSIGNED __INT64 changed by EK BuildDate: TNxDate; BuildTime: TNxTime; verMajor: Byte; verMinor: Byte; verBuild: Word; end; ////////////////////////////////////////////////////////////////////// ////////// String Table Indexes for NxCoreGetDefinedString /////////// ////////////////////////////////////////////////////////////////////// const NxST_PERMID = 2; NxST_EXCHANGE = 3; NxST_TRADECONDITION = 4; NxST_QUOTECONDITION = 5; NxST_CATEGORY = 6; NxST_HALTSTATUS = 7; NxST_HALTREASONTYPE = 8; NxST_OPENINDICATIONTYPE = 9; NxST_ORDERIMBALANCETYPE = 10; NxST_TRADEREPORTREASON = 11; NxST_EXGCORRECTIONMAP = 12; NxST_SYMBOLCHANGETYPE = 13; NxST_VOLOIMAP = 14; NxST_EXDIVIDENDATTRIB = 15; NxST_OPRAEXCHANGELIST = 16; NxST_NASDBIDTICK = 17; NxST_MARKETMAKERTYPE = 18; NxST_MMQUOTETYPE = 19; NxST_REFRESHTYPE = 20; NxST_EXPIRATIONCYCLE = 21; NxST_VOLUMETYPE = 22; NxST_QTEMATCHTYPE = 23; NxST_QTEMATCHFLAGS = 24; NxST_SIGHIGHLOWTYPE = 25; NxST_BBOCHANGEFLAGS = 26; NxST_TRADECONDFLAGS = 27; NxST_PRICEFLAGS = 28; ////////////////////////////////////////////////////////////////////// //////////////// controlFlags for NxCoreProcessTape ////////////////// ////////////////////////////////////////////////////////////////////// const NxCF_EXCLUDE_QUOTES = $00000001; // exclude Exchange Quotes NxCF_EXCLUDE_QUOTES2 = $00000002; // exclude MMQuotes NxCF_EXCLUDE_OPRA = $00000004; // exclude all option from OPRA (US) NxCF_MEMORY_ADDRESS = $04000000; // if set, memory is allocated (if possible) at the address specified by the 2nd parameter to NxCoreProcessTape (pBaseMemory) NxCF_EXCLUDE_CRC_CHECK = $08000000; // exclude crc checking /////////////////// ///// obsolete //// /////////////////// const NxCF_CRC_CHECK = 0; // include additional crc checking -- changed after 1.5 so default was enabled ////////////////////////////////////////////////////////////////////// ////////// control flag for NxCoreSaveState ////////////////////////// ////////////////////////////////////////////////////////////////////// const NxSAVESTATE_ONEPASS = $00000001; // save memory state in one pass -- save completes in one pass. Default saves gradually. NxSAVESTATE_CANCEL = $00000002; ////////////////////////////////////////////////////////////////////// /// return one of these values from your UserCallback function. ////// ////////////////////////////////////////////////////////////////////// const NxCALLBACKRETURN_CONTINUE = 0; // continue normal processing NxCALLBACKRETURN_STOP = 1; // stop processing and return control to function that called NxCoreProcessTape NxCALLBACKRETURN_RESTART = 2; // restart processing from beginning of tape. UserData and strings are preserved. ////////////////////////////////////////////////////////////////////// //////////// macros used by NxCoreAPIVersion ///////////////////////// ////////////////////////////////////////////////////////////////////// //const //Commented out by EK // NxCORE_VER_MAJOR(x) = ((unsigned int)(x) >> 24); // NxCORE_VER_MINOR(x) = (((unsigned int)(x) >> 16) & 0x000000ff); // NxCORE_VER_BUILD(x) = ( (x) & 0x0000ffff ); ////////////////////////////////////////////////////////////////////// ///////// error codes returned from NxCoreAPI functions ////////////// ////////////////////////////////////////////////////////////////////// const NxAPIERR_NOT_CALLBACK_THREAD = -1; NxAPIERR_BAD_PARAMETERS = -2; NxAPIERR_EXCEPTION = -3; NxAPIERR_OPEN_TAPE_FILE_FAILED = -4; NxAPIERR_INITIALIZE_MEMORY_FAILED = -5; NxAPIERR_NOLISTED_EXG = -6; // symbol spin -- listed exchange does not exist in current tape NxAPIERR_NOSYMBOLS_FOR_LSTEXG = -7; // symbol spin -- no symbols of the type (options/not options) for the exchange specified NxAPIERR_NOSESSION_FOR_SYMBOL = -8; // symbol spin -- no session or session does not have data type NxAPIERR_NODATATYPE_FOR_SESSION = -9; // symbol spin -- There's a session, but no trade/quote/mmquote data for session NxAPIERR_NODATA_FOR_REPEXG = -10; // symbol spin -- MMQuotes. there is session with data, but no entry for the specified reporting exg NxAPIERR_ZEROED_DATA_FOR_SESSION = -11; // symbol spin -- there is a session, but data is all zero NxAPIERR_SAVE_STATE_IN_PROGRESS = -12; NxAPIERR_NOT_SUPPORTED = -13; //***************************************************************** //******************* Function protoypes*************************** //***************************************************************** ////////////////////////////////////////////////////////////////////// /// function prototypes for callback functions passed as parameters // ////////////////////////////////////////////////////////////////////// type TNxCoreCallback = function ( NxCoreSys: PNxCoreSystem; NxCoreMsg: PNxCoreMessage): Integer; stdcall; TNxCoreCallbackTapeList = function (var YourParam: Pointer; NCTF: TNxCoreTapeFile): Integer; stdcall; TNxCoreCallbackAPIList = function (var YourParam: Pointer; NCTF: TNxCoreAPIDLLFile): Integer; stdcall; PNxCoreCallback = ^TNxCoreCallback; PNxCoreCallbackTapeList = ^TNxCoreCallbackTapeList; PNxCoreCallbackAPIList = ^TNxCoreCallbackAPIList; ////////////////////////////////////////////////////////////////////// //////////////////// main functions ////////////////////////////////// ////////////////////////////////////////////////////////////////////// type TNxCoreProcessTape = function (const FileName: PChar; const BaseMemory: PChar; ControlFlags: Cardinal; UserData: Integer; NxCoreCallBack: PNxCoreCallBack): Integer; stdcall; TNxCoreListTapes = function ( ControlFlags: Cardinal; NxCoreCallbackTapeList: TNxCoreCallbackTapeList; YourParam: Pointer): Integer; stdcall; TNxCoreListAPIDLLs = function ( ControlFlags: Cardinal; NxCoreCallbackAPIList: TNxCoreCallbackAPIList; UserParam: Pointer): Integer; stdcall; TNxCoreSpinSymbols = function ( ListedExg: Word; ControlFlags: Cardinal; SpinID: Word; NxCoreCallback: TNxCoreCallback; TempUserData: Integer): Integer; stdcall; TNxCoreSaveState = function ( StateFileName: PChar; ControlFlags: Cardinal): Integer; stdcall; // Added by MF TNxCoreSetCallback = function ( NxCoreCallBack: PNxCoreCallBack): Integer; stdcall; ////////////////////////////////////////////////////////////////////// ////// state functions -- in memory values as of last update ///////// ////////////////////////////////////////////////////////////////////// TNxCoreStateGetLastTrade = function (Out StateTrade: TNxCoreStateTrade; pnxsSymOrCtc: PNxString): Integer; stdcall; TNxCoreStateGetExgQuotes = function (Out StateExgQuotes: TNxCoreStateExgQuotes; SymOrCtc: PNxString): Integer; stdcall; TNxCoreStateGetMMQuotes = function (ReportingExg: Word; Out StateMMQuotes: TNxCoreStateMMQuotes; SymOrCtc: PNxString): Integer; stdcall; TNxCoreGetStateData = function (Buffer: PChar; BufferSize: Integer; StateType: Integer; Param1: Integer; Param2: Integer; SymOrCtc: PNxString): Integer; stdcall; ////////////////////////////////////////////////////////////////////// /// conversion functions: can be called from any thread ////////////// ////////////////////////////////////////////////////////////////////// TNxCorePriceConvert = function (lPrice: Integer; PriceType: Byte; PriceTypeNew: Byte): Integer; stdcall; TNxCorePriceFormat = function (Buff: PChar; lPrice: Integer; PriceType: Byte; ExpandWidth: Integer; bCommas: Bool): Integer; stdcall; // Replaced with delphi code to help with rounding problems. //TNxCorePriceToDouble = function (lPrice: Integer; // PriceType: Byte): Double; stdcall; TNxCoreDateFromNDays = procedure (Date: TNxDate); stdcall; TNxCoreDateFromYMD = procedure (var Date: TNxDate); stdcall; ////////////////////////////////////////////////////////////////////// ///////////////////// miscellaneous functions //////////////////////// ////////////////////////////////////////////////////////////////////// TNxCoreAPIVersion = function (): Cardinal; stdcall; TNxCoreGetDefinedString = function (ixTable: Integer; ixString: Integer): PChar; stdcall; TNxCoreGetTapeName = function (BuffTapename: PChar; BufferBytes: Integer): Integer; stdcall; TNxCoreSignalWaitEvent = function (NxCoreSystem: TNxCoreSystem; AlwaysSignal: Bool): Integer; stdcall; ////////////////////////////////////////////////////////////////////// //////////////////// Exported Function Names ///////////////////////// ////////////////////////////////////////////////////////////////////// const cszNxCoreAPIVersion = 'sNxCoreAPIVersion'; cszNxCoreProcessTape = 'sNxCoreProcessTape'; // xNxProcessOneTape cszNxCoreListTapes = 'sNxCoreListTapes'; // xNxListTapes cszNxCoreListAPIDLLs = 'sNxCoreListAPIDLLs'; cszNxCoreSpinSymbols = 'sNxCoreSpinSymbols'; // xNxIterateSymbols cszNxCoreSaveState = 'sNxCoreSaveState'; cszNxCoreStateGetExgQuotes = 'sNxCoreStateGetExgQuotes'; // xNxStateGetExgQuotes cszNxCoreStateGetMMQuotes = 'sNxCoreStateGetMMQuotes'; // xNxStateGetMMQuotes cszNxCoreStateGetLastTrade = 'sNxCoreStateGetLastTrade'; // xNxStateGetLastTrade cszNxCoreGetStateData = 'sNxCoreGetStateData'; cszNxCorePriceConvert = 'sNxCorePriceConvert'; // xNxConvertPriceType cszNxCorePriceFormat = 'sNxCorePriceFormat'; // xNxFormatPrice // cszNxCorePriceToDouble = 'sNxCorePriceToDouble'; // xNxPriceToDouble cszNxCoreDateFromNDays = 'sNxCoreDateFromNDays'; // xNxCoreDateFromNDays cszNxCoreDateFromYMD = 'sNxCoreDateFromYMD'; // xNxCoreDateFromYMD cszNxCoreGetDefinedString = 'sNxCoreGetDefinedString'; // xNxLookupString cszNxCoreGetTapeName = 'sNxCoreGetTapeName'; // xNxCoreGetTapeName cszNxCoreSignalWaitEvent = 'sNxCoreSignalWaitEvent'; // xNxCoreSignalWaitEvent // Added by MF cszNxCoreSetCallback = 'sNxCoreSetCallback'; var NxCoreAPIVersion: TNxCoreAPIVersion; NxCoreProcessTape: TNxCoreProcessTape; NxCoreListTapes: TNxCoreListTapes; NxCoreListAPIDLLs: TNxCoreListAPIDLLs; NxCoreSpinSymbols: TNxCoreSpinSymbols; NxCoreSaveState: TNxCoreSaveState; NxCoreStateGetExgQuotes: TNxCoreStateGetExgQuotes; NxCoreStateGetMMQuotes: TNxCoreStateGetMMQuotes; NxCoreStateGetLastTrade: TNxCoreStateGetLastTrade; NxCoreGetStateData: TNxCoreGetStateData; NxCorePriceConvert: TNxCorePriceConvert; NxCorePriceFormat: TNxCorePriceFormat; // NxCorePriceToDouble: TNxCorePriceToDouble; NxCoreDateFromNDays: TNxCoreDateFromNDays; NxCoreGetDefinedString: TNxCoreGetDefinedString; NxCoreGetTapeName: TNxCoreGetTapeName; NxCoreSignalWaitEvent: TNxCoreSignalWaitEvent; NxCoreSetCallback: TNxCoreSetCallback; function NxSymToStr (NxString: PNxString ): string ; function NxSymToStrippedStr (NxString : PNxString): string ; Function ListedExgFromNxCore(NxSymbol: PNxString; ExchID: Word): String; Function RegionalExgFromNxCore(ExchID: Word): String; Function IsOption(NxSymbol: PNxString): Boolean; Function IsEquity(NxSymbol: PNxString): Boolean; Function IsIndex(NxSymbol: PNxString): Boolean; Function GetTISymbol(NxSymbol: PNxString; ListedExg : Word): String; Function GetDateTimeFromNxCore(NxDate : TNxDate; NxTime : TNxTime): TDateTime; Function GetDateFromNxCore(NxDate : TNxDate): TDateTime; Function ValidListedExg(ListedExg: Word) : Boolean; Function NxCorePriceToDouble(Price: Integer; PriceType: Byte): Double; Procedure LoadSymbolTranslations(CsvFile : String); implementation uses Dialogs; var DLLLoaded: Boolean = False; const CoreAPI = 'NXCOREAPI.DLL'; var SaveExit: Pointer; DLLHandle: THandle; ErrorMode: Integer; function NxSymToStr (NxString : PNxString): string ; begin Result := PChar(@NxString.Str); end; function NxSymToStrippedStr (NxString : PNxString): string ; var J : Integer ; begin J := 1 ; Result := '' ; if NxString^.Str[J] = '@' then J := 2; while NxString^.Str[J] <> #0 do begin Result := Result + NxString^.Str[J] ; Inc(J) ; end; end; procedure NewExit; far; begin ExitProc := SaveExit; FreeLibrary(DLLHandle) end; procedure LoadDLL; begin if DLLLoaded then Exit; //ErrorMode := SetErrorMode(0); ErrorMode := SetErrorMode(SEM_NoOpenFileErrorBox); DLLHandle := LoadLibrary(Pchar(CoreAPI)); if DLLHandle >= 32 then begin DLLLoaded := True; SaveExit := ExitProc; ExitProc := @NewExit; @NxCoreAPIVersion := GetProcAddress (DLLHandle, cszNxCoreAPIVersion); @NxCoreProcessTape := GetProcAddress (DLLHandle, cszNxCoreProcessTape); @NxCoreListTapes := GetProcAddress (DLLHandle, cszNxCoreListTapes); @NxCoreListAPIDLLs := GetProcAddress (DLLHandle, cszNxCoreListAPIDLLs); @NxCoreSpinSymbols := GetProcAddress (DLLHandle, cszNxCoreSpinSymbols); @NxCoreSaveState := GetProcAddress (DLLHandle, cszNxCoreSaveState); @NxCoreStateGetExgQuotes := GetProcAddress (DLLHandle, cszNxCoreStateGetExgQuotes); @NxCoreStateGetMMQuotes := GetProcAddress (DLLHandle, cszNxCoreStateGetMMQuotes); @NxCoreStateGetLastTrade := GetProcAddress (DLLHandle, cszNxCoreStateGetLastTrade); @NxCoreGetStateData := GetProcAddress (DLLHandle, cszNxCoreGetStateData); @NxCorePriceConvert := GetProcAddress (DLLHandle, cszNxCorePriceConvert); @NxCorePriceFormat := GetProcAddress (DLLHandle, cszNxCorePriceFormat); // @NxCorePriceToDouble := GetProcAddress (DLLHandle, cszNxCorePriceToDouble); @NxCoreDateFromNDays := GetProcAddress (DLLHandle, cszNxCoreDateFromNDays); @NxCoreGetDefinedString := GetProcAddress (DLLHandle, cszNxCoreGetDefinedString); @NxCoreGetTapeName := GetProcAddress (DLLHandle, cszNxCoreGetTapeName); @NxCoreSignalWaitEvent := GetProcAddress (DLLHandle, cszNxCoreSignalWaitEvent); @NxCoreSetCallback := GetProcAddress (DLLHandle, cszNxCoreSetCallback); if @NxCoreAPIVersion = nil then ShowMessage ('NxCoreAPIVersion load from DLL failed.') ; if @NxCoreProcessTape = nil then ShowMessage ('NxCoreProcessTape load from DLL failed.') ; if @NxCoreListTapes = nil then ShowMessage ('NxCoreListTapes load from DLL failed.') ; if @NxCoreListAPIDLLs = nil then ShowMessage ('NxCoreListAPIDLLs load from DLL failed.') ; if @NxCoreSpinSymbols = nil then ShowMessage ('NxCoreSpinSymbols load from DLL failed.') ; if @NxCoreSaveState = nil then ShowMessage ('NxCoreSaveState load from DLL failed.') ; if @NxCoreStateGetExgQuotes = nil then ShowMessage ('NxCoreStateGetExgQuotes load from DLL failed.') ; if @NxCoreStateGetMMQuotes = nil then ShowMessage ('NxCoreStateGetMMQuotes load from DLL failed.') ; if @NxCoreStateGetLastTrade = nil then ShowMessage ('NxCoreStateGetLastTrade load from DLL failed.') ; if @NxCoreGetStateData = nil then ShowMessage ('NxCoreGetStateData load from DLL failed.') ; if @NxCorePriceConvert = nil then ShowMessage ('NxCorePriceConvert load from DLL failed.') ; if @NxCorePriceFormat = nil then ShowMessage ('NxCorePriceFormat load from DLL failed.') ; // if @NxCorePriceToDouble = nil then ShowMessage ('NxCorePriceToDouble load from DLL failed.') ; if @NxCoreDateFromNDays = nil then ShowMessage ('NxCoreDateFromNDays load from DLL failed.') ; if @NxCoreGetDefinedString = nil then ShowMessage ('NxCoreGetDefinedString load from DLL failed.') ; if @NxCoreGetTapeName = nil then ShowMessage ('NxCoreGetTapeName load from DLL failed.') ; if @NxCoreSignalWaitEvent = nil then ShowMessage ('NxCoreSignalWaitEvent load from DLL failed.') ; if @NxCoreSetCallback = nil then ShowMessage ('NxCoreSetCallback load from DLL failed.') ; end else begin DLLLoaded := False; WriteLn('Error: NXCOREAPI.DLL could not be loaded !!'); end; SetErrorMode(ErrorMode) ; end ; Function RegionalExgFromNxCore(ExchID: Word): String; Begin Case ExchID Of NxEXCH_NQEX: Result := 'NASD'; NxEXCH_NQAD: Result := 'NASD'; NxEXCH_NQNM: Result := 'NASD'; NxEXCH_NQSC: Result := 'NASD'; NxEXCH_NYSE: Result := 'NYSE'; NxEXCH_AMEX: Result := 'AMEX'; NxEXCH_CBOE: Result := 'CBOE'; NxEXCH_ISEX: Result := 'ISEX'; NxEXCH_PACF: Result := 'ARCA'; NxEXCH_CINC: Result := 'CINC'; NxEXCH_PHIL: Result := 'PHIL'; NxEXCH_BOST: Result := 'BOST'; NxEXCH_NQBB: Result := 'OTC'; NxEXCH_NQPK: Result := 'PINK'; NxEXCH_CHIC: Result := 'CHIC'; NxEXCH_TSE : Result := 'CAT'; NxEXCH_CDNX: Result := 'CAV'; NxEXCH_BATS: Result := 'BATS'; NxEXCH_BATY: Result := 'BATS'; NxEXCH_NTRF: Result := 'NTRF'; NxEXCH_EDGE: Result := 'EDGA'; NxEXCH_EDGX: Result := 'EDGX'; Else Result := '';//IntToStr(ExchID); End End; Function ListedExgFromNxCore(NxSymbol: PNxString; ExchID: Word): String; Begin If IsIndex(NxSymbol) Then Result := '$NDX' Else Case ExchID Of NxEXCH_NQEX: Result := 'NASD'; NxEXCH_NQAD: Result := 'NASD'; NxEXCH_NQNM: Result := 'NASD'; NxEXCH_NQSC: Result := 'NASD'; NxEXCH_NYSE: Result := 'NYSE'; NxEXCH_AMEX: Result := 'AMEX'; NxEXCH_PACF: Result := 'ARCA'; NxEXCH_NQBB: Result := 'OTC'; NxEXCH_NQPK: Result := 'PINK'; NxEXCH_TSE : Result := 'CAT'; NxEXCH_CDNX: Result := 'CAV'; NxEXCH_BATS: Result := 'BATS'; NxEXCH_BATY: Result := 'BATS' Else Result := '';//IntToStr(ExchID); End End; Function IsOption(NxSymbol: PNxString): Boolean; Begin If PChar(@NxSymbol.Str)[0]= 'o' Then Begin Result := True; End Else Begin Result := False; End End; Function IsEquity(NxSymbol: PNxString): Boolean; Begin If PChar(@NxSymbol.Str)[0]= 'e' Then Begin Result := True; End Else Begin Result := False; End End; Function IsIndex(NxSymbol: PNxString): Boolean; Begin If PChar(@NxSymbol.Str)[0]= 'i' Then Begin Result := True; End Else Begin Result := False; End End; Function GetTISymbol(NxSymbol: PNxString; ListedExg: Word): String; Var Position: Integer; FromTranslation: String; Begin Result := String(PChar(@NxSymbol.Str) + SizeOf(Char)); //Check translation table for symbol and return if found. FromTranslation := SymbolTranslations.Get('TI Symbol', String(PChar(@NxSymbol.Str))); If Length(FromTranslation) > 0 Then Begin Result := FromTranslation; Exit; End; Position := AnsiPos('.PR.', Result); If Position > 0 Then Begin Result := Copy(Result, 0, Position - 1) + '-' + Copy(Result, Position + 4, MaxInt); End Else If Length(Result) > 3 Then Begin If Copy(Result, Length(Result) - 2, 3) = '.PR' Then Result := Copy(Result, 0, Length(Result) - 3) + '-'; End; // Currently we don't get Canadian data from NxCore, but I think the rule // to be consisitent with Realtick is a little different. I think it's .WT // instead of .WS or + Position := AnsiPos('.WS.', Result); If Position > 0 Then Begin Result := Copy(Result, 0, Position - 1) + '+' + Copy(Result, Position + 4, MaxInt); End Else If Length(Result) > 3 Then Begin If Copy(Result, Length(Result) - 2, 3) = '.WS' Then Result := Copy(Result, 0, Length(Result) - 3) + '+'; End; If ListedExg = NxEXCH_TSE Then Begin Result := Result + '.CAT'; End Else If ListedExg = NxEXCH_CDNX Then Begin Result := Result + '.CAV'; End; If IsIndex(NxSymbol) Then Begin {If Result = '@RIAT' Then Result := '$TRIN-A' Else If Result = '@RINT' Then Result := '$TRIN-N' Else If Result = '@RIQT' Then Result := '$TRIN-Q' Else } Result := '$' + Result; End End; Function GetDateTimeFromNxCore(NxDate : TNxDate; NxTime : TNxTime): TDateTime; Begin If (NxDate.NDays > 0) Then Result := NxDate.NDays - 6208 + (NxTime.MsOfDay / 86400000) - 3.0 / 24.0 //ET to PT adjustment Else Result := 0 End; Function GetDateFromNxCore(NxDate : TNxDate): TDateTime; Begin If (NxDate.NDays > 0) Then Result := NxDate.NDays - 6208 Else Result := 0 End; Function ValidListedExg(ListedExg: Word) : Boolean; Begin Case ListedExg Of NxEXCH_NQEX: Result := True; NxEXCH_NQAD: Result := True; NxEXCH_NYSE: Result := True; NxEXCH_AMEX: Result := True; NxEXCH_PACF: Result := True; NxEXCH_NQNM: Result := True; NxEXCH_NQPK: Result := True; NxEXCH_NQSC: Result := True; NxEXCH_NQBB: Result := True; NxEXCH_TSE : Result := True; NxEXCH_CDNX: Result := True; NxEXCH_DTN : Result := True; NxEXCH_BATS : Result := True; NxEXCH_BATY : Result := True Else Result := False End End; // Implementation based off of NxCoreAPI documentation. This seems to give us fewer // rounding issues than relying on the API DLL. Why? I'm not really sure. I assume Delphi sets a // different floating point mode or something. Function NxCorePriceToDouble(Price: Integer; PriceType: Byte): Double; Begin Case PriceType of 1: Result := Price * 0.000000001; 2: Result := Price * 0.00000001; 3: Result := Price * 0.0000001; 4: Result := Price * 0.000001; 5: Result := Price * 0.00001; 6: Result := Price * 0.0001; 7: Result := Price * 0.001; 8: Result := Price * 0.01; 9: Result := Price * 0.1; 10: Result := Price * 1.0; 11: Result := Price * 10.0; 12: Result := Price * 100.0; 13: Result := Price * 1000.0; 14: Result := Price * 10000.0; 15: Result := Price * 100000.0; 16: Result := Price * 1000000.0; 17: Result := Price * 10000000.0; 18: Result := Price * 100000000.0; 19: Result := Price * 1000000000.0; 20: Result := Price * 0.0009765625; 21: Result := Price * 0.001953125; 22: Result := Price * 0.00390625; 23: Result := Price * 0.0078125; 24: Result := Price * 0.015625; 25: Result := Price * 0.03125; 26: Result := Price * 0.0625; 27: Result := Price * 0.125; 28: Result := Price * 0.25; 29: Result := Price * 0.50; 30: Result := Price * 1.0; 31: Result := Price * 2.0; 32: Result := Price * 4.0; 33: Result := Price * 8.0; 34: Result := Price * 16.0; 35: Result := Price * 32.0; 36: Result := Price * 64.0; 37: Result := Price * 126.0; 38: Result := Price * 256.0; 39: Result := Price * 512.0; Else Result := Price * 0.0; // Undefined behavior End End; Procedure LoadSymbolTranslations(CsvFile: String); Begin SymbolTranslations.LoadFromCSV(CsvFile); End; begin SymbolTranslations := TTwoDArray.Create; LoadDLL; end.