Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using TSLA in historical_data_operations_req() #30

Open
virtualritz opened this issue Oct 4, 2021 · 2 comments
Open

Error when using TSLA in historical_data_operations_req() #30

virtualritz opened this issue Oct 4, 2021 · 2 comments

Comments

@virtualritz
Copy link

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?

@sparkstartconsulting
Copy link
Owner

sparkstartconsulting commented Oct 5, 2021 via email

@virtualritz
Copy link
Author

Hey, no worries. I don't depend on the working atm. Just made a ticket so it doesn't fall through the cracks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants