Hello,
I'm trying to collect bids for LCOc1 as soon as the bid change in realtime.
My main issue is that I have a 10 min delay.
_________________________________
import time
import pandas as pd
import eikon as ek
import os
# Set Eikon API Key for access to financial data
ek.set_app_key('API_KEY_HERE')
# Define the instrument symbols
instruments = ["LCOc1"]
# Define the directory and file path for storing the CSV file
csv_directory = r"C:\Users\YOUR_PATH\"  # Use raw string to handle Windows paths
csv_file = os.path.join(csv_directory, "eikon_LCOc1_data.csv")
# Ensure the directory exists
os.makedirs(csv_directory, exist_ok=True)
# Define the DataFrame columns
columns = ["Timestamp", "LCOc1_BID", "LCOc1_Time"]
# Track the last recorded bid values to avoid duplicate logging
last_bids = {"LCOc1": None}
try:
    # Infinite loop to continuously fetch data
    while True:
        # Fetch BID data for LCOc1 using Eikon API
        df = ek.get_data(instruments, ["CF_BID", "CF_TIME"])[0]  # Get the first item of the returned tuple
        # Check if data was retrieved
        if df is None or df.empty:
            print("Error: No data retrieved. Retrying...")
            time.sleep(1)  # Wait before retrying
            continue
        # Extract the bid price and time for LCOc1
        try:
            lco_data = df.loc[df['Instrument'] == 'LCOc1', ['CF_BID', 'CF_TIME']].iloc[0]
            lco_bid = lco_data['CF_BID']
            lco_time = lco_data['CF_TIME']
        except IndexError:
            print("Error: Missing bid data for LCOc1.")
            time.sleep(1)
            continue
        # Log only if there is a change in bid prices
        if lco_bid != last_bids["LCOc1"]:
            timestamp = pd.Timestamp.now().strftime("%Y-%m-%d %H:%M:%S.%f")
            new_row = pd.DataFrame([[timestamp, lco_bid, lco_time]], columns=columns)
            # Append data to the CSV file (create if it doesn't exist)
            new_row.to_csv(csv_file, mode="a", index=False, header=not os.path.exists(csv_file))
            # Log the update
            print(f"New Data at {timestamp}: LCOc1 BID = {lco_bid}, Time = {lco_time}")
            # Update last recorded bid values
            last_bids["LCOc1"] = lco_bid
        # Small delay to avoid excessive API calls
        time.sleep(0.05)  # Adjust as needed
except KeyboardInterrupt:
    print("\nProcess interrupted. Data saved in:", csv_file)
_________________________________
The result looks like this :
Timestamp  | LCOc1_BID  | LCOc1_Time  | 
|---|
2025-03-12 09:52:07.812040  | 69.96  | 08:42:04  | 
2025-03-12 09:52:12.707826  | 69.95  | 08:42:08  | 
2025-03-12 09:52:15.209595  | 69.94  | 08:42:12  | 
So I have a 1 hour delay due to GMT (no problem) +  10 minutes that I don't know where it comes from.
On my Workspace, I have Realtime data going through Private network.
Thanks for your help in advance 
G