amittleider / AutoFinance.Broker

A Dotnet Core library to interact with Interactive Broker's Trader Workstation (IB TWS)
32 stars 16 forks source link

Error in GetHistoricalDataAsync() #42

Open ChrisAllisonMalta opened 6 months ago

ChrisAllisonMalta commented 6 months ago

Hi

When I try to run the Historical Data sample in the Readme, I get the following Exception:

"You submitted request with date-time attributes without explicit time zone. Please switch to use yyyymmdd-hh:mm:ss in UTC or use instrument time zone, like US/Eastern. Implied time zone functionality will be removed in the next API release"

I note there was a change last year interms of how the API expects timezones but looking through the sourcecode it seems like you're presenting the date correctly?

Am I doing something wrong here?

`

     ITwsControllerBase twsController;
    try
    {

       TwsObjectFactory twsObjectFactory = new TwsObjectFactory(_ibSettings.Host, _ibSettings.Port, 6);
        twsController  = twsObjectFactory.TwsControllerBase;
        // Setup

        await twsController.EnsureConnectedAsync();

        Contract contract = new Contract
        {
            SecType = TwsContractSecType.Stock,
            Symbol = "MSFT",
            Exchange = TwsExchange.Smart,
            PrimaryExch = TwsExchange.Island,
        };

        var queryTime = DateTime.Now.AddMonths(-6);

        // Call
        List<HistoricalDataEventArgs> historicalDataEvents =  twsController.GetHistoricalDataAsync(contract,queryTime, TwsDuration.OneMonth, TwsBarSizeSetting.OneDay, TwsHistoricalDataRequestType.Midpoint, true, false).Result;

        await twsController.DisconnectAsync();
    }    catch (Exception ex)
    {
        _logger.Error(nameof(PricingRequest), ex);
    }`