sparkstartconsulting / IBKR-API-Rust

Port of Interactive Broker's trading API written in Rust
MIT License
146 stars 43 forks source link

Using the test code places order with 200 BMW shares #36

Open yssoe opened 2 years ago

yssoe commented 2 years ago

Thank you for your work,

I just simply imported your crate and used this demo code you provided:

It placed an order of 200 shares of BMW, now I know you like the cars but I can't find in this code where this is the case, I am running TWS version Build 10.17 why is this sending orders out of the blue? When just running the below? Thanks!

use std::sync::{Arc, Mutex};
use std::thread;
use std::time::Duration;
use twsapi::core::client::EClient;
use twsapi::core::errors::IBKRApiLibError;
use twsapi::core::streamer::{Streamer, TcpStreamer};
use twsapi::examples::test_helpers::TestWrapper;

fn main() -> Result<(), IBKRApiLibError> {
    let wrapper = Arc::new(Mutex::new(TestWrapper::<TcpStreamer>::new()));
    let app = Arc::new(Mutex::new(EClient::new(wrapper.clone())));

    println!("getting connection...");

    wrapper.lock().expect("Wrapper mutex was poisoned").client = Option::from(app.clone());

    //use port 7497 for TWS or 4002 for IB Gateway, depending on the port you have set
    app.lock()
        .expect("EClient mutex was poisoned")
        .connect("127.0.0.1", 7496, 0)?;

    //4002
    thread::sleep(Duration::new(18600, 0));

    Ok(())
}
sparkstartconsulting commented 2 years ago

Because it's running a test case. Please say you did not run this against your real account without running against your paper account first.

On Thu, Sep 1, 2022 at 3:45 AM Yves @.***> wrote:

Thank you for your work,

I just simply imported your crate and used this demo code you provided:

It placed an order of 200 shares of BMW, now I know you like the cars but I can't find in this code where this is the case, I am running TWS version Build 10.17 why is this sending orders out of the blue? Thanks!

`use std::sync::{Arc, Mutex}; use std::thread; use std::time::Duration; use twsapi::core::client::EClient; use twsapi::core::errors::IBKRApiLibError; use twsapi::core::streamer::{Streamer, TcpStreamer}; use twsapi::examples::test_helpers::TestWrapper;

fn main() -> Result<(), IBKRApiLibError> { let wrapper = Arc::new(Mutex::new(TestWrapper::::new())); let app = Arc::new(Mutex::new(EClient::new(wrapper.clone())));

println!("getting connection...");

wrapper.lock().expect("Wrapper mutex was poisoned").client = Option::from(app.clone());

//use port 7497 for TWS or 4002 for IB Gateway, depending on the port you have set app.lock() .expect("EClient mutex was poisoned") .connect("127.0.0.1", 7496, 0)?;

//4002 thread::sleep(Duration::new(18600, 0));

Ok(())

}`

— Reply to this email directly, view it on GitHub https://github.com/sparkstartconsulting/IBKR-API-Rust/issues/36, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANSKV5GI7ZIYIAKSMPLOR33V4BNJLANCNFSM6AAAAAAQCCPKHY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

yssoe commented 2 years ago

No of course it was on paper account login, but please remove that test case from just importing your crate and runnig your sample code, this doesn't make any sense at all. Thanks