public decimal TickerCurrentPrice(string ticker)
        {
            Configuration.Default.AddApiKey("api_key", "OmY0M2VkYjdhMzhlYmE3Y2VhZWY4YjJiZWJlMzAzZWJi");

            var securityApi = new SecurityApi();
            var identifier  = ticker; // string | A Security identifier (Ticker, FIGI, ISIN, CUSIP, Intrinio ID)

            try
            {
                var realtimePrice = securityApi.GetSecurityRealtimePrice(identifier);
                var latestPrice   = realtimePrice.LastPrice;

                //converts nullable decemal to decemcial
                decimal?a = latestPrice;
                decimal b = a ?? -1;

                //return latestPrice;
                return(b);
            }
            catch (Exception e)
            {
                var b = 1;
                Console.WriteLine("Exception when calling SecurityApi.GetSecurityRealtimePrice: " + e.Message);
                return(b);
            }
        }
        public static void Run()
        {
            var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
            var apiInstance   = new SecurityApi(configuration);

            try
            {
                var fileInfo = new FileInfo
                {
                    FilePath = "WordProcessing/password-protected.docx",
                    Password = "******"
                };

                var options = new UpdatePasswordOptions
                {
                    FileInfo    = fileInfo,
                    OutputPath  = "output/update-password.docx",
                    NewPassword = "******"
                };

                var request  = new UpdatePasswordRequest(options);
                var response = apiInstance.UpdatePassword(request);

                Console.WriteLine("Output file path: " + response.Path);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling api: " + e.Message);
            }
        }
Exemple #3
0
        public SecurityApiTest()
        {
            var sessionManagerMock = new Mock <IAuthTokens>();

            sessionManagerMock.Setup(obj => obj.SessionToken).Returns("sessionToken");
            sessionManagerMock.Setup(obj => obj.KeyManagerToken).Returns("keyManagerToken");
            _apiExecutorMock = new Mock <IApiExecutor>();
            _securityApi     = new SecurityApi(sessionManagerMock.Object, "", new HttpClient(), _apiExecutorMock.Object);
        }
        public OAuthOptions(SecurityApi.Services.Contracts.IIdentityService identityService)
        {
            var config = AppConfiguration.Config;

            TokenEndpointPath = new PathString(config.TokenPath);
            AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(config.ExpirationMinutes);
            AccessTokenFormat = new JwtWriterFormat(this);
            Provider = new OAuthProvider(identityService);
            AllowInsecureHttp = true;
        }
Exemple #5
0
        public SecurityApiTest()
        {
            var sessionManagerMock = new Mock <IAuthTokens>();

            sessionManagerMock.Setup(obj => obj.SessionToken).Returns("sessionToken");
            sessionManagerMock.Setup(obj => obj.KeyManagerToken).Returns("keyManagerToken");
            var configuration = new Configuration();

            _apiExecutorMock = new Mock <IApiExecutor>();
            _securityApi     = new SecurityApi(sessionManagerMock.Object, configuration, _apiExecutorMock.Object);
        }
        public async Task <string> GetPriceQuoteAsync(string ticker)
        {
            Configuration.Default.AddApiKey("api_key", "OmIyMzk1OGMzNTBjOTRjYjU2NjM2MWM5MzM0Yzc4YmJk");

            var securityApi = new SecurityApi();

            try
            {
                result = await securityApi.GetSecurityRealtimePriceAsync(ticker, null);

                Console.WriteLine(result.ToJson());
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception when calling SecurityApi.GetSecurityRealtimePrice: " + e.Message);
            }

            return(result.LastPrice.ToString());
        }
        static void Main(string[] args)
        {
            AuthenticationDetails details;

            try
            {
                details = AuthenticationDetails.LoadFromJson("AuthDetails.json");
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("Could not find AuthDetails.json.\nExiting...");
                return;
            }

            SecurityApi.Init();

            var message = Authenticate(details.EGatewayUrl, details.Username, details.DecryptedPassword, details.Organization, details.ServiceHostId, details.WorkstationServiceId);

            Console.WriteLine(message);
        }
Exemple #8
0
        public static void Run()
        {
            var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
            var apiInstance   = new SecurityApi(configuration);

            try
            {
                var fileInfo = new FileInfo
                {
                    FilePath = "WordProcessing/password-protected.docx"
                };

                var request  = new CheckPasswordRequest(fileInfo.FilePath);
                var response = apiInstance.CheckPassword(request);

                Console.WriteLine("Check password: "******"Exception while calling api: " + e.Message);
            }
        }
Exemple #9
0
        public static void Main()
        {
            Configuration.Default.AddApiKey("api_key", "YOUR_API_KEY");

            var securityApi = new SecurityApi();
            var identifier  = "AAPL";       // string | A Security identifier (Ticker, FIGI, ISIN, CUSIP, Intrinio ID)
            var startDate   = "2019-01-01"; // DateTime? | Return prices on or after the date (optional)
            var endDate     = "2019-02-01"; // DateTime? | Return prices on or before the date (optional)
            var frequency   = "daily";      // string | Return stock prices in the given frequency (optional)  (default to daily)
            var pageSize    = 100;          // decimal? | The number of results to return (optional)  (default to 100)
            var nextPage    = "";           // string | Gets the next page of data from a previous API call (optional)

            try
            {
                ApiResponseSecurityStockPrices result = securityApi.GetSecurityStockPrices(identifier, DateTime.Parse(startDate), DateTime.Parse(endDate), frequency, pageSize, nextPage);

                result.StockPrices.ForEach((StockPriceSummary stockPriceSummary) => Console.WriteLine(stockPriceSummary));
            }
            catch (Exception e)
            {
                Debug.Print("Exception when calling SecurityApi.GetSecurityStockPrices: " + e.Message);
            }
        }
Exemple #10
0
        //public List<StockPriceSummary> Savior { get; } {

        //    //move the stock List / array / whatever to here so we can access it on the website


        //}

        public static void DoThis(string identifier = "AAPL", int pageSize = 3, string startDate = "2019-01-01", string freq = "daily")
        {
            Configuration.Default.AddApiKey("api_key", "OjEzNDI0MDg2ZGU4NGI2Yjc2N2ZjYWIzNDYwM2E0MDk3");

            var securityApi = new SecurityApi();
            var endDate     = DateTime.Now.ToString(); // should just leave this as a DateTime and not ToString and Parse - but what if we enter it as a dropdown later?
            //var freq = "daily";
            var nextPage = "";                         // boolean?
            List <StockPriceSummary> save = new List <StockPriceSummary>();

            try
            {
                ApiResponseSecurityStockPrices result = securityApi.GetSecurityStockPrices(identifier, DateTime.Parse(startDate), DateTime.Parse(endDate), freq, pageSize, nextPage);

                result.StockPrices.ForEach((StockPriceSummary stockPriceSummary) => Console.WriteLine(stockPriceSummary)); //save.Add(stockPriceSummary);
            }


            catch (Exception e)
            {
                Debug.Print("Exception when calling SecurityApi.GetSecurityStockPrices: " + e.Message);
            }
        }
 public void Init()
 {
     instance = new SecurityApi();
 }
        public decimal SMACurrentAverage(int periodNum, string ticker)
        {
            Configuration.Default.AddApiKey("api_key", "OmY0M2VkYjdhMzhlYmE3Y2VhZWY4YjJiZWJlMzAzZWJi");

            var securityApi = new SecurityApi();
            var identifier  = ticker;                       // string | A Security identifier (Ticker, FIGI, ISIN, CUSIP, Intrinio ID)
            var period      = periodNum;                    // int? | The number of observations, per period, to calculate Simple Moving Average (optional)  (default to 20)
            var priceKey    = "close";                      // string | The Stock Price field to use when calculating Simple Moving Average (optional)  (default to close)
            var startDate   = DateTime.Parse("2020-02-01"); // string | Return technical indicator values on or after the date (optional)
            var endDate     = DateTime.Now;                 // string | Return technical indicator values on or before the date (optional)
            var pageSize    = 20;                           // int? | The number of results to return (optional)  (default to 100)
            var nextPage    = "";                           // string | Gets the next page of data from a previous API call (optional)

            string startDateTime = startDate.ToString();
            string endDateTime   = endDate.ToString();
            var    pageSizeNum   = pageSize.ToString();

            //try
            //{
            //    ApiResponseSecuritySimpleMovingAverage result = securityApi.GetSecurityPriceTechnicalsSma(identifier, period, priceKey,  startDateTime, endDateTime, pageSize, nextPage);
            //    Console.WriteLine(result.ToJson());
            //}
            //catch (Exception e)
            //{
            //    Console.WriteLine("Exception when calling SecurityApi.GetSecurityPriceTechnicalsSma: " + e.Message);
            //}

            try
            {
                //put entrie method into try catch block
                var smaAverage = securityApi.GetSecurityPriceTechnicalsSma(identifier, period, priceKey, startDateTime, endDateTime, pageSize, nextPage).Technicals;

                //Creats a float list and names it x
                var x = new List <float>();

                //adds every line of the SMA to float list named x
                foreach (var line in smaAverage)
                {
                    var SMA = line.Sma.GetValueOrDefault();
                    x.Add(SMA);
                    //Console.WriteLine(SMA);
                }
                var     firstInList = x.FirstOrDefault();
                decimal firstNum    = Convert.ToDecimal(firstInList);

                // var sum = x.Sum();
                // decimal newSum = Convert.ToDecimal(sum);

                //calls api and gets the lastes price
                var realtimePrice = securityApi.GetSecurityRealtimePrice(identifier);
                var latestPrice   = realtimePrice.LastPrice;

                //converts nullable decemal to decemcial
                decimal?a = latestPrice;
                decimal b = a ?? -1;

                //adds the sum of last 7 day x period sma plus current price then divides by all to get current average sma for x period
                //var sumSMA = newSum + b;
                var totalSMA = firstNum + b;
                var trueSMA  = totalSMA / 2;

                return(trueSMA);
            }
            catch (Exception e)
            {
                decimal trueSMA = 0;
                Console.WriteLine("Exception when calling SecurityApi.GetSecurityPriceTechnicalsSma: " + e.Message);
                return(trueSMA);
            }
        }
Exemple #13
0
 public SecurityApiTests()
 {
     instance = new SecurityApi();
 }
 public SetIntersightSecurityUnit()
 {
     ApiInstance = new SecurityApi(Config);
     ModelObject = new SecurityUnit();
     MethodName  = "UpdateSecurityUnitWithHttpInfo";
 }
 public GetIntersightSecurityUnit()
 {
     ApiInstance = new SecurityApi(Config);
     MethodName  = "GetSecurityUnitListWithHttpInfo";
 }