TASE Israel Stock API Guide: Python Tutorial for Real-Time Data & Quantitative Trading

  1. iTick
  2. Tutorial
TASE Israel Stock API Guide: Python Tutorial for Real-Time Data & Quantitative Trading - iTick
TASE Israel Stock API Guide: Python Tutorial for Real-Time Data & Quantitative Trading

In today's environment where global portfolio allocation has become mainstream in quantitative trading, the Middle East financial markets—particularly the Tel Aviv Stock Exchange (TASE)—are attracting significant cross-border investor interest due to Israel's distinctive strengths in high technology and defense sectors. Successful quantitative trading depends heavily on high-quality data sources. iTick, a specialized financial data provider, offers real-time market data API solutions with comprehensive global coverage.

I. Why Choose iTick for TASE Market Access?

When connecting to a relatively niche yet high-potential market such as the Israeli equity market, the stability and breadth of the data source are of paramount importance.

  1. Unified Multi-Market Coverage: iTick supports not only major markets such as US, Hong Kong, and A-shares, but also provides extensive coverage of exchanges including Israel, Singapore, India, Germany, and others. Whether trading individual TASE names or pursuing cross-market arbitrage, a single API interface is sufficient.
  2. Developer-Friendly Design: Offers standard RESTful endpoints (ideal for batch historical data retrieval) and low-latency WebSocket streaming (optimized for real-time quote and trade updates), with consistent data structures that enable rapid onboarding.
  3. Free Tier Availability: For individual quant developers and early-stage teams, iTick provides a free usage tier with sufficient quota for strategy backtesting and initial validation.

II. Quick Start: Obtaining Your API Token

Before writing any code, complete these two steps:

  1. Register an Account: Visit the iTick official website and complete registration (takes approximately 30 seconds).
  2. Retrieve API Token: After logging in, navigate to the developer console to obtain your unique API token. All subsequent requests must include this token in the request headers for authentication.

III. Core API Endpoints and Python Implementation

The iTick API base URL is https://api.itick.org. All requests require the headers accept: application/json and your token.

1. Retrieve Real-Time TASE Stock Quotes (REST API)

To fetch real-time quotes for a prominent Israeli-listed company, use the unified quote endpoint. While exact TASE symbols should be confirmed via iTick's product catalog, the interface format remains consistent.

Endpoint Details

  • Path: /stock/quote
  • Parameters:
    • region: Market code (Israel uses IL)
    • code: Ticker symbol (e.g., TEVA for Teva Pharmaceutical Industries)

Python Example

      import requests

# Replace with your actual API token
API_TOKEN = "your_token_here"
headers = {
    "accept": "application/json",
    "token": API_TOKEN
}

# Request parameters
# Use correct symbol from iTick's official symbol list
region = "IL"
code = "TEVA"

url = f"https://api.itick.org/stock/quote?region={region}&code={code}"

try:
    response = requests.get(url, headers=headers)
    if response.status_code == 200:
        data = response.json().get('data', {})
        print(f"Symbol: {code}.{region}")
        print(f"Last Price: {data.get('ld')}")           # latest price
        print(f"Change %: {data.get('chp')}%")           # percentage change
        print(f"Open: {data.get('o')}")                  # opening price
        print(f"High: {data.get('h')}")                  # session high
        print(f"Low: {data.get('l')}")                   # session low
        print(f"Volume: {data.get('v')}")                # traded volume
    else:
        print(f"Request failed - Status: {response.status_code}, Error: {response.text}")
except Exception as e:
    print(f"Network error: {e}")

    

This minimal code (~10 lines of core logic) delivers real-time bid/ask and trade data from TASE, providing immediate inputs for your quantitative models.

2. Fetch Historical OHLCV Data (Backtesting)

Robust backtesting is essential before live deployment. iTick's REST API supports historical bars across multiple timeframes—from 1-minute to monthly.

Endpoint Details

  • Path: /stock/kline
  • Parameters:
    • kType: Bar type (1 = 1min, 2 = 5min, ..., 8 = daily, 9 = weekly, 10 = monthly)
    • limit: Number of bars to return
    • et: End timestamp (optional)

Python Example

      import requests
import pandas as pd

API_TOKEN = "your_token_here"
headers = {
    "accept": "application/json",
    "token": API_TOKEN
}

# Example: daily bars for an Israeli equity
region = "IL"
code = "TEVA"
kType = "8"     # daily bars
limit = "100"   # last 100 bars

url = f"https://api.itick.org/stock/kline?region={region}&code={code}&kType={kType}&limit={limit}"

response = requests.get(url, headers=headers)

if response.status_code == 200:
    kline_data = response.json().get('data', [])
    if kline_data:
        df = pd.DataFrame(kline_data)
        # Typical fields: t (timestamp), o, h, l, c, v
        df = df.rename(columns={'t': 'timestamp', 'o': 'open', 'h': 'high', 'l': 'low', 'c': 'close', 'v': 'volume'})
        df['timestamp'] = pd.to_datetime(df['timestamp'], unit='s')
        print(df[['timestamp', 'open', 'high', 'low', 'close', 'volume']].head())
    else:
        print("No data returned")
else:
    print("Request failed")

    

This approach allows you to efficiently build a historical TASE database suitable for validating mean-reversion, momentum, or other systematic strategies in the Israeli market.

3. Real-Time Streaming via WebSocket

For high-frequency monitoring or latency-sensitive applications, WebSocket provides push-based updates with millisecond-level latency.

Python Example

      import websocket
import json
import threading

WS_URL = "wss://api.itick.org/stock"  # Equity market WebSocket endpoint
API_TOKEN = "your_token_here"

def on_open(ws):
    print("Connection opened. Subscribing to TASE instrument...")
    # Subscribe to quote and tick updates
    subscribe_msg = {
        "ac": "subscribe",
        "params": "TEVA$IL",       # format: symbol$region
        "types": "quote,tick"      # quote updates + trade-by-trade
    }
    ws.send(json.dumps(subscribe_msg))

def on_message(ws, message):
    data = json.loads(message)
    # Insert strategy logic here
    print(f"Received update: {data}")

def on_error(ws, error):
    print(f"Error: {error}")

def on_close(ws, close_status_code, close_msg):
    print("Connection closed")

if __name__ == "__main__":
    ws = websocket.WebSocketApp(WS_URL,
                                header={"token": API_TOKEN},
                                on_open=on_open,
                                on_message=on_message,
                                on_error=on_error,
                                on_close=on_close)

    wst = threading.Thread(target=ws.run_forever)
    wst.start()

    try:
        while True:
            pass  # Keep main thread alive
    except KeyboardInterrupt:
        ws.close()

    

This implementation establishes a persistent connection; any new quote or trade on the subscribed TASE instrument triggers an immediate callback.

IV. Quantitative Integration: Building a Basic Signal Engine

With reliable data in place, strategy logic can be implemented. Below is a simplified dual moving average crossover example using historical data.

      # Assuming 'df' contains daily close prices retrieved via REST API

import talib

df['MA_Short'] = talib.SMA(df['close'], timeperiod=20)
df['MA_Long']  = talib.SMA(df['close'], timeperiod=60)

# Check latest two bars for crossover
if df['MA_Short'].iloc[-2] <= df['MA_Long'].iloc[-2] and df['MA_Short'].iloc[-1] > df['MA_Long'].iloc[-1]:
    print("Golden cross detected → Potential BUY signal on TASE name")
    signal = "BUY"
elif df['MA_Short'].iloc[-2] >= df['MA_Long'].iloc[-2] and df['MA_Short'].iloc[-1] < df['MA_Long'].iloc[-1]:
    print("Death cross detected → Potential SELL signal on TASE name")
    signal = "SELL"
else:
    signal = "HOLD"
    print("No clear signal → Maintain position or remain flat")

    

By feeding WebSocket real-time updates into the on_message handler, this logic can evolve into a fully automated execution pipeline.

V. Summary

The iTick API significantly lowers the barrier to accessing high-quality TASE data, eliminating the need for complex local brokerage integrations or proprietary protocols. With straightforward Python code, developers can obtain real-time quotes, historical bars, and trade-level data—ideal for cross-border quant applications, systematic strategy research, and live market monitoring systems.

For more advanced use cases (bulk symbol requests, dedicated strategy integration, enterprise-grade SLAs), contact iTick technical support for tailored API plans and preferential pricing.

Further Reading: