# NxCore Python Wrapper

Process the NxCore market data feed and historical tape files. Requires the native NxCore Library(libnx.so, libnx.dylib, or NxCoreAPI64.dll depending on the operating system). Documentation can be found [online](https://nxcoreapi.com/doc/) or using docstrings(i.e. *print(NxCore.ProcessTape.\_\_doc\_\_)*).

## Quick Start
```shell
pip install NxCore
```

Download and extract the [demo](https://www.nxcoredata.com/downloads/NxCoreAPI_SampleApps.zip).  
Change directory to extracted folder and run:

```python
import NxCore

def OnNxCoreCallback(NxCoreSys, NxCoreMsg):
    if NxCoreMsg.MessageType == NxCore.NxMSG_TRADE:

        header = NxCoreMsg.coreHeader
        symbol = header.pnxStringSymbol.String
        timestamp = header.nxExgTimestamp

        trade = NxCoreMsg.coreData.Trade
        price = NxCore.PriceToFloat(trade.Price,trade.PriceType)
        size = trade.Size

        print("Trade for {} at {:02d}:{:02d}:{:02d} for {} shares at ${:.2f}" \
            .format( symbol, timestamp.Hour, timestamp.Minute, timestamp.Second, size, price))
    return NxCore.NxCALLBACKRETURN_CONTINUE

#NxCoreAPI64.dll for Windows, libnx.so for x86 linux, libnx_aarch64.so for aarch64 linux, or libnx.dylib for macOS
if NxCore.LoadNxCore("NxCoreAPI64.dll"):
    returnValue = NxCore.ProcessTape("demo.XU.nx2", 0, 0, 0, OnNxCoreCallback)
    NxCore.ProcessReturnValue(returnValue)
else:
    print("loading library failed")
```

Further examples and more detailed guides can be found on the [NxCore Getting Started Webpage](https://nxcoreapi.com/doc/concept_BasicTrade_Python.html).

## Full Installation
```shell
pip install NxCore
```
Download the [latest Native Libraries](https://www.nxcoredata.com/downloads/NxCoreAPI_SampleApps.zip).  
Download an [NxCore Sample tape](https://www.nxcoredata.com/sample-nxcore-data/#sample-nxcore-data-download).
