Skip to content

Data Error in OA AB Plugin #2

Description

@pkpk6575

Iam running OpenAlgo locally in windows 10 PC.
Data for NSE and BSE fetch is good (1minTF and Day TF) , iam facing problem On the first run and sometimes while changing script to script getting this error (followed proper symbol list)

←[94m🔄←[0m Configuration version check passed (←[92m1.0.4←[0m)
←[96mOpenAlgo Version:←[0m ←[92m1.0.0.37←[0m
[2025-11-28 14:15:34,430] INFO in db_init_helper: Telegram DB: Connection verified (5 table(s) ready)
[2025-11-28 14:15:35,836] INFO in base: Scheduler started
[2025-11-28 14:15:35,878] INFO in base: Scheduler started
[2025-11-28 14:15:35,925] INFO in market_data_service: MarketDataService initialized
[2025-11-28 14:15:36,106] INFO in python_strategy: Directories initialized on windows
[2025-11-28 14:15:36,108] INFO in base: Scheduler started
[2025-11-28 14:15:36,109] INFO in python_strategy: Scheduler initialized with IST timezone on windows
[2025-11-28 14:15:36,110] INFO in python_strategy: Python Strategy System initialized (basic) on windows
[2025-11-28 14:15:49,827] INFO in socketio_error_handler: Socket.IO error handling initialized
[2025-11-28 14:15:49,901] INFO in security_middleware: Security middleware initialized
[2025-11-28 14:15:49,903] INFO in security_middleware: Security middleware initialized
[2025-11-28 14:15:49,912] INFO in db_init_helper: Traffic Logs DB: Connection verified (4 table(s) ready)
[2025-11-28 14:15:50,088] INFO in db_init_helper: Latency DB: Connection verified (1 table(s) ready)
[2025-11-28 14:15:50,125] INFO in latency_db: Purged 208 old data endpoint latency logs (older than 7 days)
[2025-11-28 14:15:50,634] INFO in db_init_helper: Auth DB: Connection verified (2 table(s) ready)
[2025-11-28 14:15:50,636] INFO in db_init_helper: User DB: Connection verified (1 table(s) ready)
[2025-11-28 14:15:50,645] INFO in db_init_helper: Master Contract DB: Connection verified (1 table(s) ready)
[2025-11-28 14:15:50,654] INFO in db_init_helper: Traffic Logs DB: Connection verified (4 table(s) ready)
[2025-11-28 14:15:50,655] INFO in db_init_helper: Analyzer DB: Connection verified (1 table(s) ready)
[2025-11-28 14:15:50,656] INFO in db_init_helper: API Log DB: Connection verified (1 table(s) ready)
[2025-11-28 14:15:50,657] INFO in db_init_helper: Settings DB: Connection verified (1 table(s) ready)
[2025-11-28 14:15:50,661] INFO in db_init_helper: Chartink DB: Connection verified (2 table(s) ready)
[2025-11-28 14:15:50,667] INFO in db_init_helper: Latency DB: Connection verified (1 table(s) ready)
[2025-11-28 14:15:50,675] INFO in db_init_helper: Strategy DB: Connection verified (2 table(s) ready)
[2025-11-28 14:15:50,676] INFO in db_init_helper: Sandbox DB: Connection verified (6 table(s) ready)
[2025-11-28 14:15:50,676] INFO in db_init_helper: Action Center DB: Connection verified (1 table(s) ready)
[2025-11-28 14:15:50,749] INFO in app: All databases initialized in parallel (128ms)
[2025-11-28 14:15:50,777] INFO in execution_thread: Execution engine thread started successfully
[2025-11-28 14:15:50,781] INFO in app: Execution engine auto-started (Analyzer mode is ON)
[2025-11-28 14:15:50,805] INFO in execution_thread: Sandbox Execution Engine thread started
[2025-11-28 14:15:50,830] INFO in position_manager: No CNC positions for catch-up settlement
[2025-11-28 14:15:50,859] INFO in squareoff_thread: Scheduling MIS square-off jobs (IST timezone):
[2025-11-28 14:15:50,861] INFO in app: Catch-up settlement check completed on startup
[2025-11-28 14:15:50,870] INFO in squareoff_thread: NSE_BSE: 15:15 IST (Job ID: squareoff_NSE_BSE)
[2025-11-28 14:15:50,875] INFO in squareoff_thread: CDS_BCD: 16:45 IST (Job ID: squareoff_CDS_BCD)
[2025-11-28 14:15:50,879] INFO in squareoff_thread: MCX: 23:30 IST (Job ID: squareoff_MCX)
[2025-11-28 14:15:50,882] INFO in squareoff_thread: NCDEX: 17:00 IST (Job ID: squareoff_NCDEX)
[2025-11-28 14:15:50,896] INFO in squareoff_thread: Backup check: Every 1 minute (Job ID: squareoff_backup)
[2025-11-28 14:15:50,898] INFO in squareoff_thread: T+1 Settlement: 00:00 IST (Job ID: t1_settlement)
[2025-11-28 14:15:50,904] INFO in squareoff_thread: Auto-Reset: Sunday 00:00 IST (Job ID: auto_reset)
[2025-11-28 14:15:50,928] INFO in squareoff_thread: Square-off scheduler started successfully
[2025-11-28 14:15:50,931] INFO in app: Square-off scheduler auto-started (Analyzer mode is ON)
[2025-11-28 14:15:50,943] INFO in app: Services started in parallel (177ms)
[2025-11-28 14:15:50,946] INFO in app: Running in local/integrated mode - Starting WebSocket proxy in Flask
[2025-11-28 14:15:50,952] INFO in app_integration: Starting WebSocket server in Flask application process
[2025-11-28 14:15:50,954] INFO in app_integration: Starting WebSocket proxy server in a separate thread
[2025-11-28 14:15:50,960] INFO in app_integration: Signal handlers registered: SIGINT, SIGTERM
[2025-11-28 14:15:50,963] INFO in app_integration: WebSocket proxy server thread started
[2025-11-28 14:15:50,985] INFO in app_integration: WebSocket server integration with Flask complete
[2025-11-28 14:15:51,000] INFO in logging: ============================================================
[2025-11-28 14:15:51,027] INFO in logging: OpenAlgo is running!
[2025-11-28 14:15:51,027] INFO in server: Initializing ZeroMQ listener task
[2025-11-28 14:15:51,029] INFO in logging: Access the application at: http://127.0.0.1:5000
[2025-11-28 14:15:51,030] INFO in server: Running in a non-main thread. Signal handlers will not be used.
[2025-11-28 14:15:51,031] INFO in logging: ============================================================
[2025-11-28 14:15:51,034] INFO in server: Starting WebSocket server on 127.0.0.1:8765

  • Serving Flask app 'app'
  • Debug mode: off
    [2025-11-28 14:15:51,134] INFO in server: Starting OPTIMIZED ZeroMQ listener with subscription indexing
    [2025-11-28 14:15:51,138] INFO in server: server listening on 127.0.0.1:8765
    [2025-11-28 14:15:51,141] INFO in server: WebSocket server successfully started on 127.0.0.1:8765
    [2025-11-28 14:15:56,084] INFO in session: Invalid session detected - clearing session
    [2025-11-28 14:16:05,683] INFO in auth: Login success for user: prashanth
    [2025-11-28 14:16:07,462] INFO in brlogin: Broker callback initiated for: shoonya
    [2025-11-28 14:16:07,466] INFO in brlogin: Session has user key: True
    [2025-11-28 14:16:25,341] INFO in brlogin: Broker callback initiated for: shoonya
    [2025-11-28 14:16:25,344] INFO in brlogin: Session has user key: True
    [2025-11-28 14:16:27,017] INFO in httpx_client: Running in integrated mode - HTTP/2 enabled for optimal performance
    [2025-11-28 14:16:27,021] INFO in httpx_client: Created HTTP client with automatic protocol negotiation (HTTP/2 preferred, HTTP/1.1 fallback)
    [2025-11-28 14:16:27,168] ERROR in auth_utils: Authentication error: Invalid Input : Invalid OTP
    [2025-11-28 14:16:43,781] INFO in brlogin: Broker callback initiated for: shoonya
    [2025-11-28 14:16:43,783] INFO in brlogin: Session has user key: True
    [2025-11-28 14:16:43,824] ERROR in auth_utils: Authentication error: Invalid Input : Invalid OTP
    [2025-11-28 14:17:16,302] INFO in brlogin: Broker callback initiated for: shoonya
    [2025-11-28 14:17:16,308] INFO in brlogin: Session has user key: True
    [2025-11-28 14:17:16,356] INFO in brlogin: Successfully connected broker: shoonya
    [2025-11-28 14:17:16,362] INFO in session: Session login time set to: 2025-11-28 14:17:16.362561+05:30
    [2025-11-28 14:17:16,365] INFO in auth_utils: User prashanth logged in successfully with broker shoonya
    [2025-11-28 14:17:16,422] INFO in auth_utils: Database record upserted with ID: 1
    [2025-11-28 14:17:16,455] INFO in master_contract_status_db: Initialized master contract status for shoonya
    [2025-11-28 14:17:16,495] INFO in master_contract_status_db: Updated master contract status for shoonya: downloading
    [2025-11-28 14:17:16,537] INFO in master_contract_db: Downloading shoonya Master Contract
    [2025-11-28 14:17:16,544] INFO in master_contract_db: Downloading and Unzipping shoonya Data
    [2025-11-28 14:17:16,781] INFO in master_contract_db: Successfully downloaded NSE from https://api.shoonya.com/NSE_symbols.txt.zip
    [2025-11-28 14:17:17,199] INFO in master_contract_db: Successfully downloaded NFO from https://api.shoonya.com/NFO_symbols.txt.zip
    [2025-11-28 14:17:17,517] INFO in master_contract_db: Successfully downloaded CDS from https://api.shoonya.com/CDS_symbols.txt.zip
    [2025-11-28 14:17:17,838] INFO in master_contract_db: Successfully downloaded MCX from https://api.shoonya.com/MCX_symbols.txt.zip
    [2025-11-28 14:17:18,036] INFO in master_contract_db: Successfully downloaded BSE from https://api.shoonya.com/BSE_symbols.txt.zip
    [2025-11-28 14:17:18,300] INFO in master_contract_db: Successfully downloaded BFO from https://api.shoonya.com/BFO_symbols.txt.zip
    [2025-11-28 14:17:18,322] INFO in master_contract_db: Deleting Symtoken Table
    [2025-11-28 14:17:23,835] INFO in master_contract_db: Processing shoonya NSE Data
    [2025-11-28 14:17:24,035] INFO in master_contract_db: Performing Bulk Insert
    [2025-11-28 14:17:25,641] INFO in master_contract_db: Bulk insert completed successfully with 8737 new records.
    [2025-11-28 14:17:25,646] INFO in master_contract_db: Processing shoonya BSE Data
    [2025-11-28 14:17:25,684] INFO in master_contract_db: Mapped all BSE instrument types to 'EQ'. Original types found: ['EQ']
    [2025-11-28 14:17:25,694] INFO in master_contract_db: Processed 12529 BSE equity symbols and added 2 BSE index symbols manually
    [2025-11-28 14:17:25,696] INFO in master_contract_db: Performing Bulk Insert
    [2025-11-28 14:17:27,637] INFO in master_contract_db: Bulk insert completed successfully with 12531 new records.
    [2025-11-28 14:17:27,642] INFO in master_contract_db: Processing shoonya NFO Data
    [2025-11-28 14:17:37,124] INFO in master_contract_db: Performing Bulk Insert
    [2025-11-28 14:17:49,065] INFO in master_contract_db: Bulk insert completed successfully with 82097 new records.
    [2025-11-28 14:17:49,097] INFO in master_contract_db: Processing shoonya CDS Data
    [2025-11-28 14:17:50,841] INFO in master_contract_db: Performing Bulk Insert
    [2025-11-28 14:17:54,604] INFO in master_contract_db: Bulk insert completed successfully with 11571 new records.
    [2025-11-28 14:17:54,648] INFO in master_contract_db: Processing shoonya MCX Data
    [2025-11-28 14:17:57,857] INFO in master_contract_db: Performing Bulk Insert
    [2025-11-28 14:18:02,778] INFO in master_contract_db: Bulk insert completed successfully with 22813 new records.
    [2025-11-28 14:18:02,858] INFO in master_contract_db: Processing shoonya BFO Data
    [2025-11-28 14:18:06,613] INFO in master_contract_db: Performing Bulk Insert
    [2025-11-28 14:18:16,034] INFO in master_contract_db: Bulk insert completed successfully with 32868 new records.
    [2025-11-28 14:18:16,107] INFO in master_contract_db: Deleted tmp\BFO_symbols.txt
    [2025-11-28 14:18:16,109] INFO in master_contract_db: Deleted tmp\BSE_symbols.txt
    [2025-11-28 14:18:16,110] INFO in master_contract_db: Deleted tmp\CDS_symbols.txt
    [2025-11-28 14:18:16,112] INFO in master_contract_db: Deleted tmp\MCX_symbols.txt
    [2025-11-28 14:18:16,115] INFO in master_contract_db: Deleted tmp\NFO_symbols.txt
    [2025-11-28 14:18:16,118] INFO in master_contract_db: Deleted tmp\NSE_symbols.txt
    [2025-11-28 14:18:16,209] INFO in master_contract_status_db: Updated master contract status for shoonya: success
    [2025-11-28 14:18:16,215] INFO in auth_utils: Master contract download completed for shoonya
    [2025-11-28 14:18:16,235] INFO in auth_utils: Loading symbols into memory cache for broker: shoonya
    [2025-11-28 14:18:16,743] INFO in master_contract_cache_hook: Starting cache load for broker: shoonya
    [2025-11-28 14:18:16,751] INFO in token_db_enhanced: BrokerSymbolCache initialized
    [2025-11-28 14:18:16,759] INFO in token_db_enhanced: Loading all symbols for broker: shoonya
    [2025-11-28 14:18:16,762] INFO in token_db_enhanced: Cache cleared
    [2025-11-28 14:18:26,559] INFO in token_db_enhanced: Successfully loaded 170617 symbols in 9.80 seconds. Memory usage: 80.15 MB
    [2025-11-28 14:18:26,562] INFO in token_db_enhanced: Cache valid until: 2025-11-29 03:00:00+05:30 (Session expiry: 03:00)
    [2025-11-28 14:18:27,064] INFO in master_contract_cache_hook: Successfully loaded 170617 symbols into cache in 10.31 seconds
    [2025-11-28 14:18:27,068] INFO in master_contract_cache_hook: Attempting to restore Python strategies after master contract download
    [2025-11-28 14:18:27,070] INFO in python_strategy: Checking for strategies to restore after login...
    [2025-11-28 14:18:27,079] INFO in python_strategy: Restoring strategy states from previous session...
    [2025-11-28 14:18:27,091] INFO in python_strategy: No strategies needed state restoration
    [2025-11-28 14:18:27,097] INFO in python_strategy: Post-login strategy restoration: No pending strategies to start
    [2025-11-28 14:18:27,099] INFO in master_contract_cache_hook: Python strategy restoration result: No pending strategies to start
    [2025-11-28 14:18:27,102] INFO in auth_utils: Master Contract Database Processing Completed

[2025-11-28 14:18:54,243] ERROR in data: Error in get_history: Expecting value: line 1 column 1 (char 0)
[2025-11-28 14:18:54,246] ERROR in history_service: Error in broker_module.get_history: Error fetching historical data: Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
File "D:\OPENALGO\openalgo\broker\shoonya\api\data.py", line 269, in get_history
candle = json.loads(candle)
File "C:\Users\TD01\AppData\Local\Programs\Python\Python313\Lib\json_init_.py", line 346, in loads
return _default_decoder.decode(s)
~~~~~~~~~~~~~~~~~~~~~~~^^^
File "C:\Users\TD01\AppData\Local\Programs\Python\Python313\Lib\json\decoder.py", line 345, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\TD01\AppData\Local\Programs\Python\Python313\Lib\json\decoder.py", line 363, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\OPENALGO\openalgo\services\history_service.py", line 80, in get_history_with_auth
df = data_handler.get_history(
symbol,
...<3 lines>...
end_date
)
File "D:\OPENALGO\openalgo\broker\shoonya\api\data.py", line 352, in get_history
raise Exception(f"Error fetching historical data: {str(e)}")
Exception: Error fetching historical data: Expecting value: line 1 column 1 (char 0)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions