# Getting KeyError: 'symbol' while calling get\_instrument\_by\_symbol()

**URL:** <https://community.aliceblueonline.com/t/getting-keyerror-symbol-while-calling-get-instrument-by-symbol/736>\
**Category:** API\
**Created:** [March 31, 2023, 2:33am UTC](https://community.aliceblueonline.com/t/getting-keyerror-symbol-while-calling-get-instrument-by-symbol/736 "2023-03-31T02:33:17Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rajesh\_Sivadasan](https://sea1.discourse-cdn.com/flex015/user_avatar/community.aliceblueonline.com/rajesh_sivadasan/32/62_2.png) [@Rajesh\_Sivadasan](https://community.aliceblueonline.com/u/Rajesh_Sivadasan)\
**Post date:** [March 31, 2023, 2:33am UTC](https://community.aliceblueonline.com/t/getting-keyerror-symbol-while-calling-get-instrument-by-symbol/736/1 "2023-03-31T02:33:17Z")

</div>

Traceback (most recent call last):  
File “/home/ubuntu/.local/lib/python3.10/site-packages/pandas/core/indexes/base.py”, line 3803, in get\_loc  
return self.\_engine.get\_loc(casted\_key)  
File “pandas/\_libs/index.pyx”, line 138, in pandas.\_libs.index.IndexEngine.get\_loc  
File “pandas/\_libs/index.pyx”, line 165, in pandas.\_libs.index.IndexEngine.get\_loc  
File “pandas/\_libs/hashtable\_class\_helper.pxi”, line 5745, in pandas.\_libs.hashtable.PyObjectHashTable.get\_item  
File “pandas/\_libs/hashtable\_class\_helper.pxi”, line 5753, in pandas.\_libs.hashtable.PyObjectHashTable.get\_item  
KeyError: ‘symbol’

The above exception was the direct cause of the following exception:

Traceback (most recent call last):  
File “/home/ubuntu/ab/ab\_options.py”, line 1540, in   
ins\_nifty = alice.get\_instrument\_by\_symbol(‘INDICES’, ‘NIFTY 50’)  
File “/home/ubuntu/.local/lib/python3.10/site-packages/pya3/alicebluepy.py”, line 542, in get\_instrument\_by\_symbol  
filter\_contract = contract[contract[‘symbol’] == symbol.upper()]  
File “/home/ubuntu/.local/lib/python3.10/site-packages/pandas/core/frame.py”, line 3804, in **getitem**  
indexer = self.columns.get\_loc(key)  
File “/home/ubuntu/.local/lib/python3.10/site-packages/pandas/core/indexes/base.py”, line 3805, in get\_loc  
raise KeyError(key) from err  
KeyError: ‘symbol’

---

<div class="post-metadata">

**Author:** ![nandagopal](https://avatars.discourse-cdn.com/v4/letter/n/f14d63/32.png) [@nandagopal](https://community.aliceblueonline.com/u/nandagopal)\
**Post date:** [March 31, 2023, 4:47am UTC](https://community.aliceblueonline.com/t/getting-keyerror-symbol-while-calling-get-instrument-by-symbol/736/2 "2023-03-31T04:47:02Z")

</div>

Kindly try to redownload the contract master

---

<div class="post-metadata">

**Author:** ![Market\_Alpha](https://sea1.discourse-cdn.com/flex015/user_avatar/community.aliceblueonline.com/market_alpha/32/323_2.png) [@Market\_Alpha](https://community.aliceblueonline.com/u/Market_Alpha)\
**Post date:** [March 31, 2023, 5:14am UTC](https://community.aliceblueonline.com/t/getting-keyerror-symbol-while-calling-get-instrument-by-symbol/736/3 "2023-03-31T05:14:26Z")

</div>

> [@nandagopal](#):
>
> indly try to redownload the contract mast

I download the master contract every day at 9:01 AM but still got this error. Why did this error occur for me?

---

<div class="post-metadata">

**Author:** ![nandagopal](https://avatars.discourse-cdn.com/v4/letter/n/f14d63/32.png) [@nandagopal](https://community.aliceblueonline.com/u/nandagopal)\
**Post date:** [March 31, 2023, 5:37am UTC](https://community.aliceblueonline.com/t/getting-keyerror-symbol-while-calling-get-instrument-by-symbol/736/4 "2023-03-31T05:37:57Z")

</div>

every day the contract master needs to be downloaded after 8 am Before 08:00 AM the previous day’s contract file is downloaded which is a known condition, as it is done technically, due to any glitch or any network issue .etc, the contract master wouldn’t be downloaded properly, as you set time to download the contract master try to make sure the file is downloaded as expected or not, if not then try to download manually once again.

---

<div class="post-metadata">

**Author:** ![Market\_Alpha](https://sea1.discourse-cdn.com/flex015/user_avatar/community.aliceblueonline.com/market_alpha/32/323_2.png) [@Market\_Alpha](https://community.aliceblueonline.com/u/Market_Alpha)\
**Post date:** [March 31, 2023, 7:53am UTC](https://community.aliceblueonline.com/t/getting-keyerror-symbol-while-calling-get-instrument-by-symbol/736/5 "2023-03-31T07:53:49Z")

</div>

> [@nandagopal](#):
>
> aster wouldn’t be downloaded properl

How will we know that master contract data is downloaded correctly or not? And what was the glitch today?

---

<div class="post-metadata">

**Author:** ![Market\_Alpha](https://sea1.discourse-cdn.com/flex015/user_avatar/community.aliceblueonline.com/market_alpha/32/323_2.png) [@Market\_Alpha](https://community.aliceblueonline.com/u/Market_Alpha)\
**Post date:** [March 31, 2023, 12:53pm UTC](https://community.aliceblueonline.com/t/getting-keyerror-symbol-while-calling-get-instrument-by-symbol/736/6 "2023-03-31T12:53:21Z")

</div>

Any update Aliceteam

---

<div class="post-metadata">

**Author:** ![Market\_Alpha](https://sea1.discourse-cdn.com/flex015/user_avatar/community.aliceblueonline.com/market_alpha/32/323_2.png) [@Market\_Alpha](https://community.aliceblueonline.com/u/Market_Alpha)\
**Post date:** [April 6, 2023, 7:55am UTC](https://community.aliceblueonline.com/t/getting-keyerror-symbol-while-calling-get-instrument-by-symbol/736/7 "2023-04-06T07:55:26Z")

</div>

@nandagopal Please update here.

---

<div class="post-metadata">

**Author:** ![nandagopal](https://avatars.discourse-cdn.com/v4/letter/n/f14d63/32.png) [@nandagopal](https://community.aliceblueonline.com/u/nandagopal)\
**Post date:** [April 12, 2023, 4:46am UTC](https://community.aliceblueonline.com/t/getting-keyerror-symbol-while-calling-get-instrument-by-symbol/736/8 "2023-04-12T04:46:23Z")

</div>

The sign when the contract master is not downloaded properly, if the get\_instrument\_by\_symbol or token gives error message like not found the exchange or the symbol.
