RussianInvestments / invest-api-csharp-sdk

12 stars 7 forks source link

Как реализовать запрос GetTechAnalysis? #23

Open Bodden007 opened 7 months ago

Bodden007 commented 7 months ago

Здравствуйте. Как реализовать запрос GetTechAnalysis, с помощью данной библиотеки? Пробую так, ругается `internal class Program { private static void Main(string[] args) { var settings = new Tinkoff.InvestApi.InvestApiSettings() { AccessToken = "Token" };

    var client = Tinkoff.InvestApi.InvestApiClientFactory.Create(settings);

    var getTechAnalysis = client.MarketData.GetTechAnalysis(new Tinkoff.InvestApi.V1.GetTechAnalysisRequest()
    {
        IndicatorType= "INDICATOR_TYPE_RSI",

    }) ;
}

}` В примерах не могу разобраться.

Спасибо.

Bodden007 commented 7 months ago

Пробую так, ` private static void Main(string[] args) { var settings = new Tinkoff.InvestApi.InvestApiSettings() { AccessToken = "Token" };

    var client = Tinkoff.InvestApi.InvestApiClientFactory.Create(settings);

    var getTechAnalysis = client.MarketData.GetTechAnalysis(new Tinkoff.InvestApi.V1.GetTechAnalysisRequest
    {
        IndicatorType = Tinkoff.InvestApi.V1.GetTechAnalysisRequest.Types.IndicatorType.Rsi,
        InstrumentUid = "a22a1263-8e1b-4546-a1aa-416463f104d3",
        From = Timestamp.FromDateTime(DateTime.UtcNow.AddYears(2023)),
        To = Timestamp.FromDateTime(DateTime.UtcNow),
        Interval = Tinkoff.InvestApi.V1.GetTechAnalysisRequest.Types.IndicatorInterval.OneDay,
        TypeOfPrice = Tinkoff.InvestApi.V1.GetTechAnalysisRequest.Types.TypeOfPrice.High,
        Length = 96,
        Deviation =
        {
            DeviationMultiplier =
            {
                Units = 266,
                Nano= 905
            }
        }           

    }); ;

    foreach (var techAnalysis in getTechAnalysis.TechnicalIndicators)
    {
        Console.WriteLine(
            $"{techAnalysis.Timestamp} {techAnalysis.MiddleBand}");
    }
}` 

Получаю исключение: Tinkoff.InvestApi.V1.GetTechAnalysisRequest.Deviation.get вернул null.

Bodden007 commented 7 months ago

Deviation ловит исключение null