├── src ├── constants.ts ├── MutualFunds │ ├── instruments.ts │ ├── holdings.ts │ ├── sips.ts │ └── orders.ts ├── index.ts ├── Orders │ ├── trades.ts │ ├── orders-variety.ts │ └── orders.ts ├── User │ ├── user-profile.ts │ ├── session-token.ts │ └── user-margins-segment.ts ├── Portfolio │ ├── holdings.ts │ └── positions.ts ├── HistoricalData │ └── candle-data.ts ├── router.ts ├── Instruments │ └── instruments.ts ├── Quotes │ └── quotes.ts └── GTT │ └── triggers.ts ├── tslint.json ├── package.json ├── .vscode └── launch.json ├── README.md ├── .gitignore ├── index.html └── tsconfig.json /src/constants.ts: -------------------------------------------------------------------------------- 1 | export const Error400 = "Missing or bad request parameters or values"; 2 | export const Success200 = "Success"; -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "defaultSeverity": "error", 3 | "extends": "tslint-config-airbnb", 4 | "jsRules": {}, 5 | "rules": {}, 6 | "rulesDirectory": [] 7 | } -------------------------------------------------------------------------------- /src/MutualFunds/instruments.ts: -------------------------------------------------------------------------------- 1 | export const GETMFInstruments = (request: any, response: any) => { 2 | response.status(200).jsonp({ 3 | "message": "No mock needed! This API can be directly called from https://api.kite.trade/mf/instruments" 4 | }); 5 | } 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zerodha-sandbox", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "tsc && node ./transpiled-build/index.js", 8 | "build": "tsc" 9 | }, 10 | "author": "Zameer Ansari (https://nordible.com)", 11 | "license": "ISC", 12 | "dependencies": { 13 | "@types/node": "^12.12.2", 14 | "cors": "^2.8.5", 15 | "express": "^4.17.1", 16 | "json-server": "^0.15.1", 17 | "tslint-config-airbnb": "^5.11.2", 18 | "typescript": "^3.6.4" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "launch", 10 | "name": "Launch Program", 11 | "program": "${workspaceFolder}/transpiled-build/index.js", 12 | "preLaunchTask": "tsc: build - tsconfig.json", 13 | "outFiles": [ 14 | "${workspaceFolder}/**/*.js" 15 | ] 16 | } 17 | ] 18 | } -------------------------------------------------------------------------------- /src/MutualFunds/holdings.ts: -------------------------------------------------------------------------------- 1 | export const GETMFHoldings = (request: any, response: any) => { 2 | 3 | response.status(200).jsonp({ 4 | "COLLABORATION-NEEDED": "Please contibute the random data generation logic and query string validation logic https://github.com/nordible/zerodha-sandbox/pulls", 5 | "status": "success", 6 | "data": [{ 7 | "folio": "123123/123", 8 | "fund": "Kotak Select Focus Fund - Direct Plan", 9 | "tradingsymbol": "INF174K01LS2", 10 | "average_price": 30.729, 11 | "last_price": 33.014, 12 | "pnl": 594.769, 13 | "last_price_date": "2016-11-11", 14 | "quantity": 260.337 15 | }] 16 | }); 17 | } 18 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import { router } from "./router"; 2 | 3 | const express = require('express'); 4 | const server = express(); 5 | const port = process.env.PORT || 3000; 6 | const cors = require('cors'); 7 | 8 | router(server); 9 | 10 | const path = require('path'); 11 | const publicFolder = path.join(__dirname, '../'); 12 | server.get('/', function (req: any, res: any) { 13 | res.sendFile(path.join(publicFolder, 'index.html')); 14 | }); 15 | server.use('/', express.static(publicFolder)); 16 | 17 | server.use(cors()); 18 | 19 | server.listen(port, () => { 20 | 21 | console.log(` 22 | Mock server is running at PORT ${port}\n 23 | Free sandbox for testing Zerodha's Kite and Coin APIs\n 24 | Learn more https://nordible.com/zerodha-sandbox/\n 25 | \u00a9 nordible ${new Date().getFullYear()}`); 26 | }); -------------------------------------------------------------------------------- /src/Orders/trades.ts: -------------------------------------------------------------------------------- 1 | export const GETTrades = (request: any, response: any) => { 2 | response.status(200).jsonp({ 3 | "COLLABORATION-NEEDED": "Please contibute the request body handling logic https://github.com/nordible/zerodha-sandbox/pulls", 4 | "status": "success", 5 | "data": [{ 6 | "trade_id": "159918", 7 | "order_id": "151220000000000", 8 | "exchange_order_id": "511220371736111", 9 | 10 | "tradingsymbol": "ACC", 11 | "exchange": "NSE", 12 | "instrument_token": "22", 13 | 14 | "transaction_type": "BUY", 15 | "product": "MIS", 16 | "average_price": 100.98, 17 | "quantity": 10, 18 | 19 | "fill_timestamp": "2015-12-20 15:01:44", 20 | "exchange_timestamp": "2015-12-20 15:01:43" 21 | 22 | }] 23 | }); 24 | } -------------------------------------------------------------------------------- /src/User/user-profile.ts: -------------------------------------------------------------------------------- 1 | export const GETUserProfile = (request: any, response: any) => { 2 | 3 | response.status(200).jsonp({ 4 | "status": "success", 5 | "data": { 6 | "user_type": "investor", 7 | "email": "info@nordible.com", 8 | "user_name": "Nordible Software", 9 | "user_shortname": "Nordible", 10 | "broker": "ZERODHA", 11 | "exchanges": [ 12 | "MCX", 13 | "BSE", 14 | "NSE", 15 | "BFO", 16 | "NFO", 17 | "CDS" 18 | ], 19 | "products": [ 20 | "BO", 21 | "CNC", 22 | "CO", 23 | "MIS", 24 | "NRML" 25 | ], 26 | "order_types": [ 27 | "LIMIT", 28 | "MARKET", 29 | "SL", 30 | "SL-M" 31 | ] 32 | } 33 | }); 34 | } -------------------------------------------------------------------------------- /src/Portfolio/holdings.ts: -------------------------------------------------------------------------------- 1 | export const GETHoldings = (request: any, response: any) => { 2 | response.status(200).jsonp({ 3 | "status": "success", 4 | "data": [{ 5 | "tradingsymbol": "ABHICAP", 6 | "exchange": "BSE", 7 | "isin": "INE516F01016", 8 | "quantity": 1, 9 | "t1_quantity": 1, 10 | 11 | "average_price": 94.75, 12 | "last_price": 93.75, 13 | "pnl": -100.0, 14 | 15 | "product": "CNC", 16 | "collateral_quantity": 0, 17 | "collateral_type": null 18 | }, { 19 | "tradingsymbol": "AXISBANK", 20 | "exchange": "NSE", 21 | "isin": "INE238A01034", 22 | "quantity": 1, 23 | "t1_quantity": 0, 24 | 25 | "average_price": 475.0, 26 | "last_price": 432.55, 27 | "pnl": -42.50, 28 | 29 | "product": "CNC", 30 | "collateral_quantity": 0, 31 | "collateral_type": null 32 | }] 33 | }); 34 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # zerodha-sandbox 2 | This repository is the code for the [Free Zerodha APIs sandbox environment](https://nordible.com/zerodha-sandbox/) provided by nordible 3 | 4 | ## Run it locally 5 | 6 | * Clone the repository 7 | 8 | `git clone https://github.com/nordible/zerodha-sandbox.git` 9 | 10 | * Go to the project directory 11 | 12 | `cd zerodha-sandbox` 13 | 14 | * Install npm packages 15 | 16 | `npm i` 17 | 18 | * Execute 19 | 20 | `npm start` 21 | 22 | ## Collaborations are most welcome! 23 | Collaborations [pull requests](https://github.com/nordible/zerodha-mock-apis/pulls) are welcome! 24 | 25 | ## Bugs and Issues 26 | 27 | Have a bug or an issue with? [Open a new issue](https://github.com/nordible/zerodha-mock-apis/issues) here on GitHub. 28 | 29 | ## Copyright and License 30 | 31 | Code licensed under [MIT](https://opensource.org/licenses/MIT). Everything else is [CC](http://creativecommons.org/) 32 | 33 | ## © nordible 34 | 35 | * [nordible](http://nordible.com/) 36 | * [twitter.com/nordiblehq](https://twitter.com/nordiblehq) 37 | * [fb.com/nordible](https://www.facebook.com/nordible) 38 | -------------------------------------------------------------------------------- /src/Orders/orders-variety.ts: -------------------------------------------------------------------------------- 1 | export const POSTOrderVariety = (request: any, response: any) => { 2 | response.status(200).jsonp({ 3 | "COLLABORATION-NEEDED": "Please contibute the request body handling logic https://github.com/nordible/zerodha-sandbox/pulls", 4 | "status": "success", 5 | "data": { 6 | "order_id": "151220000000000" 7 | } 8 | }); 9 | } 10 | 11 | export const PUTOrderVariety = (request: any, response: any) => { 12 | response.status(200).jsonp({ 13 | "COLLABORATION-NEEDED": "Please contibute the request body handling logic https://github.com/nordible/zerodha-sandbox/pulls", 14 | "status": "success", 15 | "data": { 16 | "order_id": "151220000000000" 17 | } 18 | }); 19 | } 20 | 21 | export const DELETEOrderVariety = (request: any, response: any) => { 22 | response.status(200).jsonp({ 23 | "COLLABORATION-NEEDED": "Please contibute the request body handling logic https://github.com/nordible/zerodha-sandbox/pulls", 24 | "status": "success", 25 | "data": { 26 | "order_id": "151220000000000" 27 | } 28 | }); 29 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (https://nodejs.org/api/addons.html) 33 | /transpiled-build 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # TypeScript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | # next.js build output 61 | .next -------------------------------------------------------------------------------- /src/User/session-token.ts: -------------------------------------------------------------------------------- 1 | import { Error400, Success200 } from "../constants"; 2 | 3 | export const POSTSessionToken = (request: any, response: any) => { 4 | 5 | response.status(200).jsonp({ 6 | "status": "success", 7 | "data": { 8 | "user_id": "XX000", 9 | "user_name": "Kite Connect", 10 | "user_shortname": "Kite", 11 | "email": "kite@kite.trade", 12 | "user_type": "investor", 13 | "broker": "ZERODHA", 14 | "exchanges": [ 15 | "MCX", 16 | "BSE", 17 | "NSE", 18 | "BFO", 19 | "NFO", 20 | "CDS" 21 | ], 22 | "products": [ 23 | "BO", 24 | "CNC", 25 | "CO", 26 | "MIS", 27 | "NRML" 28 | ], 29 | "order_types": [ 30 | "LIMIT", 31 | "MARKET", 32 | "SL", 33 | "SL-M" 34 | ], 35 | "api_key": "xxxxxx", 36 | "access_token": "yyyyyy", 37 | "public_token": "zzzzzz", 38 | "refresh_token": null, 39 | "login_time": "2018-01-01 16:15:14", 40 | "avatar_url": null 41 | } 42 | }); 43 | } 44 | 45 | export const DELETESessionToken = (request: any, response: any) => { 46 | if (request.query.access_token && request.query.api_key) { 47 | response.status(200).jsonp({ message: Success200 });; 48 | } else { 49 | response.status(400).jsonp({ message: Error400 }); 50 | } 51 | } -------------------------------------------------------------------------------- /src/Portfolio/positions.ts: -------------------------------------------------------------------------------- 1 | export const GETPositions = (request: any, response: any) => { 2 | response.status(200).jsonp({ 3 | "status": "success", 4 | "data": { 5 | "net": [{ 6 | "tradingsymbol": "NIFTY15DEC9500CE", 7 | "exchange": "NFO", 8 | "instrument_token": 41453, 9 | "product": "NRML", 10 | 11 | "quantity": -100, 12 | "overnight_quantity": -100, 13 | "multiplier": 1, 14 | 15 | "average_price": 3.475, 16 | "close_price": 0.75, 17 | "last_price": 0.75, 18 | "value": 75.0, 19 | "pnl": 272.5, 20 | "m2m": 0.0, 21 | "unrealised": 0.0, 22 | "realised": 0.0, 23 | 24 | "buy_quantity": 0, 25 | "buy_price": 0, 26 | "buy_value": 0.0, 27 | "buy_m2m": 0.0, 28 | 29 | "day_buy_quantity": 0, 30 | "day_buy_price": 0, 31 | "day_buy_value": 0.0, 32 | 33 | "day_sell_quantity": 0, 34 | "day_sell_price": 0, 35 | "day_sell_value": 0.0, 36 | 37 | "sell_quantity": 100, 38 | "sell_price": 3.475, 39 | "sell_value": 347.5, 40 | "sell_m2m": 75.0 41 | }], 42 | "day": [] 43 | } 44 | }); 45 | } 46 | 47 | export const PUTPositions = (request: any, response: any) => { 48 | response.status(200).jsonp({ 49 | "COLLABORATION-NEEDED": "Please contibute the request body handling logic https://github.com/nordible/zerodha-sandbox/pulls", 50 | "status": "success", 51 | "data": true 52 | }); 53 | } 54 | -------------------------------------------------------------------------------- /src/User/user-margins-segment.ts: -------------------------------------------------------------------------------- 1 | export const GETUserMarginSegments = (request: any, response: any) => { 2 | response.status(200).jsonp({ 3 | "COLLABORATION-NEEDED": "Please contibute the segment handling logic https://github.com/nordible/zerodha-sandbox/pulls", 4 | "status": "success", 5 | "data": { 6 | "equity": { 7 | "enabled": true, 8 | "net": 24966.7493, 9 | "available": { 10 | "adhoc_margin": 0, 11 | "cash": 25000, 12 | "collateral": 0, 13 | "intraday_payin": 0 14 | }, 15 | "utilised": { 16 | "debits": 33.2507, 17 | "exposure": 0, 18 | "m2m_realised": -0.25, 19 | "m2m_unrealised": 0, 20 | "option_premium": 0, 21 | "payout": 0, 22 | "span": 0, 23 | "holding_sales": 0, 24 | "turnover": 0 25 | } 26 | }, 27 | "commodity": { 28 | "enabled": true, 29 | "net": 25000, 30 | "available": { 31 | "adhoc_margin": 0, 32 | "cash": 25000, 33 | "collateral": 0, 34 | "intraday_payin": 0 35 | }, 36 | "utilised": { 37 | "debits": 0, 38 | "exposure": 0, 39 | "m2m_realised": 0, 40 | "m2m_unrealised": 0, 41 | "option_premium": 0, 42 | "payout": 0, 43 | "span": 0, 44 | "holding_sales": 0, 45 | "turnover": 0 46 | } 47 | } 48 | } 49 | } 50 | ); 51 | } -------------------------------------------------------------------------------- /src/HistoricalData/candle-data.ts: -------------------------------------------------------------------------------- 1 | export const GETCandleData = (request: any, response: any) => { 2 | response.status(200).jsonp({ 3 | "COLLABORATION-NEEDED": "Please contibute the random data generation logic and query string validation logic https://github.com/nordible/zerodha-sandbox/pulls", 4 | "status": "success", 5 | "data": { 6 | "candles": [ 7 | ["2015-12-28T09:15:00+0530", 1386.4, 1388, 1381.05, 1385.1, 788], 8 | ["2015-12-28T09:16:00+0530", 1385.1, 1389.1, 1383.85, 1385.5, 609], 9 | ["2015-12-28T09:17:00+0530", 1385.5, 1387, 1385.5, 1385.7, 212], 10 | ["2015-12-28T09:18:00+0530", 1387, 1387.95, 1385.3, 1387.95, 1208], 11 | ["2015-12-28T09:19:00+0530", 1387, 1387.55, 1385.6, 1386.25, 716], 12 | ["2015-12-28T09:20:00+0530", 1386.95, 1389.95, 1386.95, 1389, 727], 13 | ["2015-12-28T09:21:00+0530", 1389, 1392.95, 1389, 1392.95, 291], 14 | ["2015-12-28T09:22:00+0530", 1392.95, 1393, 1392, 1392.95, 180], 15 | ["2015-12-28T09:23:00+0530", 1392.95, 1393, 1392, 1392.15, 1869], 16 | ["2016-01-01T13:22:00+0530", 1386.4, 1388, 1381.05, 1385.1, 788], 17 | ["2016-01-01T13:23:00+0530", 1385.1, 1389.1, 1383.85, 1385.5, 613], 18 | ["2016-01-01T13:24:00+0530", 1385.5, 1387, 1385.5, 1385.7, 212], 19 | ["2016-01-01T13:25:00+0530", 1387, 1387.95, 1385.3, 1387.95, 1208], 20 | ["2016-01-01T13:26:00+0530", 1387, 1387.55, 1385.6, 1386.25, 716], 21 | ["2016-01-01T13:27:00+0530", 1386.95, 1389.95, 1386.95, 1389, 727], 22 | ["2016-01-01T13:28:00+0530", 1389, 1392.95, 1389, 1392.95, 291], 23 | ["2016-01-01T13:29:00+0530", 1392.95, 1393, 1392, 1392.95, 180], 24 | ["2016-01-01T13:30:00+0530", 1392.95, 1393, 1392, 1392.15, 1869] 25 | ] 26 | } 27 | }); 28 | } -------------------------------------------------------------------------------- /src/MutualFunds/sips.ts: -------------------------------------------------------------------------------- 1 | export const POSTMFSips = (request: any, response: any) => { 2 | response.status(200).jsonp({ 3 | "COLLABORATION-NEEDED": "Please contibute the random data generation logic and query string validation logic https://github.com/nordible/zerodha-sandbox/pulls", 4 | "status": "success", 5 | "data": { 6 | "order_id": "123457", 7 | "sip_id": "123457" 8 | } 9 | }); 10 | } 11 | 12 | export const PUTMFSipsByOrderId = (request: any, response: any) => { 13 | response.status(200).jsonp({ 14 | "COLLABORATION-NEEDED": "Please contibute the random data generation logic and query string validation logic https://github.com/nordible/zerodha-sandbox/pulls", 15 | "status": "success", 16 | "data": {} 17 | }); 18 | } 19 | 20 | export const DELETEMFSipsByOrderId = (request: any, response: any) => { 21 | response.status(200).jsonp({ 22 | "message": "Zerodha have not given the sample response of this API" 23 | }); 24 | } 25 | 26 | export const GETMFSips = (request: any, response: any) => { 27 | 28 | response.status(200).jsonp({ 29 | "COLLABORATION-NEEDED": "Please contibute the random data generation logic and query string validation logic https://github.com/nordible/zerodha-sandbox/pulls", 30 | "status": "success", 31 | "data": [{ 32 | "sip_id": "1234", 33 | "tradingsymbol": "INF090I01239", 34 | "fund": "Franklin India Prima Plus", 35 | "dividend_type": "growth", 36 | "transaction_type": "BUY", 37 | "status": "ACTIVE", 38 | "created": "2016-01-01 13:00:00", 39 | "frequency": "monthly", 40 | "instalment_amount": 1000, 41 | "instalments": -1, 42 | "last_instalment": "2017-07-05 07:33:32", 43 | "pending_instalments": -1, 44 | "instalment_date": 5, 45 | "tag": "" 46 | }] 47 | }); 48 | } 49 | 50 | export const GETMFSipsByOrderId = (request: any, response: any) => { 51 | response.status(200).jsonp({ 52 | "COLLABORATION-NEEDED": "Please contibute the random data generation logic and query string validation logic https://github.com/nordible/zerodha-sandbox/pulls", 53 | "status": "success", 54 | "data": { 55 | "sip_id": "1234", 56 | "tradingsymbol": "INF090I01239", 57 | "fund": "Franklin India Prima Plus", 58 | "dividend_type": "growth", 59 | "transaction_type": "BUY", 60 | "status": "ACTIVE", 61 | "created": "2016-01-01 13:00:00", 62 | "frequency": "monthly", 63 | "instalment_amount": 1000, 64 | "instalments": -1, 65 | "last_instalment": "2017-07-05 07:33:32", 66 | "pending_instalments": -1, 67 | "instalment_date": 5, 68 | "tag": "" 69 | } 70 | }); 71 | } -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Zerodha APIs Test environment by nordible 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |

Zerodha APIs Test environment

15 |

Free sandbox for testing Zerodha's Kite and Coin APIs

16 | APIs are mocked at this root URL https://zerodha-sandbox.herokuapp.com/ 17 |
18 | 19 |
20 |
21 |
22 |

v3 APIs

23 |

All the v3 API mocks available*

24 |
25 |
26 |

Endpoint

27 |

Replace the API endpoint to https://zerodha-sandbox.herokuapp.com/

28 |
29 |
30 |

Free

31 |

No need of any paid API keys

32 |
33 |
34 | 35 |
36 |
37 |

Open source

38 |

The APIs are open source

39 |
40 |
41 |

Contribute

42 |

Contributions are most welcome!

43 |
44 |
45 |

Coffee

46 |

We love coffee

47 |
48 |
49 | 50 |
51 |
52 |

Run locally

53 |

You can run it like any npm project

54 |
55 |
56 |

Slow?

57 |

Your very first request will be slow. Be patient!

58 |
59 |
60 |

Collab request

61 |

COLLABORATION-NEEDED is our extra key to indicate collaborations needs :)

62 |
63 |
64 | 65 | 66 |
67 | 68 | 69 | 70 | 76 | 77 | -------------------------------------------------------------------------------- /src/MutualFunds/orders.ts: -------------------------------------------------------------------------------- 1 | export const POSTMFOrders = (request: any, response: any) => { 2 | 3 | response.status(200).jsonp({ 4 | "COLLABORATION-NEEDED": "Please contibute the random data generation logic and query string validation logic https://github.com/nordible/zerodha-sandbox/pulls", 5 | "status": "success", 6 | "data": { 7 | "order_id": "123456" 8 | } 9 | }); 10 | } 11 | 12 | export const DELETEMFOrderById = (request: any, response: any) => { 13 | 14 | response.status(200).jsonp({ 15 | "COLLABORATION-NEEDED": "Please contibute the random data generation logic and query string validation logic https://github.com/nordible/zerodha-sandbox/pulls", 16 | "status": "success", 17 | "data": { 18 | "order_id": "123456" 19 | } 20 | }); 21 | } 22 | 23 | export const GETMFOrders = (request: any, response: any) => { 24 | 25 | response.status(200).jsonp({ 26 | "COLLABORATION-NEEDED": "Please contibute the random data generation logic and query string validation logic https://github.com/nordible/zerodha-sandbox/pulls", 27 | "status": "success", 28 | "data": [{ 29 | "order_id": "123123", 30 | "exchange_order_id": "12341234", 31 | "tradingsymbol": "INF090I01239", 32 | "status": "COMPLETE", 33 | "status_message": "", 34 | "folio": "1234ABC/123", 35 | "fund": "Franklin India Prima Plus", 36 | "order_timestamp": "2016-07-05 13:38", 37 | "exchange_timestamp": "2016-07-06", 38 | "settlement_id": "1617100", 39 | "transaction_type": "BUY", 40 | "variety": "regular", 41 | "purchase_type": "FRESH", 42 | "quantity": 10, 43 | "price": 0, 44 | "last_price": 580, 45 | "last_price_date": "2016-07-10", 46 | "average_price": 500.4463, 47 | "placed_by": "AB0012", 48 | "tag": "" 49 | }] 50 | }) 51 | } 52 | 53 | export const GETMFOrdersById = (request: any, response: any) => { 54 | 55 | response.status(200).jsonp({ 56 | "COLLABORATION-NEEDED": "Please contibute the random data generation logic and query string validation logic https://github.com/nordible/zerodha-sandbox/pulls", 57 | "status": "success", 58 | "data": { 59 | "order_id": "123123", 60 | "exchange_order_id": "12341234", 61 | "tradingsymbol": "INF090I01239", 62 | "status": "COMPLETE", 63 | "status_message": "", 64 | "folio": "1234ABC/123", 65 | "fund": "Franklin India Prima Plus", 66 | "order_timestamp": "2016-07-05 13:38", 67 | "exchange_timestamp": "2016-07-06", 68 | "settlement_id": "1617100", 69 | "transaction_type": "BUY", 70 | "variety": "regular", 71 | "purchase_type": "FRESH", 72 | "quantity": 10, 73 | "price": 0, 74 | "last_price": 580, 75 | "average_price": 500.4463, 76 | "placed_by": "AB0012", 77 | "tag": "" 78 | } 79 | }); 80 | } -------------------------------------------------------------------------------- /src/router.ts: -------------------------------------------------------------------------------- 1 | import { POSTSessionToken, DELETESessionToken } from "./User/session-token"; 2 | import { GETUserProfile } from "./User/user-profile"; 3 | import { GETUserMarginSegments } from "./User/user-margins-segment"; 4 | import { POSTOrderVariety, PUTOrderVariety, DELETEOrderVariety } from './Orders/orders-variety'; 5 | import { GETOrders, GETOrderById, GETOrderByIdTrades } from './Orders/orders'; 6 | import { GETTrades } from './Orders/trades'; 7 | import { GETHoldings } from './Portfolio/holdings'; 8 | import { GETPositions } from './Portfolio/positions'; 9 | import { PUTPositions } from './Portfolio/positions'; 10 | import { GetInstruments, GetInstrumentsByExchange } from './Instruments/instruments'; 11 | import { GetQuotes, GetQuotesOHLC, GetQuotesLTP } from './Quotes/quotes'; 12 | import { GETCandleData } from './HistoricalData/candle-data'; 13 | import { POSTMFOrders, DELETEMFOrderById, GETMFOrders, GETMFOrdersById} from './MutualFunds/orders'; 14 | import { POSTMFSips, PUTMFSipsByOrderId, DELETEMFSipsByOrderId, GETMFSips, GETMFSipsByOrderId } from "./MutualFunds/sips"; 15 | import { GETMFHoldings } from "./MutualFunds/holdings"; 16 | import { GETMFInstruments } from "./MutualFunds/instruments"; 17 | import { DELETEGTTtriggerById, PUTGTTtriggerById, GETGTTtriggerById, GETGTTtrigger, POSTGTTtrigger } from "./GTT/triggers"; 18 | 19 | const UnderContruction = (request: any, response: any) => { 20 | response.status(503).jsonp({ 21 | "COLLABORATION-NEEDED": "Please contibute the API response https://github.com/nordible/zerodha-sandbox/pulls" 22 | }); 23 | } 24 | 25 | export const router = (server: any) => { 26 | 27 | // User routes 28 | server.post('/session/token', POSTSessionToken); 29 | server.post('/user/profile', GETUserProfile); 30 | server.get('/user/margins', GETUserMarginSegments); 31 | server.get('/user/margins/:segment', GETUserMarginSegments); 32 | server.delete('/session/token', DELETESessionToken); 33 | 34 | // Orders routes 35 | server.post('/orders/:variety', POSTOrderVariety); 36 | server.put('/orders/:variety/:order_id', PUTOrderVariety); 37 | server.delete('/orders/:variety/:order_id', DELETEOrderVariety); 38 | server.get('/orders', GETOrders); 39 | server.get('/orders/:order_id', GETOrderById); 40 | server.get('/trades', GETTrades); 41 | server.get('/orders/:order_id/trades', GETOrderByIdTrades); 42 | 43 | // Portfolio 44 | server.get('/portfolio/holdings', GETHoldings); 45 | server.get('/portfolio/positions', GETPositions); 46 | server.put('/portfolio/positions', PUTPositions); 47 | 48 | // Market quotes and instruments 49 | server.get('/instruments', GetInstruments); 50 | server.get('/instruments/:exchange', GetInstrumentsByExchange); 51 | server.get('/quote', GetQuotes); 52 | server.get('/quote/ohlc', GetQuotesOHLC); 53 | server.get('/quote/ltp', GetQuotesLTP); 54 | 55 | // Historical candle data 56 | server.get('/instruments/historical/:instrument_token/:interval', GETCandleData); 57 | 58 | // Mutual funds 59 | server.post('/mf/orders', POSTMFOrders); 60 | server.delete('/mf/orders/:order_id', DELETEMFOrderById); 61 | server.get('/mf/orders', GETMFOrders); 62 | server.get('/mf/orders/:order_id', GETMFOrdersById); 63 | server.post('/mf/sips', POSTMFSips); 64 | server.put('/mf/sips/:order_id', PUTMFSipsByOrderId); 65 | server.delete('/mf/sips/:order_id', DELETEMFSipsByOrderId); 66 | server.get('/mf/sips/', GETMFSips); 67 | server.get('/mf/sips/:order_id', GETMFSipsByOrderId); 68 | server.get('/mf/holdings', GETMFHoldings); 69 | server.get('/mf/instruments', GETMFInstruments); 70 | 71 | // GTT - Good Till Triggered orders 72 | server.post('/gtt/triggers', POSTGTTtrigger); 73 | server.get('/gtt/triggers', GETGTTtrigger); 74 | server.get('/gtt/triggers/:id', GETGTTtriggerById); 75 | server.put('/gtt/triggers/:id', PUTGTTtriggerById); 76 | server.delete('/gtt/triggers/:id', DELETEGTTtriggerById); 77 | 78 | 79 | } -------------------------------------------------------------------------------- /src/Instruments/instruments.ts: -------------------------------------------------------------------------------- 1 | export const GetInstruments = (request: any, response: any) => { 2 | response.status(200).jsonp({ 3 | "message": "No mock needed! This API can be directly called from https://api.kite.trade/instruments" 4 | }); 5 | } 6 | 7 | export const GetInstrumentsByExchange = (request: any, response: any) => { 8 | 9 | response.status(200).jsonp({ 10 | "COLLABORATION-NEEDED": "Please contibute the request query string handling logic https://github.com/nordible/zerodha-sandbox/pulls", 11 | "status": "success", 12 | "data": { 13 | "41729": { 14 | "instrument_token": 41729, 15 | "timestamp": "2018-01-12 10:31:54", 16 | "last_price": 278.75, 17 | "last_quantity": 8, 18 | "last_trade_time": "2018-01-12 10:31:54", 19 | "average_price": 279.04, 20 | "volume": 559981, 21 | "buy_quantity": 703982, 22 | "sell_quantity": 424423, 23 | "ohlc": { 24 | "open": 279.45, 25 | "high": 280.55, 26 | "low": 277.4, 27 | "close": 279.05 28 | }, 29 | "net_change": 0, 30 | "oi": 0, 31 | "oi_day_high": 0, 32 | "oi_day_low": 0, 33 | "depth": { 34 | "buy": [ 35 | { 36 | "price": 278.7, 37 | "quantity": 750, 38 | "orders": 1 39 | }, 40 | { 41 | "price": 278.6, 42 | "quantity": 340, 43 | "orders": 3 44 | }, 45 | { 46 | "price": 278.55, 47 | "quantity": 1880, 48 | "orders": 5 49 | }, 50 | { 51 | "price": 278.5, 52 | "quantity": 2259, 53 | "orders": 10 54 | }, 55 | { 56 | "price": 278.45, 57 | "quantity": 1456, 58 | "orders": 4 59 | } 60 | ], 61 | "sell": [ 62 | { 63 | "price": 278.75, 64 | "quantity": 117, 65 | "orders": 5 66 | }, 67 | { 68 | "price": 278.8, 69 | "quantity": 382, 70 | "orders": 2 71 | }, 72 | { 73 | "price": 278.85, 74 | "quantity": 5, 75 | "orders": 1 76 | }, 77 | { 78 | "price": 278.9, 79 | "quantity": 518, 80 | "orders": 2 81 | }, 82 | { 83 | "price": 278.95, 84 | "quantity": 2663, 85 | "orders": 7 86 | } 87 | ] 88 | } 89 | }, 90 | "NSE:INFY": { 91 | "instrument_token": 408065, 92 | "timestamp": "2018-01-12 10:31:54", 93 | "last_price": 1075.1, 94 | "last_quantity": 14, 95 | "last_trade_time": "2018-01-12 10:31:53", 96 | "average_price": 1077.13, 97 | "volume": 1311662, 98 | "buy_quantity": 235801, 99 | "sell_quantity": 496803, 100 | } 101 | } 102 | }); 103 | } 104 | 105 | -------------------------------------------------------------------------------- /src/Quotes/quotes.ts: -------------------------------------------------------------------------------- 1 | export const GetQuotes = (request: any, response: any) => { 2 | response.status(200).jsonp({ 3 | "COLLABORATION-NEEDED": "Please contibute the request query string handling logic https://github.com/nordible/zerodha-sandbox/pulls", 4 | "status": "success", 5 | "data": { 6 | "41729": { 7 | "instrument_token": 41729, 8 | "timestamp": "2018-01-12 10:31:54", 9 | "last_price": 278.75, 10 | "last_quantity": 8, 11 | "last_trade_time": "2018-01-12 10:31:54", 12 | "average_price": 279.04, 13 | "volume": 559981, 14 | "buy_quantity": 703982, 15 | "sell_quantity": 424423, 16 | "ohlc": { 17 | "open": 279.45, 18 | "high": 280.55, 19 | "low": 277.4, 20 | "close": 279.05 21 | }, 22 | "net_change": 0, 23 | "oi": 0, 24 | "oi_day_high": 0, 25 | "oi_day_low": 0, 26 | "depth": { 27 | "buy": [ 28 | { 29 | "price": 278.7, 30 | "quantity": 750, 31 | "orders": 1 32 | }, 33 | { 34 | "price": 278.6, 35 | "quantity": 340, 36 | "orders": 3 37 | }, 38 | { 39 | "price": 278.55, 40 | "quantity": 1880, 41 | "orders": 5 42 | }, 43 | { 44 | "price": 278.5, 45 | "quantity": 2259, 46 | "orders": 10 47 | }, 48 | { 49 | "price": 278.45, 50 | "quantity": 1456, 51 | "orders": 4 52 | } 53 | ], 54 | "sell": [ 55 | { 56 | "price": 278.75, 57 | "quantity": 117, 58 | "orders": 5 59 | }, 60 | { 61 | "price": 278.8, 62 | "quantity": 382, 63 | "orders": 2 64 | }, 65 | { 66 | "price": 278.85, 67 | "quantity": 5, 68 | "orders": 1 69 | }, 70 | { 71 | "price": 278.9, 72 | "quantity": 518, 73 | "orders": 2 74 | }, 75 | { 76 | "price": 278.95, 77 | "quantity": 2663, 78 | "orders": 7 79 | } 80 | ] 81 | } 82 | }, 83 | "NSE:INFY": { 84 | "instrument_token": 408065, 85 | "timestamp": "2018-01-12 10:31:54", 86 | "last_price": 1075.1, 87 | "last_quantity": 14, 88 | "last_trade_time": "2018-01-12 10:31:53", 89 | "average_price": 1077.13, 90 | "volume": 1311662, 91 | "buy_quantity": 235801, 92 | "sell_quantity": 496803, 93 | } 94 | } 95 | }); 96 | } 97 | 98 | export const GetQuotesOHLC = (request: any, response: any) => { 99 | response.status(200).jsonp({ 100 | "COLLABORATION-NEEDED": "Please contibute the request query string handling logic https://github.com/nordible/zerodha-sandbox/pulls", 101 | "status": "success", 102 | "data": { 103 | "BSE:SENSEX": { 104 | "instrument_token": 265, 105 | "last_price": 31606.48, 106 | "ohlc": { 107 | "open": 31713.5, 108 | "high": 31713.5, 109 | "low": 31586.53, 110 | "close": 31809.55 111 | } 112 | }, 113 | "NSE:INFY": { 114 | "instrument_token": 408065, 115 | "last_price": 890.9, 116 | "ohlc": { 117 | "open": 900, 118 | "high": 900.3, 119 | "low": 890, 120 | "close": 901.9 121 | } 122 | }, 123 | "NSE:NIFTY 50": { 124 | "instrument_token": 256265, 125 | "last_price": 9893.4, 126 | "ohlc": { 127 | "open": 9899.25, 128 | "high": 9911.9, 129 | "low": 9882.55, 130 | "close": 9952.2 131 | } 132 | } 133 | } 134 | }); 135 | } 136 | 137 | export const GetQuotesLTP = (request: any, response: any) => { 138 | 139 | response.status(200).jsonp({ 140 | "COLLABORATION-NEEDED": "Please contibute the request query string handling logic https://github.com/nordible/zerodha-sandbox/pulls", 141 | "status": "success", 142 | "data": { 143 | "BSE:SENSEX": { 144 | "instrument_token": 265, 145 | "last_price": 31606.48 146 | }, 147 | "NSE:INFY": { 148 | "instrument_token": 408065, 149 | "last_price": 890.9 150 | }, 151 | "NSE:NIFTY 50": { 152 | "instrument_token": 256265, 153 | "last_price": 9893.4 154 | } 155 | } 156 | }); 157 | } 158 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Basic Options */ 4 | // "incremental": true, /* Enable incremental compilation */ 5 | "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ 6 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ 7 | // "lib": [], /* Specify library files to be included in the compilation. */ 8 | // "allowJs": true, /* Allow javascript files to be compiled. */ 9 | // "checkJs": true, /* Report errors in .js files. */ 10 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ 11 | // "declaration": true, /* Generates corresponding '.d.ts' file. */ 12 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ 13 | "sourceMap": true, /* Generates corresponding '.map' file. */ 14 | // "outFile": "./", /* Concatenate and emit output to single file. */ 15 | "outDir": "./transpiled-build", /* Redirect output structure to the directory. */ 16 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 17 | // "composite": true, /* Enable project compilation */ 18 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ 19 | // "removeComments": true, /* Do not emit comments to output. */ 20 | // "noEmit": true, /* Do not emit outputs. */ 21 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 22 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 23 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 24 | 25 | /* Strict Type-Checking Options */ 26 | "strict": true, /* Enable all strict type-checking options. */ 27 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 28 | // "strictNullChecks": true, /* Enable strict null checks. */ 29 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 30 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ 31 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 32 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 33 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 34 | 35 | /* Additional Checks */ 36 | // "noUnusedLocals": true, /* Report errors on unused locals. */ 37 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 38 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 39 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 40 | 41 | /* Module Resolution Options */ 42 | // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ 43 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 44 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 45 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ 46 | // "typeRoots": [], /* List of folders to include type definitions from. */ 47 | // "types": [], /* Type declaration files to be included in compilation. */ 48 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 49 | "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 50 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 51 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 52 | 53 | /* Source Map Options */ 54 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 55 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 56 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 57 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 58 | 59 | /* Experimental Options */ 60 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 61 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/Orders/orders.ts: -------------------------------------------------------------------------------- 1 | export const GETOrders = (request: any, response: any) => { 2 | response.status(200).jsonp({ 3 | "COLLABORATION-NEEDED": "Please contibute the request body handling logic https://github.com/nordible/zerodha-sandbox/pulls", 4 | "status": "success", 5 | "data": [{ 6 | "order_id": "151220000000000", 7 | "parent_order_id": "151210000000000", 8 | "exchange_order_id": null, 9 | "placed_by": "AB0012", 10 | "variety": "regular", 11 | "status": "REJECTED", 12 | 13 | "tradingsymbol": "ACC", 14 | "exchange": "NSE", 15 | "instrument_token": 22, 16 | "transaction_type": "BUY", 17 | "order_type": "MARKET", 18 | "product": "NRML", 19 | "validity": "DAY", 20 | 21 | "price": 0.0, 22 | "quantity": 75, 23 | "trigger_price": 0.0, 24 | 25 | "average_price": 0.0, 26 | "pending_quantity": 0, 27 | "filled_quantity": 0, 28 | "disclosed_quantity": 0, 29 | "market_protection": 0, 30 | 31 | "order_timestamp": "2015-12-20 15:01:43", 32 | "exchange_timestamp": null, 33 | 34 | "status_message": "RMS:Margin Exceeds, Required:0, Available:0", 35 | "tag": null 36 | }] 37 | }); 38 | } 39 | 40 | export const GETOrderById = (request: any, response: any) => { 41 | response.status(200).jsonp({ 42 | "COLLABORATION-NEEDED": "Please contibute the request body handling logic https://github.com/nordible/zerodha-sandbox/pulls", 43 | "status": "success", 44 | "data": [ 45 | { 46 | "average_price": 0, 47 | "cancelled_quantity": 0, 48 | "disclosed_quantity": 0, 49 | "exchange": "NSE", 50 | "exchange_order_id": null, 51 | "exchange_timestamp": null, 52 | "filled_quantity": 0, 53 | "instrument_token": 1, 54 | "market_protection": 0, 55 | "order_id": "171222000539943", 56 | "order_timestamp": "2017-12-22 10:36:09", 57 | "order_type": "SL", 58 | "parent_order_id": null, 59 | "pending_quantity": 1, 60 | "placed_by": "ZQXXXX", 61 | "price": 130, 62 | "product": "MIS", 63 | "quantity": 1, 64 | "status": "PUT ORDER REQ RECEIVED", 65 | "status_message": null, 66 | "tag": null, 67 | "tradingsymbol": "ASHOKLEY", 68 | "transaction_type": "BUY", 69 | "trigger_price": 128, 70 | "validity": "DAY", 71 | "variety": "regular" 72 | }, 73 | { 74 | "average_price": 0, 75 | "cancelled_quantity": 0, 76 | "disclosed_quantity": 0, 77 | "exchange": "NSE", 78 | "exchange_order_id": null, 79 | "exchange_timestamp": null, 80 | "filled_quantity": 0, 81 | "instrument_token": 54273, 82 | "market_protection": 0, 83 | "order_id": "171222000539943", 84 | "order_timestamp": "2017-12-22 10:36:09", 85 | "order_type": "SL", 86 | "parent_order_id": null, 87 | "pending_quantity": 1, 88 | "placed_by": "ZQXXXX", 89 | "price": 130, 90 | "product": "MIS", 91 | "quantity": 1, 92 | "status": "VALIDATION PENDING", 93 | "status_message": null, 94 | "tag": null, 95 | "tradingsymbol": "ASHOKLEY", 96 | "transaction_type": "BUY", 97 | "trigger_price": 128, 98 | "validity": "DAY", 99 | "variety": "regular" 100 | }, 101 | { 102 | "average_price": 0, 103 | "cancelled_quantity": 0, 104 | "disclosed_quantity": 0, 105 | "exchange": "NSE", 106 | "exchange_order_id": null, 107 | "exchange_timestamp": null, 108 | "filled_quantity": 0, 109 | "instrument_token": 54273, 110 | "market_protection": 0, 111 | "order_id": "171222000539943", 112 | "order_timestamp": "2017-12-22 10:36:09", 113 | "order_type": "SL", 114 | "parent_order_id": null, 115 | "pending_quantity": 0, 116 | "placed_by": "ZQXXXX", 117 | "price": 130, 118 | "product": "MIS", 119 | "quantity": 1, 120 | "status": "REJECTED", 121 | "status_message": "RMS:Rule: Check circuit limit including square off order exceeds for entity account-DH0490 across exchange across segment across product ", 122 | "tag": null, 123 | "tradingsymbol": "ASHOKLEY", 124 | "transaction_type": "BUY", 125 | "trigger_price": 128, 126 | "validity": "DAY", 127 | "variety": "regular" 128 | } 129 | ] 130 | }); 131 | } 132 | 133 | export const GETOrderByIdTrades = (request: any, response: any) => { 134 | response.status(200).jsonp({ 135 | "COLLABORATION-NEEDED": "Please contibute the request body handling logic https://github.com/nordible/zerodha-sandbox/pulls", 136 | "status": "success", 137 | "data": [{ 138 | "trade_id": "159918", 139 | "order_id": "151220000000000", 140 | "exchange_order_id": "511220371736111", 141 | 142 | "tradingsymbol": "ACC", 143 | "exchange": "NSE", 144 | "instrument_token": "22", 145 | 146 | "transaction_type": "BUY", 147 | "product": "MIS", 148 | "average_price": 100.98, 149 | "quantity": 10, 150 | 151 | "fill_timestamp": "2015-12-20 15:01:44", 152 | "exchange_timestamp": "2015-12-20 15:01:43" 153 | 154 | }] 155 | }); 156 | } -------------------------------------------------------------------------------- /src/GTT/triggers.ts: -------------------------------------------------------------------------------- 1 | export const POSTGTTtrigger = (request: any, response: any) => { 2 | 3 | response.status(200).jsonp({ 4 | "COLLABORATION-NEEDED": "Please contibute the random data generation logic and request body validation logic https://github.com/nordible/zerodha-sandbox/pulls", 5 | "status":"success", 6 | "data":{ 7 | "trigger_id":1337 8 | } 9 | }); 10 | } 11 | 12 | export const GETGTTtrigger = (request: any, response: any) => { 13 | 14 | response.status(200).jsonp({ 15 | "COLLABORATION-NEEDED": "Please contibute the random data generation logic https://github.com/nordible/zerodha-sandbox/pulls", 16 | "status": "success", 17 | "data": [ 18 | { 19 | "id": 112127, 20 | "user_id": "XX0000", 21 | "parent_trigger": null, 22 | "type": "single", 23 | "created_at": "2019-09-12 13:25:16", 24 | "updated_at": "2019-09-12 13:25:16", 25 | "expires_at": "2020-09-12 13:25:16", 26 | "status": "active", 27 | "condition": { 28 | "exchange": "NSE", 29 | "last_price": 798, 30 | "tradingsymbol": "INFY", 31 | "trigger_values": [ 32 | 702 33 | ], 34 | "instrument_token": 408065 35 | }, 36 | "orders": [ 37 | { 38 | "account_id": "", 39 | "parent_order_id": "", 40 | "exchange": "NSE", 41 | "tradingsymbol": "INFY", 42 | "validity": "", 43 | "product": "CNC", 44 | "order_type": "LIMIT", 45 | "transaction_type": "BUY", 46 | "quantity": 1, 47 | "disclosed_quantity": 0, 48 | "price": 702.5, 49 | "trigger_price": 0, 50 | "ltp_atp": "", 51 | "squareoff_abs_tick": "", 52 | "stoploss_abs_tick": "", 53 | "squareoff": 0, 54 | "stoploss": 0, 55 | "trailing_stoploss": 0, 56 | "meta": "", 57 | "guid": "", 58 | "result": null 59 | } 60 | ], 61 | "meta": {} 62 | }, 63 | { 64 | "id": 105099, 65 | "user_id": "XX0000", 66 | "parent_trigger": null, 67 | "type": "two-leg", 68 | "created_at": "2019-09-09 15:13:22", 69 | "updated_at": "2019-09-09 15:15:08", 70 | "expires_at": "2020-01-01 12:00:00", 71 | "status": "triggered", 72 | "condition": { 73 | "exchange": "NSE", 74 | "last_price": 102.6, 75 | "tradingsymbol": "RAIN", 76 | "trigger_values": [ 77 | 102.0, 78 | 103.7 79 | ], 80 | "instrument_token": 3926273 81 | }, 82 | "orders": [ 83 | { 84 | "account_id": "", 85 | "parent_order_id": "", 86 | "exchange": "NSE", 87 | "tradingsymbol": "RAIN", 88 | "validity": "", 89 | "product": "CNC", 90 | "order_type": "LIMIT", 91 | "transaction_type": "SELL", 92 | "quantity": 1, 93 | "disclosed_quantity": 0, 94 | "price": 1, 95 | "trigger_price": 0, 96 | "ltp_atp": "", 97 | "squareoff_abs_tick": "", 98 | "stoploss_abs_tick": "", 99 | "squareoff": 0, 100 | "stoploss": 0, 101 | "trailing_stoploss": 0, 102 | "meta": "", 103 | "guid": "", 104 | "result": null 105 | }, 106 | { 107 | "account_id": "", 108 | "parent_order_id": "", 109 | "exchange": "NSE", 110 | "tradingsymbol": "RAIN", 111 | "validity": "", 112 | "product": "CNC", 113 | "order_type": "LIMIT", 114 | "transaction_type": "SELL", 115 | "quantity": 1, 116 | "disclosed_quantity": 0, 117 | "price": 1, 118 | "trigger_price": 0, 119 | "ltp_atp": "", 120 | "squareoff_abs_tick": "", 121 | "stoploss_abs_tick": "", 122 | "squareoff": 0, 123 | "stoploss": 0, 124 | "trailing_stoploss": 0, 125 | "meta": "", 126 | "guid": "", 127 | "result": { 128 | "account_id": "XX0000", 129 | "parent_order_id": "", 130 | "exchange": "NSE", 131 | "tradingsymbol": "RAIN", 132 | "validity": "DAY", 133 | "product": "CNC", 134 | "order_type": "LIMIT", 135 | "transaction_type": "SELL", 136 | "quantity": 1, 137 | "disclosed_quantity": 0, 138 | "price": 1, 139 | "trigger_price": 0, 140 | "ltp_atp": "LTP", 141 | "squareoff_abs_tick": "absolute", 142 | "stoploss_abs_tick": "absolute", 143 | "squareoff": 0, 144 | "stoploss": 0, 145 | "trailing_stoploss": 0, 146 | "meta": "{\"app_id\":12617,\"gtt\":105099}", 147 | "guid": "", 148 | "timestamp": "2019-09-09 15:15:08", 149 | "triggered_at": 103.7, 150 | "order_result": { 151 | "status": "failed", 152 | "order_id": "", 153 | "rejection_reason": "Your order price is lower than the current lower circuit limit of 70.65. Place an order within the daily range." 154 | } 155 | } 156 | } 157 | ], 158 | "meta": null 159 | } 160 | ] 161 | }); 162 | } 163 | 164 | export const GETGTTtriggerById = (request: any, response: any) => { 165 | 166 | response.status(200).jsonp({ 167 | "COLLABORATION-NEEDED": "Please contibute the random data generation logic and query params validation logic https://github.com/nordible/zerodha-sandbox/pulls", 168 | "status": "success", 169 | "data": { 170 | "id": 105099, 171 | "user_id": "XX0000", 172 | "parent_trigger": null, 173 | "type": "two-leg", 174 | "created_at": "2019-09-09 15:13:22", 175 | "updated_at": "2019-09-09 15:15:08", 176 | "expires_at": "2020-01-01 12:00:00", 177 | "status": "triggered", 178 | "condition": { 179 | "exchange": "NSE", 180 | "last_price": 102.6, 181 | "tradingsymbol": "RAIN", 182 | "trigger_values": [ 183 | 102.0, 184 | 103.7 185 | ], 186 | "instrument_token": 3926273 187 | }, 188 | "orders": [ 189 | { 190 | "account_id": "", 191 | "parent_order_id": "", 192 | "exchange": "NSE", 193 | "tradingsymbol": "RAIN", 194 | "validity": "", 195 | "product": "CNC", 196 | "order_type": "LIMIT", 197 | "transaction_type": "SELL", 198 | "quantity": 1, 199 | "disclosed_quantity": 0, 200 | "price": 1, 201 | "trigger_price": 0, 202 | "ltp_atp": "", 203 | "squareoff_abs_tick": "", 204 | "stoploss_abs_tick": "", 205 | "squareoff": 0, 206 | "stoploss": 0, 207 | "trailing_stoploss": 0, 208 | "meta": "", 209 | "guid": "", 210 | "result": null 211 | }, 212 | { 213 | "account_id": "", 214 | "parent_order_id": "", 215 | "exchange": "NSE", 216 | "tradingsymbol": "RAIN", 217 | "validity": "", 218 | "product": "CNC", 219 | "order_type": "LIMIT", 220 | "transaction_type": "SELL", 221 | "quantity": 1, 222 | "disclosed_quantity": 0, 223 | "price": 1, 224 | "trigger_price": 0, 225 | "ltp_atp": "", 226 | "squareoff_abs_tick": "", 227 | "stoploss_abs_tick": "", 228 | "squareoff": 0, 229 | "stoploss": 0, 230 | "trailing_stoploss": 0, 231 | "meta": "", 232 | "guid": "", 233 | "result": { 234 | "account_id": "XX0000", 235 | "parent_order_id": "", 236 | "exchange": "NSE", 237 | "tradingsymbol": "RAIN", 238 | "validity": "DAY", 239 | "product": "CNC", 240 | "order_type": "LIMIT", 241 | "transaction_type": "SELL", 242 | "quantity": 1, 243 | "disclosed_quantity": 0, 244 | "price": 1, 245 | "trigger_price": 0, 246 | "ltp_atp": "LTP", 247 | "squareoff_abs_tick": "absolute", 248 | "stoploss_abs_tick": "absolute", 249 | "squareoff": 0, 250 | "stoploss": 0, 251 | "trailing_stoploss": 0, 252 | "meta": "{\"app_id\":12617,\"gtt\":105099}", 253 | "guid": "", 254 | "timestamp": "2019-09-09 15:15:08", 255 | "triggered_at": 103.7, 256 | "order_result": { 257 | "status": "failed", 258 | "order_id": "", 259 | "rejection_reason": "Your order price is lower than the current lower circuit limit of 70.65. Place an order within the daily range." 260 | } 261 | } 262 | } 263 | ], 264 | "meta": null 265 | } 266 | }); 267 | } 268 | 269 | export const PUTGTTtriggerById = (request: any, response: any) => { 270 | 271 | response.status(200).jsonp({ 272 | "COLLABORATION-NEEDED": "Please contibute the random data generation logic and request body validation logic https://github.com/nordible/zerodha-sandbox/pulls", 273 | "status":"success", 274 | "data":{ 275 | "trigger_id":1337 276 | } 277 | }); 278 | } 279 | 280 | export const DELETEGTTtriggerById = (request: any, response: any) => { 281 | 282 | response.status(200).jsonp({ 283 | "COLLABORATION-NEEDED": "Please contibute the random data generation logic and query string validation logic https://github.com/nordible/zerodha-sandbox/pulls", 284 | "status":"success", 285 | "data":{ 286 | "trigger_id":1337 287 | } 288 | }); 289 | } --------------------------------------------------------------------------------