Functionality
These functions control the symbols that are present in the NxCore callback. By default all symbols are present in the callback. These functions are implemented in the Python/Java wrapper to reduce how often code crosses from the native library to Python/Java code. This can be used in conjunction with RemovePermission to further improve performance.
Usage
These functions are only available in the Java and Python API and are not part of the native NxCore API.
Only UserData1 is avaliable after calling these functions, since UserData2 is used by these functions.
The function can be called before ProcessTape.
Only one of these functions may be used. If multiple are called, only the most recent is applied.
The symbols must include the prefix.
FilterSymbols
The NxCore callback will only return the symbol or symbols specified.
Python:
FilterSymbols(Symbol1) FilterSymbols((Symbol1, ListedExg1)) FilterSymbols([Symbol1, Symbol2, Symbol3,...]) FilterSymbols([(Symbol1, ListedExg1), (Symbol2, ListedExg2), (Symbol3, ListedExg3),...])
Java:
boolean FilterSymbols(String symbolArray[]) boolean FilterSymbols(String symbol)
ExcludeSymbols
The NxCore callback will not return the symbol or symbols specified.
Python:
ExcludeSymbols(Symbol1) ExcludeSymbols((Symbol1, ListedExg1)) ExcludeSymbols([Symbol1,Symbol2,Symbol3,...]) ExcludeSymbols([(Symbol1,ListedExg1),(Symbol2,ListedExg2),(Symbol3,ListedExg3),...])
Java:
boolean ExcludeSymbols(String symbolArray[]) boolean ExcludeSymbols(String symbol)
FilterSymbolsRange
The NxCore callback will only return symbols within the alphabetical range. An empty String can be used as the begining or end of the range.
Python:
FilterSymbolsRange(StartSymbol, EndSymbol[, ListedExg])
Java:
boolean FilterSymbolsRange(String startSymbol,String endSymbol)
Example
import net.nanex.NxCoreClass; class FilterSymbolsSample extends NxCoreClass{ @Override public int OnNxCoreCallback(NxCoreSystem nxCoreSys, NxCoreMessage nxCoreMsg) { switch (nxCoreMsg.MessageType) { case defines.NxMSG_TRADE: NxCoreTrade nt = nxCoreMsg.coreData.Trade; NxCoreHeader ch = nxCoreMsg.coreHeader; NxTime t = ch.nxExgTimestamp; System.out.println(String.format("%02d:%02d:%02d.%03d %s %d@%.2f)", t.Hour, t.Minute, t.Second, t.Millisecond, ch.pnxStringSymbol.String, nt.Size, PriceToDouble(nt.Price, nt.PriceType))); break; } return defines.NxCALLBACKRETURN_CONTINUE; } public static void main(String args[]) { FilterSymbolsSample nxCore = new FilterSymbolsSample(); String[] symbols = {"eSPY","eQQQ"}; //nxCore.FilterSymbolsRange("eSPY","");//Process equities starting with SPY alphabetically //nxCore.ExcludeSymbols(symbols);//Process everything except equity SPY and QQQ nxCore.FilterSymbols(symbols);//Only process equity SPY and QQQ 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 ch = NxCoreMsg.coreHeader t = ch.nxExgTimestamp print("{:02d}:{:02d}:{:02d}.{:03d} {} Price({}@{:.2f}))".format( t.Hour, t.Minute, t.Second, t.Millisecond, ch.pnxStringSymbol.String, nt.Size, NxCore.PriceToDouble(nt.Price, nt.PriceType))) return NxCore.NxCALLBACKRETURN_CONTINUE #NxCore.FilterSymbolsRange("eSPY","");#Process equities starting with SPY alphabetically #NxCore.ExcludeSymbols(["eSPY","eQQQ"]);#Process everything except equity SPY and QQQ NxCore.FilterSymbols(["eSPY","eQQQ"]);#Only process equity SPY and QQQ if NxCore.LoadNxCore("NxCoreAPI64.dll"): returnValue = NxCore.ProcessTape(tapePath, 0, NxCore.NxCF_EXCLUDE_CRC_CHECK, 0, OnNxCoreCallback) else: print("loading library failed") |