Basic: | Intro/Trade | Quote | Category | Status | Symbol | Options |
Detailed: | Trade | Quote |
Introduction to Symbols
This guide assumes you have already read the "Getting Started With Trades" guide. All symbols will receive either a NxMSG_SYMBOLSPIN message or an add NxMSG_SYMBOLCHANGE message. Near the start of the tape, a symbol spin mesage is sent for all existing symbols. If a new symbol is added afterwards, then it receives a Symbol Change message instead. By looking at both of these message types it is possible to get a complete list of symbols.
Code
using System; using NxCoreAPI; class SymbolSample { static unsafe int OnNxCoreCallback(NxCoreSystem* pNxCoreSys, NxCoreMessage* pNxCoreMsg) { if (pNxCoreMsg->MessageType == NxCore.NxMSG_SYMBOLSPIN) { NxCoreHeader* pHeader = &pNxCoreMsg->coreHeader; String symbol = new String(&pHeader->pnxStringSymbol->String); NxTime* pTimestamp = &pHeader->nxExgTimestamp; String exchange = new String(NxCore.GetDefinedString(NxCore.NxST_EXCHANGE, pHeader->ListedExg)); Console.WriteLine("symbol {0:s} is listed on {1:s}", symbol, exchange); } if(pNxCoreMsg->MessageType == NxCore.NxMSG_SYMBOLCHANGE && pNxCoreMsg->coreData.SymbolChange.Status == NxCore.NxSS_ADD) { NxCoreHeader* pHeader = &pNxCoreMsg->coreHeader; String symbol = new String(&pHeader->pnxStringSymbol->String); NxTime* pTimestamp = &pHeader->nxExgTimestamp; String exchange = new String(NxCore.GetDefinedString(NxCore.NxST_EXCHANGE, pHeader->ListedExg)); Console.WriteLine("new symbol {0:s} is listed on {1:s}", symbol, exchange); } return NxCore.NxCALLBACKRETURN_CONTINUE; } static unsafe void Main(string[] args) { if (args.Length < 1) return; int returnValue = NxCore.ProcessTape(args[0], null, 0, 0, SymbolSample.OnNxCoreCallback); NxCore.processReturnValue(returnValue); } }
Symbol Spin
Near the start of each tape a Symbol Spin message is sent for every symbol present at that time. coreHeader will be populated with the symbol information. Usually it will not be necessary to process the SymbolSpin object in coreData. |
if (pNxCoreMsg->MessageType == NxCore.NxMSG_SYMBOLSPIN) {
NxCoreHeader* pHeader = &pNxCoreMsg->coreHeader;
String symbol = new String(&pHeader->pnxStringSymbol->String);
NxTime* pTimestamp = &pHeader->nxExgTimestamp;
String exchange = new String(NxCore.GetDefinedString(
NxCore.NxST_EXCHANGE, pHeader->ListedExg));
...
}
|
Symbol Change
Symbol Change messages can either be sent for newly added symbols or symbols that the source feed reports as deleted. The Status field indicates whether it is an added or deleted symbol. |
if(pNxCoreMsg->MessageType == NxCore.NxMSG_SYMBOLCHANGE && pNxCoreMsg->coreData.SymbolChange.Status == NxCore.NxSS_ADD) { NxCoreHeader* pHeader = &pNxCoreMsg->coreHeader; String symbol = new String(&pHeader->pnxStringSymbol->String); NxTime* pTimestamp = &pHeader->nxExgTimestamp; String exchange = new String(NxCore.GetDefinedString( NxCore.NxST_EXCHANGE, pHeader->ListedExg)); ... } |
Next:
Options