Skip to content

Error when using TSLA in historical_data_operations_req() #30

@virtualritz

Description

@virtualritz

I changed the example contract_samples::simple_future() for TSLA in historical_data_operations_req() like so:

pub fn historical_data_operations_req(&self) -> Result<(), IBKRApiLibError> {
        // Requesting historical data
        
        let contract = Contract {
            symbol: "TSLA".to_string(),
            sec_type: "STK".to_string(),
            exchange: "SMART".to_string(),
            currency: "USD".to_string(),
            ..Default::default()
        };

        self.client
            .as_ref()
            .unwrap()
            .try_lock()
            .unwrap()
            .req_head_time_stamp(
                4101,
                &contract,
                "TRADES",
                0,
                1,
            )?;

        let dt = Utc::now();
        let query_time = dt.format("%Y%m%d %H:%M:%S").to_string();
        info!("Request Time:  {}", query_time);

        self.client
            .as_ref()
            .expect(CLIENT_IS_NONE)
            .lock()
            .expect(CLIENT_POISONED_MUTEX)
            .req_historical_data(
                4102,
                &contract,
                query_time.as_str(),
                "60 D",
                "1 day",
                "MIDPOINT",
                1,
                1,
                false,
                vec![],
            )?;

        self.client
            .as_ref()
            .expect(CLIENT_IS_NONE)
            .lock()
            .expect(CLIENT_POISONED_MUTEX)
            .req_historical_data(
                4103,
                &contract,
                query_time.as_str(),
                "10 D",
                "1 min",
                "TRADES",
                1,
                1,
                false,
                vec![],
            )?;

        self.client
            .as_ref()
            .expect(CLIENT_IS_NONE)
            .lock()
            .expect(CLIENT_POISONED_MUTEX)
            .req_historical_data(
                4104,
                &contract,
                "",
                "1 M",
                "1 day",
                "MIDPOINT",
                1,
                1,
                true,
                vec![],
            )?;

        Ok(())
    }

What I get is No market data permissions for ISLAND STK for each of the three req_historical_data() calls. Only the req_head_time_stamp() calls succeeds:

2021-10-04 18:06:29 twsapi::examples::test_helpers src/examples/test_helpers.rs line: 3403 INFO - fundamental_data -- req_id: 4101, delta_neutral_contract: 20100629  08:00:00
2021-10-04 18:06:29 twsapi::examples::test_helpers src/examples/test_helpers.rs line: 3038 ERROR - req_id: 4102 ,error_code: 162 , error_string:Historical Market Data Service error message:No market data permissions for ISLAND STK
2021-10-04 18:06:29 twsapi::examples::test_helpers src/examples/test_helpers.rs line: 3038 ERROR - req_id: 4103 ,error_code: 162 , error_string:Historical Market Data Service error message:No market data permissions for ISLAND STK
2021-10-04 18:06:29 twsapi::examples::test_helpers src/examples/test_helpers.rs line: 3038 ERROR - req_id: 4104 ,error_code: 162 , error_string:Historical Market Data Service error message:No market data permissions for ISLAND STK

I tried the same from the Python ib sync API and it works. What am I missing here?

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