AccelPix Data API

Introduction

Python library to connect and stream the market data.
This is websocket and fallback transport based library with all the functionalyties to get eod and live streaming data

Simple and easy integration with your web application, all heavy weight work are back lifted.

What’s new

v1.3.3 : 29-Aug-2022

  1. Option Chain and Option Chain Range subscription and unsubscription method.

v1.3.2 : 02-Aug-2022

  1. Introducing Option chain subscription and unsubscription method.

v1.3.1 : 28-Jan-2022

  1. New callback for Trade snapshot during subscription, earlier it was provided along with Trade callback
  2. Segment subscription for the entitled user
  3. Introducing Option Greeks

v1.3.0 : 06-May-2021

  1. Upper and lower price band for EQ market added – refer ‘Refs snapshot data’ section

Live ticks aggregation which provides current day minutes bar – refer ‘History data – Inraday’ section

Simple steps to up and running

For Streaming Data:

  1. Initialize
  2. Register required callbacks
  3. Do subscribe with symbols list

For History Data:

  1. Initialize
  2. Async call to respective methods exposed

Working sample is available at the bottom of this help page

Installation

pip install pix-apidata 

Import

import asyncio
from pix_apidata import *

Initialize

api = apidata_lib.ApiData()
event_loop = asyncio.get_event_loop()

apiKey = "api-access-key" //provided by your data vendor
apiHost = "apidata.accelpix.in" OR "apidata5.accelpix.in" //provided by your data vendor
scheme = "https" // use either https (default scheme) or http 
await api.initialize(apiKey, apiHost, scheme) 

# *** IMPORTANT ***

# *** initialize(...) - wait for initialize to complete before making any other API calls.

Symbol Master

Use below REST API to get Master Data

(Only for master data download due to larger data size)

https://apidata.accelpix.in/api/hsd/Masters/2?fmt=json

#response data
{
  xid: 1,
  tkr: "20MICRONS",
  atkr: null,
  ctkr: null,
  exp: "1970-01-01 00:00:00",
  utkr: null,
  inst: "EQUITY",
  a3tkr: null,
  sp: 0.00,
  tk: 16921
}

Callbacks for live streaming

Available callbacks

api.on_trade_update(on_trade)

api.on_best_update(on_best)

api.on_refs_update(on_refs)

api.on_srefs_update(on_srefs)

api.on_tradeSnapshot_update(on_tradeSnap)

api.on_greeks_update(on_greeks)

Trade

#callback to listen for trade data
api.on_trade_update(on_trade)
def on_trade(msg):
  print(msg) # Trade msg
  t = apidata_models.Trade(msg)
  print(t.ticker , t.oi) #likewise object can be called for id, kind, ticker, segment, price, qty, volume, oi

#response data
  {
    id: 0, 
    ticker: 'NIFTY-1', 
    segmentId: 2, 
    time: 1293704493, 
    price: 13958.6, 
    qty: 75, 
    volume: 1587975, 
    oi: 9700275,
    kind: 'T'
  } 

Trade snapshot data

#callback to listen for trade snapshot, called during subcription process
#listen to onTrade callback for continuouse stream data
api.on_tradeSnapshot_update(on_tradeSnapshot)
def on_tradeSnapshot(msg):
  print(msg) # TradeSnapshot msg
  t = apidata_models.Trade(msg)
  print(t.ticker , t.oi) #likewise object can be called for id, kind, ticker, segment, price, qty, volume, oi

#response data
  {
    id: 0, 
    ticker: 'NIFTY-1', 
    segmentId: 2, 
    time: 1293704493, 
    price: 13958.6, 
    qty: 75, 
    volume: 1587975, 
    oi: 9700275,
    kind: 'T'
  } 

Best

#callback to listen for bid, ask and respective qty
api.on_best_update(on_best)
def on_best(msg):
  print(msg) # Best msg
  b = apidata_models.Best(msg)
  print(b.ticker , b.bidPrice) #likewise object can be called for segmentId, kind, bidQty, askPrice, askQty

#response data
  {
    ticker: 'NIFTY-1', 
    segmentId: 2, 
    kind: 'B', 
    bidPrice: 13957.45, 
    bidQty: 75, 
    askPrice: 13958.8, 
    askQty: 75, 
    time: 1293704493
  }  

Recent change in Refs data

#callback to listen for change in o, h, l, c, oi and avg data
api.on_trade_ref(on_ref)
def on_ref(msg):
  print(msg) # Refs msg
  ref = apidata_models.Refs(msg)
  print(ref.price) #likewise object can be called for segmentId, kind, ticker

#response data
  {
    kind: 'A',
    ticker: 'NIFTY-1',
    segmentId: 2,
    price: 11781.08984375
  }

Refs snapshot data

#callback to listen for o, h, l, c, oi and avg snapshot
api.on_srefs_update(on_srefs)
def on_srefs(msg):
  print(msg) # Srefs msg
  sref = apidata_models.RefsSnapshot(msg)
  print(sref.high) #likewise object can be called for kind, ticker, segmentId, open, close, high, low, avg, oi, upperBand and lowerBand

#response data
  {
    kind: 'V', 
    ticker: 'NIFTY-1',
    segmentId: 2, 
    open: 11749.650390625, 
    close: 11681.5498046875,
    avg: 11780.8603515625,
    high: 11822,
    low: 11731.2001953125,
    oi: 10615950,
    upperBand: 0,
    lowerBand: 0

  }

OptionGreeks data

#callback to listen for optionGreek data
api.on_greeks_update(on_greeks)
def on_greeks(msg):
  print(msg) # Option Greeks Data
  greeks = apidata_models.Greeks(msg)
  print(greeks.gamma) # likewise object can be called for kind, ticker, iv, delta, theta, vega, gamma, ivvwap, vanna, charm, speed, zomma, color, volga, veta, tgr, tv and dtr

#response data
  {
    kind:'G',
    ticker:'NIFTY2220318500CE',
    charm:13.510149002075195,
    color:0.0010876863962039351,
    ivvwap:0.2657951712608337,
    speed:-0.25761404633522034,
    tgr:1437.1766357421875,
    theta:-3.690974235534668,
    tv:-28860.783203125,
    vega:1.935671329498291,
    veta:57653.11328125,
    volga:0.000020740208128700033,
    zomma:3.531916377141897e-7,
    iv:0.2650300860404968,
    gamma:0.00012788892490789294,
    dtr:-1.9068187475204468,
    delta:0.03707314282655716
  }

OptionGreeks Snapshot data

#callback to listen for optionGreek snap data
api.on_greeks_update(on_greeks)
def on_greekSnapshot(msg):
  print(msg) # Option Greeks snap data
  greeks = apidata_models.Greeks(msg)
  print(greeks.gamma) # likewise object can be called for kind, ticker, iv, delta, theta, vega, gamma, ivvwap, vanna, charm, speed, zomma, color, volga, veta, tgr, tv and dtr

#response data
  {
    kind:'G',
    ticker:'NIFTY2220318500CE',
    charm:13.510149002075195,
    color:0.0010876863962039351,
    ivvwap:0.2657951712608337,
    speed:-0.25761404633522034,
    tgr:1437.1766357421875,
    theta:-3.690974235534668,
    tv:-28860.783203125,
    vega:1.935671329498291,
    veta:57653.11328125,
    volga:0.000020740208128700033,
    zomma:3.531916377141897e-7,
    iv:0.2650300860404968,
    gamma:0.00012788892490789294,
    dtr:-1.9068187475204468,
    delta:0.03707314282655716
  }

Callbacks for connection status

api.on_connection_started(connection_started)

api.on_connection_stopped(connection_stopped)

# Fired when connection is successful
def connection_started():
  print("Connection started callback")

# Fired when the connection is closed after automatic retry or some issues in networking
# Need to re-establish the connection manually

def connection_stopped():
  print("connection Stopped callback")

Live stream subscription

Subscribe to receive updates of segments entitled to you

needSnapshot = False
await api.subscribeSegments(needSnapshot)
# IMPORTANT NOTE:
# If needSnapshot = True, then buffer the updates received on 'api.on_tradeSnapshot_update' and 'api.on_srefs_update' before processing. 
# Data transfer is huge and you may get disconnected from server in-case if you don't process the incoming updates as fast enough.
# It's advised to buffer the data then process it once 'api.subscribeSegments' method returns.

Subscribe to receive ALL updates

 await api.subscribeAll('NIFTY-1')

Subscribe to receive TRADE updates

 await api.subscribeTrade(['NIFTY-1','BANKNIFTY-1','NIFTY 50'])

Subscribe to receive REFS and BEST updates

await api.subscribeBestAndRefs(['NIFTY-1','BANKNIFTY-1'])

Subscribe to receive Greeks updates

await api.subscribeGreeks(['NIFTY2220318500CE'])

Subscribe to receive Optionchain updates

# params: spotName, Expiry Date
# subscribe to full chain
await api.subscribeOptionChain('BANKNIFTY','20220901')
# subscribe to range of strikes(CE, PE) considering current spot value(at time of subscribe) as the mid-point, essentially 10 strike(CE,PE) below mid-point and 10 strikes(CE, PE) above mid-point and total of 40 contracts subscribed for the below call.
await api.subscribeOptionChainRange('NIFTY','20220901',10)

Unsubscribe live stream

# unsubscribe single symbol
 await api.unsubscribeAll(['NIFTY-1'])
# unsubscribe multiple symbol
 await api.unsubscribeAll(['NIFTY-1','BANKNIFTY-1'])

Unsubscribe Optionchain updates

await api.unsubscribeOptionChain('NIFTY','20220609')

Unsubscribe Greeks updates

await api.unsubscribeGreeks(['NIFTY2220318500CE'])

History data – Eod

# Continues data
#params: ticker, startDate, endDate
await api.get_eod("NIFTY-1", "20200828", "20200901")

# Contract data
#params: underlying ticker, startDate, endDate, contractExpiryDate
await api.get_eod_contract("NIFTY", "20200828", "20200901", "20201029")

#response data
{
  td: '2020-08-28T00:00:00',
  op: 11630,
  hp: 11708,
  lp: 11617.05,
  cp: 11689.05,
  vol: 260625,
  oi: 488325
}

History data – Inraday

Provides intra-eod bars with the time resolution in minutes (default:’5′ mins)

You can set minute resolution to ‘1’, ‘5’, ’10’ and so on.

Custom minute resolution also supported like ‘3’, ‘7’ and so on.

Passing CURRENT DATE as parameter in ‘toDate’ will respond the LIVE ticks aggregated upto the time it traded today. Last BAR of the current day may be incomplete. Current day tick aggregation response will always provide complete bar list from the beginning of day.

# Continues data 
#params: ticker, startDate, endDate, resolution
await api.get_intra_eod("NIFTY-1", "20210603", "20210604", "5")

# Contract data
#params: underlying ticker, startDate, endDate, contractExpiryDate
await api.get_intra_eod_contract("NIFTY", "20200828", "20200901", "20201029", "5")

#response data
{
  td: '2020-08-28T09:15:00',
  op: 11630,
  hp: 11643.45,
  lp: 11630,
  cp: 11639.8,
  vol: 4575,
  oi: 440475
}

History data – Ticks

Provides back log ticks from the date time specified till current live time, that is the ticks available till request hit the server.

#params: ticker, fromDateTime
await api.get_back_ticks("BANKNIFTY-1", "20201016 15:00:00")

#response data
{
  td: 2020-11-16T15:00:01.000Z,
  pr: 23600,
  vol: 125,
  oi: 1692375
}

Example

import asyncio
import time
#import requests
from pix_apidata import *

api = apidata_lib.ApiData()
event_loop = asyncio.get_event_loop()

async def main():
    api.on_connection_started(connection_started)
    api.on_connection_stopped(connection_stopped)
    api.on_trade_update(on_trade)
    api.on_best_update(on_best)
    api.on_refs_update(on_refs)
    api.on_srefs_update(on_srefs)
    api.on_tradeSnapshot_update(on_tradeSnapshot)
    api.on_greeks_update(on_greeks)
    api.on_greekSnapshot_update(on_greekSnapshot)

    key = "your-api-key"
    host = "apidata.accelpix.in"
    scheme = "http"
    s = await api.initialize(key, host,scheme)
    print(s)

    his = await api.get_intra_eod("NIFTY-1","20210603", "20210604", "5")
    print("History : ",his)

    syms = ['NIFTY-1', 'BANKNIFTY-1']
    symsGreeks = ["BANKNIFTY2290126500CE"]
    await api.subscribeAll(syms)
    # await api.subscribeOptionChain('NIFTY','20220901')
    # await api.subscribeGreeks(symsGreeks)
    # await api.subscribeOptionChainRange('NIFTY','20220901',3)
    print("Subscribe Done")
    #needSnapshot = False
    #await api.subscribeSegments(needSnapshot)
    #time.sleep(5)
    # await api.unsubscribeAll(['NIFTY-1'])
    # await api.unsubscribeGreeks(['BANKNIFTY2290126500CE'])
    # await api.unsubscribeOptionChain('NIFTY','20220901')

def on_trade(msg):
    trd = apidata_models.Trade(msg)
    print("Trade : ",msg) # or print(trd.volume) likewise object can be called for id, kind, ticker, segment, price, qty, oi

def on_best(msg):
    bst = apidata_models.Best(msg)
    print("Best : ",msg) # or print(bst.bidPrice) likewise object can be called for ticker, segmentId, kind, bidQty, askPrice, askQty

def on_refs(msg):
    ref = apidata_models.Refs(msg)
    print("Refs snapshot : ",msg) # or print(ref.price) likewise object can be called for segmentId, kind, ticker

def on_srefs(msg):
    sref = apidata_models.RefsSnapshot(msg)
    print("Refs update : ",msg) # or print(sref.high) likewise object can be called for kind, ticker, segmentId, open, close, low, avg, oi, lowerBand,upperBand

def on_tradeSnapshot(msg):
    trdSnap = apidata_models.Trade(msg)
    print("TradeSnap : ",msg) # or print(trdSnap.volume) likewise object can be called for id, kind, ticker, segment, price, qty, oi

def on_greeks(msg):
    greeks = apidata_models.Greeks(msg)
    print("OptionGreeks : ",msg) # or print(greeks.gamma) likewise object can be called for kind, ticker, iv, delta, theta, vega, gamma, ivvwap, vanna, charm, speed, zomma, color, volga, veta, tgr, tv and dtr

def on_greekSnapshot(msg):
    gr = apidata_models.Greeks(msg)
    print(msg) # or print(greeks.gamma) likewise object can be called for kind, ticker, iv, delta, theta, vega, gamma, ivvwap, vanna, charm, speed, zomma, color, volga, veta, tgr, tv and dtr

def connection_started():
    print("Connection started callback")

def connection_stopped():
    print("Connection stopped callback")

event_loop.create_task(main())
try:
   event_loop.run_forever()
finally:
   event_loop.close()

Read More
Avatar of admin admin September 7, 2022 0 Comments

AccelPix Data API

Introduction

JavaScript library to connect and stream the market data.
This is websocket and fallback transport based library with all the functionalities to get eod and live streaming data

Simple and easy integration with your web application/portal, all heavy weight work are back lifted.

What’s new

v1.2.6 : 29-Aug-2022

  1. Option Chain and Option Chain Range subscription and unsubscription method.

v1.2.5 : 15-May-2022

  1. Previous OI added – refer ‘Refs snapshot data’ section
  2. Master data api with Lot size

v1.2.4 : 28-Jan-2022

  1. Intraducing Option Greeks

v1.2.3 : 21-Aug-2021

  1. New callback for Trade snapshot during subscription, earlier it was provided along with Trade callback
  2. Segment subscription for the entitled user

v1.2.1 : 06-May-2021

  1. Upper and lower price band for EQ market added – refer ‘Refs snapshot data’ section
  2. Live ticks aggregation which provides current day minutes bar – refer ‘History data – Inraday’ section

    Simple steps to up and running

    For Streaming Data

  3. Initialize
  4. Register required callbacks in apidata.callbacks
  5. Do subscribe with symbols list in apidata.stream

For History Data

  1. Initialize
  2. Async call to respective methods exposed in apidata.history

    Working sample is available at the bottom of this help page

Installation

npm i pix-apidata --save

Import

const apidata = require("pix-apidata");

Browser

Modules are available in ‘apidata’ from the bundle.js

<script src=".srcbundle.js"></script>

Initialize

This should be the first api call before making any other

const apiKey = "api-access-key" //provided by your data vendor
const apiHost = "apidata.accelpix.in" or "apidata5.accelpix.in" //provided by your data vendor
const scheme = "https" // use either http (default scheme) or https
await apidata.initialize(apiKey, apiHost, scheme) 

// *** IMPORTANT ***

// *** initialize(...) - returns a Promise and wait for it to complete before making any other API calls.

Symbol Master

Use below REST API to get Master Data

(Only for master data download due to larger data size)

https://apidata.accelpix.in/api/hsd/Masters/2?fmt=json

OR

https://apidata5.accelpix.in/api/hsd/Masters/2?fmt=json

With LOT size

https://apidata.accelpix.in/api/hsd/Masters/3?fmt=json

OR

https://apidata5.accelpix.in/api/hsd/Masters/3?fmt=json

// response data
// Returns Master[] with following structure
Master {
  xid: 1, // segment id. 1 - EQ, 2 - F&O, 3 - NCD, 5 - MCX and so on
  tkr: '20MICRONS', // ticker name - used to communicate with server for data
  atkr: null, // alternative ticker - used for mapping or display purpose
  ctkr: null, // contract ticker or current name of FUT - used for mapping or display purpose
  exp: 1970-01-01T00:00:00.000Z, // contract expiry or default to UNIX time
  utkr: null, // underlying ticker of F&O contract, eg. NIFTY for NIFTY FUT or NIFTY OPT
  inst: 'EQUITY', // instrument name of the symbol - EQUITY, FUTSTK, FUTIDX, OPTSTK, OPTIDX etc.
  a3tkr: null, // another alternative ticker - used for mapping or display purpose
  sp: '0.00', // strike price of the option contract
  tk: 16921, // exchange defined token of the symbol
  lot: 0 //Lot size
}

Modules available

apidata.history
apidata.stream
apidata.callbacks

Callbacks for live streaming

Trade data

//callback to listen for trade data
apidata.callbacks.onTrade(msg => {
  console.log(msg);
})

//response data
Trade {
  id: 0,
  ticker: 'BANKNIFTY-1',
  segmentId: 2,
  time: 2020-11-16T15:30:00.000Z,
  price: 23560,
  qty: 300,
  volume: 7499525,
  oi: 1503450,
  kind: 'T'
}

Trade snapshot data

//callback to listen for trade snapshot, called during subcription process, 
//listen to onTrade callback for continuouse stream data
apidata.callbacks.onTradeSnapshot(msg => {
  console.log(msg);
})

//response data
Trade {
  id: 0,
  ticker: 'BANKNIFTY-1',
  segmentId: 2,
  time: 2020-11-16T15:30:00.000Z,
  price: 23560,
  qty: 300,
  volume: 7499525,
  oi: 1503450,
  kind: 'T'
}

Best data

//callback to listen for bid, ask and respective qty
apidata.callbacks.onBest(msg => {
  console.log(msg);
})

//response data
Best {
  ticker: 'NIFTY-1',
  segmentId: 2,
  kind: 'B',
  bidPrice: 11766.65,
  bidQty: 300,
  askPrice: 11768.05,
  askQty: 225,
  time: 2061-09-02T07:00:00.000Z
}

Recent change in Refs data

//callback to listen for change in o, h, l, c, oi and avg data
apidata.callbacks.onRefs(msg => {
  console.log(msg);
})

//response data
Refs {
  kind: 'A',
  ticker: 'NIFTY-1',
  segmentId: 2,
  price: 11788.17
}

Refs snapshot data

//callback to listen for o, h, l, c, oi and avg snapshot
apidata.callbacks.onRefsSnapshot(msg => {
  console.log(msg);
})

//response data
RefsSnapshot {
  kind: 'V',
  ticker: 'BANKNIFTY-1',
  segmentId: 2,
  open: 23201.2,
  close: 23110.3,
  high: 23717,
  low: 23183,
  avg: 23470.65,
  oi: 1503450,
  upperBand: 0,
  lowerBand: 0,
  poi: 15898756
}

Option Greek data

//callback to listen for Greeks data
apidata.callbacks.onGreeks(msg => {
  console.log(msg);
})

//response data
Greeks {
  kind: 'G',
  token: 0,
  ticker: 'BANKNIFTY2240737500CE',
  iv: 0.2588011622428894,
  delta: 0.8822246193885803,
  theta: -77.46974182128906,
  vega: 2.561089515686035,
  gamma: 0.0005879841046407819,
  ivvwap: 0.18449798226356506,
  vanna: -3.667503833770752,
  charm: 1.109373927116394,
  speed: -0.000002092838712997036,
  zomma: 0.0009008663473650813,
  color: 0.0002725007652770728,
  volga: 5643.75439453125,
  veta: 2929.610107421875,
  tgr: -131754.828125,
  tv: -30.24874496459961,
  dtr: -0.011387989856302738,
  highiv: 0,
  lowiv: 0,
  twapiv: 0.19661587476730347,
  timestamp: 0  timestamp:1333597502420254464 //Time in nanoseconds from 01-Jan-1980 00:00:00 UTC
}

Greek snapshot data

//callback to listen greek snapshot
apidata.callbacks.onGreekSnapshot(msg => {
  console.log(msg);
})

//response data
Greeks {
  kind: 'G',
  token: 0,
  ticker: 'BANKNIFTY2240737500CE',
  iv: 0.2588011622428894,
  delta: 0.8822246193885803,
  theta: -77.46974182128906,
  vega: 2.561089515686035,
  gamma: 0.0005879841046407819,
  ivvwap: 0.18449798226356506,
  vanna: -3.667503833770752,
  charm: 1.109373927116394,
  speed: -0.000002092838712997036,
  zomma: 0.0009008663473650813,
  color: 0.0002725007652770728,
  volga: 5643.75439453125,
  veta: 2929.610107421875,
  tgr: -131754.828125,
  tv: -30.24874496459961,
  dtr: -0.011387989856302738,
  highiv: 0,
  lowiv: 0,
  twapiv: 0.19661587476730347,
  timestamp:1333597502420254464 //Time in nanoseconds from 01-Jan-1980 00:00:00 UTC
}

Callbacks for connection status

// Fired when connection is successful
apidata.callbacks.onConnected(() => {
  console.log("Connected successfully...");
})

// Fired when the connection is closed after automatic retry or some issues in networking
// Need to re-establish the connection manually
apidata.callbacks.onClosed((err) => {
  console.log("Connected close due to...", err);
})

Live stream subscription

Subscribe to receive updates of segments entitled to you

var needSnapshot = false;
var status = await apidata.stream.subscribeSegments(needSnapshot)
// IMPORTANT NOTE:
// If needSnapshot = true, then buffer the updates received on 'apidata.callbacks.onTradeSnapshot' and 'apidata.callbacks.onRefsSnapshot' before processing. 
// Data transfer is huge and you may get disconnected from server in-case if you don't process the incoming updates as fast enough.
// It's advised to buffer the data then process it once 'apidata.stream.subscribeSegments' method returns.

Subscribe to receive ALL updates of the symbols subscribed

//subscribe single symbol
await apidata.stream.subscribeAll(['NIFTY-1'])
//subscribe multiple symbol
await apidata.stream.subscribeAll(['NIFTY-1','BANKNIFTY-1'])

Subscribe to receive TRADE updates of the symbols subscribed

await apidata.stream.subscribeTrade(['NIFTY-1','BANKNIFTY-1'])

Subscribe to receive REFS and BEST updates of the symbols subscribed

await apidata.stream.subscribeBestAndRefs(['NIFTY-1','INFY-1']);

Subscribe Greek live stream

await apidata.stream.subscribeGreeks(['NIFTY2220318500CE'])

Subscribe Optionchain live stream

//params: underlying ticker, ExpiryDate
await apidata.stream.subscribeOptionChain('NIFTY', '20220609');

Unsubscribe live stream

//unsubscribe single symbol
await apidata.stream.unsubscribeAll(['NIFTY-1'])
//unsubscribe multiple symbol
await apidata.stream.unsubscribeAll(['NIFTY-1','BANKNIFTY-1'])

Subscribe and Unsubscribe Greeks data

await apidata.stream.subscribeGreeks(['NIFTY2220318500CE','NIFTY2220318000PE'])
await apidata.stream.unsubscribeGreeks(['NIFTY2220318500CE','NIFTY2220318000PE'])

Subscribe and Unsubscribe Option Chain

//subscribe to full chain
await apidata.stream.subscribeOptionChain('BANKNIFTY','20220901')
//subscribe to range of strikes(CE, PE) considering current spot value(at time of subscribe) as the mid-point, essentially 10 strike(CE,PE) below mid-point and 10 strikes(CE, PE) above mid-point and total of 40 contracts subscribed for the below call.
await apidata.stream.subscribeOptionChainRange('NIFTY','20220901',10)
//unsubscribe the chain
await apidata.stream.unsubscribeOptionChain('NIFTY','20220901')

History data – Eod

//*** Continues data
//params: ticker, startDate, endDate
await apidata.history.getEod("NIFTY-1", "20200828", "20200901")

//*** Contract data
//params: underlying ticker, startDate, endDate, contractExpiryDate
await apidata.history.getEodContract("NIFTY", "20200828", "20200901", "20201029")

//response data
{
  td: '2020-08-28T00:00:00',
  op: 11630,
  hp: 11708,
  lp: 11617.05,
  cp: 11689.05,
  vol: 260625,
  oi: 488325
}

History data – Inraday

Provides intra-eod bars with the time resolution in minutes (default:’5′ mins)

You can set minute resolution to ‘1’, ‘5’, ’10’ and so on.

Custom minute resolution also supported like ‘3’, ‘7’ and so on.

Passing CURRENT DATE as parameter in ‘toDate’ will respond the LIVE ticks aggregated upto the time it traded today. Last BAR of the current day may be incomplete. Current day tick aggregation response will always provide complete bar list from the beginning of day.

//*** Continues data
//params: ticker, startDate, endDate, resolution
await apidata.history.getIntraEod("NIFTY-1", "20200828", "20200901", "5")

//*** Contract data
//params: underlying ticker, startDate, endDate, contractExpiryDate
await apidata.history.getIntraEodContract("NIFTY", "20200828", "20200901", "20201029", "5")

//response data
{
  td: '2020-08-28T09:15:00',
  op: 11630,
  hp: 11643.45,
  lp: 11630,
  cp: 11639.8,
  vol: 4575,
  oi: 440475
}

History data – Ticks

Provides back log ticks from the date time specified till current live time, that is the ticks available till request hit the server.

//params: ticker, fromDateTime
await apidata.history.getBackTicks("BANKNIFTY-1", "20201016 15:00:00")

//response data
{
  td: 2020-11-16T15:00:01.000Z,
  pr: 23600,
  vol: 125,
  oi: 1692375
}

Example

var apidata = require('pix-apidata')

const apiKey = "your-api-key"
const apiServer = "apidata.accelpix.in"

apidata.callbacks.onTrade(t => {
  console.log(t);
})
apidata.callbacks.onGreeks(greek => {
  console.log(greek);
})

apidata.initialize(apiKey, apiServer)
  .then(async () => {
    await apidata.stream.subscribeAll(['NIFTY-1'])
    await apidata.stream.subscribeGreeks(["NIFTY2220318500CE"])
    await apidata.stream.subscribeOptionChain('NIFTY', '20220609')
    // await apidata.stream.unsubscribeOptionChain('NIFTY', '20220609');
    let eod = await apidata.history.getEod('NIFTY 50', '20201001', '20201030')
    console.log(eod);
  })

Read More
Avatar of admin admin August 30, 2022 0 Comments

RestAPI

ACCELPIX REST API

REST API for historical and tick data download

EOD Data:

GET http://{server}/api/fda/rest/{ticker}/{yyyyMMdd:start}/{yyyyMMdd:end}?api_token={your api key}

Example:
http://apidata5.accelpix.in/api/fda/rest/NIFTY 50/20220701/20220715?api_token=cvFRDRmyKXp2%2BY9KKgPBfC0%3Dm

Response:
[
    {
        "tkr": ""NIFTY 50"",
        "td": "2022-01-03 00:00:00",
        "op": 17387.1500,
        "hp": 17646.6500,
        "lp": 17383.3000,
        "cp": 17625.7000,
        "vol": 0,
        "oi": 0,
        "eod": true
    },
    {
        "tkr": ""NIFTY 50"",
        "td": "2022-01-04 00:00:00",
        "op": 17681.4000,
        "hp": 17827.6000,
        "lp": 17593.5500,
        "cp": 17805.2500,
        "vol": 0,
        "oi": 0,
        "eod": true
    }
]

Intra-EOD Data:

Intra-Eod for completed session

GET http://{server}/api/fda/rest/{ticker}/{yyyyMMdd:start}/{yyyyMMdd:end}/{resolution:minutes}?api_token={your api key}

Example:
http://apidata5.accelpix.in/api/fda/rest/NIFTY 50/20220321/20220321/5?api_token=cvFRDRmyKXp2%2BY9KKgPBfC0%3Dm

Response:
[
    {
        "tkr": "NIFTY 50",
        "td": "2022-03-21 09:07:00",
        "op": 17329.5000,
        "hp": 17329.5000,
        "lp": 17329.5000,
        "cp": 17329.5000,
        "vol": 0,
        "oi": 0,
        "eod": false
    },
    {
        "tkr": "NIFTY 50",
        "td": "2022-03-21 09:15:00",
        "op": 17330.6000,
        "hp": 17353.3500,
        "lp": 17266.8500,
        "cp": 17279.8500,
        "vol": 24978283,
        "oi": 0,
        "eod": false
    },
    {
        "tkr": "NIFTY 50",
        "td": "2022-03-21 09:20:00",
        "op": 17277.6000,
        "hp": 17337.8000,
        "lp": 17255.7000,
        "cp": 17333.6500,
        "vol": 20795075,
        "oi": 0,
        "eod": false
    }
]

Live Intra OHLC


GET http://{server}/api/fda/rest/{ticker}/{yyyyMMdd HH:mm:ss-start time}/{yyyyMMdd  HH:mm:ss-end time}/{resolution:minutes}?api_token={your api key}

Example:
http://apidata5.accelpix.in/api/fda/rest/NIFTY 50/20220707 15:00:00/20220707 15:15:00/5?api_token=cvFRDRmyKXp2%2BY9KKgPBfC0%3Dm

Response:
[
    {
        "tkr": "NIFTY 50",
        "td": "2022-07-07 15:00:00",
        "op": 16127.8000,
        "hp": 16141.0000,
        "lp": 16112.3500,
        "cp": 16135.1500,
        "vol": 7400612,
        "oi": 0,
        "eod": false
    },
    {
        "tkr": "NIFTY 50",
        "td": "2022-07-07 15:05:00",
        "op": 16135.9500,
        "hp": 16150.5000,
        "lp": 16130.7500,
        "cp": 16144.3000,
        "vol": 6414606,
        "oi": 0,
        "eod": false
    },
    {
        "tkr": "NIFTY 50",
        "td": "2022-07-07 15:10:00",
        "op": 16144.3500,
        "hp": 16147.3000,
        "lp": 16127.4000,
        "cp": 16127.4000,
        "vol": 7033143,
        "oi": 0,
        "eod": false
    }
]

Quotes Data:


POST http://{server}/api/fda/rest/quote?api_token={your api key}

Example:
http://apidata5.accelpix.in/api/fda/rest/quote?api_token=cvFRDRmyKXp2%2BY9KKgPBfC0%3Dm

Request Body:
["TCS","NIFTY-1"]

Response:
[
    {
        "tkr": "TCS",
        "sid": 1,
        "tkn": 0,
        "tm": 1332344400,
        "pr": 3626.7,
        "qty": 0,
        "vol": 2413206,
        "bp": 0.0,
        "bq": 0,
        "ap": 3626.7,
        "aq": 1163,
        "op": 3696.0,
        "cp": 3626.7,
        "hp": 3713.95,
        "lp": 3615.0,
        "avg": 3650.29,
        "oi": 0,
        "val": 0.0,
        "band": 10,
        "upc": 3989.35,
        "lrc": 3264.05,
        "poi": 0,
        "chg": 0.0,
        "chgpc": 0.0
    },
    {
        "tkr": "NIFTY-1",
        "sid": 2,
        "tkn": 0,
        "tm": 1332343800,
        "pr": 17167.85,
        "qty": 200,
        "vol": 9308800,
        "bp": 17163.1,
        "bq": 200,
        "ap": 17167.9,
        "aq": 850,
        "op": 17332.2,
        "cp": 17322.05,
        "hp": 17392.1,
        "lp": 17130.65,
        "avg": 17234.96,
        "oi": 10866050,
        "val": 0.0,
        "band": 0,
        "upc": 0.0,
        "lrc": 0.0,
        "poi": 10866050,
        "chg": -154.20117,
        "chgpc": -0.89
    }
]

Master Data:


GET http://{server}/api/fda/rest/master?api_token={your api key}

Example:
http://apidata5.accelpix.in/api/fda/rest/master?api_token=cvFRDRmyKXp2%2BY9KKgPBfC0%3Dm

Response:
[
    {
        "xid": 1,
        "tkr": "NIFTY 50",
        "atkr": "NIFTY_50",
        "ctkr": null,
        "exp": "1970-01-01 00:00:00",
        "utkr": null,
        "inst": "INDEX",
        "a3tkr": null,
        "sp": 0.00,
        "tk": 99,
        "lot": 0
    },
    {
        "xid": 1,
        "tkr": "TCS",
        "atkr": null,
        "ctkr": null,
        "exp": "1970-01-01 00:00:00",
        "utkr": null,
        "inst": "EQUITY",
        "a3tkr": null,
        "sp": 0.00,
        "tk": 11536,
        "lot": 0
    },
        "xid": 2,
        "tkr": "BANKNIFTY-1",
        "atkr": "BANKNIFTY_1",
        "ctkr": "BANKNIFTY22JUL",
        "exp": "2022-07-28 00:00:00",
        "utkr": "BANKNIFTY",
        "inst": "FUTIDX",
        "a3tkr": "BANKNIFTY-I",
        "sp": 0.00,
        "tk": 53734,
        "lot": 25
    }

]

Samples

# python
import requests
import urllib.parse

ulr_base = "http://apidata5.accelpix.in/api/fda/rest"
key = urllib.parse.quote("your api token here")

# EOD request
eod = requests.get(ulr_base + "/nifty-1/20220101/20220301?api_token=" + key)
print(eod.content)

# Quote data reuest
quote = requests.post(ulr_base + "/quote?api_token=" + key, json=['NIFTY-1', 'NIFTY BANK'])
print(quote.content)

“`c#
// .net
static async Task Main(string[] args)
{
const string urlBase = “http://apidata5.accelpix.in/api/fda/rest“;
var key = Uri.EscapeDataString(“your api token here”);

var client = new HttpClient();

// Eod request
var d = await client.GetStringAsync(urlBase + "/nifty-1/20220101/20220301?api_token=" + key);
Console.WriteLine(d);

// Quote request
var syms = new List<string> { "NIFTY-1", "NIFTY BANK" };
var q = await client.PostAsync(urlBase + "/quote?api_token=" + key, new StringContent(JsonConvert.SerializeObject(syms), Encoding.UTF8, "application/json"));
var r = await q.Content.ReadAsStringAsync();
Console.WriteLine(r);

Console.ReadLine();

}

Read More
Avatar of admin admin July 7, 2022 0 Comments