├── .github
└── workflows
│ └── php-test.yml
├── .gitignore
├── CHANGELOG.md
├── LICENSE.md
├── README.md
├── composer.json
├── examples
└── kiteconnect_sample.php
├── phpunit.xml.dist
├── psalm.xml.dist
├── src
├── Exception
│ ├── DataException.php
│ ├── GeneralException.php
│ ├── InputException.php
│ ├── KiteException.php
│ ├── NetworkException.php
│ ├── OrderException.php
│ ├── PermissionException.php
│ └── TokenException.php
└── KiteConnect.php
└── tests
├── KiteConnectTest.php
├── MockJson.php
└── mock_responses
├── gtt_delete_order.json
├── gtt_get_order.json
├── gtt_get_orders.json
├── gtt_modify_order.json
├── gtt_place_order.json
├── historical_minute.json
├── holdings.json
├── instruments_all.csv
├── instruments_nse.csv
├── ltp.json
├── margins.json
├── mf_holdings.json
├── mf_instruments.csv
├── mf_orders.json
├── mf_orders_info.json
├── mf_sip_info.json
├── mf_sips.json
├── ohlc.json
├── order_info.json
├── order_response.json
├── order_trades.json
├── orders.json
├── positions.json
├── profile.json
├── quote.json
├── trades.json
├── trigger_range.json
└── virtual_contract_note.json
/.github/workflows/php-test.yml:
--------------------------------------------------------------------------------
1 | name: Run Tests
2 |
3 | on: [push, pull_request]
4 | jobs:
5 | test:
6 | strategy:
7 | matrix:
8 | php-versions: ["8.0", "8.1"]
9 | os: ["ubuntu-latest", "macos-latest"]
10 | phpunit-versions: ["9.5.4"]
11 |
12 | runs-on: ${{ matrix.os }}
13 |
14 | steps:
15 | - uses: actions/checkout@v2
16 |
17 | - name: Setup PHP
18 | uses: shivammathur/setup-php@v2
19 | with:
20 | php-version: ${{ matrix.php-versions }}
21 |
22 | - name: Install composer dependencies
23 | run: composer install --no-scripts
24 |
25 | - name: Install PHPUnit
26 | run: composer global require "phpunit/phpunit=${{ matrix.phpunit-versions }}"
27 |
28 | - name: PHPUnit tests
29 | run: ~/.composer/vendor/bin/phpunit tests
30 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | .php_cs
3 | .php_cs.cache
4 | .phpunit.result.cache
5 | build
6 | composer.lock
7 | coverage
8 | docs
9 | phpunit.xml
10 | psalm.xml
11 | vendor
12 | index.php
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | All notable changes to `phpkiteconnect` will be documented in this file.
4 |
5 | ## 4.0.0 - 2021-04-06
6 | - Major refactor to project structure and code
7 | - PHP support 7.3+
8 | - Integrated composer packagist
9 | - Integrated Guzzle HTTP client ditching CURL
10 | - Units Tests
11 |
12 |
13 | ## 1.0.0 - 202X-XX-XX
14 |
15 | - initial release
16 | #### New Features
17 | - method: `getProfile`
18 | - method: `getOHLC`
19 | - method: `getLTP`
20 | - method: `getMFOrders`
21 | - method: `getMFHoldings`
22 | - method: `placeMFOrder`
23 | - method: `cancelMFOrder`
24 | - method: `getMFSIPS`
25 | - method: `placeMFSIP`
26 | - method: `modifyMFSIP`
27 | - method: `cancelMFSIP`
28 | - method: `getMFInstruments`
29 | - method: `exitOrder`
30 | - method: `renewAccessToken`
31 | - method: `invalidateRefreshToken`
32 |
33 | API method name changes
34 | =======================
35 |
36 | | v2 | v3 |
37 | | ------------------------- | ------------------------- |
38 | | requestAccessToken | generateSession |
39 | | invalidateToken | invalidateAccessToken |
40 | | setSessionHook | setSessionExpiryHook |
41 | | loginUrl | getLoginURL |
42 | | margins | getMargins |
43 | | orderPlace | placeOrder |
44 | | orderModify | modifyOrder |
45 | | orderCancel | cancelOrder |
46 | | orders | getOrders |
47 | | orders(order_id) | getOrderHistory |
48 | | trades | getTrades |
49 | | trades(order_id) | getOrderTrades |
50 | | holdings | getHoldings |
51 | | positions | getPositions |
52 | | productModify | convertPosition |
53 | | instruments | getInstruments |
54 | | historical | getHistoricalData |
55 | | triggerRange | getTriggerRange |
56 |
57 | Params and other changes
58 | ========================
59 | - `placeOrder` method takes all the params as array including `variety`
60 | - `modifyOrder` method takes all the params as array including `variety` and `order_id`
61 | - `cancelOrder` method takes all the params as array
62 | - `convertPosition` method takes all the params as array
63 | - `getHistoricalData` method takes all the params as array
64 | - [Changes in `requestAccessToken` response structure](https://kite.trade/docs/connect/v3/user/#response-attributes)
65 | - [Changes in `getPositions` response structure](https://kite.trade/docs/connect/v3/portfolio/#response-attributes_1)
66 | - [Changes in `getQuote` response structure](https://kite.trade/docs/connect/v3/market-quotes/#retrieving-full-market-quotes)
67 | - [Changes in `placeOrder` params](https://kite.trade/docs/connect/v3/orders/#bracket-order-bo-parameters)
68 | - Changes in `getHistoricalData` params
69 | - All datetime string fields has been converted to `Date` object.
70 | - `getOrders`, `getOrderHistory`, `getTrades`, `getOrderTrades`, `getMFOrders` responses fields `order_timestamp`, `exchange_timestamp`, `fill_timestamp`
71 | - `getMFSIPS` fields `created`, `last_instalment`
72 | - `generateSession` field `login_time`
73 | - `getQuote` fields `timestamp`, `last_trade_time`
74 | - `getInstruments` field `expiry`
75 | - `getMFInstruments` field `last_price_date`
76 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) [Zerodha Technology](http://zerodha.com)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # The Kite Connect API PHP client - v3
2 |
3 | The Official PHP client for communicating with the [Kite Connect API](https://kite.trade).
4 |
5 | Note: For PHP version < 8.0. You can refer to our [previous version](https://github.com/zerodha/phpkiteconnect/releases/tag/v3.0.0).
6 | Kite Connect is a set of REST-like APIs that expose many capabilities required to build a complete investment and trading platform. Execute orders in real time, manage user portfolio and more, with the simple HTTP API collection.
7 |
8 | [Zerodha Technology](http://zerodha.com) (c) 2021. Licensed under the MIT License.
9 |
10 | ## Documentation
11 |
12 | - [PHP client documentation](https://kite.trade/docs/phpkiteconnect/v3)
13 | - [Kite Connect HTTP API documentation](https://kite.trade/docs/connect/v3)
14 |
15 | ## Installing
16 |
17 | ### Requirements
18 |
19 | 1. Install [PHP](https://www.php.net/manual/en/install.php) version 8.0 or higher.
20 | 2. Install [Composer](https://getcomposer.org/download/), which is used to install PHP packages.
21 |
22 | You can install the package via composer:
23 |
24 | ```bash
25 | composer require zerodha/phpkiteconnect
26 | ```
27 |
28 | Note: You can refer to our previous version [here](https://github.com/zerodha/phpkiteconnect/releases/tag/v3.0.0) for PHP version < 8.0.
29 |
30 | ## Usage
31 |
32 | ```php
33 | login_url()
44 | try {
45 | $user = $kite->generateSession("request_token_obtained", "your_api_secret");
46 | echo "Authentication successful. \n";
47 | print_r($user);
48 | $kite->setAccessToken($user->access_token);
49 | } catch(Exception $e) {
50 | echo "Authentication failed: ".$e->getMessage();
51 | throw $e;
52 | }
53 |
54 | echo $user->user_id." has logged in";
55 |
56 | // Get the list of positions.
57 | echo "Positions: \n";
58 | print_r($kite->getPositions());
59 |
60 | // Place order.
61 | $order = $kite->placeOrder("regular", [
62 | "tradingsymbol" => "INFY",
63 | "exchange" => "NSE",
64 | "quantity" => 1,
65 | "transaction_type" => "BUY",
66 | "order_type" => "MARKET",
67 | "product" => "NRML"
68 | ]);
69 |
70 | echo "Order id is ".$order->order_id;
71 | ?>
72 | ```
73 |
74 | ## Examples
75 |
76 | Check [examples folder](https://github.com/zerodha/phpkiteconnect/tree/master/examples) for more examples.
77 |
78 | Refer to the [PHP client documentation](https://kite.trade/docs/phpkiteconnect/v3) for the complete list of supported methods.
79 |
80 | ## Run unit tests
81 |
82 | ```
83 | phpunit tests/KiteConnectTest.php
84 | ```
85 |
86 | ## Generate documentation
87 |
88 | ```
89 | $ apt-get install wget
90 | $ wget https://phpdoc.org/phpDocumentor.phar
91 | $ chmod +x phpDocumentor.phar
92 | $ ./phpDocumentor.phar run -d ./src/ -t ./doc/
93 | ```
94 |
95 | ## Changelog
96 |
97 | [Check CHANGELOG.md](CHANGELOG.md)
98 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "zerodha/phpkiteconnect",
3 | "description": "The PHP client library for the Kite Connect trading APIs Resources",
4 | "type": "library",
5 | "keywords": [
6 | "zerodha",
7 | "phpkiteconnect"
8 | ],
9 | "homepage": "https://github.com/zerodha/phpkiteconnect",
10 | "license": "MIT",
11 | "authors": [
12 | {
13 | "name": "zerodha",
14 | "email": "kite@zerodha.com",
15 | "role": "Owner"
16 | }
17 | ],
18 | "require": {
19 | "php": ">=7.3",
20 | "ext-curl": "*",
21 | "ext-json": "*",
22 | "ext-zlib": "*",
23 | "guzzlehttp/guzzle": "^7.2",
24 | "guzzlehttp/psr7": "^1.7"
25 | },
26 | "require-dev": {
27 | "friendsofphp/php-cs-fixer": "^2.17",
28 | "phpunit/phpunit": "^9.5",
29 | "vimeo/psalm": "^4.3"
30 | },
31 | "autoload": {
32 | "psr-4": {
33 | "KiteConnect\\": "src/"
34 | }
35 | },
36 | "autoload-dev": {
37 | "psr-4": {
38 | "KiteConnect\\Tests\\": "tests"
39 | }
40 | },
41 | "scripts": {
42 | "psalm": "vendor/bin/psalm",
43 | "test": "vendor/bin/phpunit",
44 | "test-coverage": "vendor/bin/phpunit --coverage-html coverage",
45 | "format": "vendor/bin/php-cs-fixer fix --allow-risky=yes"
46 | },
47 | "config": {
48 | "sort-packages": true
49 | },
50 | "minimum-stability": "dev",
51 | "prefer-stable": true
52 | }
53 |
--------------------------------------------------------------------------------
/examples/kiteconnect_sample.php:
--------------------------------------------------------------------------------
1 | login_url()
13 | try {
14 | $user = $kite->generateSession("request_token", "secret_key");
15 |
16 | echo "Authentication successful. \n";
17 | print_r($user);
18 |
19 | $kite->setAccessToken($user->access_token);
20 | } catch (Exception $e) {
21 | echo "Authentication failed: " . $e->getMessage();
22 |
23 | throw $e;
24 | }
25 |
26 | echo $user->user_id . " has logged in";
27 |
28 | // Get the list of positions.
29 | echo "Positions: \n";
30 | print_r($kite->getPositions());
31 |
32 | // Get the list of holdings.
33 | echo "Holdings: \n";
34 | print_r($kite->getHoldings());
35 |
36 | // Retrieve quote and market depth for list of instruments.
37 | echo "Quote: \n";
38 | print_r($kite->getQuote(["NSE:INFY", "NSE:SBIN"]));
39 |
40 | // Place order.
41 | $order = $kite->placeOrder("regular", [
42 | "tradingsymbol" => "INFY",
43 | "exchange" => "NSE",
44 | "quantity" => 1,
45 | "transaction_type" => "BUY",
46 | "order_type" => "MARKET",
47 | "product" => "CNC",
48 | ]);
49 |
50 | echo "Order id is " . $order->order_id;
51 |
52 | // fetch order margin
53 | $order_param = [["exchange" => "NSE",
54 | "tradingsymbol" => "INFY",
55 | "transaction_type" => $kite::TRANSACTION_TYPE_BUY,
56 | "variety" => $kite::VARIETY_REGULAR,
57 | "product" => $kite::PRODUCT_CNC,
58 | "order_type" => $kite::ORDER_TYPE_MARKET,
59 | "quantity" => 1,
60 | ],];
61 |
62 | print_r($kite->orderMargins($order_param));
63 |
64 | $place_GTT = $kite->placeGTT([
65 | "trigger_type" => $kite::GTT_TYPE_SINGLE,
66 | "tradingsymbol" => "TATAMOTORS",
67 | "exchange" => "NSE",
68 | "trigger_values" => array(310),
69 | "last_price" => 315,
70 | "orders" => array([
71 | "transaction_type" => $kite::TRANSACTION_TYPE_BUY,
72 | "quantity" => 1,
73 | "product" => $kite::PRODUCT_CNC,
74 | "order_type" => $kite::ORDER_TYPE_LIMIT,
75 | "price" => 314
76 | ])
77 | ]);
78 | echo "Trigger id is ".$place_GTT->trigger_id;
79 |
80 | $orderParams = [[
81 | "order_id" => "111111111",
82 | "exchange" => "NSE",
83 | "tradingsymbol" => "SBIN",
84 | "transaction_type" => $kite::TRANSACTION_TYPE_BUY,
85 | "variety" => $kite::VARIETY_REGULAR,
86 | "product" => $kite::PRODUCT_CNC,
87 | "order_type" => $kite::ORDER_TYPE_MARKET,
88 | "quantity" => 1,
89 | "average_price" => 560
90 | ],
91 | [
92 | "order_id" => "2222222222",
93 | "exchange" => "MCX",
94 | "tradingsymbol" => "GOLDPETAL23JULFUT",
95 | "transaction_type" => $kite::TRANSACTION_TYPE_SELL,
96 | "variety" => $kite::VARIETY_REGULAR,
97 | "product" => $kite::PRODUCT_NRML,
98 | "order_type" => $kite::ORDER_TYPE_LIMIT,
99 | "quantity" => 1,
100 | "average_price" => 5862
101 | ],
102 | [
103 | "order_id" => "3333333333",
104 | "exchange" => "NFO",
105 | "tradingsymbol" => "NIFTY2371317900PE",
106 | "transaction_type" => $kite::TRANSACTION_TYPE_SELL,
107 | "variety" => $kite::VARIETY_REGULAR,
108 | "product" => $kite::PRODUCT_NRML,
109 | "order_type" => $kite::ORDER_TYPE_LIMIT,
110 | "quantity" => 100,
111 | "average_price" => 1.5
112 | ]
113 | ];
114 |
115 | print_r($kite->getVirtualContractNote($orderParams));
116 |
117 | ?>
118 |
--------------------------------------------------------------------------------
/phpunit.xml.dist:
--------------------------------------------------------------------------------
1 |
2 |
Class Object 753 | * ( 754 | * [instrument_token] => 128031748 755 | * [exchange_token] => 500124 756 | * [tradingsymbol] => DRREDDY* 757 | * [name] => DR.REDDYS LABORATORIES 758 | * [last_price] => 0 759 | * [expiry] => 760 | * [strike] => 0 761 | * [tick_size] => 0.05 762 | * [lot_size] => 1 763 | * [instrument_type] => EQ 764 | * [segment] => BSE 765 | * [exchange] => BSE 766 | * ) 767 | *768 | * 769 | * @param string|null $exchange (Optional) Exchange. 770 | * @return array 771 | * @throws DataException 772 | * @throws GeneralException 773 | * @throws InputException 774 | * @throws NetworkException 775 | * @throws OrderException 776 | * @throws PermissionException 777 | * @throws TokenException 778 | */ 779 | public function getInstruments(?string $exchange = null): array 780 | { 781 | if ($exchange) { 782 | $params = ["exchange" => $exchange]; 783 | 784 | return $this->parseInstrumentsToCSV($this->get("market.instruments", $params)); 785 | } else { 786 | return $this->parseInstrumentsToCSV($this->get("market.instruments.all")); 787 | } 788 | } 789 | 790 | /** 791 | * Retrieve quote and market depth for list of instruments. 792 | * 793 | * @param array $instruments instruments is a list of instruments, Instrument are in the format of `tradingsymbol:exchange`. 794 | * For example NSE:INFY 795 | * @return array 796 | * @throws DataException 797 | * @throws GeneralException 798 | * @throws InputException 799 | * @throws NetworkException 800 | * @throws OrderException 801 | * @throws PermissionException 802 | * @throws TokenException 803 | */ 804 | public function getQuote(array $instruments): array 805 | { 806 | return $this->formatResponseArray($this->get("market.quote", ["i" => $instruments])); 807 | } 808 | 809 | /** 810 | * Retrieve OHLC for list of instruments. 811 | * 812 | * @param array $instruments instruments is a list of instruments, Instrument are in the format of `tradingsymbol:exchange`. 813 | * For example NSE:INFY 814 | * @return mixed 815 | * @throws DataException 816 | * @throws GeneralException 817 | * @throws InputException 818 | * @throws NetworkException 819 | * @throws OrderException 820 | * @throws PermissionException 821 | * @throws TokenException 822 | */ 823 | public function getOHLC(array $instruments): mixed 824 | { 825 | return $this->get("market.quote.ohlc", ["i" => $instruments]); 826 | } 827 | 828 | /** 829 | * Retrieve LTP for list of instruments. 830 | * 831 | * @param array $instruments instruments is a list of instruments, Instrument are in the format of `tradingsymbol:exchange`. 832 | * For example NSE:INFY 833 | * @return mixed 834 | * @throws DataException 835 | * @throws GeneralException 836 | * @throws InputException 837 | * @throws NetworkException 838 | * @throws OrderException 839 | * @throws PermissionException 840 | * @throws TokenException 841 | */ 842 | public function getLTP(array $instruments): mixed 843 | { 844 | return $this->get("market.quote.ltp", ["i" => $instruments]); 845 | } 846 | 847 | /** 848 | * Retrieve historical data (candles) for an instrument. 849 | * 850 | * Although the actual response JSON from the API does not have field 851 | * names such has 'open', 'high' etc., this functin call structures 852 | * the data into an array of objects with field names. For example: 853 | *
stdClass Object 854 | * ( 855 | * [date] => 2016-05-02T09:15:00+0530 856 | * [open] => 1442 857 | * [high] => 1446.45 858 | * [low] => 1416.15 859 | * [close] => 1420.55 860 | * [volume] => 205976 861 | * ) 862 | *863 | * 864 | * 865 | * @param string $instrument_token "instrument_token" Instrument identifier (retrieved from the instruments()) call. 866 | * @param string $interval "interval" candle interval (minute, day, 5 minute etc.) 867 | * @param string|DateTime $from "from" From date (String in format of 'yyyy-mm-dd HH:MM:SS' or Date object). 868 | * @param string|DateTime $to "to" To date (String in format of 'yyyy-mm-dd HH:MM:SS' or Date object). 869 | * @param bool $continuous "continuous" is a bool flag to get continuous data for futures and options instruments. Defaults to false. 870 | * @param bool $oi 871 | * @return array 872 | * @throws Exception 873 | */ 874 | public function getHistoricalData( 875 | string $instrument_token, 876 | string $interval, 877 | $from, 878 | $to, 879 | bool $continuous = false, 880 | bool $oi = false 881 | ): array { 882 | $params = [ 883 | "instrument_token" => $instrument_token, 884 | "interval" => $interval, 885 | "from" => $from, 886 | "to" => $to, 887 | "continuous" => $continuous, 888 | "oi" => $oi, 889 | ]; 890 | 891 | if ($from instanceof DateTime) { 892 | $params["from"] = $from->format("Y-m-d H:i:s"); 893 | } 894 | 895 | if ($to instanceof DateTime) { 896 | $params["to"] = $to->format("Y-m-d H:i:s"); 897 | } 898 | 899 | if ($params["continuous"] == false) { 900 | $params["continuous"] = 0; 901 | } else { 902 | $params["continuous"] = 1; 903 | } 904 | 905 | if ($params["oi"] == false) { 906 | $params["oi"] = 0; 907 | } else { 908 | $params["oi"] = 1; 909 | } 910 | 911 | $data = $this->get("market.historical", $params); 912 | 913 | $records = []; 914 | foreach ($data->candles as $j) { 915 | $r = new stdclass; 916 | $r->date = new DateTime($j[0], new DateTimeZone("Asia/Kolkata")); 917 | $r->open = $j[1]; 918 | $r->high = $j[2]; 919 | $r->low = $j[3]; 920 | $r->close = $j[4]; 921 | $r->volume = $j[5]; 922 | if (! empty($j[6])) { 923 | $r->oi = $j[6]; 924 | } 925 | 926 | $records[] = $r; 927 | } 928 | 929 | return $records; 930 | } 931 | 932 | /** 933 | * Retrieve the buy/sell trigger range for Cover Orders. 934 | * 935 | * @param string $transaction_type Transaction type 936 | * @param mixed $instruments 937 | * @return array 938 | * @throws DataException 939 | * @throws GeneralException 940 | * @throws InputException 941 | * @throws NetworkException 942 | * @throws OrderException 943 | * @throws PermissionException 944 | * @throws TokenException 945 | */ 946 | public function getTriggerRange(string $transaction_type, $instruments): array 947 | { 948 | return $this->get( 949 | "market.trigger_range", 950 | ["i" => $instruments, "transaction_type" => strtolower($transaction_type)] 951 | ); 952 | } 953 | 954 | /** 955 | * Get the list of MF orders / order info for individual order. 956 | * @param string|null $orderId (Optional) Order id. 957 | * @return mixed 958 | * @throws DataException 959 | * @throws GeneralException 960 | * @throws InputException 961 | * @throws NetworkException 962 | * @throws OrderException 963 | * @throws PermissionException 964 | * @throws TokenException 965 | */ 966 | public function getMFOrders(?string $orderId = null): mixed 967 | { 968 | if ($orderId) { 969 | return $this->formatResponse($this->get("mf.order.info", ["order_id" => $orderId])); 970 | } 971 | 972 | return $this->formatResponseArray($this->get("mf.orders")); 973 | } 974 | 975 | /** 976 | * Get the list of MF holdings. 977 | * @return array 978 | * @throws DataException 979 | * @throws GeneralException 980 | * @throws InputException 981 | * @throws NetworkException 982 | * @throws OrderException 983 | * @throws PermissionException 984 | * @throws TokenException 985 | */ 986 | public function getMFHoldings(): array 987 | { 988 | return $this->get("mf.holdings"); 989 | } 990 | 991 | /** 992 | * Place an mutual fund order. 993 | * 994 | * @param array $params [Order parameters](https://kite.trade/docs/connect/v3/mf/#orders) 995 | * $param string "tradingsymbol" Tradingsymbol (ISIN) of the fund. 996 | * $param string "transaction_type" Transaction type (BUY or SELL). 997 | * $param int|null "quantity" Quantity to SELL. Not applicable on BUYs. 998 | * $param float|null "amount" (Optional) Amount worth of units to purchase. Not applicable on SELLs 999 | * $param string|null "tag" (Optional) An optional tag to apply to an order to identify it (alphanumeric, max 8 chars) 1000 | * @return string 1001 | * @throws DataException 1002 | * @throws GeneralException 1003 | * @throws InputException 1004 | * @throws NetworkException 1005 | * @throws OrderException 1006 | * @throws PermissionException 1007 | * @throws TokenException 1008 | */ 1009 | public function placeMFOrder(array $params): string 1010 | { 1011 | return $this->post("mf.order.place", $params); 1012 | } 1013 | 1014 | /** 1015 | * Cancel an mutual fund order. 1016 | * 1017 | * @param string $orderId Order id. 1018 | * @return string 1019 | * @throws DataException 1020 | * @throws GeneralException 1021 | * @throws InputException 1022 | * @throws NetworkException 1023 | * @throws OrderException 1024 | * @throws PermissionException 1025 | * @throws TokenException 1026 | */ 1027 | public function cancelMFOrder(string $orderId): string 1028 | { 1029 | return $this->delete("mf.order.cancel", ["order_id" => $orderId]); 1030 | } 1031 | 1032 | /** 1033 | * Get the list of mutual fund SIP's or individual SIP info. 1034 | * @param string|null $sip_id (Optional) SIP id. 1035 | * @return mixed 1036 | * @throws DataException 1037 | * @throws GeneralException 1038 | * @throws InputException 1039 | * @throws NetworkException 1040 | * @throws OrderException 1041 | * @throws PermissionException 1042 | * @throws TokenException 1043 | */ 1044 | public function getMFSIPS(?string $sip_id = null): mixed 1045 | { 1046 | if ($sip_id) { 1047 | return $this->formatResponse($this->get("mf.sip.info", ["sip_id" => $sip_id])); 1048 | } 1049 | 1050 | return $this->formatResponseArray($this->get("mf.sips")); 1051 | } 1052 | 1053 | /** 1054 | * Place an mutual fund order. 1055 | * 1056 | * @param array $params [Mutual fund SIP parameters](https://kite.trade/docs/connect/v3/mf/#sip-orders) 1057 | * $param string "tradingsymbol" Tradingsymbol (ISIN) of the fund. 1058 | * $param float "amount" Amount worth of units to purchase. Not applicable on SELLs 1059 | * $param int "instalments" Number of instalments to trigger. If set to -1, instalments are triggered at fixed intervals until the SIP is cancelled 1060 | * $param string "frequency" Order frequency. weekly, monthly, or quarterly. 1061 | * $param float|null "initial_amount" (Optional) Amount worth of units to purchase before the SIP starts. 1062 | * $param int|null "instalment_day" (Optional) If frequency is monthly, the day of the month (1, 5, 10, 15, 20, 25) to trigger the order on. 1063 | * $param string|null "tag" An optional (Optional) tag to apply to an order to identify it (alphanumeric, max 8 chars) 1064 | * @return string 1065 | * @throws DataException 1066 | * @throws GeneralException 1067 | * @throws InputException 1068 | * @throws NetworkException 1069 | * @throws OrderException 1070 | * @throws PermissionException 1071 | * @throws TokenException 1072 | */ 1073 | public function placeMFSIP(array $params): string 1074 | { 1075 | return $this->post("mf.sip.place", $params); 1076 | } 1077 | 1078 | /** 1079 | * Place an mutual fund order. 1080 | * 1081 | * @param string $sip_id Mutual fund SIP ID. 1082 | * @param array $params [Mutual fund SIP modify parameters](https://kite.trade/docs/connect/v1/#orders30) 1083 | * $param float "amount" Amount worth of units to purchase. Not applicable on SELLs 1084 | * $param int|null "instalments" (Optional) Number of instalments to trigger. If set to -1, instalments are triggered at fixed intervals until the SIP is cancelled 1085 | * $param string|null "frequency" (Optional) Order frequency. weekly, monthly, or quarterly. 1086 | * $param int|null "instalment_day" (Optional) If frequency is monthly, the day of the month (1, 5, 10, 15, 20, 25) to trigger the order on. 1087 | * $param string|null "status" (Optional) Pause or unpause an SIP (active or paused). 1088 | * @return string 1089 | * @throws DataException 1090 | * @throws GeneralException 1091 | * @throws InputException 1092 | * @throws NetworkException 1093 | * @throws OrderException 1094 | * @throws PermissionException 1095 | * @throws TokenException 1096 | */ 1097 | public function modifyMFSIP(string $sip_id, array $params): string 1098 | { 1099 | $params["sip_id"] = $sip_id; 1100 | 1101 | return $this->put("mf.sip.modify", $params); 1102 | } 1103 | 1104 | /** 1105 | * Cancel an mutual fund order. 1106 | * 1107 | * @param string $sip_id SIP id. 1108 | * @return string 1109 | * @throws DataException 1110 | * @throws GeneralException 1111 | * @throws InputException 1112 | * @throws NetworkException 1113 | * @throws OrderException 1114 | * @throws PermissionException 1115 | * @throws TokenException 1116 | */ 1117 | public function cancelMFSIP(string $sip_id): string 1118 | { 1119 | return $this->delete("mf.sip.cancel", ["sip_id" => $sip_id]); 1120 | } 1121 | 1122 | /** 1123 | * Get list of mutual fund instruments. 1124 | * 1125 | * @return array 1126 | * @throws DataException 1127 | * @throws GeneralException 1128 | * @throws InputException 1129 | * @throws NetworkException 1130 | * @throws OrderException 1131 | * @throws PermissionException 1132 | * @throws TokenException 1133 | */ 1134 | public function getMFInstruments(): array 1135 | { 1136 | return $this->parseMFInstrumentsToCSV($this->get("mf.instruments")); 1137 | } 1138 | 1139 | /** 1140 | * Get the list of all orders placed for the day. 1141 | * @return array 1142 | * @throws DataException 1143 | * @throws GeneralException 1144 | * @throws InputException 1145 | * @throws NetworkException 1146 | * @throws OrderException 1147 | * @throws PermissionException 1148 | * @throws TokenException 1149 | */ 1150 | public function getGTTs(): array 1151 | { 1152 | return $this->formatResponseArray($this->get("gtt.triggers")); 1153 | } 1154 | 1155 | /** 1156 | * Get detail of individual GTT order. 1157 | * @param string $triggerId Trigger ID 1158 | * @return mixed 1159 | * @throws DataException 1160 | * @throws GeneralException 1161 | * @throws InputException 1162 | * @throws NetworkException 1163 | * @throws OrderException 1164 | * @throws PermissionException 1165 | * @throws TokenException 1166 | */ 1167 | public function getGTT(string $triggerId): mixed 1168 | { 1169 | return $this->formatResponse($this->get("gtt.trigger_info", ["trigger_id" => $triggerId])); 1170 | } 1171 | 1172 | /** 1173 | * Delete an GTT order 1174 | * @param string $triggerId "trigger_id" Trigger ID 1175 | * @return mixed 1176 | * @throws DataException 1177 | * @throws GeneralException 1178 | * @throws InputException 1179 | * @throws NetworkException 1180 | * @throws OrderException 1181 | * @throws PermissionException 1182 | * @throws TokenException 1183 | */ 1184 | public function deleteGTT(string $triggerId) 1185 | { 1186 | return $this->delete("gtt.delete", ["trigger_id" => $triggerId]); 1187 | } 1188 | 1189 | /** 1190 | * @param mixed $params 1191 | * @return array 1192 | * @throws DataException 1193 | */ 1194 | private function getGTTPayload($params): array 1195 | { 1196 | if ($params["trigger_type"] == self::GTT_TYPE_OCO && count($params["trigger_values"]) != 2) { 1197 | throw new DataException("Invalid `trigger_values` for `OCO` order type"); 1198 | } 1199 | if ($params["trigger_type"] == self::GTT_TYPE_SINGLE && count($params["trigger_values"]) != 1) { 1200 | throw new DataException("Invalid `trigger_values` for `single` order type"); 1201 | } 1202 | $condition = [ 1203 | "exchange" => $params["exchange"], 1204 | "tradingsymbol" => $params["tradingsymbol"], 1205 | "trigger_values" => $params["trigger_values"], 1206 | "last_price" => (float)$params["last_price"], 1207 | ]; 1208 | $orders = []; 1209 | foreach ($params["orders"] as &$o) { 1210 | array_push($orders, [ 1211 | "transaction_type" => $o["transaction_type"], 1212 | "order_type" => $o["order_type"], 1213 | "product" => $o["product"], 1214 | "quantity" => (int)$o["quantity"], 1215 | "price" => (float)($o["price"]), 1216 | "exchange" => $params["exchange"], 1217 | "tradingsymbol" => $params["tradingsymbol"], 1218 | ]); 1219 | } 1220 | 1221 | return [ 1222 | "condition" => $condition, 1223 | "orders" => $orders, 1224 | ]; 1225 | } 1226 | 1227 | /** 1228 | * Place a GTT. Check [GTT documentation](https://kite.trade/docs/connect/v3/gtt/#placing-orders) for details. 1229 | *
1230 | * $params = [
1231 | * // GTT type, its either `$kite::GTT_TYPE_OCO` or `$kite::GTT_TYPE_SINGLE`.
1232 | * "trigger_type" => $kite::GTT_TYPE_OCO,
1233 | * // Tradingsymbol of the instrument (ex. RELIANCE, INFY).
1234 | * "tradingsymbol" => "SBIN",
1235 | * // Exchange in which instrument is listed (NSE, BSE, NFO, BFO, CDS, MCX).
1236 | * "exchange" => "NSE",
1237 | * // List of trigger values, number of items depends on trigger type.
1238 | * "trigger_values" => array(300, 400),
1239 | * // Price at which trigger is created. This is usually the last price of the instrument.
1240 | * "last_price" => 318,
1241 | * // List of orders. Check [order params](https://kite.trade/docs/connect/v3/orders/#regular-order-parameters) for all available params.
1242 | * "orders" => array([
1243 | * "transaction_type" => $kite::TRANSACTION_TYPE_SELL,
1244 | * "quantity" => 1,
1245 | * "product" => $kite::PRODUCT_CNC,
1246 | * "order_type" => $kite::ORDER_TYPE_LIMIT,
1247 | * "price" => 300
1248 | * ], [
1249 | * "transaction_type" => $kite::TRANSACTION_TYPE_SELL,
1250 | * "quantity" => 1,
1251 | * "product" => $kite::PRODUCT_CNC,
1252 | * "order_type" => $kite::ORDER_TYPE_LIMIT,
1253 | * "price" => 400
1254 | * ])
1255 | * ]
1256 | *
1257 | *
1258 | * @param array $params GTT Params. Check above for required fields.
1259 | * @return mixed
1260 | * @throws DataException
1261 | * @throws GeneralException
1262 | * @throws InputException
1263 | * @throws NetworkException
1264 | * @throws OrderException
1265 | * @throws PermissionException
1266 | * @throws TokenException
1267 | */
1268 | public function placeGTT(array $params)
1269 | {
1270 | $payload = $this->getGTTPayload($params);
1271 |
1272 | return $this->post("gtt.place", [
1273 | "condition" => json_encode($payload["condition"]),
1274 | "orders" => json_encode($payload["orders"]),
1275 | "type" => $params["trigger_type"],
1276 | ]);
1277 | }
1278 |
1279 | /**
1280 | * Modify GTT. Check [GTT documentation](https://kite.trade/docs/connect/v3/gtt/#modify-order) for details.
1281 | *
1282 | * $params = [
1283 | * // GTT type, its either `$kite::GTT_TYPE_OCO` or `$kite::GTT_TYPE_SINGLE`.
1284 | * "trigger_type" => $kite::GTT_TYPE_OCO,
1285 | * // Tradingsymbol of the instrument (ex. RELIANCE, INFY).
1286 | * "tradingsymbol" => "SBIN",
1287 | * // Exchange in which instrument is listed (NSE, BSE, NFO, BFO, CDS, MCX).
1288 | * "exchange" => "NSE",
1289 | * // List of trigger values, number of items depends on trigger type.
1290 | * "trigger_values" => array(300, 400),
1291 | * // Price at which trigger is created. This is usually the last price of the instrument.
1292 | * "last_price" => 318,
1293 | * // List of orders. Check [order params](https://kite.trade/docs/connect/v3/orders/#regular-order-parameters) for all available params.
1294 | * "orders" => array([
1295 | * "transaction_type" => $kite::TRANSACTION_TYPE_SELL,
1296 | * "quantity" => 1,
1297 | * "product" => $kite::PRODUCT_CNC,
1298 | * "order_type" => $kite::ORDER_TYPE_LIMIT,
1299 | * "price" => 300
1300 | * ], [
1301 | * "transaction_type" => $kite::TRANSACTION_TYPE_SELL,
1302 | * "quantity" => 1,
1303 | * "product" => $kite::PRODUCT_CNC,
1304 | * "order_type" => $kite::ORDER_TYPE_LIMIT,
1305 | * "price" => 400
1306 | * ])
1307 | * ]
1308 | *
1309 | * @param int $triggerId GTT Trigger ID
1310 | * @param array $params GTT Params. Check above for required fields.
1311 | * @return mixed
1312 | * @throws DataException
1313 | * @throws GeneralException
1314 | * @throws InputException
1315 | * @throws NetworkException
1316 | * @throws OrderException
1317 | * @throws PermissionException
1318 | * @throws TokenException
1319 | */
1320 | public function modifyGTT(int $triggerId, array $params)
1321 | {
1322 | $payload = $this->getGTTPayload($params);
1323 |
1324 | return $this->put("gtt.modify", [
1325 | "condition" => json_encode($payload["condition"]),
1326 | "orders" => json_encode($payload["orders"]),
1327 | "type" => $params["trigger_type"],
1328 | "trigger_id" => $triggerId,
1329 | ]);
1330 | }
1331 |
1332 | /**
1333 | * Format response array, For example datetime string to DateTime object
1334 | * @param mixed $data
1335 | * @return mixed
1336 | * @throws Exception
1337 | */
1338 | private function formatResponse($data)
1339 | {
1340 | foreach (self::$dateFields as $field) {
1341 | if (isset($data->$field) && strlen($data->$field) == 19) {
1342 | $data->$field = new DateTime($data->$field, new DateTimeZone("Asia/Kolkata"));
1343 | }
1344 | }
1345 |
1346 | return $data;
1347 | }
1348 |
1349 | /**
1350 | * Format array of responses
1351 | * @param mixed $data
1352 | * @return array
1353 | * @throws Exception
1354 | */
1355 | private function formatResponseArray($data): array
1356 | {
1357 | $results = [];
1358 | foreach ($data as $k => $item) {
1359 | $results[$k] = $this->formatResponse($item);
1360 | }
1361 |
1362 | return $results;
1363 | }
1364 |
1365 | /**
1366 | * Alias for sending a GET request.
1367 | *
1368 | * @param string $route Route name mapped in self::$routes.
1369 | * @param array|null $params Request parameters.
1370 | * @param string $headerContent
1371 | * @return mixed Array or object (deserialised JSON).
1372 | * @throws DataException
1373 | * @throws GeneralException
1374 | * @throws InputException
1375 | * @throws NetworkException
1376 | * @throws OrderException
1377 | * @throws PermissionException
1378 | * @throws TokenException
1379 | */
1380 | private function get(string $route, array $params = [], string $headerContent = '')
1381 | {
1382 | return $this->request($route, "GET", $params, $headerContent);
1383 | }
1384 |
1385 | /**
1386 | * Alias for sending a GET request.
1387 | *
1388 | * @param string $route Route name mapped in self::$routes.
1389 | * @param array|null $params Request parameters.
1390 | * @param string $headerContent
1391 | * @return mixed Array or object (deserialised JSON).
1392 | * @throws DataException
1393 | * @throws GeneralException
1394 | * @throws InputException
1395 | * @throws NetworkException
1396 | * @throws OrderException
1397 | * @throws PermissionException
1398 | * @throws TokenException
1399 | */
1400 | private function post(string $route, array $params = [], string $headerContent = '')
1401 | {
1402 | return $this->request($route, "POST", $params, $headerContent);
1403 | }
1404 |
1405 | /**
1406 | * Alias for sending a PUT request.
1407 | *
1408 | * @param string $route Route name mapped in self::$routes.
1409 | * @param array|null $params Request parameters.
1410 | * @param string $headerContent
1411 | * @return mixed Array or object (deserialised JSON).
1412 | * @throws DataException
1413 | * @throws GeneralException
1414 | * @throws InputException
1415 | * @throws NetworkException
1416 | * @throws OrderException
1417 | * @throws PermissionException
1418 | * @throws TokenException
1419 | */
1420 | private function put(string $route, array $params = [], string $headerContent = '')
1421 | {
1422 | return $this->request($route, "PUT", $params, $headerContent);
1423 | }
1424 |
1425 | /**
1426 | * Alias for sending a GET request.
1427 | *
1428 | * @param string $route Route name mapped in self::$routes.
1429 | * @param array|null $params Request parameters.
1430 | * @param string $headerContent
1431 | * @return mixed Array or object (deserialised JSON).
1432 | * @throws DataException
1433 | * @throws GeneralException
1434 | * @throws InputException
1435 | * @throws NetworkException
1436 | * @throws OrderException
1437 | * @throws PermissionException
1438 | * @throws TokenException
1439 | */
1440 | private function delete(string $route, array $params = [], string $headerContent = '')
1441 | {
1442 | return $this->request($route, "DELETE", $params, $headerContent);
1443 | }
1444 |
1445 | /**
1446 | * Make an HTTP request.
1447 | *
1448 | * @param string $route Route name mapped in self::$routes.
1449 | * @param string $method The HTTP method to send (GET, POST, PUT, DELETE).
1450 | * @param array|null $params Request parameters.
1451 | * @param string $headerContent Header content
1452 | * @return mixed Array or object (deserialised JSON).
1453 | * @throws DataException
1454 | * @throws GeneralException
1455 | * @throws InputException
1456 | * @throws NetworkException
1457 | * @throws OrderException
1458 | * @throws PermissionException
1459 | * @throws TokenException
1460 | */
1461 | private function request(string $route, string $method, array $params, string $headerContent)
1462 | {
1463 | $uri = $this->routes[$route];
1464 | // 'RESTful' URLs.
1465 | if (strpos($uri, "{") !== false) {
1466 | foreach ($params as $key => $value) {
1467 | $uri = str_replace("{" . $key . "}", (string)$value, $uri);
1468 | }
1469 | }
1470 |
1471 | $url = $this->baseUrl . $uri;
1472 |
1473 | if ($this->debug) {
1474 | print("Request: " . $method . " " . $url . "\n");
1475 | var_dump($params);
1476 | }
1477 | // Set the header content type
1478 | if ($headerContent) {
1479 | $content_type = $headerContent;
1480 | } else {
1481 | // By default set header content type to be form-urlencoded
1482 | $content_type = "application/x-www-form-urlencoded";
1483 | }
1484 |
1485 | // Prepare the request header
1486 | $request_headers = [
1487 | "Content-Type" => $content_type,
1488 | "User-Agent" => "phpkiteconnect/" . self::VERSION,
1489 | "X-Kite-Version" => 3,
1490 | ];
1491 |
1492 | if ($this->apiKey && $this->accessToken) {
1493 | $request_headers["Authorization"] = "token " . $this->apiKey . ":" . $this->accessToken;
1494 | }
1495 | // Make the HTTP request.
1496 | $resp = $this->guzzle($url, $method, $request_headers, $params, $this->guzzleClient);
1497 |
1498 | $headers = $resp["headers"];
1499 | $result = $resp["body"];
1500 |
1501 | if ($this->debug) {
1502 | print("Response :" . $result . "\n");
1503 | }
1504 | if (empty($headers["Content-Type"])) {
1505 | throw new DataException("Unknown content-type in response");
1506 | } elseif (strpos($headers["Content-Type"][0], "application/json") !== false) {
1507 | $json = json_decode($result);
1508 | if (! $json) {
1509 | throw new DataException("Couldn't parse JSON response");
1510 | }
1511 |
1512 | // Token error.
1513 | if ($json->status == "error") {
1514 | if ($headers["status_code"] == 403) {
1515 | if ($this->sessionHook) {
1516 | $this->sessionHook->call($this);
1517 |
1518 | return null;
1519 | }
1520 | }
1521 | $this->throwSuitableException($headers, $json);
1522 | }
1523 | return $json->data;
1524 | } elseif (strpos($headers["Content-Type"][0], "text/csv") !== false) {
1525 | return $result;
1526 | } else {
1527 | throw new DataException("Invalid response: " . $result, $headers["status_code"]);
1528 | }
1529 | }
1530 |
1531 | /**
1532 | * Make an HTTP request using the PHP Guzzle http client.
1533 | *
1534 | * @param string $url The full URL to retrieve
1535 | * @param string $method The HTTP method to send (GET, POST, PUT, DELETE).
1536 | * @param array|null $headers Array of HTTP request headers to send.
1537 | * @param array|null $params Array of key=>value request parameters.
1538 | * @return array Returns an array with response "headers" and "body".
1539 | */
1540 | private function guzzle(string $url, string $method, ?array $headers, $params = null, $guzzleClient = null): array
1541 | {
1542 | // set header to Guzzle http client
1543 | // mock patching isn't allowed in PHP
1544 | // Need to pass guzzle client as dependency to mock http response for unit tests
1545 | if ($guzzleClient) {
1546 | $client = $guzzleClient;
1547 | } else {
1548 | $client = new Client(['headers' => $headers, 'timeout' => $this->timeout]);
1549 | }
1550 |
1551 | // declare http body array
1552 | $body_array = [];
1553 | if ($method == "POST" || $method == "PUT") {
1554 | // send JSON body payload for JSON content-type requested
1555 | if($headers['Content-Type'] == 'application/json') {
1556 | $body_array = ['body' => implode(" ",$params)];
1557 | } else {
1558 | $body_array = ['form_params' => $params];
1559 | }
1560 | } elseif ($method == "GET" || $method == "DELETE") {
1561 | $payload = http_build_query($params && is_array($params) ? $params : []);
1562 | // remove un-required url encoded strings
1563 | $payload = preg_replace("/%5B(\d+?)%5D/", "", $payload);
1564 | $body_array = ['query' => $payload];
1565 | }
1566 | try {
1567 | $response = $client->request($method, $url, $body_array);
1568 | } catch(RequestException $e){
1569 | // fetch all error response field
1570 | $response = $e->getResponse();
1571 | }
1572 |
1573 | $result = $response->getBody()->getContents();
1574 |
1575 | $response_headers = $response->getHeaders();
1576 | // add Status Code in response header
1577 | $response_headers['status_code'] = $response->getStatusCode();
1578 | return ["headers" => $response_headers, "body" => $result];
1579 | }
1580 |
1581 | /**
1582 | * Parse a CSV dump into an array of objects.
1583 | *
1584 | * @param string $csv Complete CSV dump.
1585 | * @return array
1586 | * @throws Exception
1587 | */
1588 | private function parseInstrumentsToCSV(string $csv): array
1589 | {
1590 | $lines = explode("\n", $csv);
1591 |
1592 | $records = [];
1593 | $head = [];
1594 | for ($count = 0; $count < count($lines); $count++) {
1595 | $colums = str_getcsv($lines[$count]);
1596 | if ($colums) {
1597 | if (count($colums) < 5) {
1598 | //why this condition is necessary ?
1599 | continue;
1600 | }
1601 |
1602 | // First line is the header.
1603 | if ($count === 0) {
1604 | $head = $colums;
1605 |
1606 | continue;
1607 | }
1608 |
1609 | // Combine header columns + values to an associative array
1610 | // and then to an object;
1611 | $record = (object)array_combine($head, $colums);
1612 | $record->last_price = floatval($record->last_price);
1613 | $record->strike = floatval($record->strike);
1614 | $record->tick_size = floatval($record->tick_size);
1615 | $record->lot_size = floatval($record->lot_size);
1616 |
1617 | if (! empty($record->expiry) && strlen($record->expiry) == 10) {
1618 | $record->expiry = new DateTime($record->expiry, new DateTimeZone("Asia/Kolkata"));
1619 | }
1620 |
1621 | $records[] = $record;
1622 | }
1623 | }
1624 |
1625 | return $records;
1626 | }
1627 |
1628 | /**
1629 | * Parse a CSV dump into an array of objects.
1630 | *
1631 | * @param string $csv Complete CSV dump.
1632 | * @return array
1633 | * @throws Exception
1634 | */
1635 | private function parseMFInstrumentsToCSV(string $csv): array
1636 | {
1637 | $lines = explode("\n", $csv);
1638 |
1639 | $records = [];
1640 | $head = [];
1641 | for ($n = 0; $n < count($lines); $n++) {
1642 | if ($cols = @str_getcsv($lines[$n])) {
1643 | if (count($cols) < 5) {
1644 | continue;
1645 | }
1646 |
1647 | // First line is the header.
1648 | if ($n === 0) {
1649 | $head = $cols;
1650 |
1651 | continue;
1652 | }
1653 |
1654 | // Combine header columns + values to an associative array
1655 | // and then to an object;
1656 | $o = (object)array_combine($head, $cols);
1657 | $o->minimum_purchase_amount = floatval($o->minimum_purchase_amount);
1658 | $o->purchase_amount_multiplier = floatval($o->purchase_amount_multiplier);
1659 | $o->minimum_additional_purchase_amount = floatval($o->minimum_additional_purchase_amount);
1660 | $o->minimum_redemption_quantity = floatval($o->minimum_redemption_quantity);
1661 | $o->redemption_quantity_multiplier = floatval($o->redemption_quantity_multiplier);
1662 | $o->last_price = floatval($o->last_price);
1663 | $o->purchase_allowed = boolval(intval($o->purchase_allowed));
1664 | $o->redemption_allowed = boolval(intval($o->redemption_allowed));
1665 |
1666 | if (! empty($o->last_price_date) && strlen($o->last_price_date) == 10) {
1667 | $o->last_price_date = new DateTime($o->last_price_date, new DateTimeZone("Asia/Kolkata"));
1668 | }
1669 |
1670 | $records[] = $o;
1671 | }
1672 | }
1673 |
1674 | return $records;
1675 | }
1676 |
1677 | /**
1678 | * Throw Exception based on response
1679 | *
1680 | * @param array $headers
1681 | * @param mixed $json
1682 | * @return void
1683 | * @throws DataException
1684 | * @throws GeneralException
1685 | * @throws OrderException
1686 | * @throws PermissionException
1687 | * @throws NetworkException
1688 | * @throws InputException
1689 | * @throws TokenException
1690 | */
1691 | private function throwSuitableException(array $headers, $json): void
1692 | {
1693 | switch ($json->error_type) {
1694 | case 'DataException':
1695 | throw new DataException($json->message, $headers['status_code']);
1696 | case 'InputException':
1697 | throw new InputException($json->message, $headers['status_code']);
1698 | case 'NetworkException':
1699 | throw new NetworkException($json->message, $headers['status_code']);
1700 | case 'OrderException':
1701 | throw new OrderException($json->message, $headers['status_code']);
1702 | case 'PermissionException':
1703 | throw new PermissionException($json->message, $headers['status_code']);
1704 | case 'TokenException':
1705 | throw new TokenException($json->message, $headers['status_code']);
1706 | default:
1707 | throw new GeneralException($json->message, $headers['status_code']);
1708 | }
1709 | }
1710 | }
1711 | ?>
--------------------------------------------------------------------------------
/tests/KiteConnectTest.php:
--------------------------------------------------------------------------------
1 | getLoginURL();
27 | $expectedLoginUrl = 'https://kite.trade/connect/login?api_key=token&v=3';
28 | $this->assertEquals($expectedLoginUrl, $actualLoginUrl);
29 | }
30 |
31 | /**
32 | * @test
33 | * @return void
34 | */
35 | public function test_login_url_is_string(): void
36 | {
37 | $kiteConnect = new KiteConnect('token');
38 | $loginUrl = $kiteConnect->getLoginURL();
39 | $this->assertIsString($loginUrl);
40 | }
41 |
42 | /**
43 | * @test
44 | * @return void
45 | */
46 | public function it_can_be_instantiated_with_token(): void
47 | {
48 | $kiteConnect = new KiteConnect('token');
49 | $this->assertInstanceOf(KiteConnect::class, $kiteConnect);
50 | }
51 |
52 | /**
53 | * @test
54 | * @return void
55 | */
56 | public function it_can_be_instantiated_with_token_and_access_token(): void
57 | {
58 | $kiteConnect = new KiteConnect('token', 'access_token');
59 | $this->assertInstanceOf(KiteConnect::class, $kiteConnect);
60 | }
61 |
62 | /**
63 | * @test Mock intialization
64 | */
65 | public function initializeMock()
66 | {
67 | $timeout = 7;
68 | $mock_data = new MockJson();
69 | // Create a mock and queue required responses.
70 | $client = new Client(['handler' => $mock_data->generateMock()]);
71 | // Inject guzzleClient
72 | $kiteConnect = new KiteConnect('api_key', 'access_token', NULL, false, $timeout, $client);
73 | $this->assertNotNull($kiteConnect);
74 |
75 | return $kiteConnect;
76 | }
77 |
78 | /**
79 | * @depends initializeMock
80 | * @test getProfile
81 | */
82 | public function getProfileTest($kiteConnect): void
83 | {
84 | $response = $kiteConnect->getProfile();
85 |
86 | $this->assertObjectHasAttribute('user_id',$response);
87 | $this->assertObjectHasAttribute('user_name',$response);
88 | $this->assertObjectHasAttribute('exchanges',$response);
89 | $this->assertObjectHasAttribute('meta',$response);
90 | }
91 |
92 | /**
93 | * @depends initializeMock
94 | * @test getMargins
95 | */
96 | public function getMarginsTest($kiteConnect): void
97 | {
98 | $response = $kiteConnect->getMargins();
99 |
100 | $this->assertObjectHasAttribute('equity',$response);
101 | $this->assertObjectHasAttribute('commodity',$response);
102 | }
103 |
104 | /**
105 | * @depends initializeMock
106 | * @test getQuote
107 | */
108 | public function getQuoteTest($kiteConnect): void
109 | {
110 | $response = $kiteConnect->getQuote(['NSE:INFY', 'NSE:SBIN']);
111 |
112 | $this->assertArrayHasKey('NSE:INFY', $response);
113 | $this->assertArrayHasKey('NSE:SBIN', $response);
114 |
115 | foreach ($response as $values) {
116 | $this->assertObjectHasAttribute('instrument_token',$values);
117 | $this->assertObjectHasAttribute('ohlc',$values);
118 | $this->assertObjectHasAttribute('depth',$values);
119 | }
120 | }
121 |
122 | /**
123 | * @depends initializeMock
124 | * @test getOHLC
125 | */
126 | public function getOHLCTest($kiteConnect): void
127 | {
128 | $response = $kiteConnect->getOHLC(['NSE:INFY', 'NSE:SBIN']);
129 |
130 | $this->assertObjectHasAttribute('NSE:INFY', $response);
131 | $this->assertObjectHasAttribute('NSE:SBIN', $response);
132 |
133 | foreach ($response as $values) {
134 | $this->assertObjectHasAttribute('instrument_token',$values);
135 | $this->assertObjectHasAttribute('ohlc',$values);
136 | $this->assertObjectHasAttribute('last_price',$values);
137 | }
138 | }
139 |
140 | /**
141 | * @depends initializeMock
142 | * @test getLTP
143 | */
144 | public function getLTPTest($kiteConnect): void
145 | {
146 | $response = $kiteConnect->getLTP(['NSE:INFY', 'NSE:SBIN']);
147 |
148 | $this->assertObjectHasAttribute('NSE:INFY', $response);
149 | $this->assertObjectHasAttribute('NSE:SBIN', $response);
150 |
151 | foreach ($response as $values) {
152 | $this->assertObjectHasAttribute('instrument_token',$values);
153 | $this->assertObjectHasAttribute('last_price',$values);
154 | }
155 | }
156 |
157 | /**
158 | * @depends initializeMock
159 | * @test getHoldings
160 | */
161 | public function getHoldingsTest($kiteConnect): void
162 | {
163 | $response = $kiteConnect->getHoldings();
164 |
165 | foreach ($response as $values) {
166 | $this->assertObjectHasAttribute('tradingsymbol',$values);
167 | $this->assertObjectHasAttribute('exchange',$values);
168 | $this->assertObjectHasAttribute('pnl',$values);
169 | }
170 | }
171 |
172 | /**
173 | * @depends initializeMock
174 | * @test getPositions
175 | */
176 | public function getPositionsTest($kiteConnect): void
177 | {
178 | $response = $kiteConnect->getPositions();
179 | $this->assertObjectHasAttribute('net',$response);
180 |
181 | foreach ($response as $values) {
182 | foreach ($values as $value2){
183 | $this->assertObjectHasAttribute('tradingsymbol',$value2);
184 | $this->assertObjectHasAttribute('exchange',$value2);
185 | $this->assertObjectHasAttribute('average_price',$value2);
186 | }
187 | }
188 |
189 | }
190 |
191 | /**
192 | * @depends initializeMock
193 | * @test placeOrder
194 | */
195 | public function placeOrderTest($kiteConnect): void
196 | {
197 | $response = $kiteConnect->placeOrder("regular", [
198 | "tradingsymbol" => "INFY",
199 | "exchange" => "NSE",
200 | "quantity" => 1,
201 | "transaction_type" => "BUY",
202 | "order_type" => "MARKET",
203 | "product" => "NRML"
204 | ]);
205 |
206 | $this->assertObjectHasAttribute('order_id',$response);
207 |
208 | }
209 |
210 | /**
211 | * @depends initializeMock
212 | * @test getOrders
213 | */
214 | public function getOrdersTest($kiteConnect): void
215 | {
216 | $response = $kiteConnect->getOrders();
217 |
218 | foreach ($response as $values) {
219 | $this->assertObjectHasAttribute('order_id',$values);
220 | $this->assertObjectHasAttribute('exchange_timestamp',$values);
221 | $this->assertObjectHasAttribute('status',$values);
222 | $this->assertObjectHasAttribute('order_id',$values);
223 | }
224 |
225 | }
226 |
227 | /**
228 | * @depends initializeMock
229 | * @test getOrderHistory
230 | */
231 | public function getOrderHistoryTest($kiteConnect): void
232 | {
233 | $response = $kiteConnect->getOrderHistory('123456789');
234 |
235 | foreach ($response as $values) {
236 | $this->assertObjectHasAttribute('order_id',$values);
237 | $this->assertObjectHasAttribute('exchange_timestamp',$values);
238 | $this->assertObjectHasAttribute('status',$values);
239 | }
240 |
241 | }
242 |
243 | /**
244 | * @depends initializeMock
245 | * @test getOrderTrades
246 | */
247 | public function getOrderTradesTest($kiteConnect): void
248 | {
249 | $response = $kiteConnect->getOrderTrades('123456789');
250 |
251 | foreach ($response as $values) {
252 | $this->assertObjectHasAttribute('average_price',$values);
253 | $this->assertObjectHasAttribute('transaction_type',$values);
254 | $this->assertObjectHasAttribute('order_timestamp',$values);
255 | $this->assertObjectHasAttribute('order_id',$values);
256 | }
257 |
258 | }
259 |
260 | /**
261 | * @depends initializeMock
262 | * @test getTrades
263 | */
264 | public function getTradesTest($kiteConnect): void
265 | {
266 | $response = $kiteConnect->getTrades();
267 |
268 | foreach ($response as $values) {
269 | $this->assertObjectHasAttribute('trade_id',$values);
270 | $this->assertObjectHasAttribute('exchange_order_id',$values);
271 | $this->assertObjectHasAttribute('order_id',$values);
272 | $this->assertObjectHasAttribute('instrument_token',$values);
273 | }
274 |
275 | }
276 |
277 | /**
278 | * @depends initializeMock
279 | * @test placeGTT
280 | */
281 | public function placeGTTTest($kiteConnect): void
282 | {
283 | $response = $kiteConnect->placeGTT([
284 | "trigger_type" => $kiteConnect::GTT_TYPE_SINGLE,
285 | "tradingsymbol" => "TATAMOTORS",
286 | "exchange" => "NSE",
287 | "trigger_values" => array(310),
288 | "last_price" => 315,
289 | "orders" => array([
290 | "transaction_type" => $kiteConnect::TRANSACTION_TYPE_SELL,
291 | "quantity" => 1,
292 | "product" => $kiteConnect::PRODUCT_CNC,
293 | "order_type" => $kiteConnect::ORDER_TYPE_LIMIT,
294 | "price" => 300],
295 | [
296 | "transaction_type" => $kiteConnect::TRANSACTION_TYPE_SELL,
297 | "quantity" => 1,
298 | "product" => $kiteConnect::PRODUCT_CNC,
299 | "order_type" => $kiteConnect::ORDER_TYPE_LIMIT,
300 | "price" => 400
301 | ])]);
302 |
303 | $this->assertObjectHasAttribute('trigger_id',$response);
304 | }
305 |
306 | /**
307 | * @depends initializeMock
308 | * @test getGTTs
309 | */
310 | public function getGTTsTest($kiteConnect): void
311 | {
312 | $response = $kiteConnect->getGTTs();
313 |
314 | foreach ($response as $values) {
315 | $this->assertObjectHasAttribute('id',$values);
316 | $this->assertObjectHasAttribute('created_at',$values);
317 | $this->assertObjectHasAttribute('status',$values);
318 | $this->assertObjectHasAttribute('condition',$values);
319 | }
320 |
321 | }
322 |
323 | /**
324 | * @depends initializeMock
325 | * @test getGTT
326 | */
327 | public function getGTTTest($kiteConnect): void
328 | {
329 | $response = $kiteConnect->getGTT('123');
330 |
331 | $this->assertObjectHasAttribute('id',$response);
332 | $this->assertObjectHasAttribute('user_id',$response);
333 | $this->assertObjectHasAttribute('orders',$response);
334 | $this->assertObjectHasAttribute('condition',$response);
335 |
336 | }
337 |
338 | /**
339 | * @depends initializeMock
340 | * @test modifyGTT
341 | */
342 | public function modifyGTTTest($kiteConnect): void
343 | {
344 | $response = $kiteConnect->modifyGTT(123, [
345 | "orders" => array([
346 | "transaction_type" => $kiteConnect::TRANSACTION_TYPE_SELL,
347 | "quantity" => 1,
348 | "product" => $kiteConnect::PRODUCT_CNC,
349 | "order_type" => $kiteConnect::ORDER_TYPE_LIMIT,
350 | "price" => 300],
351 | [
352 | "transaction_type" => $kiteConnect::TRANSACTION_TYPE_SELL,
353 | "quantity" => 1,
354 | "product" => $kiteConnect::PRODUCT_CNC,
355 | "order_type" => $kiteConnect::ORDER_TYPE_LIMIT,
356 | "price" => 400
357 | ]),
358 | "tradingsymbol" => "TATAMOTORS",
359 | "exchange" => "NSE",
360 | "trigger_values" => array(310),
361 | "last_price" => 315,
362 | "trigger_type" => $kiteConnect::GTT_TYPE_SINGLE,
363 | "trigger_id" => 123]);
364 |
365 | $this->assertObjectHasAttribute('trigger_id',$response);
366 | }
367 |
368 | /**
369 | * @depends initializeMock
370 | * @test deleteGTT
371 | */
372 | public function deleteGTTTest($kiteConnect): void
373 | {
374 | $response = $kiteConnect->deleteGTT('123');
375 |
376 | $this->assertObjectHasAttribute('trigger_id',$response);
377 |
378 | }
379 |
380 | /**
381 | * @depends initializeMock
382 | * @test getHistoricalData
383 | */
384 | public function getHistoricalDataTest($kiteConnect): void
385 | {
386 | $response = $kiteConnect->getHistoricalData(15495682, 'minute', '2021-01-20', '2021-01-25');
387 |
388 | foreach ($response as $values) {
389 | $this->assertObjectHasAttribute('date',$values);
390 | $this->assertObjectHasAttribute('open',$values);
391 | $this->assertObjectHasAttribute('high',$values);
392 | $this->assertObjectHasAttribute('low',$values);
393 | $this->assertObjectHasAttribute('close',$values);
394 | $this->assertObjectHasAttribute('volume',$values);
395 | }
396 |
397 | }
398 |
399 | /**
400 | * @depends initializeMock
401 | * @test getMFOrders
402 | */
403 | public function getMFOrdersTest($kiteConnect): void
404 | {
405 | $response = $kiteConnect->getMFOrders();
406 |
407 | foreach ($response as $values) {
408 | $this->assertObjectHasAttribute('order_id',$values);
409 | $this->assertObjectHasAttribute('tradingsymbol',$values);
410 | $this->assertObjectHasAttribute('purchase_type',$values);
411 | $this->assertObjectHasAttribute('fund',$values);
412 | }
413 |
414 | }
415 |
416 | /**
417 | * @depends initializeMock
418 | * @test getMFOrders
419 | */
420 | public function getMFOrderindTest($kiteConnect): void
421 | {
422 | $response = $kiteConnect->getMFOrders('123456789');
423 |
424 | $this->assertObjectHasAttribute('order_id',$response);
425 | $this->assertObjectHasAttribute('fund',$response);
426 | $this->assertObjectHasAttribute('order_timestamp',$response);
427 | $this->assertObjectHasAttribute('amount',$response);
428 | }
429 |
430 | /**
431 | * @depends initializeMock
432 | * @test getMFSIPS
433 | */
434 | public function getMFSIPSTest($kiteConnect): void
435 | {
436 | $response = $kiteConnect->getMFSIPS();
437 |
438 | foreach ($response as $values) {
439 | $this->assertObjectHasAttribute('sip_id',$values);
440 | $this->assertObjectHasAttribute('fund',$values);
441 | $this->assertObjectHasAttribute('instalment_amount',$values);
442 | $this->assertObjectHasAttribute('dividend_type',$values);
443 | }
444 | }
445 |
446 | /**
447 | * @depends initializeMock
448 | * @test getMFSIPS
449 | */
450 | public function getMFSIPSindvTest($kiteConnect): void
451 | {
452 | $response = $kiteConnect->getMFSIPS('123456789');
453 |
454 | $this->assertObjectHasAttribute('sip_id',$response);
455 | $this->assertObjectHasAttribute('last_instalment',$response);
456 | $this->assertObjectHasAttribute('pending_instalments',$response);
457 | $this->assertObjectHasAttribute('instalment_date',$response);
458 | }
459 |
460 | /**
461 | * @depends initializeMock
462 | * @test getMFHoldings
463 | */
464 | public function getMFHoldingsTest($kiteConnect): void
465 | {
466 | $response = $kiteConnect->getMFHoldings();
467 |
468 | foreach ($response as $values) {
469 | $this->assertObjectHasAttribute('folio',$values);
470 | $this->assertObjectHasAttribute('fund',$values);
471 | $this->assertObjectHasAttribute('tradingsymbol',$values);
472 | $this->assertObjectHasAttribute('pnl',$values);
473 | }
474 | }
475 |
476 | /**
477 | * @depends initializeMock
478 | * @test getVirtualContractNote
479 | */
480 | public function getVirtualContractNoteTest($kiteConnect): void
481 | {
482 | $orderParams = [[
483 | "order_id" => "111111111",
484 | "exchange" => "NSE",
485 | "tradingsymbol" => "SBIN",
486 | "transaction_type" => $kiteConnect::TRANSACTION_TYPE_BUY,
487 | "variety" => $kiteConnect::VARIETY_REGULAR,
488 | "product" => $kiteConnect::PRODUCT_CNC,
489 | "order_type" => $kiteConnect::ORDER_TYPE_MARKET,
490 | "quantity" => 1,
491 | "average_price" => 560
492 | ],
493 | [
494 | "order_id" => "2222222222",
495 | "exchange" => "MCX",
496 | "tradingsymbol" => "GOLDPETAL23JULFUT",
497 | "transaction_type" => $kiteConnect::TRANSACTION_TYPE_SELL,
498 | "variety" => $kiteConnect::VARIETY_REGULAR,
499 | "product" => $kiteConnect::PRODUCT_NRML,
500 | "order_type" => $kiteConnect::ORDER_TYPE_LIMIT,
501 | "quantity" => 1,
502 | "average_price" => 5862
503 | ],
504 | [
505 | "order_id" => "3333333333",
506 | "exchange" => "NFO",
507 | "tradingsymbol" => "NIFTY2371317900PE",
508 | "transaction_type" => $kiteConnect::TRANSACTION_TYPE_SELL,
509 | "variety" => $kiteConnect::VARIETY_REGULAR,
510 | "product" => $kiteConnect::PRODUCT_NRML,
511 | "order_type" => $kiteConnect::ORDER_TYPE_LIMIT,
512 | "quantity" => 100,
513 | "average_price" => 1.5
514 | ]
515 | ];
516 | $response = $kiteConnect->getVirtualContractNote($orderParams);
517 |
518 | foreach ($response as $values) {
519 | $this->assertObjectHasAttribute('charges',$values);
520 | $this->assertObjectHasAttribute('transaction_type',$values);
521 | $this->assertObjectHasAttribute('tradingsymbol',$values);
522 | }
523 | }
524 |
525 | /**
526 | * @depends initializeMock
527 | * @test getInstruments
528 | */
529 | public function getInstrumentsTest($kiteConnect): void
530 | {
531 | $response = $kiteConnect->getInstruments();
532 |
533 | foreach ($response as $values) {
534 | $this->assertObjectHasAttribute('instrument_token',$values);
535 | $this->assertObjectHasAttribute('exchange_token',$values);
536 | $this->assertObjectHasAttribute('tradingsymbol',$values);
537 | $this->assertObjectHasAttribute('name',$values);
538 | }
539 | }
540 |
541 | /**
542 | * @depends initializeMock
543 | * @test getInstruments with Exchange
544 | */
545 | public function getInstrumentsExchangeTest($kiteConnect): void
546 | {
547 | $response = $kiteConnect->getInstruments('NSE');
548 |
549 | foreach ($response as $values) {
550 | $this->assertObjectHasAttribute('instrument_token',$values);
551 | $this->assertObjectHasAttribute('exchange_token',$values);
552 | $this->assertObjectHasAttribute('tradingsymbol',$values);
553 | $this->assertObjectHasAttribute('name',$values);
554 | }
555 | }
556 |
557 | /**
558 | * @depends initializeMock
559 | * @test getMFInstruments
560 | */
561 | public function getMFInstrumentsTest($kiteConnect): void
562 | {
563 | $response = $kiteConnect->getMFInstruments();
564 |
565 | foreach ($response as $values) {
566 | $this->assertObjectHasAttribute('tradingsymbol',$values);
567 | $this->assertObjectHasAttribute('amc',$values);
568 | $this->assertObjectHasAttribute('scheme_type',$values);
569 | $this->assertObjectHasAttribute('redemption_allowed',$values);
570 | }
571 | }
572 | }
573 |
--------------------------------------------------------------------------------
/tests/MockJson.php:
--------------------------------------------------------------------------------
1 | 'application/json'];
15 | $mock_files = [
16 | "profile.json",
17 | "margins.json",
18 | "quote.json",
19 | "ohlc.json",
20 | "ltp.json",
21 | "holdings.json",
22 | "positions.json",
23 | "order_response.json",
24 | "orders.json",
25 | "order_info.json",
26 | "order_trades.json",
27 | "trades.json",
28 | "gtt_place_order.json",
29 | "gtt_get_orders.json",
30 | "gtt_get_order.json",
31 | "gtt_modify_order.json",
32 | "gtt_delete_order.json",
33 | "historical_minute.json",
34 | "mf_orders.json",
35 | "mf_orders_info.json",
36 | "mf_sips.json",
37 | "mf_sip_info.json",
38 | "mf_holdings.json",
39 | "virtual_contract_note.json",
40 | ];
41 | $response_array = array();
42 | foreach ($mock_files as $values) {
43 | $response_array[] = new Response($status_code, $header_content, $this->fetchMock($values));
44 | }
45 | // add all text/csv header based content-type response
46 | $response_array[] = new Response($status_code, ['Content-Type' => 'text/csv'], $this->fetchMock("instruments_all.csv"));
47 | $response_array[] = new Response($status_code, ['Content-Type' => 'text/csv'], $this->fetchMock("instruments_nse.csv"));
48 | $response_array[] = new Response($status_code, ['Content-Type' => 'text/csv'], $this->fetchMock("mf_instruments.csv"));
49 |
50 | $mock = new MockHandler($response_array);
51 | $handlerStack = HandlerStack::create($mock);
52 |
53 | return $handlerStack;
54 | }
55 |
56 | public function fetchMock(string $route)
57 | {
58 | // root mock response file location
59 | $file_root = "./tests/mock_responses/";
60 | $fetch_mock = file_get_contents($file_root. $route);
61 | return $fetch_mock;
62 | }
63 | }
64 |
65 | ?>
--------------------------------------------------------------------------------
/tests/mock_responses/gtt_delete_order.json:
--------------------------------------------------------------------------------
1 | {"status":"success","data":{"trigger_id":123}}
--------------------------------------------------------------------------------
/tests/mock_responses/gtt_get_order.json:
--------------------------------------------------------------------------------
1 | {
2 | "status": "success",
3 | "data": {
4 | "id": 123,
5 | "user_id": "PH2965",
6 | "parent_trigger": null,
7 | "type": "two-leg",
8 | "created_at": "2019-09-09 17:13:26",
9 | "updated_at": "2019-09-09 17:13:26",
10 | "expires_at": "2020-09-09 17:13:26",
11 | "status": "active",
12 | "condition": {
13 | "exchange": "NSE",
14 | "last_price": 278,
15 | "tradingsymbol": "SBIN",
16 | "trigger_values": [
17 | 264.1,
18 | 291.9
19 | ],
20 | "instrument_token": 779521
21 | },
22 | "orders": [
23 | {
24 | "account_id": "",
25 | "parent_order_id": "",
26 | "exchange": "NSE",
27 | "tradingsymbol": "SBIN",
28 | "validity": "",
29 | "product": "CNC",
30 | "order_type": "LIMIT",
31 | "transaction_type": "SELL",
32 | "quantity": 1,
33 | "disclosed_quantity": 0,
34 | "price": 264.1,
35 | "trigger_price": 0,
36 | "ltp_atp": "",
37 | "squareoff_abs_tick": "",
38 | "stoploss_abs_tick": "",
39 | "squareoff": 0,
40 | "stoploss": 0,
41 | "trailing_stoploss": 0,
42 | "meta": "",
43 | "guid": "",
44 | "result": null
45 | },
46 | {
47 | "account_id": "",
48 | "parent_order_id": "",
49 | "exchange": "NSE",
50 | "tradingsymbol": "SBIN",
51 | "validity": "",
52 | "product": "CNC",
53 | "order_type": "LIMIT",
54 | "transaction_type": "SELL",
55 | "quantity": 1,
56 | "disclosed_quantity": 0,
57 | "price": 291.9,
58 | "trigger_price": 0,
59 | "ltp_atp": "",
60 | "squareoff_abs_tick": "",
61 | "stoploss_abs_tick": "",
62 | "squareoff": 0,
63 | "stoploss": 0,
64 | "trailing_stoploss": 0,
65 | "meta": "",
66 | "guid": "",
67 | "result": null
68 | }
69 | ],
70 | "meta": {}
71 | }
72 | }
--------------------------------------------------------------------------------
/tests/mock_responses/gtt_get_orders.json:
--------------------------------------------------------------------------------
1 | {
2 | "status": "success",
3 | "data": [
4 | {
5 | "id": 105402,
6 | "user_id": "PH2965",
7 | "parent_trigger": null,
8 | "type": "two-leg",
9 | "created_at": "2019-09-09 17:13:26",
10 | "updated_at": "2019-09-09 17:13:26",
11 | "expires_at": "2020-09-09 17:13:26",
12 | "status": "active",
13 | "condition": {
14 | "exchange": "NSE",
15 | "last_price": 278,
16 | "tradingsymbol": "SBIN",
17 | "trigger_values": [
18 | 264.1,
19 | 291.9
20 | ],
21 | "instrument_token": 779521
22 | },
23 | "orders": [
24 | {
25 | "account_id": "",
26 | "parent_order_id": "",
27 | "exchange": "NSE",
28 | "tradingsymbol": "SBIN",
29 | "validity": "",
30 | "product": "CNC",
31 | "order_type": "LIMIT",
32 | "transaction_type": "SELL",
33 | "quantity": 1,
34 | "disclosed_quantity": 0,
35 | "price": 264.1,
36 | "trigger_price": 0,
37 | "ltp_atp": "",
38 | "squareoff_abs_tick": "",
39 | "stoploss_abs_tick": "",
40 | "squareoff": 0,
41 | "stoploss": 0,
42 | "trailing_stoploss": 0,
43 | "meta": "",
44 | "guid": "",
45 | "result": null
46 | },
47 | {
48 | "account_id": "",
49 | "parent_order_id": "",
50 | "exchange": "NSE",
51 | "tradingsymbol": "SBIN",
52 | "validity": "",
53 | "product": "CNC",
54 | "order_type": "LIMIT",
55 | "transaction_type": "SELL",
56 | "quantity": 1,
57 | "disclosed_quantity": 0,
58 | "price": 291.9,
59 | "trigger_price": 0,
60 | "ltp_atp": "",
61 | "squareoff_abs_tick": "",
62 | "stoploss_abs_tick": "",
63 | "squareoff": 0,
64 | "stoploss": 0,
65 | "trailing_stoploss": 0,
66 | "meta": "",
67 | "guid": "",
68 | "result": null
69 | }
70 | ],
71 | "meta": {}
72 | },
73 | {
74 | "id": 105099,
75 | "user_id": "PH2965",
76 | "parent_trigger": null,
77 | "type": "two-leg",
78 | "created_at": "2019-09-09 15:13:22",
79 | "updated_at": "2019-09-09 15:15:08",
80 | "expires_at": "2020-01-01 12:00:00",
81 | "status": "triggered",
82 | "condition": {
83 | "exchange": "NSE",
84 | "last_price": 102.6,
85 | "tradingsymbol": "RAIN",
86 | "trigger_values": [
87 | 102,
88 | 103.7
89 | ],
90 | "instrument_token": 3926273
91 | },
92 | "orders": [
93 | {
94 | "account_id": "",
95 | "parent_order_id": "",
96 | "exchange": "NSE",
97 | "tradingsymbol": "RAIN",
98 | "validity": "",
99 | "product": "CNC",
100 | "order_type": "LIMIT",
101 | "transaction_type": "SELL",
102 | "quantity": 1,
103 | "disclosed_quantity": 0,
104 | "price": 1,
105 | "trigger_price": 0,
106 | "ltp_atp": "",
107 | "squareoff_abs_tick": "",
108 | "stoploss_abs_tick": "",
109 | "squareoff": 0,
110 | "stoploss": 0,
111 | "trailing_stoploss": 0,
112 | "meta": "",
113 | "guid": "",
114 | "result": null
115 | },
116 | {
117 | "account_id": "",
118 | "parent_order_id": "",
119 | "exchange": "NSE",
120 | "tradingsymbol": "RAIN",
121 | "validity": "",
122 | "product": "CNC",
123 | "order_type": "LIMIT",
124 | "transaction_type": "SELL",
125 | "quantity": 1,
126 | "disclosed_quantity": 0,
127 | "price": 1,
128 | "trigger_price": 0,
129 | "ltp_atp": "",
130 | "squareoff_abs_tick": "",
131 | "stoploss_abs_tick": "",
132 | "squareoff": 0,
133 | "stoploss": 0,
134 | "trailing_stoploss": 0,
135 | "meta": "",
136 | "guid": "",
137 | "result": {
138 | "account_id": "PH2965",
139 | "parent_order_id": "",
140 | "exchange": "NSE",
141 | "tradingsymbol": "RAIN",
142 | "validity": "DAY",
143 | "product": "CNC",
144 | "order_type": "LIMIT",
145 | "transaction_type": "SELL",
146 | "quantity": 1,
147 | "disclosed_quantity": 0,
148 | "price": 1,
149 | "trigger_price": 0,
150 | "ltp_atp": "LTP",
151 | "squareoff_abs_tick": "absolute",
152 | "stoploss_abs_tick": "absolute",
153 | "squareoff": 0,
154 | "stoploss": 0,
155 | "trailing_stoploss": 0,
156 | "meta": "{\"app_id\":12617,\"gtt\":105099}",
157 | "guid": "",
158 | "timestamp": "2019-09-09 15:15:08",
159 | "triggered_at": 103.7,
160 | "order_result": {
161 | "status": "failed",
162 | "order_id": "",
163 | "rejection_reason": "Your order price is lower than the current lower circuit limit of 70.65. Place an order within the daily range."
164 | }
165 | }
166 | }
167 | ],
168 | "meta": null
169 | },
170 | {
171 | "id": 17531,
172 | "user_id": "PH2965",
173 | "parent_trigger": null,
174 | "type": "two-leg",
175 | "created_at": "2019-08-01 15:32:45",
176 | "updated_at": "2019-09-04 09:26:18",
177 | "expires_at": "2020-08-01 00:00:00",
178 | "status": "triggered",
179 | "condition": {
180 | "exchange": "NSE",
181 | "last_price": 1464.6,
182 | "tradingsymbol": "ACC",
183 | "trigger_values": [
184 | 1427.9,
185 | 1684.55
186 | ]
187 | },
188 | "orders": [
189 | {
190 | "account_id": "",
191 | "parent_order_id": "",
192 | "exchange": "NSE",
193 | "tradingsymbol": "ACC",
194 | "validity": "",
195 | "product": "CNC",
196 | "order_type": "LIMIT",
197 | "transaction_type": "SELL",
198 | "quantity": 6,
199 | "disclosed_quantity": 0,
200 | "price": 1419.35,
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": {
211 | "account_id": "PH2965",
212 | "parent_order_id": "",
213 | "exchange": "NSE",
214 | "tradingsymbol": "ACC",
215 | "validity": "DAY",
216 | "product": "CNC",
217 | "order_type": "LIMIT",
218 | "transaction_type": "SELL",
219 | "quantity": 6,
220 | "disclosed_quantity": 0,
221 | "price": 1419.35,
222 | "trigger_price": 0,
223 | "ltp_atp": "LTP",
224 | "squareoff_abs_tick": "absolute",
225 | "stoploss_abs_tick": "absolute",
226 | "squareoff": 0,
227 | "stoploss": 0,
228 | "trailing_stoploss": 0,
229 | "meta": "{\"app_id\":12617,\"gtt\":17531}",
230 | "guid": "",
231 | "timestamp": "2019-09-04 09:26:18",
232 | "triggered_at": 1427.5,
233 | "order_result": {
234 | "status": "success",
235 | "order_id": "190904000274307",
236 | "rejection_reason": ""
237 | }
238 | }
239 | },
240 | {
241 | "account_id": "",
242 | "parent_order_id": "",
243 | "exchange": "NSE",
244 | "tradingsymbol": "ACC",
245 | "validity": "",
246 | "product": "CNC",
247 | "order_type": "LIMIT",
248 | "transaction_type": "SELL",
249 | "quantity": 6,
250 | "disclosed_quantity": 0,
251 | "price": 1684.8,
252 | "trigger_price": 0,
253 | "ltp_atp": "",
254 | "squareoff_abs_tick": "",
255 | "stoploss_abs_tick": "",
256 | "squareoff": 0,
257 | "stoploss": 0,
258 | "trailing_stoploss": 0,
259 | "meta": "",
260 | "guid": "",
261 | "result": null
262 | }
263 | ],
264 | "meta": {}
265 | }
266 | ]
267 | }
--------------------------------------------------------------------------------
/tests/mock_responses/gtt_modify_order.json:
--------------------------------------------------------------------------------
1 | {"status":"success","data":{"trigger_id":123}}
--------------------------------------------------------------------------------
/tests/mock_responses/gtt_place_order.json:
--------------------------------------------------------------------------------
1 | {"status":"success","data":{"trigger_id":123}}
--------------------------------------------------------------------------------
/tests/mock_responses/historical_minute.json:
--------------------------------------------------------------------------------
1 | {
2 | "status": "success",
3 | "data": {
4 | "candles": [
5 | [
6 | "2017-12-15T09:15:00+0530",
7 | 1704.5,
8 | 1705,
9 | 1699.25,
10 | 1702.8,
11 | 2499,
12 | 0
13 | ],
14 | [
15 | "2017-12-15T09:16:00+0530",
16 | 1702,
17 | 1702,
18 | 1698.15,
19 | 1698.15,
20 | 1271,
21 | 0
22 | ]
23 | ]
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/tests/mock_responses/holdings.json:
--------------------------------------------------------------------------------
1 | {
2 | "status": "success",
3 | "data": [
4 | {
5 | "tradingsymbol": "BENGALASM",
6 | "exchange": "BSE",
7 | "instrument_token": 136472324,
8 | "isin": "INE083K01017",
9 | "product": "CNC",
10 | "price": 0,
11 | "quantity": 1,
12 | "t1_quantity": 0,
13 | "realised_quantity": 1,
14 | "collateral_quantity": 0,
15 | "collateral_type": "",
16 | "average_price": 1150,
17 | "last_price": 2620,
18 | "close_price": 2751.1,
19 | "pnl": 1470,
20 | "day_change": -131.0999999999999,
21 | "day_change_percentage": -4.7653665806404675
22 | },
23 | {
24 | "tradingsymbol": "CONFIPET",
25 | "exchange": "BSE",
26 | "instrument_token": 134868228,
27 | "isin": "INE552D01024",
28 | "product": "CNC",
29 | "price": 0,
30 | "quantity": 1,
31 | "t1_quantity": 0,
32 | "realised_quantity": 1,
33 | "collateral_quantity": 0,
34 | "collateral_type": "",
35 | "average_price": 5.89,
36 | "last_price": 31.35,
37 | "close_price": 31.5,
38 | "pnl": 25.46,
39 | "day_change": -0.14999999999999858,
40 | "day_change_percentage": -0.4761904761904716
41 | },
42 | {
43 | "tradingsymbol": "IPOWER",
44 | "exchange": "BSE",
45 | "instrument_token": 131175684,
46 | "isin": "INE468F01010",
47 | "product": "CNC",
48 | "price": 0,
49 | "quantity": 1,
50 | "t1_quantity": 0,
51 | "realised_quantity": 1,
52 | "collateral_quantity": 0,
53 | "collateral_type": "",
54 | "average_price": 0,
55 | "last_price": 1.95,
56 | "close_price": 0,
57 | "pnl": 1.95,
58 | "day_change": 0,
59 | "day_change_percentage": 0
60 | },
61 | {
62 | "tradingsymbol": "JCTLTD",
63 | "exchange": "BSE",
64 | "instrument_token": 128057092,
65 | "isin": "INE945A01026",
66 | "product": "CNC",
67 | "price": 0,
68 | "quantity": 1,
69 | "t1_quantity": 0,
70 | "realised_quantity": 1,
71 | "collateral_quantity": 0,
72 | "collateral_type": "",
73 | "average_price": 6.03,
74 | "last_price": 3.5,
75 | "close_price": 3.48,
76 | "pnl": -2.5300000000000002,
77 | "day_change": 0.020000000000000018,
78 | "day_change_percentage": 0.5747126436781614
79 | },
80 | {
81 | "tradingsymbol": "SPICEJET",
82 | "exchange": "BSE",
83 | "instrument_token": 128072964,
84 | "isin": "INE285B01017",
85 | "product": "CNC",
86 | "price": 0,
87 | "quantity": 5,
88 | "t1_quantity": 0,
89 | "realised_quantity": 5,
90 | "collateral_quantity": 0,
91 | "collateral_type": "",
92 | "average_price": 61.2,
93 | "last_price": 145.65,
94 | "close_price": 146.05,
95 | "pnl": 422.25,
96 | "day_change": -0.4000000000000057,
97 | "day_change_percentage": -0.2738788086271864
98 | },
99 | {
100 | "tradingsymbol": "ADANIENT",
101 | "exchange": "NSE",
102 | "instrument_token": 6401,
103 | "isin": "INE423A01024",
104 | "product": "CNC",
105 | "price": 0,
106 | "quantity": 2,
107 | "t1_quantity": 0,
108 | "realised_quantity": 2,
109 | "collateral_quantity": 0,
110 | "collateral_type": "",
111 | "average_price": 77.375,
112 | "last_price": 165.25,
113 | "close_price": 165.95,
114 | "pnl": 175.75,
115 | "day_change": -0.6999999999999886,
116 | "day_change_percentage": -0.42181379933714286
117 | },
118 | {
119 | "tradingsymbol": "ADANIPORTS",
120 | "exchange": "NSE",
121 | "instrument_token": 3861249,
122 | "isin": "INE742F01042",
123 | "product": "CNC",
124 | "price": 0,
125 | "quantity": 2,
126 | "t1_quantity": 0,
127 | "realised_quantity": 2,
128 | "collateral_quantity": 0,
129 | "collateral_type": "",
130 | "average_price": 238.875,
131 | "last_price": 398.7,
132 | "close_price": 404.2,
133 | "pnl": 319.65,
134 | "day_change": -5.5,
135 | "day_change_percentage": -1.3607125185551707
136 | },
137 | {
138 | "tradingsymbol": "ADANIPOWER",
139 | "exchange": "NSE",
140 | "instrument_token": 4451329,
141 | "isin": "INE814H01011",
142 | "product": "CNC",
143 | "price": 0,
144 | "quantity": 2,
145 | "t1_quantity": 0,
146 | "realised_quantity": 2,
147 | "collateral_quantity": 0,
148 | "collateral_type": "",
149 | "average_price": 32,
150 | "last_price": 40.7,
151 | "close_price": 40.65,
152 | "pnl": 17.400000000000006,
153 | "day_change": 0.05000000000000426,
154 | "day_change_percentage": 0.12300123001231063
155 | },
156 | {
157 | "tradingsymbol": "APOLLOTYRE",
158 | "exchange": "NSE",
159 | "instrument_token": 41729,
160 | "isin": "INE438A01022",
161 | "product": "CNC",
162 | "price": 0,
163 | "quantity": 4,
164 | "t1_quantity": 0,
165 | "realised_quantity": 4,
166 | "collateral_quantity": 0,
167 | "collateral_type": "",
168 | "average_price": 206.9,
169 | "last_price": 268.8,
170 | "close_price": 268.85,
171 | "pnl": 247.60000000000002,
172 | "day_change": -0.05000000000001137,
173 | "day_change_percentage": -0.018597731076812854
174 | },
175 | {
176 | "tradingsymbol": "ASHOKLEY",
177 | "exchange": "NSE",
178 | "instrument_token": 54273,
179 | "isin": "INE208A01029",
180 | "product": "CNC",
181 | "price": 0,
182 | "quantity": 3,
183 | "t1_quantity": 0,
184 | "realised_quantity": 3,
185 | "collateral_quantity": 0,
186 | "collateral_type": "",
187 | "average_price": 103.08333333333299,
188 | "last_price": 117.7,
189 | "close_price": 118.6,
190 | "pnl": 43.850000000001046,
191 | "day_change": -0.8999999999999915,
192 | "day_change_percentage": -0.7588532883642424
193 | },
194 | {
195 | "tradingsymbol": "AXISBANK",
196 | "exchange": "NSE",
197 | "instrument_token": 1510401,
198 | "isin": "INE238A01034",
199 | "product": "CNC",
200 | "price": 0,
201 | "quantity": 11,
202 | "t1_quantity": 0,
203 | "realised_quantity": 11,
204 | "collateral_quantity": 0,
205 | "collateral_type": "",
206 | "average_price": 460.227272727273,
207 | "last_price": 546.85,
208 | "close_price": 554.6,
209 | "pnl": 952.8499999999975,
210 | "day_change": -7.75,
211 | "day_change_percentage": -1.3974035340786153
212 | },
213 | {
214 | "tradingsymbol": "CIPLA",
215 | "exchange": "NSE",
216 | "instrument_token": 177665,
217 | "isin": "INE059A01026",
218 | "product": "CNC",
219 | "price": 0,
220 | "quantity": 1,
221 | "t1_quantity": 0,
222 | "realised_quantity": 1,
223 | "collateral_quantity": 0,
224 | "collateral_type": "",
225 | "average_price": 546.6,
226 | "last_price": 606.05,
227 | "close_price": 612.65,
228 | "pnl": 59.44999999999993,
229 | "day_change": -6.600000000000023,
230 | "day_change_percentage": -1.0772871949726637
231 | },
232 | {
233 | "tradingsymbol": "DBCORP",
234 | "exchange": "NSE",
235 | "instrument_token": 4577537,
236 | "isin": "INE950I01011",
237 | "product": "CNC",
238 | "price": 0,
239 | "quantity": 2,
240 | "t1_quantity": 0,
241 | "realised_quantity": 2,
242 | "collateral_quantity": 0,
243 | "collateral_type": "",
244 | "average_price": 351,
245 | "last_price": 353.7,
246 | "close_price": 346.7,
247 | "pnl": 5.399999999999977,
248 | "day_change": 7,
249 | "day_change_percentage": 2.0190366310931642
250 | },
251 | {
252 | "tradingsymbol": "DHANBANK",
253 | "exchange": "NSE",
254 | "instrument_token": 2907905,
255 | "isin": "INE680A01011",
256 | "product": "CNC",
257 | "price": 0,
258 | "quantity": 1,
259 | "t1_quantity": 0,
260 | "realised_quantity": 1,
261 | "collateral_quantity": 0,
262 | "collateral_type": "",
263 | "average_price": 24.7,
264 | "last_price": 29.95,
265 | "close_price": 29.8,
266 | "pnl": 5.25,
267 | "day_change": 0.14999999999999858,
268 | "day_change_percentage": 0.5033557046979817
269 | },
270 | {
271 | "tradingsymbol": "DMART",
272 | "exchange": "NSE",
273 | "instrument_token": 5097729,
274 | "isin": "INE192R01011",
275 | "product": "CNC",
276 | "price": 0,
277 | "quantity": 2,
278 | "t1_quantity": 0,
279 | "realised_quantity": 2,
280 | "collateral_quantity": 0,
281 | "collateral_type": "",
282 | "average_price": 889.95,
283 | "last_price": 1148.35,
284 | "close_price": 1146.35,
285 | "pnl": 516.7999999999997,
286 | "day_change": 2,
287 | "day_change_percentage": 0.17446678588563705
288 | },
289 | {
290 | "tradingsymbol": "DQE-BE",
291 | "exchange": "NSE",
292 | "instrument_token": 6211329,
293 | "isin": "INE656K01010",
294 | "product": "CNC",
295 | "price": 0,
296 | "quantity": 1,
297 | "t1_quantity": 0,
298 | "realised_quantity": 1,
299 | "collateral_quantity": 0,
300 | "collateral_type": "",
301 | "average_price": 35.7,
302 | "last_price": 18.45,
303 | "close_price": 18.45,
304 | "pnl": -17.250000000000004,
305 | "day_change": 0,
306 | "day_change_percentage": 0
307 | },
308 | {
309 | "tradingsymbol": "FINCABLES",
310 | "exchange": "NSE",
311 | "instrument_token": 265729,
312 | "isin": "INE235A01022",
313 | "product": "CNC",
314 | "price": 0,
315 | "quantity": 2,
316 | "t1_quantity": 0,
317 | "realised_quantity": 2,
318 | "collateral_quantity": 0,
319 | "collateral_type": "",
320 | "average_price": 411.55,
321 | "last_price": 699.45,
322 | "close_price": 706.25,
323 | "pnl": 575.8000000000001,
324 | "day_change": -6.7999999999999545,
325 | "day_change_percentage": -0.9628318584070731
326 | },
327 | {
328 | "tradingsymbol": "FSL",
329 | "exchange": "NSE",
330 | "instrument_token": 3661825,
331 | "isin": "INE684F01012",
332 | "product": "CNC",
333 | "price": 0,
334 | "quantity": 17,
335 | "t1_quantity": 0,
336 | "realised_quantity": 17,
337 | "collateral_quantity": 0,
338 | "collateral_type": "",
339 | "average_price": 36.8,
340 | "last_price": 40.5,
341 | "close_price": 40.15,
342 | "pnl": 62.90000000000005,
343 | "day_change": 0.3500000000000014,
344 | "day_change_percentage": 0.8717310087173136
345 | },
346 | {
347 | "tradingsymbol": "GABRIEL",
348 | "exchange": "NSE",
349 | "instrument_token": 277761,
350 | "isin": "INE524A01029",
351 | "product": "CNC",
352 | "price": 0,
353 | "quantity": 6,
354 | "t1_quantity": 0,
355 | "realised_quantity": 6,
356 | "collateral_quantity": 0,
357 | "collateral_type": "",
358 | "average_price": 107.55,
359 | "last_price": 196.15,
360 | "close_price": 195.25,
361 | "pnl": 531.6,
362 | "day_change": 0.9000000000000057,
363 | "day_change_percentage": 0.46094750320102723
364 | },
365 | {
366 | "tradingsymbol": "GAIL",
367 | "exchange": "NSE",
368 | "instrument_token": 1207553,
369 | "isin": "INE129A01019",
370 | "product": "CNC",
371 | "price": 0,
372 | "quantity": 1,
373 | "t1_quantity": 0,
374 | "realised_quantity": 1,
375 | "collateral_quantity": 0,
376 | "collateral_type": "",
377 | "average_price": 454.7,
378 | "last_price": 511.2,
379 | "close_price": 508.1,
380 | "pnl": 56.5,
381 | "day_change": 3.099999999999966,
382 | "day_change_percentage": 0.6101161188742307
383 | },
384 | {
385 | "tradingsymbol": "GVKPIL-BE",
386 | "exchange": "NSE",
387 | "instrument_token": 3386625,
388 | "isin": "INE251H01024",
389 | "product": "CNC",
390 | "price": 0,
391 | "quantity": 20,
392 | "t1_quantity": 0,
393 | "realised_quantity": 20,
394 | "collateral_quantity": 0,
395 | "collateral_type": "",
396 | "average_price": 5.75,
397 | "last_price": 18.15,
398 | "close_price": 18.1,
399 | "pnl": 247.99999999999997,
400 | "day_change": 0.04999999999999716,
401 | "day_change_percentage": 0.27624309392263624
402 | },
403 | {
404 | "tradingsymbol": "HDFCBANK",
405 | "exchange": "NSE",
406 | "instrument_token": 341249,
407 | "isin": "INE040A01026",
408 | "product": "CNC",
409 | "price": 0,
410 | "quantity": 2,
411 | "t1_quantity": 0,
412 | "realised_quantity": 2,
413 | "collateral_quantity": 0,
414 | "collateral_type": "",
415 | "average_price": 1234.5,
416 | "last_price": 1878.05,
417 | "close_price": 1856.75,
418 | "pnl": 1287.1,
419 | "day_change": 21.299999999999955,
420 | "day_change_percentage": 1.14716574660024
421 | },
422 | {
423 | "tradingsymbol": "HMVL",
424 | "exchange": "NSE",
425 | "instrument_token": 4918017,
426 | "isin": "INE871K01015",
427 | "product": "CNC",
428 | "price": 0,
429 | "quantity": 2,
430 | "t1_quantity": 0,
431 | "realised_quantity": 2,
432 | "collateral_quantity": 0,
433 | "collateral_type": "",
434 | "average_price": 271.9,
435 | "last_price": 250.55,
436 | "close_price": 248.35,
437 | "pnl": -42.69999999999993,
438 | "day_change": 2.200000000000017,
439 | "day_change_percentage": 0.8858465874773574
440 | },
441 | {
442 | "tradingsymbol": "ICICIBANK",
443 | "exchange": "NSE",
444 | "instrument_token": 1270529,
445 | "isin": "INE090A01021",
446 | "product": "CNC",
447 | "price": 0,
448 | "quantity": 1,
449 | "t1_quantity": 0,
450 | "realised_quantity": 1,
451 | "collateral_quantity": 0,
452 | "collateral_type": "",
453 | "average_price": 309.7,
454 | "last_price": 315.3,
455 | "close_price": 312.8,
456 | "pnl": 5.600000000000023,
457 | "day_change": 2.5,
458 | "day_change_percentage": 0.7992327365728901
459 | },
460 | {
461 | "tradingsymbol": "ICIL",
462 | "exchange": "NSE",
463 | "instrument_token": 3068673,
464 | "isin": "INE483B01026",
465 | "product": "CNC",
466 | "price": 0,
467 | "quantity": 4,
468 | "t1_quantity": 0,
469 | "realised_quantity": 4,
470 | "collateral_quantity": 0,
471 | "collateral_type": "",
472 | "average_price": 157.5,
473 | "last_price": 125.7,
474 | "close_price": 120.25,
475 | "pnl": -127.19999999999999,
476 | "day_change": 5.450000000000003,
477 | "day_change_percentage": 4.532224532224535
478 | },
479 | {
480 | "tradingsymbol": "IDBI",
481 | "exchange": "NSE",
482 | "instrument_token": 377857,
483 | "isin": "INE008A01015",
484 | "product": "CNC",
485 | "price": 0,
486 | "quantity": 3,
487 | "t1_quantity": 0,
488 | "realised_quantity": 3,
489 | "collateral_quantity": 0,
490 | "collateral_type": "",
491 | "average_price": 59.79999999999999,
492 | "last_price": 60.35,
493 | "close_price": 60.05,
494 | "pnl": 1.650000000000034,
495 | "day_change": 0.30000000000000426,
496 | "day_change_percentage": 0.4995836802664517
497 | },
498 | {
499 | "tradingsymbol": "INFY",
500 | "exchange": "NSE",
501 | "instrument_token": 408065,
502 | "isin": "INE009A01021",
503 | "product": "CNC",
504 | "price": 0,
505 | "quantity": 1,
506 | "t1_quantity": 0,
507 | "realised_quantity": 1,
508 | "collateral_quantity": 0,
509 | "collateral_type": "",
510 | "average_price": 967.95,
511 | "last_price": 1033.25,
512 | "close_price": 1034.25,
513 | "pnl": 65.29999999999995,
514 | "day_change": -1,
515 | "day_change_percentage": -0.09668842156151801
516 | },
517 | {
518 | "tradingsymbol": "ITC",
519 | "exchange": "NSE",
520 | "instrument_token": 424961,
521 | "isin": "INE154A01025",
522 | "product": "CNC",
523 | "price": 0,
524 | "quantity": 1,
525 | "t1_quantity": 0,
526 | "realised_quantity": 1,
527 | "collateral_quantity": 0,
528 | "collateral_type": "",
529 | "average_price": 274.5,
530 | "last_price": 261.85,
531 | "close_price": 262.15,
532 | "pnl": -12.649999999999977,
533 | "day_change": -0.2999999999999545,
534 | "day_change_percentage": -0.11443829868394223
535 | },
536 | {
537 | "tradingsymbol": "JKIL",
538 | "exchange": "NSE",
539 | "instrument_token": 3908097,
540 | "isin": "INE576I01022",
541 | "product": "CNC",
542 | "price": 0,
543 | "quantity": 3,
544 | "t1_quantity": 0,
545 | "realised_quantity": 3,
546 | "collateral_quantity": 0,
547 | "collateral_type": "",
548 | "average_price": 216.1,
549 | "last_price": 301.75,
550 | "close_price": 308.2,
551 | "pnl": 256.95000000000005,
552 | "day_change": -6.449999999999989,
553 | "day_change_percentage": -2.0927968851395162
554 | },
555 | {
556 | "tradingsymbol": "JPASSOCIAT",
557 | "exchange": "NSE",
558 | "instrument_token": 2933761,
559 | "isin": "INE455F01025",
560 | "product": "CNC",
561 | "price": 0,
562 | "quantity": 11,
563 | "t1_quantity": 0,
564 | "realised_quantity": 11,
565 | "collateral_quantity": 0,
566 | "collateral_type": "",
567 | "average_price": 8.00909090909091,
568 | "last_price": 23.2,
569 | "close_price": 21.35,
570 | "pnl": 167.1,
571 | "day_change": 1.8499999999999979,
572 | "day_change_percentage": 8.665105386416851
573 | },
574 | {
575 | "tradingsymbol": "KRIDHANINF",
576 | "exchange": "NSE",
577 | "instrument_token": 2938881,
578 | "isin": "INE524L01026",
579 | "product": "CNC",
580 | "price": 0,
581 | "quantity": 1,
582 | "t1_quantity": 0,
583 | "realised_quantity": 1,
584 | "collateral_quantity": 0,
585 | "collateral_type": "",
586 | "average_price": 91.75,
587 | "last_price": 121.2,
588 | "close_price": 122.25,
589 | "pnl": 29.450000000000003,
590 | "day_change": -1.0499999999999972,
591 | "day_change_percentage": -0.85889570552147
592 | },
593 | {
594 | "tradingsymbol": "KSL",
595 | "exchange": "NSE",
596 | "instrument_token": 4835585,
597 | "isin": "INE907A01026",
598 | "product": "CNC",
599 | "price": 0,
600 | "quantity": 2,
601 | "t1_quantity": 0,
602 | "realised_quantity": 2,
603 | "collateral_quantity": 0,
604 | "collateral_type": "",
605 | "average_price": 289.75,
606 | "last_price": 408.4,
607 | "close_price": 398.5,
608 | "pnl": 237.29999999999995,
609 | "day_change": 9.899999999999977,
610 | "day_change_percentage": 2.484316185696356
611 | },
612 | {
613 | "tradingsymbol": "KTKBANK",
614 | "exchange": "NSE",
615 | "instrument_token": 2061825,
616 | "isin": "INE614B01018",
617 | "product": "CNC",
618 | "price": 0,
619 | "quantity": 1,
620 | "t1_quantity": 0,
621 | "realised_quantity": 1,
622 | "collateral_quantity": 0,
623 | "collateral_type": "",
624 | "average_price": 122.05,
625 | "last_price": 149.4,
626 | "close_price": 151.9,
627 | "pnl": 27.35000000000001,
628 | "day_change": -2.5,
629 | "day_change_percentage": -1.6458196181698483
630 | },
631 | {
632 | "tradingsymbol": "L&TFH",
633 | "exchange": "NSE",
634 | "instrument_token": 6386689,
635 | "isin": "INE498L01015",
636 | "product": "CNC",
637 | "price": 0,
638 | "quantity": 2,
639 | "t1_quantity": 0,
640 | "realised_quantity": 2,
641 | "collateral_quantity": 0,
642 | "collateral_type": "",
643 | "average_price": 85.075,
644 | "last_price": 173.45,
645 | "close_price": 176.75,
646 | "pnl": 176.74999999999997,
647 | "day_change": -3.3000000000000114,
648 | "day_change_percentage": -1.8670438472418733
649 | },
650 | {
651 | "tradingsymbol": "NFL",
652 | "exchange": "NSE",
653 | "instrument_token": 3564801,
654 | "isin": "INE870D01012",
655 | "product": "CNC",
656 | "price": 0,
657 | "quantity": 1,
658 | "t1_quantity": 0,
659 | "realised_quantity": 1,
660 | "collateral_quantity": 0,
661 | "collateral_type": "",
662 | "average_price": 0,
663 | "last_price": 69.25,
664 | "close_price": 68.25,
665 | "pnl": 69.25,
666 | "day_change": 1,
667 | "day_change_percentage": 1.465201465201465
668 | },
669 | {
670 | "tradingsymbol": "PNB",
671 | "exchange": "NSE",
672 | "instrument_token": 2730497,
673 | "isin": "INE160A01022",
674 | "product": "CNC",
675 | "price": 0,
676 | "quantity": 2,
677 | "t1_quantity": 0,
678 | "realised_quantity": 2,
679 | "collateral_quantity": 0,
680 | "collateral_type": "",
681 | "average_price": 112.3,
682 | "last_price": 170.8,
683 | "close_price": 174.1,
684 | "pnl": 117.00000000000003,
685 | "day_change": -3.299999999999983,
686 | "day_change_percentage": -1.8954623779437008
687 | },
688 | {
689 | "tradingsymbol": "PTC",
690 | "exchange": "NSE",
691 | "instrument_token": 2906881,
692 | "isin": "INE877F01012",
693 | "product": "CNC",
694 | "price": 0,
695 | "quantity": 2,
696 | "t1_quantity": 0,
697 | "realised_quantity": 2,
698 | "collateral_quantity": 0,
699 | "collateral_type": "",
700 | "average_price": 75.125,
701 | "last_price": 115.55,
702 | "close_price": 116.55,
703 | "pnl": 80.85,
704 | "day_change": -1,
705 | "day_change_percentage": -0.8580008580008579
706 | },
707 | {
708 | "tradingsymbol": "QUICKHEAL",
709 | "exchange": "NSE",
710 | "instrument_token": 3357697,
711 | "isin": "INE306L01010",
712 | "product": "CNC",
713 | "price": 0,
714 | "quantity": 1,
715 | "t1_quantity": 0,
716 | "realised_quantity": 1,
717 | "collateral_quantity": 0,
718 | "collateral_type": "",
719 | "average_price": 245,
720 | "last_price": 318.15,
721 | "close_price": 313.2,
722 | "pnl": 73.14999999999998,
723 | "day_change": 4.949999999999989,
724 | "day_change_percentage": 1.5804597701149388
725 | },
726 | {
727 | "tradingsymbol": "RAJRAYON-BE",
728 | "exchange": "NSE",
729 | "instrument_token": 3577601,
730 | "isin": "INE533D01024",
731 | "product": "CNC",
732 | "price": 0,
733 | "quantity": 1,
734 | "t1_quantity": 0,
735 | "realised_quantity": 1,
736 | "collateral_quantity": 0,
737 | "collateral_type": "",
738 | "average_price": 0.2,
739 | "last_price": 0.35,
740 | "close_price": 0.35,
741 | "pnl": 0.14999999999999997,
742 | "day_change": 0,
743 | "day_change_percentage": 0
744 | },
745 | {
746 | "tradingsymbol": "RELIANCE",
747 | "exchange": "NSE",
748 | "instrument_token": 738561,
749 | "isin": "INE002A01018",
750 | "product": "CNC",
751 | "price": 0,
752 | "quantity": 160,
753 | "t1_quantity": 0,
754 | "realised_quantity": 160,
755 | "collateral_quantity": 0,
756 | "collateral_type": "",
757 | "average_price": 513.513924050633,
758 | "last_price": 924.2,
759 | "close_price": 923.75,
760 | "pnl": 65709.77215189872,
761 | "day_change": 0.4500000000000455,
762 | "day_change_percentage": 0.04871447902571534
763 | },
764 | {
765 | "tradingsymbol": "SAIL",
766 | "exchange": "NSE",
767 | "instrument_token": 758529,
768 | "isin": "INE114A01011",
769 | "product": "CNC",
770 | "price": 0,
771 | "quantity": 1,
772 | "t1_quantity": 0,
773 | "realised_quantity": 1,
774 | "collateral_quantity": 0,
775 | "collateral_type": "",
776 | "average_price": 61,
777 | "last_price": 92.75,
778 | "close_price": 91.1,
779 | "pnl": 31.75,
780 | "day_change": 1.6500000000000057,
781 | "day_change_percentage": 1.8111964873765156
782 | },
783 | {
784 | "tradingsymbol": "SBIN",
785 | "exchange": "NSE",
786 | "instrument_token": 779521,
787 | "isin": "INE062A01020",
788 | "product": "CNC",
789 | "price": 0,
790 | "quantity": 50,
791 | "t1_quantity": 0,
792 | "realised_quantity": 50,
793 | "collateral_quantity": 0,
794 | "collateral_type": "",
795 | "average_price": 263.824,
796 | "last_price": 308.4,
797 | "close_price": 314.85,
798 | "pnl": 2228.7999999999984,
799 | "day_change": -6.4500000000000455,
800 | "day_change_percentage": -2.0485945688423204
801 | },
802 | {
803 | "tradingsymbol": "SKMEGGPROD",
804 | "exchange": "NSE",
805 | "instrument_token": 1211393,
806 | "isin": "INE411D01015",
807 | "product": "CNC",
808 | "price": 0,
809 | "quantity": 1,
810 | "t1_quantity": 0,
811 | "realised_quantity": 1,
812 | "collateral_quantity": 0,
813 | "collateral_type": "",
814 | "average_price": 181.4,
815 | "last_price": 96.95,
816 | "close_price": 97.15,
817 | "pnl": -84.45,
818 | "day_change": -0.20000000000000284,
819 | "day_change_percentage": -0.20586721564591132
820 | }
821 | ]
822 | }
823 |
--------------------------------------------------------------------------------
/tests/mock_responses/instruments_all.csv:
--------------------------------------------------------------------------------
1 | instrument_token,exchange_token,tradingsymbol,name,last_price,expiry,strike,tick_size,lot_size,instrument_type,segment,exchange
2 | 3813889,14898,CENTRALBK-BE,CENTRAL BANK OF INDIA,0.0,,0.0,0.05,1,EQ,NSE,NSE
3 | 4645121,18145,EMMBI-BL,EMMBI INDUSTRIES,0.0,,0.0,0.05,1,EQ,NSE,NSE
4 | 4531969,17703,MIDCAPIWIN-BL,ICICI PRU MIDCAP IWIN ETF,0.0,,0.0,0.01,1,EQ,NSE,NSE
5 | 5533953,21617,ABCAPITAL-BL,ADITYA BIRLA CAPITAL,0.0,,0.0,0.05,1,EQ,NSE,NSE
6 | 3861249,15083,ADANIPORTS,ADANI PORT & SEZ,0.0,,0.0,0.05,1,EQ,NSE,NSE
7 | 4419329,17263,ARMANFIN,ARMAN FIN SERV,0.0,,0.0,0.05,1,EQ,NSE,NSE
8 | 12073986,47164,BANKNIFTY18JAN23500CE,,2528.4,2018-01-25,23500.0,0.05,40,CE,NFO-OPT,NFO
9 | 13693186,53489,ADANIPORTS17DEC490PE,,80.65,2017-12-28,490.0,0.05,2500,PE,NFO-OPT,NFO
10 | 136483588,533139,FFTF16BGR,FORTIS FIXED TERM FUND - SERIE,0.0,,0.0,0.01,1,EQ,BSE,BSE
11 | 3713281,14505,BALAMINES-BE,BALAJI AMINES,0.0,,0.0,0.05,1,EQ,NSE,NSE
12 | 1373441,5365,BATAINDIA-BE,BATA INDIA DEP RS,0.0,,0.0,0.05,1,EQ,NSE,NSE
13 | 5421569,21178,CDSL-BE,CENTRAL DEPO SER (I),0.0,,0.0,0.05,1,EQ,NSE,NSE
14 | 5421313,21177,CDSL-BL,CENTRAL DEPO SER (I),0.0,,0.0,0.05,1,EQ,NSE,NSE
15 | 1374209,5368,CHENNPETRO-BE,CHENNAI PETRO CORP DE,0.0,,0.0,0.05,1,EQ,NSE,NSE
16 | 3419393,13357,GANGOTRI,GANGOTRI TEXTILES,0.0,,0.0,0.05,1,EQ,NSE,NSE
17 | 2703361,10560,NAVKARCORP-BL,NAVKAR CORPORATION,0.0,,0.0,0.05,1,EQ,NSE,NSE
18 | 5001473,19537,PDPL,PARENTERAL DRUGS,0.0,,0.0,0.05,1,EQ,NSE,NSE
19 | 12074242,47165,BANKNIFTY18JAN23500PE,,35.15,2018-01-25,23500.0,0.05,40,PE,NFO-OPT,NFO
20 | 12074498,47166,BANKNIFTY18JAN23600CE,,2435.55,2018-01-25,23600.0,0.05,40,CE,NFO-OPT,NFO
21 | 5420545,21174,CDSL,CENTRAL DEPO SER (I),0.0,,0.0,0.05,1,EQ,NSE,NSE
22 | 3370497,13166,CELEBRITY-BL,CELEBRITY FASHIONS,0.0,,0.0,0.05,1,EQ,NSE,NSE
23 | 12074754,47167,BANKNIFTY18JAN23600PE,,41.25,2018-01-25,23600.0,0.05,40,PE,NFO-OPT,NFO
24 | 3146497,12291,CENTEXT-BL,CENTURY EXTRUSIONS,0.0,,0.0,0.05,1,EQ,NSE,NSE
25 | 4550145,17774,GROBTEA-BE,THE GROB TEA COMPANY,0.0,,0.0,0.05,1,EQ,NSE,NSE
26 | 21227266,82919,INDIACEM17DEC220PE,,43.45,2017-12-28,220.0,0.05,3500,PE,NFO-OPT,NFO
27 | 6938881,27105,CHROMATIC-BE,CHROMATIC INDIA,0.0,,0.0,0.05,1,EQ,NSE,NSE
28 | 4578305,17884,DBCORP-BL,D.B.CORP,0.0,,0.0,0.05,1,EQ,NSE,NSE
29 | 3155457,12326,DCW-BL,DCW,0.0,,0.0,0.05,1,EQ,NSE,NSE
30 | 5101569,19928,HUDCO-N8,7.64% TAX FREETRI SR2B,0.0,,0.0,0.01,1,EQ,NSE,NSE
31 | 1707521,6670,INFARINDIA,INFAR (INDIA),0.0,,0.0,0.05,1,EQ,NSE,NSE
32 | 21227522,82920,INDIACEM17DEC225CE,,0.4,2017-12-28,225.0,0.05,3500,CE,NFO-OPT,NFO
33 | 21228290,82923,INDIACEM17DEC230PE,,53.1,2017-12-28,230.0,0.05,3500,PE,NFO-OPT,NFO
34 | 136484868,533144,COX&KINGS,COX & KINGS,0.0,,0.0,0.05,1,EQ,BSE,BSE
35 | 12072962,47160,BANKNIFTY18JAN23400CE,,2622.0,2018-01-25,23400.0,0.05,40,CE,NFO-OPT,NFO
36 | 12073474,47162,BANKNIFTY18JAN23400PE,,29.85,2018-01-25,23400.0,0.05,40,PE,NFO-OPT,NFO
37 | 12075010,47168,BANKNIFTY18JAN23700CE,,2343.55,2018-01-25,23700.0,0.05,40,CE,NFO-OPT,NFO
38 | 21227778,82921,INDIACEM17DEC225PE,,48.25,2017-12-28,225.0,0.05,3500,PE,NFO-OPT,NFO
39 | 21228034,82922,INDIACEM17DEC230CE,,0.25,2017-12-28,230.0,0.05,3500,CE,NFO-OPT,NFO
40 | 112655620,440061,828GOI27-ML,828GOI2027,0.0,,0.0,0.25,500000,EQ,BSE,BSE
41 | 136441604,532975,AISHWARYA,AISHWARYA TELECOM,0.0,,0.0,0.01,1,EQ,BSE,BSE
42 | 136483076,533137,DEN,DEN NETWORKS,0.0,,0.0,0.05,1,EQ,BSE,BSE
43 | 136483332,533138,ASTEC,ASTEC LIFESCIENCES,0.0,,0.0,0.05,1,EQ,BSE,BSE
44 | 136485380,533146,DLINKINDIA,D-LINK (INDIA),0.0,,0.0,0.05,1,EQ,BSE,BSE
45 | 1219329,4763,BANKBARODA-BE,BOB - DEPO SETT,0.0,,0.0,0.05,1,EQ,NSE,NSE
46 | 2928385,11439,BANKBEES,RELIANCE ETF BANK BEES,0.0,,0.0,0.01,1,EQ,NSE,NSE
47 | 3715841,14515,BANSWRAS-BE,BANSWARA SYNTEX,0.0,,0.0,0.05,1,EQ,NSE,NSE
48 | 3137281,12255,BERGEPAINT-BL,BERGER PAINTS (I),0.0,,0.0,0.05,1,EQ,NSE,NSE
49 | 3901185,15239,BIRLAMONEY,ADITYA BIRLA MONEY,0.0,,0.0,0.05,1,EQ,NSE,NSE
50 | 1789185,6989,CARRIERAIR-BE,CARRIER AIRCON DEPO,0.0,,0.0,0.05,1,EQ,NSE,NSE
51 | 3123713,12202,CASTEXTECH-BL,CASTEX TECHNOLOGIES,0.0,,0.0,0.05,1,EQ,NSE,NSE
52 | 136485892,533148,JSWENERGY,JSW ENERGY,0.0,,0.0,0.05,1,EQ,BSE,BSE
53 | 136486916,533152,MBLINFRA,MBL INFRASTRUCTURES,0.0,,0.0,0.05,1,EQ,BSE,BSE
54 | 136487172,533153,FDCLTDBBPH,FDC*,0.0,,0.0,0.05,1,EQ,BSE,BSE
55 | 138027524,539170,AXISHB23DD,AXIS MUTUAL FUND,0.0,,0.0,0.01,1,EQ,BSE,BSE
56 | 244332292,954423,RCL14JUL16B,RCL-NIFTY-14-1-19-PVT,0.0,,0.0,0.01,10,EQ,BSE,BSE
57 | 244352260,954501,8HDFCL18,HDFCL-8%-15-1-18-PVT,0.0,,0.0,0.01,1,EQ,BSE,BSE
58 | 244834820,956386,945SREI24,SREI-9.45%-26-5-24-PVT,0.0,,0.0,0.01,1,EQ,BSE,BSE
59 | 5534209,21618,ABCAPITAL-BE,ADITYA BIRLA CAPITAL,0.0,,0.0,0.05,1,EQ,NSE,NSE
60 | 3412225,13329,ERAINFRA-BL,ERA INFRA ENGINEERING,0.0,,0.0,0.05,1,EQ,NSE,NSE
61 | 1884161,7360,SETFNN50-BL,SBI-ETF NIFTY NEXT 50,0.0,,0.0,0.01,1,EQ,NSE,NSE
62 | 3028225,11829,SSWL,STEEL STRIPS WHEELS,0.0,,0.0,0.05,1,EQ,NSE,NSE
63 | 12075266,47169,BANKNIFTY18JAN23700PE,,48.15,2018-01-25,23700.0,0.05,40,PE,NFO-OPT,NFO
64 | 12525058,48926,BANKNIFTY17DEC22500PE,,8.0,2017-12-28,22500.0,0.05,40,PE,NFO-OPT,NFO
65 | 13842434,54072,BANKNIFTY17NOV23600PE,,3.0,2017-11-30,23600.0,0.05,40,PE,NFO-OPT,NFO
66 | 6128129,23938,ESSARPORTS-BE,ESSAR PORTS,0.0,,0.0,0.05,1,EQ,NSE,NSE
67 | 21231874,82937,INDIANB17DEC160PE,,0.05,2017-12-28,160.0,0.05,2000,PE,NFO-OPT,NFO
68 | 136492036,533172,IVZINGOLD,INVESCO INDIA GOLD EXCHANGE TR,0.0,,0.0,0.01,1,EQ,BSE,BSE
69 | 21232386,82939,INDIANB17DEC170PE,,0.05,2017-12-28,170.0,0.05,2000,PE,NFO-OPT,NFO
70 | 13845506,54084,BANKNIFTY17NOV23900PE,,2.25,2017-11-30,23900.0,0.05,40,PE,NFO-OPT,NFO
71 | 136504580,533221,AHLWEST,ASIAN HOTELS (WEST),0.0,,0.0,0.05,1,EQ,BSE,BSE
72 | 4671233,18247,DEEPIND-BL,DEEP INDUSTRIES,0.0,,0.0,0.05,1,EQ,NSE,NSE
73 | 6562305,25634,ESSARSHPNG,ESSAR SHIPPING,0.0,,0.0,0.05,1,EQ,NSE,NSE
74 | 136518404,533275,GAL,GYSCOAL ALLOYS,0.0,,0.0,0.01,1,EQ,BSE,BSE
75 | 3604481,14080,GODREJIND-BE,GODREJ INDUSTRIES,0.0,,0.0,0.05,1,EQ,NSE,NSE
76 | 4527361,17685,GPTINFRA,GPT INFRAPROJECTS,0.0,,0.0,0.05,1,EQ,NSE,NSE
77 | 13845762,54085,BANKNIFTY17NOV24000CE,,1776.2,2017-11-30,24000.0,0.05,40,CE,NFO-OPT,NFO
78 | 211713,827,DEEPAKFERT,DEEPAK FERTILIZERS & PETR,0.0,,0.0,0.05,1,EQ,NSE,NSE
79 | 1256193,4907,ENGINERSIN,ENGINEERS INDIA,0.0,,0.0,0.05,1,EQ,NSE,NSE
80 | 3449089,13473,GTNTEX,GTN TEXTILES,0.0,,0.0,0.05,1,EQ,NSE,NSE
81 | 5003009,19543,HDFCMFGETF,HDFC GOLD ETF,0.0,,0.0,0.05,1,EQ,NSE,NSE
82 | 2166273,8462,DUNCANSIND-BE,DUNCANS INDUSTRIES,0.0,,0.0,0.05,1,EQ,NSE,NSE
83 | 21230850,82933,INDIANB17DEC140PE,,0.05,2017-12-28,140.0,0.05,2000,PE,NFO-OPT,NFO
84 | 21231106,82934,INDIANB17DEC150CE,,262.45,2017-12-28,150.0,0.05,2000,CE,NFO-OPT,NFO
85 | 21231362,82935,INDIANB17DEC150PE,,0.05,2017-12-28,150.0,0.05,2000,PE,NFO-OPT,NFO
86 | 136518660,533276,BSLIMITED,BS,0.0,,0.0,0.01,1,EQ,BSE,BSE
87 | 3798529,14838,DECCANCE,DECCAN CEMENTS,0.0,,0.0,0.05,1,EQ,NSE,NSE
88 | 212481,830,DEEPAKNITR,DEEPAK NITRITE,0.0,,0.0,0.05,1,EQ,NSE,NSE
89 | 3542273,13837,DONEAR-BL,DONEAR IND.,0.0,,0.0,0.05,1,EQ,NSE,NSE
90 | 3862529,15088,EDL,EMPEE DISTI.,0.0,,0.0,0.05,1,EQ,NSE,NSE
91 | 2389505,9334,RAVALSUGAR-BE,RAVALGAONSUGAR FARM,0.0,,0.0,0.05,1,EQ,NSE,NSE
92 | 21231618,82936,INDIANB17DEC160CE,,252.5,2017-12-28,160.0,0.05,2000,CE,NFO-OPT,NFO
93 | 21232130,82938,INDIANB17DEC170CE,,242.55,2017-12-28,170.0,0.05,2000,CE,NFO-OPT,NFO
94 | 112653060,440051,830GOI42-ML,830GOI2042,0.0,,0.0,0.25,500000,EQ,BSE,BSE
95 | 7697153,30067,DUNCANSLTD-BE,DUNCANS INDUSTRIES,0.0,,0.0,0.05,1,EQ,NSE,NSE
96 | 4818433,18822,ENDURANCE,ENDURANCE TECHNO.,0.0,,0.0,0.05,1,EQ,NSE,NSE
97 | 2683649,10483,ENTEGRA,ENTEGRA,0.0,,0.0,0.05,1,EQ,NSE,NSE
98 | 3411713,13327,ERAINFRA,ERA INFRA ENGINEERING,0.0,,0.0,0.05,1,EQ,NSE,NSE
99 | 6563329,25638,ESSARSHPNG-BE,ESSAR SHIPPING,0.0,,0.0,0.05,1,EQ,NSE,NSE
100 | 4352001,17000,GISOLUTION-BE,GI ENGINEERING SOLNS,0.0,,0.0,0.05,1,EQ,NSE,NSE
101 |
--------------------------------------------------------------------------------
/tests/mock_responses/instruments_nse.csv:
--------------------------------------------------------------------------------
1 | instrument_token,exchange_token,tradingsymbol,name,last_price,expiry,strike,tick_size,lot_size,instrument_type,segment,exchange
2 | 3813889,14898,CENTRALBK-BE,CENTRAL BANK OF INDIA,0.0,,0.0,0.05,1,EQ,NSE,NSE
3 | 4645121,18145,EMMBI-BL,EMMBI INDUSTRIES,0.0,,0.0,0.05,1,EQ,NSE,NSE
4 | 4531969,17703,MIDCAPIWIN-BL,ICICI PRU MIDCAP IWIN ETF,0.0,,0.0,0.01,1,EQ,NSE,NSE
5 | 5533953,21617,ABCAPITAL-BL,ADITYA BIRLA CAPITAL,0.0,,0.0,0.05,1,EQ,NSE,NSE
6 | 3861249,15083,ADANIPORTS,ADANI PORT & SEZ,0.0,,0.0,0.05,1,EQ,NSE,NSE
7 | 4419329,17263,ARMANFIN,ARMAN FIN SERV,0.0,,0.0,0.05,1,EQ,NSE,NSE
8 | 3713281,14505,BALAMINES-BE,BALAJI AMINES,0.0,,0.0,0.05,1,EQ,NSE,NSE
9 | 1373441,5365,BATAINDIA-BE,BATA INDIA DEP RS,0.0,,0.0,0.05,1,EQ,NSE,NSE
10 | 5421569,21178,CDSL-BE,CENTRAL DEPO SER (I),0.0,,0.0,0.05,1,EQ,NSE,NSE
11 | 5421313,21177,CDSL-BL,CENTRAL DEPO SER (I),0.0,,0.0,0.05,1,EQ,NSE,NSE
12 | 1374209,5368,CHENNPETRO-BE,CHENNAI PETRO CORP DE,0.0,,0.0,0.05,1,EQ,NSE,NSE
13 | 3419393,13357,GANGOTRI,GANGOTRI TEXTILES,0.0,,0.0,0.05,1,EQ,NSE,NSE
14 | 2703361,10560,NAVKARCORP-BL,NAVKAR CORPORATION,0.0,,0.0,0.05,1,EQ,NSE,NSE
15 | 5001473,19537,PDPL,PARENTERAL DRUGS,0.0,,0.0,0.05,1,EQ,NSE,NSE
16 | 5420545,21174,CDSL,CENTRAL DEPO SER (I),0.0,,0.0,0.05,1,EQ,NSE,NSE
17 | 3370497,13166,CELEBRITY-BL,CELEBRITY FASHIONS,0.0,,0.0,0.05,1,EQ,NSE,NSE
18 | 3146497,12291,CENTEXT-BL,CENTURY EXTRUSIONS,0.0,,0.0,0.05,1,EQ,NSE,NSE
19 | 4550145,17774,GROBTEA-BE,THE GROB TEA COMPANY,0.0,,0.0,0.05,1,EQ,NSE,NSE
20 | 6938881,27105,CHROMATIC-BE,CHROMATIC INDIA,0.0,,0.0,0.05,1,EQ,NSE,NSE
21 | 4578305,17884,DBCORP-BL,D.B.CORP,0.0,,0.0,0.05,1,EQ,NSE,NSE
22 | 3155457,12326,DCW-BL,DCW,0.0,,0.0,0.05,1,EQ,NSE,NSE
23 | 5101569,19928,HUDCO-N8,7.64% TAX FREETRI SR2B,0.0,,0.0,0.01,1,EQ,NSE,NSE
24 | 1707521,6670,INFARINDIA,INFAR (INDIA),0.0,,0.0,0.05,1,EQ,NSE,NSE
25 | 1219329,4763,BANKBARODA-BE,BOB - DEPO SETT,0.0,,0.0,0.05,1,EQ,NSE,NSE
26 | 2928385,11439,BANKBEES,RELIANCE ETF BANK BEES,0.0,,0.0,0.01,1,EQ,NSE,NSE
27 | 3715841,14515,BANSWRAS-BE,BANSWARA SYNTEX,0.0,,0.0,0.05,1,EQ,NSE,NSE
28 | 3137281,12255,BERGEPAINT-BL,BERGER PAINTS (I),0.0,,0.0,0.05,1,EQ,NSE,NSE
29 | 3901185,15239,BIRLAMONEY,ADITYA BIRLA MONEY,0.0,,0.0,0.05,1,EQ,NSE,NSE
30 | 1789185,6989,CARRIERAIR-BE,CARRIER AIRCON DEPO,0.0,,0.0,0.05,1,EQ,NSE,NSE
31 | 3123713,12202,CASTEXTECH-BL,CASTEX TECHNOLOGIES,0.0,,0.0,0.05,1,EQ,NSE,NSE
32 | 5534209,21618,ABCAPITAL-BE,ADITYA BIRLA CAPITAL,0.0,,0.0,0.05,1,EQ,NSE,NSE
33 | 3412225,13329,ERAINFRA-BL,ERA INFRA ENGINEERING,0.0,,0.0,0.05,1,EQ,NSE,NSE
34 | 1884161,7360,SETFNN50-BL,SBI-ETF NIFTY NEXT 50,0.0,,0.0,0.01,1,EQ,NSE,NSE
35 | 3028225,11829,SSWL,STEEL STRIPS WHEELS,0.0,,0.0,0.05,1,EQ,NSE,NSE
36 | 6128129,23938,ESSARPORTS-BE,ESSAR PORTS,0.0,,0.0,0.05,1,EQ,NSE,NSE
37 | 4671233,18247,DEEPIND-BL,DEEP INDUSTRIES,0.0,,0.0,0.05,1,EQ,NSE,NSE
38 | 6562305,25634,ESSARSHPNG,ESSAR SHIPPING,0.0,,0.0,0.05,1,EQ,NSE,NSE
39 | 3604481,14080,GODREJIND-BE,GODREJ INDUSTRIES,0.0,,0.0,0.05,1,EQ,NSE,NSE
40 | 4527361,17685,GPTINFRA,GPT INFRAPROJECTS,0.0,,0.0,0.05,1,EQ,NSE,NSE
41 | 211713,827,DEEPAKFERT,DEEPAK FERTILIZERS & PETR,0.0,,0.0,0.05,1,EQ,NSE,NSE
42 | 1256193,4907,ENGINERSIN,ENGINEERS INDIA,0.0,,0.0,0.05,1,EQ,NSE,NSE
43 | 3449089,13473,GTNTEX,GTN TEXTILES,0.0,,0.0,0.05,1,EQ,NSE,NSE
44 | 5003009,19543,HDFCMFGETF,HDFC GOLD ETF,0.0,,0.0,0.05,1,EQ,NSE,NSE
45 | 2166273,8462,DUNCANSIND-BE,DUNCANS INDUSTRIES,0.0,,0.0,0.05,1,EQ,NSE,NSE
46 | 3798529,14838,DECCANCE,DECCAN CEMENTS,0.0,,0.0,0.05,1,EQ,NSE,NSE
47 | 212481,830,DEEPAKNITR,DEEPAK NITRITE,0.0,,0.0,0.05,1,EQ,NSE,NSE
48 | 3542273,13837,DONEAR-BL,DONEAR IND.,0.0,,0.0,0.05,1,EQ,NSE,NSE
49 | 3862529,15088,EDL,EMPEE DISTI.,0.0,,0.0,0.05,1,EQ,NSE,NSE
50 | 2389505,9334,RAVALSUGAR-BE,RAVALGAONSUGAR FARM,0.0,,0.0,0.05,1,EQ,NSE,NSE
51 | 7697153,30067,DUNCANSLTD-BE,DUNCANS INDUSTRIES,0.0,,0.0,0.05,1,EQ,NSE,NSE
52 | 4818433,18822,ENDURANCE,ENDURANCE TECHNO.,0.0,,0.0,0.05,1,EQ,NSE,NSE
53 | 2683649,10483,ENTEGRA,ENTEGRA,0.0,,0.0,0.05,1,EQ,NSE,NSE
54 | 3411713,13327,ERAINFRA,ERA INFRA ENGINEERING,0.0,,0.0,0.05,1,EQ,NSE,NSE
55 | 6563329,25638,ESSARSHPNG-BE,ESSAR SHIPPING,0.0,,0.0,0.05,1,EQ,NSE,NSE
56 | 4352001,17000,GISOLUTION-BE,GI ENGINEERING SOLNS,0.0,,0.0,0.05,1,EQ,NSE,NSE
57 | 1934849,7558,GONTERPEIP-BE,GONTERMANN PEIPERS DEPO,0.0,,0.0,0.05,1,EQ,NSE,NSE
58 | 2185985,8539,GTNIND-BE,GTN INDUSTRIES,0.0,,0.0,0.05,1,EQ,NSE,NSE
59 | 3179009,12418,GUFICBIO-BL,GUFIC BIOSCIENCES,0.0,,0.0,0.05,1,EQ,NSE,NSE
60 | 4915969,19203,SGBNOV24-GB,2.50% GOLDBONDS2024 TR-VI,0.0,,0.0,0.01,1,EQ,NSE,NSE
61 | 5401857,21101,STARCEMENT-BE,STAR CEMENT,0.0,,0.0,0.05,1,EQ,NSE,NSE
62 | 5533185,21614,ABCAPITAL,ADITYA BIRLA CAPITAL,0.0,,0.0,0.05,1,EQ,NSE,NSE
63 | 3372545,13174,BALKRISIND-BL,BALKRISHNA IND.,0.0,,0.0,0.05,1,EQ,NSE,NSE
64 | 2160129,8438,DATAPROINF-BE,DATAPROINFO - ROLL SETT,0.0,,0.0,0.05,1,EQ,NSE,NSE
65 | 7590401,29650,HUDCO-N7,BOND 7.19% PA TAX FREE S2,0.0,,0.0,0.01,1,EQ,NSE,NSE
66 | 3914497,15291,HERCULES-BL,HERCULES HOI.,0.0,,0.0,0.05,1,EQ,NSE,NSE
67 | 4365313,17052,HARITASEAT,HARITA SEATING SYS.,0.0,,0.0,0.05,1,EQ,NSE,NSE
68 | 3183361,12435,HERITGFOOD-BL,HERITAGE FOODS,0.0,,0.0,0.05,1,EQ,NSE,NSE
69 | 1806849,7058,HESTERBIO-BL,HESTER BIOSCIENCES,0.0,,0.0,0.05,1,EQ,NSE,NSE
70 | 4895233,19122,HIGHGROUND-BE,HIGH GROUND ENTP,0.0,,0.0,0.05,1,EQ,NSE,NSE
71 | 3508225,13704,HINDZINC-BL,HINDUSTAN ZINC,0.0,,0.0,0.05,1,EQ,NSE,NSE
72 | 1804289,7048,HESTERBIO,HESTER BIOSCIENCES,0.0,,0.0,0.05,1,EQ,NSE,NSE
73 | 4894977,19121,HIGHGROUND-BL,HIGH GROUND ENTP,0.0,,0.0,0.05,1,EQ,NSE,NSE
74 | 3188225,12454,HIL-BL,HIL,0.0,,0.0,0.05,1,EQ,NSE,NSE
75 | 3745537,14631,HILTON-BE,HILTON METAL FORGING,0.0,,0.0,0.05,1,EQ,NSE,NSE
76 | 4593409,17943,HINDCOPPER-BE,HINDUSTAN COPPER,0.0,,0.0,0.05,1,EQ,NSE,NSE
77 | 4364801,17050,HINDNATGLS-BE,HIND NATL GLASS & IND,0.0,,0.0,0.05,1,EQ,NSE,NSE
78 | 4767233,18622,IBULHSGFIN-N7,SEC RED NCD SR. IV,0.0,,0.0,0.01,1,EQ,NSE,NSE
79 | 7589889,29648,HUDCO-N6,BOND 7.03% PA TAX FREE S1,0.0,,0.0,0.01,1,EQ,NSE,NSE
80 | 5110273,19962,HUDCO-NA,8.14% TAX FREETRI SR1A,0.0,,0.0,0.01,1,EQ,NSE,NSE
81 | 3790593,14807,HDIL-BE,HOUSING DEV & INFRA,0.0,,0.0,0.05,1,EQ,NSE,NSE
82 | 3914753,15292,HERCULES-BE,HERCULES HOI.,0.0,,0.0,0.05,1,EQ,NSE,NSE
83 | 4774913,18652,ICICIPRULI,ICICI PRU LIFE INS CO,0.0,,0.0,0.05,1,EQ,NSE,NSE
84 | 3607041,14090,IGPL-BE,I G PETROCHEMICALS,0.0,,0.0,0.05,1,EQ,NSE,NSE
85 | 3606017,14086,IGPL,I G PETROCHEMICALS,0.0,,0.0,0.05,1,EQ,NSE,NSE
86 | 3718401,14525,ICRA-BL,ICRA,0.0,,0.0,0.05,1,EQ,NSE,NSE
87 | 3489793,13632,ICSA,ICSA (INDIA),0.0,,0.0,0.05,1,EQ,NSE,NSE
88 | 3189761,12460,IDBI-BL,IDBI BANK,0.0,,0.0,0.05,1,EQ,NSE,NSE
89 | 2795521,10920,IDFCBANK-NE,BOND 0% 2022 TR-3 SR-II,0.0,,0.0,0.01,1,EQ,NSE,NSE
90 | 2883073,11262,IGL,INDRAPRASTHA GAS,0.0,,0.0,0.05,1,EQ,NSE,NSE
91 | 5357825,20929,JALAN-SM,JALAN TRANSOLU. INDIA,0.0,,0.0,0.05,1,EQ,NSE,NSE
92 | 1388801,5425,JBFIND-BE,JBF INDUS -DEP-LS ML,0.0,,0.0,0.05,1,EQ,NSE,NSE
93 | 3083265,12044,JCHAC-BL,JOHNSON CONTROLS HITACHI,0.0,,0.0,0.05,1,EQ,NSE,NSE
94 | 3857153,15067,JCTEL-BL,JCT ELE.,0.0,,0.0,0.05,1,EQ,NSE,NSE
95 | 2997505,11709,JETAIRWAYS,JET AIRWAYS (INDIA),0.0,,0.0,0.05,1,EQ,NSE,NSE
96 | 3513089,13723,JHS-BE,JHS SVEND. LAB.,0.0,,0.0,0.05,1,EQ,NSE,NSE
97 | 3006209,11743,JINDALPHOT,JINDAL PHOTO,0.0,,0.0,0.05,1,EQ,NSE,NSE
98 | 4400641,17190,SHRIPISTON-BE,SHRIRAM PIST. & RING,0.0,,0.0,0.05,1,EQ,NSE,NSE
99 | 2122497,8291,SHRIYAMSEC-BE,SHRIYAM SEC & FIN,0.0,,0.0,0.05,1,EQ,NSE,NSE
100 | 510209,1993,IRFC-ND,BOND 8.44% PA TF TII-SIB,0.0,,0.0,0.01,1,EQ,NSE,NSE
101 |
--------------------------------------------------------------------------------
/tests/mock_responses/ltp.json:
--------------------------------------------------------------------------------
1 | {
2 | "status": "success",
3 | "data": {
4 | "NSE:INFY": {
5 | "instrument_token": 408065,
6 | "last_price": 1074.35
7 | },
8 | "NSE:SBIN": {
9 | "instrument_token": 408065,
10 | "last_price": 1074.35
11 | }
12 |
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/tests/mock_responses/margins.json:
--------------------------------------------------------------------------------
1 | {
2 | "status": "success",
3 | "data": {
4 | "equity": {
5 | "enabled": true,
6 | "net": 15481.524,
7 | "available": {
8 | "adhoc_margin": 0,
9 | "cash": 9929.024,
10 | "collateral": 5554.5,
11 | "intraday_payin": 0
12 | },
13 | "utilised": {
14 | "debits": 2,
15 | "exposure": 0,
16 | "m2m_realised": -2,
17 | "m2m_unrealised": 0,
18 | "option_premium": 0,
19 | "payout": 0,
20 | "span": 0,
21 | "holding_sales": 0,
22 | "turnover": 0
23 | }
24 | },
25 | "commodity": {
26 | "enabled": true,
27 | "net": 29675.93,
28 | "available": {
29 | "adhoc_margin": 0,
30 | "cash": 29249.93,
31 | "collateral": 0,
32 | "intraday_payin": 0
33 | },
34 | "utilised": {
35 | "debits": -426,
36 | "exposure": 0,
37 | "m2m_realised": 426,
38 | "m2m_unrealised": 0,
39 | "option_premium": 0,
40 | "payout": 0,
41 | "span": 0,
42 | "holding_sales": 0,
43 | "turnover": 0
44 | }
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/tests/mock_responses/mf_holdings.json:
--------------------------------------------------------------------------------
1 | {
2 | "status": "success",
3 | "data": [
4 | {
5 | "folio": "385080203",
6 | "fund": "DSP BlackRock Money Manager Fund",
7 | "tradingsymbol": "INF740K01QQ3",
8 | "average_price": 2146.131,
9 | "last_price": 2277.0708,
10 | "pnl": 61.018,
11 | "quantity": 0.466
12 | },
13 | {
14 | "folio": "1052046771",
15 | "fund": "HDFC TaxSaver - Regular Plan",
16 | "tradingsymbol": "INF179K01BB8",
17 | "average_price": 345.849,
18 | "last_price": 559.081,
19 | "pnl": 61963.074,
20 | "quantity": 290.59
21 | },
22 | {
23 | "folio": "91022348426",
24 | "fund": "Axis Long Term Equity Fund",
25 | "tradingsymbol": "INF846K01131",
26 | "average_price": 28.779,
27 | "last_price": 41.3876,
28 | "pnl": 44467.717,
29 | "quantity": 3526.834
30 | },
31 | {
32 | "folio": "488155267386",
33 | "fund": "Reliance Money Manager Fund",
34 | "tradingsymbol": "INF204K01EY0",
35 | "average_price": 1002.948,
36 | "last_price": 1007.5645,
37 | "pnl": 2.304,
38 | "quantity": 0.499
39 | }
40 | ]
41 | }
42 |
--------------------------------------------------------------------------------
/tests/mock_responses/mf_instruments.csv:
--------------------------------------------------------------------------------
1 | tradingsymbol,amc,name,purchase_allowed,redemption_allowed,minimum_purchase_amount,purchase_amount_multiplier,minimum_additional_purchase_amount,minimum_redemption_quantity,redemption_quantity_multiplier,dividend_type,scheme_type,plan,settlement_type,last_price,last_price_date
2 | INF209K01157,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Advantage Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,equity,regular,T3,106.8,2017-11-23
3 | INF209K01165,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Advantage Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,equity,regular,T3,436.72,2017-11-23
4 | INF209K01VG0,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Advantage Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,equity,direct,T3,134.2,2017-11-23
5 | INF209K01VH8,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Advantage Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,equity,direct,T3,453.46,2017-11-23
6 | INF209K01BS7,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Balanced 95 Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,equity,regular,T3,153.26,2017-11-23
7 | INF209K01BT5,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Balanced 95 Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,equity,regular,T3,758.0,2017-11-23
8 | INF209K01ZC0,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Balanced 95 Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,equity,direct,T3,796.56,2017-11-23
9 | INF209KA1LH3,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Balanced 95 Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,equity,direct,T3,219.49,2017-11-23
10 | INF084M01AB8,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Balanced Advantage Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,balanced,regular,T3,50.46,2017-11-23
11 | INF084M01AC6,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Balanced Advantage Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,balanced,regular,T3,22.07,2017-11-23
12 | INF084M01DJ5,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Balanced Advantage Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,balanced,direct,T3,52.43,2017-11-23
13 | INF084M01DK3,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Balanced Advantage Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,balanced,direct,T3,23.0,2017-11-23
14 | INF209K010W9,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Banking And Financial Services Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,equity,regular,T3,19.62,2017-11-23
15 | INF209K011W7,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Banking And Financial Services Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,equity,regular,T3,27.94,2017-11-23
16 | INF209K013W3,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Banking And Financial Services Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,equity,direct,T3,24.55,2017-11-23
17 | INF209K014W1,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Banking And Financial Services Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,equity,direct,T3,28.99,2017-11-23
18 | INF209K01BE7,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Banking and PSU Debt Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,debt,regular,T1,9.9875,2017-11-23
19 | INF209K01BF4,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Banking and PSU Debt Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,debt,regular,T1,49.8034,2017-11-23
20 | INF209K01YJ8,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Banking and PSU Debt Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,debt,direct,T1,12.7089,2017-11-23
21 | INF209K01YK6,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Banking and PSU Debt Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,debt,direct,T1,10.4884,2017-11-23
22 | INF209K01YL4,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Banking and PSU Debt Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,debt,direct,T1,51.1321,2017-11-23
23 | INF209K01LQ0,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Cash Manager,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,debt,regular,T1,408.9951,2017-11-23
24 | INF209K01XU7,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Cash Manager - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,debt,direct,T1,425.8148,2017-11-23
25 | INF209K01RU9,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Cash Plus,1,1,5000.0,1.0,1000.0,0.001,0.001,growth,liquid,regular,T1,271.5949,2017-11-23
26 | INF209K01VA3,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Cash Plus - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,liquid,direct,T1,272.5712,2017-11-23
27 | INF209K01VD7,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Cash Plus - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,liquid,direct,T1,147.9867,2017-11-23
28 | INF209K01199,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Commodity Equities Fund - Global Agri Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,equity,regular,T6,16.4009,2017-11-23
29 | INF209K01207,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Commodity Equities Fund - Global Agri Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,equity,regular,T6,23.1229,2017-11-23
30 | INF209K01AH2,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Constant Maturity 10 Year Gilt Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,debt,regular,T1,50.6235,2017-11-23
31 | INF209K01AI0,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Constant Maturity 10 Year Gilt Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,debt,regular,T1,12.0695,2017-11-23
32 | INF209K01XS1,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Constant Maturity 10 Year Gilt Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,debt,direct,T1,50.998,2017-11-23
33 | INF209KA1K47,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Corporate Bond Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,debt,regular,T1,12.6521,2017-11-23
34 | INF209KA1K54,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Corporate Bond Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,debt,regular,T1,11.4171,2017-11-23
35 | INF209KA1K88,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Corporate Bond Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,debt,direct,T1,12.9524,2017-11-23
36 | INF209KA1K96,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Corporate Bond Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,debt,direct,T1,11.708,2017-11-23
37 | INF209K01397,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Dividend Yield Plus,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,equity,regular,T3,17.25,2017-11-23
38 | INF209K01405,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Dividend Yield Plus,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,equity,regular,T3,178.4,2017-11-23
39 | INF209K01Q55,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Dividend Yield Plus - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,equity,direct,T3,26.66,2017-11-23
40 | INF209K01WA1,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Dividend Yield Plus - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,equity,direct,T3,185.33,2017-11-23
41 | INF209K01793,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Dynamic Bond Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,debt,regular,T1,30.0556,2017-11-23
42 | INF209K01801,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Dynamic Bond Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,debt,regular,T1,10.9249,2017-11-23
43 | INF209K01819,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Dynamic Bond Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,debt,regular,T1,10.1744,2017-11-23
44 | INF209KA1TV7,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Dynamic Bond Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,equity,regular,T1,12.1802,2017-11-23
45 | INF209K01N82,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Dynamic Bond Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,debt,direct,T1,30.8721,2017-11-23
46 | INF209K01R62,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Dynamic Bond Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,debt,direct,T1,11.1149,2017-11-23
47 | INF209K01R88,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Dynamic Bond Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,debt,direct,T1,10.4108,2017-11-23
48 | INF209KA1TX3,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Dynamic Bond Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,debt,direct,T1,12.4196,2017-11-23
49 | INF209K01256,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Enhanced Arbitrage Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,equity,regular,T3,10.8783,2017-11-23
50 | INF209K01264,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Enhanced Arbitrage Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,equity,regular,T3,17.5067,2017-11-23
51 | INF209K01P80,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Enhanced Arbitrage Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,equity,direct,T3,11.0934,2017-11-23
52 | INF209K01VP1,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Enhanced Arbitrage Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,equity,direct,T3,17.9567,2017-11-23
53 | INF209K01AJ8,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Equity Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,equity,regular,T3,710.7,2017-11-23
54 | INF209K01AQ3,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Equity Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,equity,regular,T3,104.58,2017-11-23
55 | INF209K01XX1,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Equity Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,equity,direct,T3,742.17,2017-11-23
56 | INF209KA1TS3,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Equity Savings Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,equity,regular,T3,13.1,2017-11-23
57 | INF209KA1TT1,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Equity Savings Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,equity,regular,T3,11.64,2017-11-23
58 | INF209KA1TP9,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Equity Savings Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,equity,direct,T3,13.54,2017-11-23
59 | INF209KA1TQ7,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Equity Savings Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,equity,direct,T3,12.27,2017-11-23
60 | INF084M01101,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Financial Planning FoF Aggressive Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,fof,regular,T4,21.9919,2017-11-23
61 | INF084M01119,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Financial Planning FoF Aggressive Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,fof,regular,T4,20.13,2017-11-23
62 | INF084M01044,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Financial Planning FoF Conservative Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,fof,regular,T4,17.3032,2017-11-23
63 | INF084M01051,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Financial Planning FoF Conservative Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,fof,regular,T4,15.744,2017-11-23
64 | INF084M01077,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Financial Planning FoF Prudent Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,fof,regular,T4,19.0899,2017-11-23
65 | INF084M01085,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Financial Planning FoF Prudent Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,fof,regular,T4,17.1217,2017-11-23
66 | INF209K01MG9,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Floating Rate Fund - Long Term Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,debt,regular,T1,208.1037,2017-11-23
67 | INF209K01UX7,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Floating Rate Fund - Long Term Plan - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,debt,direct,T1,210.3858,2017-11-23
68 | INF209K01RV7,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Floating Rate Fund - Short Term Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,liquid,regular,T1,225.569,2017-11-23
69 | INF209K01UU3,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Floating Rate Fund - Short Term Plan - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,liquid,direct,T1,226.363,2017-11-23
70 | INF209K01BO6,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Frontline Equity Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,equity,regular,T3,27.34,2017-11-23
71 | INF209K01BR9,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Frontline Equity Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,equity,regular,T3,217.34,2017-11-23
72 | INF209K01YX9,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Frontline Equity Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,equity,direct,T3,50.73,2017-11-23
73 | INF209K01YY7,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Frontline Equity Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,equity,direct,T3,227.39,2017-11-23
74 | INF209K01AC3,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Gilt Plus - PF Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,debt,regular,T1,48.6101,2017-11-23
75 | INF209K01AD1,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Gilt Plus - PF Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,debt,regular,T1,48.6101,2017-11-23
76 | INF209K01AF6,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Gilt Plus - PF Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,debt,regular,T1,10.1758,2017-11-23
77 | INF209K01XP7,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Gilt Plus - PF Plan - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,debt,direct,T1,49.8019,2017-11-23
78 | INF209K01XQ5,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Gilt Plus - PF Plan - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,debt,direct,T1,49.8019,2017-11-23
79 | INF209KA1LC4,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Gilt Plus - PF Plan - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,debt,direct,T1,10.3855,2017-11-23
80 | INF209K01PF4,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Gold Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,fof,regular,T3,9.5415,2017-11-23
81 | INF209K01PG2,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Gold Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,fof,regular,T3,9.5402,2017-11-23
82 | INF209K01YT7,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Gold Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,fof,direct,T3,9.6571,2017-11-23
83 | INF209K01YU5,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Gold Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,fof,direct,T3,9.6609,2017-11-23
84 | INF209K01R13,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Income Plus - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,debt,direct,T1,13.3298,2017-11-23
85 | INF209K01WY1,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Income Plus - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,debt,direct,T1,78.7456,2017-11-23
86 | INF209KA1WL2,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Income Plus - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,debt,direct,T1,11.621,2017-11-23
87 | INF209K01579,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Income Plus - Regular Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,debt,regular,T1,76.0586,2017-11-23
88 | INF209K01587,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Income Plus - Regular Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,debt,regular,T1,12.7941,2017-11-23
89 | INF209K01LA4,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Index Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,equity,regular,T3,13.3014,2017-11-23
90 | INF209K01LB2,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Index Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,equity,regular,T3,101.4926,2017-11-23
91 | INF209K01VX5,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Index Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,equity,direct,T3,13.4709,2017-11-23
92 | INF209K01VY3,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life Index Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,equity,direct,T3,101.6988,2017-11-23
93 | INF209K01439,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life India GenNext Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,equity,regular,T3,25.71,2017-11-23
94 | INF209K01447,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life India GenNext Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,equity,regular,T3,78.3,2017-11-23
95 | INF209K01Q63,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life India GenNext Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,equity,direct,T3,29.23,2017-11-23
96 | INF209K01WC7,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life India GenNext Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,equity,direct,T3,82.08,2017-11-23
97 | INF209K01280,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life India Opportunities Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,equity,regular,T3,30.52,2017-11-23
98 | INF209K01298,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life India Opportunities Fund,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,equity,regular,T3,146.95,2017-11-23
99 | INF209K01P98,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life India Opportunities Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,payout,equity,direct,T3,42.01,2017-11-23
100 | INF209K01VR7,BirlaSunLifeMutualFund_MF,Aditya Birla Sun Life India Opportunities Fund - Direct Plan,1,1,1000.0,1.0,1000.0,0.001,0.001,growth,equity,direct,T3,151.59,2017-11-23
101 |
--------------------------------------------------------------------------------
/tests/mock_responses/mf_orders.json:
--------------------------------------------------------------------------------
1 | {
2 | "status": "success",
3 | "data": [
4 | {
5 | "order_id": "867688079445476",
6 | "exchange_order_id": "",
7 | "tradingsymbol": "INF174K01LS2",
8 | "status": "CANCELLED",
9 | "status_message": "",
10 | "folio": "",
11 | "fund": "Kotak Select Focus Fund - Direct Plan",
12 | "order_timestamp": "2017-12-28 11:44",
13 | "exchange_timestamp": "",
14 | "settlement_id": "",
15 | "transaction_type": "BUY",
16 | "variety": "regular",
17 | "purchase_type": "FRESH",
18 | "quantity": 0,
19 | "amount": 5000,
20 | "last_price": 35.135,
21 | "average_price": 0,
22 | "placed_by": "DA0017",
23 | "tag": ""
24 | },
25 | {
26 | "order_id": "396109826218232",
27 | "exchange_order_id": "",
28 | "tradingsymbol": "INF174K01LS2",
29 | "status": "CANCELLED",
30 | "status_message": "",
31 | "folio": "",
32 | "fund": "Kotak Select Focus Fund - Direct Plan",
33 | "order_timestamp": "2017-12-28 11:40",
34 | "exchange_timestamp": "",
35 | "settlement_id": "",
36 | "transaction_type": "BUY",
37 | "variety": "regular",
38 | "purchase_type": "FRESH",
39 | "quantity": 0,
40 | "amount": 5000,
41 | "last_price": 35.135,
42 | "average_price": 0,
43 | "placed_by": "DA0017",
44 | "tag": ""
45 | }
46 | ]
47 | }
48 |
--------------------------------------------------------------------------------
/tests/mock_responses/mf_orders_info.json:
--------------------------------------------------------------------------------
1 | {
2 | "status": "success",
3 | "data": {
4 | "order_id": "460687158435713",
5 | "exchange_order_id": "",
6 | "tradingsymbol": "INF174K01LS2",
7 | "status": "CANCELLED",
8 | "status_message": "",
9 | "folio": "",
10 | "fund": "Kotak Select Focus Fund - Direct Plan",
11 | "order_timestamp": "2017-12-29 11:44",
12 | "exchange_timestamp": "",
13 | "settlement_id": "",
14 | "transaction_type": "BUY",
15 | "variety": "regular",
16 | "purchase_type": "FRESH",
17 | "quantity": 0,
18 | "amount": 5000,
19 | "last_price": 35.135,
20 | "average_price": 0,
21 | "placed_by": "DA0017",
22 | "tag": ""
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/tests/mock_responses/mf_sip_info.json:
--------------------------------------------------------------------------------
1 | {
2 | "status": "success",
3 | "data": {
4 | "sip_id": "1234",
5 | "tradingsymbol": "INF090I01239",
6 | "fund": "Franklin India Prima Plus",
7 | "dividend_type": "growth",
8 | "transaction_type": "BUY",
9 | "status": "ACTIVE",
10 | "created": "2016-01-01 13:00:00",
11 | "frequency": "monthly",
12 | "instalment_amount": 1000,
13 | "instalments": -1,
14 | "last_instalment": "2017-07-05 07:33:32",
15 | "pending_instalments": -1,
16 | "instalment_date": 5,
17 | "tag": ""
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/tests/mock_responses/mf_sips.json:
--------------------------------------------------------------------------------
1 | {
2 | "status": "success",
3 | "data": [
4 | {
5 | "sip_id": "367614126230235",
6 | "tradingsymbol": "INF846K01131",
7 | "fund": "Axis Long Term Equity Fund",
8 | "dividend_type": "growth",
9 | "transaction_type": "BUY",
10 | "status": "ACTIVE",
11 | "created": "2018-04-30 12:25:00",
12 | "frequency": "weekly",
13 | "trigger_price": 0,
14 | "instalment_amount": 500,
15 | "instalments": -1,
16 | "last_instalment": "2018-05-14 07:18:56",
17 | "pending_instalments": -1,
18 | "instalment_day": 0,
19 | "tag": ""
20 | }
21 | ]
22 | }
23 |
--------------------------------------------------------------------------------
/tests/mock_responses/ohlc.json:
--------------------------------------------------------------------------------
1 | {
2 | "status": "success",
3 | "data": {
4 | "NSE:INFY": {
5 | "instrument_token": 408065,
6 | "last_price": 1075,
7 | "ohlc": {
8 | "open": 1085.8,
9 | "high": 1085.9,
10 | "low": 1070.9,
11 | "close": 1075.8
12 | }
13 | },
14 | "NSE:SBIN": {
15 | "instrument_token": 408065,
16 | "last_price": 1075,
17 | "ohlc": {
18 | "open": 1085.8,
19 | "high": 1085.9,
20 | "low": 1070.9,
21 | "close": 1075.8
22 | }
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/tests/mock_responses/order_info.json:
--------------------------------------------------------------------------------
1 | {
2 | "status": "success",
3 | "data": [
4 | {
5 | "average_price": 0,
6 | "cancelled_quantity": 0,
7 | "disclosed_quantity": 0,
8 | "exchange": "NSE",
9 | "exchange_order_id": null,
10 | "exchange_timestamp": null,
11 | "filled_quantity": 0,
12 | "instrument_token": 1,
13 | "order_id": "171229000724687",
14 | "order_timestamp": "2017-12-29 11:06:52",
15 | "order_type": "LIMIT",
16 | "parent_order_id": null,
17 | "pending_quantity": 1,
18 | "placed_by": "DA0017",
19 | "price": 300,
20 | "product": "CNC",
21 | "quantity": 1,
22 | "status": "PUT ORDER REQ RECEIVED",
23 | "status_message": null,
24 | "tag": null,
25 | "tradingsymbol": "SBIN",
26 | "transaction_type": "BUY",
27 | "trigger_price": 0,
28 | "validity": "DAY",
29 | "variety": "regular"
30 | },
31 | {
32 | "average_price": 0,
33 | "cancelled_quantity": 0,
34 | "disclosed_quantity": 0,
35 | "exchange": "NSE",
36 | "exchange_order_id": null,
37 | "exchange_timestamp": null,
38 | "filled_quantity": 0,
39 | "instrument_token": 779521,
40 | "order_id": "171229000724687",
41 | "order_timestamp": "2017-12-29 11:06:52",
42 | "order_type": "LIMIT",
43 | "parent_order_id": null,
44 | "pending_quantity": 1,
45 | "placed_by": "DA0017",
46 | "price": 300,
47 | "product": "CNC",
48 | "quantity": 1,
49 | "status": "VALIDATION PENDING",
50 | "status_message": null,
51 | "tag": null,
52 | "tradingsymbol": "SBIN",
53 | "transaction_type": "BUY",
54 | "trigger_price": 0,
55 | "validity": "DAY",
56 | "variety": "regular"
57 | },
58 | {
59 | "average_price": 0,
60 | "cancelled_quantity": 0,
61 | "disclosed_quantity": 0,
62 | "exchange": "NSE",
63 | "exchange_order_id": null,
64 | "exchange_timestamp": null,
65 | "filled_quantity": 0,
66 | "instrument_token": 779521,
67 | "order_id": "171229000724687",
68 | "order_timestamp": "2017-12-29 11:06:52",
69 | "order_type": "LIMIT",
70 | "parent_order_id": null,
71 | "pending_quantity": 1,
72 | "placed_by": "DA0017",
73 | "price": 300,
74 | "product": "CNC",
75 | "quantity": 1,
76 | "status": "OPEN PENDING",
77 | "status_message": null,
78 | "tag": null,
79 | "tradingsymbol": "SBIN",
80 | "transaction_type": "BUY",
81 | "trigger_price": 0,
82 | "validity": "DAY",
83 | "variety": "regular"
84 | },
85 | {
86 | "average_price": 0,
87 | "cancelled_quantity": 0,
88 | "disclosed_quantity": 0,
89 | "exchange": "NSE",
90 | "exchange_order_id": "1300000001887410",
91 | "exchange_timestamp": "2017-12-29 11:06:52",
92 | "filled_quantity": 0,
93 | "instrument_token": 779521,
94 | "order_id": "171229000724687",
95 | "order_timestamp": "2017-12-29 11:06:52",
96 | "order_type": "LIMIT",
97 | "parent_order_id": null,
98 | "pending_quantity": 1,
99 | "placed_by": "DA0017",
100 | "price": 300,
101 | "product": "CNC",
102 | "quantity": 1,
103 | "status": "OPEN",
104 | "status_message": null,
105 | "tag": null,
106 | "tradingsymbol": "SBIN",
107 | "transaction_type": "BUY",
108 | "trigger_price": 0,
109 | "validity": "DAY",
110 | "variety": "regular"
111 | },
112 | {
113 | "average_price": 0,
114 | "cancelled_quantity": 0,
115 | "disclosed_quantity": 0,
116 | "exchange": "NSE",
117 | "exchange_order_id": "1300000001887410",
118 | "exchange_timestamp": "2017-12-29 11:06:52",
119 | "filled_quantity": 0,
120 | "instrument_token": 779521,
121 | "order_id": "171229000724687",
122 | "order_timestamp": "2017-12-29 11:08:16",
123 | "order_type": "LIMIT",
124 | "parent_order_id": null,
125 | "pending_quantity": 1,
126 | "placed_by": "DA0017",
127 | "price": 300,
128 | "product": "CNC",
129 | "quantity": 1,
130 | "status": "MODIFY VALIDATION PENDING",
131 | "status_message": null,
132 | "tag": null,
133 | "tradingsymbol": "SBIN",
134 | "transaction_type": "BUY",
135 | "trigger_price": 0,
136 | "validity": "DAY",
137 | "variety": "regular"
138 | },
139 | {
140 | "average_price": 0,
141 | "cancelled_quantity": 0,
142 | "disclosed_quantity": 0,
143 | "exchange": "NSE",
144 | "exchange_order_id": "1300000001887410",
145 | "exchange_timestamp": "2017-12-29 11:06:52",
146 | "filled_quantity": 0,
147 | "instrument_token": 779521,
148 | "order_id": "171229000724687",
149 | "order_timestamp": "2017-12-29 11:08:16",
150 | "order_type": "LIMIT",
151 | "parent_order_id": null,
152 | "pending_quantity": 1,
153 | "placed_by": "DA0017",
154 | "price": 300,
155 | "product": "CNC",
156 | "quantity": 1,
157 | "status": "MODIFY PENDING",
158 | "status_message": null,
159 | "tag": null,
160 | "tradingsymbol": "SBIN",
161 | "transaction_type": "BUY",
162 | "trigger_price": 0,
163 | "validity": "DAY",
164 | "variety": "regular"
165 | },
166 | {
167 | "average_price": 0,
168 | "cancelled_quantity": 0,
169 | "disclosed_quantity": 0,
170 | "exchange": "NSE",
171 | "exchange_order_id": "1300000001887410",
172 | "exchange_timestamp": "2017-12-29 11:08:16",
173 | "filled_quantity": 0,
174 | "instrument_token": 779521,
175 | "order_id": "171229000724687",
176 | "order_timestamp": "2017-12-29 11:08:16",
177 | "order_type": "LIMIT",
178 | "parent_order_id": null,
179 | "pending_quantity": 1,
180 | "placed_by": "DA0017",
181 | "price": 300,
182 | "product": "CNC",
183 | "quantity": 1,
184 | "status": "MODIFIED",
185 | "status_message": null,
186 | "tag": null,
187 | "tradingsymbol": "SBIN",
188 | "transaction_type": "BUY",
189 | "trigger_price": 0,
190 | "validity": "DAY",
191 | "variety": "regular"
192 | },
193 | {
194 | "average_price": 0,
195 | "cancelled_quantity": 0,
196 | "disclosed_quantity": 0,
197 | "exchange": "NSE",
198 | "exchange_order_id": "1300000001887410",
199 | "exchange_timestamp": "2017-12-29 11:08:16",
200 | "filled_quantity": 0,
201 | "instrument_token": 779521,
202 | "order_id": "171229000724687",
203 | "order_timestamp": "2017-12-29 11:08:16",
204 | "order_type": "LIMIT",
205 | "parent_order_id": null,
206 | "pending_quantity": 1,
207 | "placed_by": "DA0017",
208 | "price": 300.1,
209 | "product": "CNC",
210 | "quantity": 1,
211 | "status": "OPEN",
212 | "status_message": null,
213 | "tag": null,
214 | "tradingsymbol": "SBIN",
215 | "transaction_type": "BUY",
216 | "trigger_price": 0,
217 | "validity": "DAY",
218 | "variety": "regular"
219 | }
220 | ]
221 | }
222 |
--------------------------------------------------------------------------------
/tests/mock_responses/order_response.json:
--------------------------------------------------------------------------------
1 | {
2 | "status": "success",
3 | "data": {
4 | "order_id": "151220000000000"
5 | }
6 | }
--------------------------------------------------------------------------------
/tests/mock_responses/order_trades.json:
--------------------------------------------------------------------------------
1 | {
2 | "status": "success",
3 | "data": [
4 | {
5 | "average_price": 310.7,
6 | "exchange": "NSE",
7 | "exchange_order_id": "1300000001887410",
8 | "exchange_timestamp": "2017-12-29 12:02:05",
9 | "instrument_token": 779521,
10 | "order_id": "171229000724687",
11 | "order_timestamp": "12:02:05",
12 | "product": "CNC",
13 | "quantity": 1,
14 | "trade_id": "75894751",
15 | "tradingsymbol": "SBIN",
16 | "transaction_type": "BUY"
17 | }
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/tests/mock_responses/orders.json:
--------------------------------------------------------------------------------
1 | {
2 | "status": "success",
3 | "data": [
4 | {
5 | "account_id": "",
6 | "placed_by": "DA0017",
7 | "order_id": "171228000850038",
8 | "exchange_order_id": "211736200053802",
9 | "parent_order_id": "",
10 | "status": "COMPLETE",
11 | "status_message": "",
12 | "order_timestamp": "2017-12-28 11:39:14",
13 | "exchange_update_timestamp": "",
14 | "exchange_timestamp": "2017-12-28 11:39:14",
15 | "meta": "",
16 | "rejected_by": "",
17 | "variety": "regular",
18 | "exchange": "MCX",
19 | "tradingsymbol": "GOLDGUINEA17DECFUT",
20 | "instrument_token": 53505799,
21 | "order_type": "LIMIT",
22 | "transaction_type": "SELL",
23 | "validity": "DAY",
24 | "product": "NRML",
25 | "quantity": 3,
26 | "disclosed_quantity": 0,
27 | "price": 23337,
28 | "trigger_price": 0,
29 | "average_price": 23337,
30 | "filled_quantity": 3,
31 | "pending_quantity": 0,
32 | "cancelled_quantity": 0
33 | },
34 | {
35 | "account_id": "",
36 | "placed_by": "DA0017",
37 | "order_id": "171228000912853",
38 | "exchange_order_id": "1300000002730006",
39 | "parent_order_id": "",
40 | "status": "COMPLETE",
41 | "status_message": "",
42 | "order_timestamp": "2017-12-28 12:09:31",
43 | "exchange_update_timestamp": "",
44 | "exchange_timestamp": "2017-12-28 12:00:28",
45 | "meta": "",
46 | "rejected_by": "",
47 | "variety": "co",
48 | "exchange": "NSE",
49 | "tradingsymbol": "SBIN",
50 | "instrument_token": 779521,
51 | "order_type": "LIMIT",
52 | "transaction_type": "BUY",
53 | "validity": "DAY",
54 | "product": "CO",
55 | "quantity": 1,
56 | "disclosed_quantity": 0,
57 | "price": 311,
58 | "trigger_price": 0,
59 | "average_price": 311,
60 | "filled_quantity": 1,
61 | "pending_quantity": 0,
62 | "cancelled_quantity": 0
63 | },
64 | {
65 | "account_id": "",
66 | "placed_by": "DA0017",
67 | "order_id": "171228001116651",
68 | "exchange_order_id": "211736200111089",
69 | "parent_order_id": "",
70 | "status": "COMPLETE",
71 | "status_message": "",
72 | "order_timestamp": "2017-12-28 13:08:49",
73 | "exchange_update_timestamp": "",
74 | "exchange_timestamp": "2017-12-28 13:08:49",
75 | "meta": "",
76 | "rejected_by": "",
77 | "variety": "regular",
78 | "exchange": "MCX",
79 | "tradingsymbol": "GOLDGUINEA17DECFUT",
80 | "instrument_token": 53505799,
81 | "order_type": "LIMIT",
82 | "transaction_type": "BUY",
83 | "validity": "DAY",
84 | "product": "NRML",
85 | "quantity": 1,
86 | "disclosed_quantity": 0,
87 | "price": 23388,
88 | "trigger_price": 0,
89 | "average_price": 23388,
90 | "filled_quantity": 1,
91 | "pending_quantity": 0,
92 | "cancelled_quantity": 0
93 | },
94 | {
95 | "account_id": "",
96 | "placed_by": "DA0017",
97 | "order_id": "171228000912854",
98 | "exchange_order_id": "1300000002730007",
99 | "parent_order_id": "171228000912853",
100 | "status": "COMPLETE",
101 | "status_message": "",
102 | "order_timestamp": "2017-12-28 15:00:40",
103 | "exchange_update_timestamp": "",
104 | "exchange_timestamp": "2017-12-28 15:00:40",
105 | "meta": "",
106 | "rejected_by": "",
107 | "variety": "co",
108 | "exchange": "NSE",
109 | "tradingsymbol": "SBIN",
110 | "instrument_token": 779521,
111 | "order_type": "LIMIT",
112 | "transaction_type": "SELL",
113 | "validity": "DAY",
114 | "product": "CO",
115 | "quantity": 1,
116 | "disclosed_quantity": 0,
117 | "price": 0,
118 | "trigger_price": 309,
119 | "average_price": 309,
120 | "filled_quantity": 1,
121 | "pending_quantity": 0,
122 | "cancelled_quantity": 0
123 | },
124 | {
125 | "account_id": "",
126 | "placed_by": "DA0017",
127 | "order_id": "171228001686586",
128 | "exchange_order_id": "211736200181323",
129 | "parent_order_id": "",
130 | "status": "COMPLETE",
131 | "status_message": "",
132 | "order_timestamp": "2017-12-28 15:28:56",
133 | "exchange_update_timestamp": "",
134 | "exchange_timestamp": "2017-12-28 15:28:56",
135 | "meta": "",
136 | "rejected_by": "",
137 | "variety": "regular",
138 | "exchange": "MCX",
139 | "tradingsymbol": "GOLDGUINEA17DECFUT",
140 | "instrument_token": 53505799,
141 | "order_type": "LIMIT",
142 | "transaction_type": "SELL",
143 | "validity": "DAY",
144 | "product": "NRML",
145 | "quantity": 1,
146 | "disclosed_quantity": 0,
147 | "price": 23349,
148 | "trigger_price": 0,
149 | "average_price": 23349,
150 | "filled_quantity": 1,
151 | "pending_quantity": 0,
152 | "cancelled_quantity": 0
153 | },
154 | {
155 | "account_id": "",
156 | "placed_by": "DA0017",
157 | "order_id": "171228001730092",
158 | "exchange_order_id": "211736200297236",
159 | "parent_order_id": "",
160 | "status": "COMPLETE",
161 | "status_message": "",
162 | "order_timestamp": "2017-12-28 19:28:27",
163 | "exchange_update_timestamp": "",
164 | "exchange_timestamp": "2017-12-28 19:28:27",
165 | "meta": "",
166 | "rejected_by": "",
167 | "variety": "regular",
168 | "exchange": "MCX",
169 | "tradingsymbol": "LEADMINI17DECFUT",
170 | "instrument_token": 53496327,
171 | "order_type": "LIMIT",
172 | "transaction_type": "BUY",
173 | "validity": "DAY",
174 | "product": "NRML",
175 | "quantity": 1,
176 | "disclosed_quantity": 0,
177 | "price": 161.05,
178 | "trigger_price": 0,
179 | "average_price": 161.05,
180 | "filled_quantity": 1,
181 | "pending_quantity": 0,
182 | "cancelled_quantity": 0
183 | },
184 | {
185 | "account_id": "",
186 | "placed_by": "DA0017",
187 | "order_id": "171228001731490",
188 | "exchange_order_id": "211736200302177",
189 | "parent_order_id": "",
190 | "status": "COMPLETE",
191 | "status_message": "",
192 | "order_timestamp": "2017-12-28 19:37:12",
193 | "exchange_update_timestamp": "",
194 | "exchange_timestamp": "2017-12-28 19:37:12",
195 | "meta": "",
196 | "rejected_by": "",
197 | "variety": "regular",
198 | "exchange": "MCX",
199 | "tradingsymbol": "LEADMINI17DECFUT",
200 | "instrument_token": 53496327,
201 | "order_type": "LIMIT",
202 | "transaction_type": "SELL",
203 | "validity": "DAY",
204 | "product": "NRML",
205 | "quantity": 1,
206 | "disclosed_quantity": 0,
207 | "price": 161.2,
208 | "trigger_price": 0,
209 | "average_price": 161.2,
210 | "filled_quantity": 1,
211 | "pending_quantity": 0,
212 | "cancelled_quantity": 0
213 | }
214 | ]
215 | }
216 |
--------------------------------------------------------------------------------
/tests/mock_responses/positions.json:
--------------------------------------------------------------------------------
1 | {
2 | "status": "success",
3 | "data": {
4 | "net": [
5 | {
6 | "tradingsymbol": "LEADMINI17DECFUT",
7 | "exchange": "MCX",
8 | "instrument_token": 53496327,
9 | "product": "NRML",
10 | "quantity": 1,
11 | "overnight_quantity": 0,
12 | "multiplier": 1000,
13 | "average_price": 161.05,
14 | "close_price": 0,
15 | "last_price": 161.05,
16 | "value": -161050,
17 | "pnl": 0,
18 | "m2m": 0,
19 | "unrealised": 0,
20 | "realised": 0,
21 | "buy_quantity": 1,
22 | "buy_price": 161.05,
23 | "buy_value": 161050,
24 | "buy_m2m": 161050,
25 | "sell_quantity": 0,
26 | "sell_price": 0,
27 | "sell_value": 0,
28 | "sell_m2m": 0,
29 | "day_buy_quantity": 1,
30 | "day_buy_price": 161.05,
31 | "day_buy_value": 161050,
32 | "day_sell_quantity": 0,
33 | "day_sell_price": 0,
34 | "day_sell_value": 0
35 | },
36 | {
37 | "tradingsymbol": "GOLDGUINEA17DECFUT",
38 | "exchange": "MCX",
39 | "instrument_token": 53505799,
40 | "product": "NRML",
41 | "quantity": 0,
42 | "overnight_quantity": 3,
43 | "multiplier": 1,
44 | "average_price": 0,
45 | "close_price": 23232,
46 | "last_price": 23355,
47 | "value": 801,
48 | "pnl": 801,
49 | "m2m": 276,
50 | "unrealised": 801,
51 | "realised": 0,
52 | "buy_quantity": 4,
53 | "buy_price": 23139.75,
54 | "buy_value": 92559,
55 | "buy_m2m": 93084,
56 | "sell_quantity": 4,
57 | "sell_price": 23340,
58 | "sell_value": 93360,
59 | "sell_m2m": 93360,
60 | "day_buy_quantity": 1,
61 | "day_buy_price": 23388,
62 | "day_buy_value": 23388,
63 | "day_sell_quantity": 4,
64 | "day_sell_price": 23340,
65 | "day_sell_value": 93360
66 | },
67 | {
68 | "tradingsymbol": "SBIN",
69 | "exchange": "NSE",
70 | "instrument_token": 779521,
71 | "product": "CO",
72 | "quantity": 0,
73 | "overnight_quantity": 0,
74 | "multiplier": 1,
75 | "average_price": 0,
76 | "close_price": 0,
77 | "last_price": 308.4,
78 | "value": -2,
79 | "pnl": -2,
80 | "m2m": -2,
81 | "unrealised": -2,
82 | "realised": 0,
83 | "buy_quantity": 1,
84 | "buy_price": 311,
85 | "buy_value": 311,
86 | "buy_m2m": 311,
87 | "sell_quantity": 1,
88 | "sell_price": 309,
89 | "sell_value": 309,
90 | "sell_m2m": 309,
91 | "day_buy_quantity": 1,
92 | "day_buy_price": 311,
93 | "day_buy_value": 311,
94 | "day_sell_quantity": 1,
95 | "day_sell_price": 309,
96 | "day_sell_value": 309
97 | }
98 | ],
99 | "day": [
100 | {
101 | "tradingsymbol": "GOLDGUINEA17DECFUT",
102 | "exchange": "MCX",
103 | "instrument_token": 53505799,
104 | "product": "NRML",
105 | "quantity": -3,
106 | "overnight_quantity": 0,
107 | "multiplier": 1,
108 | "average_price": 23340,
109 | "close_price": 23232,
110 | "last_price": 23355,
111 | "value": 69972,
112 | "pnl": -93,
113 | "m2m": -93,
114 | "unrealised": -93,
115 | "realised": 0,
116 | "buy_quantity": 1,
117 | "buy_price": 23388,
118 | "buy_value": 23388,
119 | "buy_m2m": 23388,
120 | "sell_quantity": 4,
121 | "sell_price": 23340,
122 | "sell_value": 93360,
123 | "sell_m2m": 93360,
124 | "day_buy_quantity": 1,
125 | "day_buy_price": 23388,
126 | "day_buy_value": 23388,
127 | "day_sell_quantity": 4,
128 | "day_sell_price": 23340,
129 | "day_sell_value": 93360
130 | },
131 | {
132 | "tradingsymbol": "LEADMINI17DECFUT",
133 | "exchange": "MCX",
134 | "instrument_token": 53496327,
135 | "product": "NRML",
136 | "quantity": 1,
137 | "overnight_quantity": 0,
138 | "multiplier": 1000,
139 | "average_price": 161.05,
140 | "close_price": 0,
141 | "last_price": 161.05,
142 | "value": -161050,
143 | "pnl": 0,
144 | "m2m": 0,
145 | "unrealised": 0,
146 | "realised": 0,
147 | "buy_quantity": 1,
148 | "buy_price": 161.05,
149 | "buy_value": 161050,
150 | "buy_m2m": 161050,
151 | "sell_quantity": 0,
152 | "sell_price": 0,
153 | "sell_value": 0,
154 | "sell_m2m": 0,
155 | "day_buy_quantity": 1,
156 | "day_buy_price": 161.05,
157 | "day_buy_value": 161050,
158 | "day_sell_quantity": 0,
159 | "day_sell_price": 0,
160 | "day_sell_value": 0
161 | },
162 | {
163 | "tradingsymbol": "SBIN",
164 | "exchange": "NSE",
165 | "instrument_token": 779521,
166 | "product": "CO",
167 | "quantity": 0,
168 | "overnight_quantity": 0,
169 | "multiplier": 1,
170 | "average_price": 0,
171 | "close_price": 0,
172 | "last_price": 308.4,
173 | "value": -2,
174 | "pnl": -2,
175 | "m2m": -2,
176 | "unrealised": -2,
177 | "realised": 0,
178 | "buy_quantity": 1,
179 | "buy_price": 311,
180 | "buy_value": 311,
181 | "buy_m2m": 311,
182 | "sell_quantity": 1,
183 | "sell_price": 309,
184 | "sell_value": 309,
185 | "sell_m2m": 309,
186 | "day_buy_quantity": 1,
187 | "day_buy_price": 311,
188 | "day_buy_value": 311,
189 | "day_sell_quantity": 1,
190 | "day_sell_price": 309,
191 | "day_sell_value": 309
192 | }
193 | ]
194 | }
195 | }
196 |
--------------------------------------------------------------------------------
/tests/mock_responses/profile.json:
--------------------------------------------------------------------------------
1 | {
2 | "status": "success",
3 | "data": {
4 | "user_id": "AB1234",
5 | "user_type": "investor",
6 | "email": "xxxyyy@gmail.com",
7 | "user_name": "AxAx Bxx",
8 | "user_shortname": "abc",
9 | "broker": "ZERODHA",
10 | "exchanges": [
11 | "BSE",
12 | "BFO",
13 | "NFO",
14 | "MCX",
15 | "CDS",
16 | "NSE"
17 | ],
18 | "products": [
19 | "BO",
20 | "CNC",
21 | "CO",
22 | "MIS",
23 | "NRML"
24 | ],
25 | "order_types": [
26 | "LIMIT",
27 | "MARKET",
28 | "SL",
29 | "SL-M"
30 | ],
31 | "meta": {
32 | "demat_consent": "XXXX"
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/tests/mock_responses/quote.json:
--------------------------------------------------------------------------------
1 | {
2 | "status": "success",
3 | "data": {
4 | "NSE:INFY": {
5 | "instrument_token": 408065,
6 | "timestamp": "2018-01-12 10:40:29",
7 | "last_price": 1074.8,
8 | "last_quantity": 55,
9 | "last_trade_time": "2018-01-12 10:40:28",
10 | "average_price": 1077.03,
11 | "volume": 1368065,
12 | "buy_quantity": 240020,
13 | "sell_quantity": 509481,
14 | "ohlc": {
15 | "open": 1085.8,
16 | "high": 1085.9,
17 | "low": 1070.9,
18 | "close": 1075.8
19 | },
20 | "net_change": 0,
21 | "oi": 0,
22 | "oi_day_high": 0,
23 | "oi_day_low": 0,
24 | "depth": {
25 | "buy": [
26 | {
27 | "price": 1074.8,
28 | "quantity": 35,
29 | "orders": 1
30 | },
31 | {
32 | "price": 1074.65,
33 | "quantity": 5,
34 | "orders": 1
35 | },
36 | {
37 | "price": 1074.6,
38 | "quantity": 14,
39 | "orders": 1
40 | },
41 | {
42 | "price": 1074.5,
43 | "quantity": 1529,
44 | "orders": 3
45 | },
46 | {
47 | "price": 1074.45,
48 | "quantity": 139,
49 | "orders": 1
50 | }
51 | ],
52 | "sell": [
53 | {
54 | "price": 1074.85,
55 | "quantity": 32,
56 | "orders": 1
57 | },
58 | {
59 | "price": 1075,
60 | "quantity": 1264,
61 | "orders": 18
62 | },
63 | {
64 | "price": 1075.1,
65 | "quantity": 14,
66 | "orders": 1
67 | },
68 | {
69 | "price": 1075.2,
70 | "quantity": 600,
71 | "orders": 1
72 | },
73 | {
74 | "price": 1075.25,
75 | "quantity": 22,
76 | "orders": 2
77 | }
78 | ]
79 | }
80 | },
81 | "NSE:SBIN": {
82 | "instrument_token": 408065,
83 | "timestamp": "2018-01-12 10:40:29",
84 | "last_price": 1074.8,
85 | "last_quantity": 55,
86 | "last_trade_time": "2018-01-12 10:40:28",
87 | "average_price": 1077.03,
88 | "volume": 1368065,
89 | "buy_quantity": 240020,
90 | "sell_quantity": 509481,
91 | "ohlc": {
92 | "open": 1085.8,
93 | "high": 1085.9,
94 | "low": 1070.9,
95 | "close": 1075.8
96 | },
97 | "net_change": 0,
98 | "oi": 0,
99 | "oi_day_high": 0,
100 | "oi_day_low": 0,
101 | "depth": {
102 | "buy": [
103 | {
104 | "price": 1074.8,
105 | "quantity": 35,
106 | "orders": 1
107 | },
108 | {
109 | "price": 1074.65,
110 | "quantity": 5,
111 | "orders": 1
112 | },
113 | {
114 | "price": 1074.6,
115 | "quantity": 14,
116 | "orders": 1
117 | },
118 | {
119 | "price": 1074.5,
120 | "quantity": 1529,
121 | "orders": 3
122 | },
123 | {
124 | "price": 1074.45,
125 | "quantity": 139,
126 | "orders": 1
127 | }
128 | ],
129 | "sell": [
130 | {
131 | "price": 1074.85,
132 | "quantity": 32,
133 | "orders": 1
134 | },
135 | {
136 | "price": 1075,
137 | "quantity": 1264,
138 | "orders": 18
139 | },
140 | {
141 | "price": 1075.1,
142 | "quantity": 14,
143 | "orders": 1
144 | },
145 | {
146 | "price": 1075.2,
147 | "quantity": 600,
148 | "orders": 1
149 | },
150 | {
151 | "price": 1075.25,
152 | "quantity": 22,
153 | "orders": 2
154 | }
155 | ]
156 | }
157 | }
158 | }
159 | }
160 |
--------------------------------------------------------------------------------
/tests/mock_responses/trades.json:
--------------------------------------------------------------------------------
1 | {
2 | "status": "success",
3 | "data": [
4 | {
5 | "average_price": 310.7,
6 | "exchange": "NSE",
7 | "exchange_order_id": "1300000001887410",
8 | "exchange_timestamp": "2017-12-29 12:02:05",
9 | "instrument_token": 779521,
10 | "order_id": "171229000724687",
11 | "order_timestamp": "12:02:05",
12 | "product": "CNC",
13 | "quantity": 1,
14 | "trade_id": "75894751",
15 | "tradingsymbol": "SBIN",
16 | "transaction_type": "BUY"
17 | }
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/tests/mock_responses/trigger_range.json:
--------------------------------------------------------------------------------
1 | {
2 | "status": "success",
3 | "data": {
4 | "NSE:INFY": {
5 | "instrument_token": 0,
6 | "lower": 1075.599,
7 | "upper": 1138.2
8 | },
9 | "NSE:RELIANCE": {
10 | "instrument_token": 0,
11 | "lower": 870.57475,
12 | "upper": 902.15
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/tests/mock_responses/virtual_contract_note.json:
--------------------------------------------------------------------------------
1 | {
2 | "status": "success",
3 | "data": [
4 | {
5 | "transaction_type": "BUY",
6 | "tradingsymbol": "SBIN",
7 | "exchange": "NSE",
8 | "variety": "regular",
9 | "product": "CNC",
10 | "order_type": "MARKET",
11 | "quantity": 1,
12 | "price": 560,
13 | "charges": {
14 | "transaction_tax": 0.56,
15 | "transaction_tax_type": "stt",
16 | "exchange_turnover_charge": 0.01876,
17 | "sebi_turnover_charge": 0.00056,
18 | "brokerage": 0,
19 | "stamp_duty": 0,
20 | "gst": {
21 | "igst": 0.0033767999999999997,
22 | "cgst": 0,
23 | "sgst": 0,
24 | "total": 0.0033767999999999997
25 | },
26 | "total": 0.5826968
27 | }
28 | },
29 | {
30 | "transaction_type": "SELL",
31 | "tradingsymbol": "GOLDPETAL23JULFUT",
32 | "exchange": "MCX",
33 | "variety": "regular",
34 | "product": "NRML",
35 | "order_type": "LIMIT",
36 | "quantity": 1,
37 | "price": 5862,
38 | "charges": {
39 | "transaction_tax": 0.5862,
40 | "transaction_tax_type": "ctt",
41 | "exchange_turnover_charge": 0.152412,
42 | "sebi_turnover_charge": 0.005862,
43 | "brokerage": 1.7586,
44 | "stamp_duty": 0,
45 | "gst": {
46 | "igst": 0.34503732,
47 | "cgst": 0,
48 | "sgst": 0,
49 | "total": 0.34503732
50 | },
51 | "total": 2.84811132
52 | }
53 | },
54 | {
55 | "transaction_type": "BUY",
56 | "tradingsymbol": "NIFTY2371317900PE",
57 | "exchange": "NFO",
58 | "variety": "regular",
59 | "product": "NRML",
60 | "order_type": "LIMIT",
61 | "quantity": 100,
62 | "price": 1.5,
63 | "charges": {
64 | "transaction_tax": 0,
65 | "transaction_tax_type": "stt",
66 | "exchange_turnover_charge": 0.07575,
67 | "sebi_turnover_charge": 0.00015,
68 | "brokerage": 20,
69 | "stamp_duty": 0,
70 | "gst": {
71 | "igst": 3.613527,
72 | "cgst": 0,
73 | "sgst": 0,
74 | "total": 3.613527
75 | },
76 | "total": 23.689427000000002
77 | }
78 | }
79 | ]
80 | }
81 |
--------------------------------------------------------------------------------