示例#1
0
 public bool Login(string requestToken)
 {
     try
     {
         RequestToken = requestToken;
         User user = Kite.GenerateSession(requestToken, MySecret);
         MyPublicToken = user.PublicToken;
         MyAccessToken = user.AccessToken;
         Kite.SetAccessToken(MyAccessToken);
         //Kite.GetLTP(new string[] { "NSE:MEGH", "NSE:GTLINFRA" });
         //for (int i = 0; i < 2; i++)
         //{
         //    Kite k = new Kite(MyAPIKey, Debug:true);
         //    RequestToken = requestToken;
         //  //  User user1 = k.GenerateSession(requestToken, MySecret);
         //    k.SetAccessToken(MyAccessToken);
         //    k.GetLTP(new string[] { "NSE:SUBEX","NSE:SBI" });
         //}
         //StartPositionAsync();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
示例#2
0
        public void TestSetAccessToken()
        {
            Kite kite = new Kite("apikey");

            kite.SetAccessToken("access_token");
            Assert.ThrowsException <TokenException>(() => kite.GetPositions());
        }
示例#3
0
 private void WatchLTP()
 {
     try
     {
         var ltps = Kite.GetLTP(_configuredStocksForLTP.ToArray());
         foreach (var item in ltps)
         {
             try
             {
                 if (_cachedStockLtp[item.Key] != item.Value.LastPrice)
                 {
                     Events.RaiseStockLTPChangedEvent(item.Key, item.Value.LastPrice);
                     _cachedStockLtp[item.Key] = item.Value.LastPrice;
                 }
             }
             catch (KeyNotFoundException)
             {
                 Events.RaiseStockLTPChangedEvent(item.Key, item.Value.LastPrice);
                 _cachedStockLtp[item.Key] = item.Value.LastPrice;
             }
         }
     }
     catch (Exception ex)
     {
     }
 }
        //
        // Kite(A, B, C, D) -> Perpendicular(Intersection(Segment(A, C), Segment(B, D))
        //
        public static List <EdgeAggregator> Instantiate(GroundedClause clause)
        {
            annotation.active = EngineUIBridge.JustificationSwitch.DIAGONALS_OF_KITE_ARE_PERPENDICULAR;

            List <EdgeAggregator> newGrounded = new List <EdgeAggregator>();

            if (clause is Kite)
            {
                Kite kite = clause as Kite;

                newGrounded.AddRange(InstantiateToTheorem(kite, kite));
            }
            else if (clause is Strengthened)
            {
                Strengthened streng = clause as Strengthened;

                if (!(streng.strengthened is Kite))
                {
                    return(newGrounded);
                }

                newGrounded.AddRange(InstantiateToTheorem(streng.strengthened as Kite, streng));
            }

            return(newGrounded);
        }
示例#5
0
        public void TestOrderMargins()
        {
            string json = File.ReadAllText(@"responses/order_margins.json", Encoding.UTF8);

            ms.SetResponse("application/json", json);
            Kite kite = new Kite("apikey", Root: "http://localhost:8080");

            OrderMarginParams param = new OrderMarginParams();

            param.Exchange        = Constants.EXCHANGE_NFO;
            param.TradingSymbol   = "ASHOKLEY20NOVFUT";
            param.TransactionType = Constants.TRANSACTION_TYPE_SELL;
            param.Quantity        = 1;
            param.Price           = 64.0000m;
            param.OrderType       = Constants.ORDER_TYPE_MARKET;
            param.Product         = Constants.PRODUCT_MIS;

            List <OrderMargin> margins = kite.GetOrderMargins(new List <OrderMarginParams>()
            {
                param
            });

            Assert.AreEqual(margins[0].Total, (decimal)8.36025);
            Assert.AreEqual(margins[0].SPAN, (decimal)5.408);
        }
示例#6
0
 private static KiteDto KiteToDto(Kite kite)
 {
     return(new KiteDto()
     {
         KiteId = kite.Id, KiteModelId = kite.KiteModelId, PrincipalColor = kite.PrincipalColor, PurchaseDate = kite.PurchaseDate, Size = kite.Size
     });
 }
示例#7
0
        public void TestBasketMarginsCompact()
        {
            string json = File.ReadAllText(@"responses/basket_margins_compact.json", Encoding.UTF8);

            ms.SetResponse("application/json", json);
            Kite kite = new Kite("apikey", Root: "http://localhost:8080");

            OrderMarginParams param = new OrderMarginParams();

            param.Exchange        = Constants.EXCHANGE_NFO;
            param.TradingSymbol   = "ASHOKLEY21JULFUT";
            param.TransactionType = Constants.TRANSACTION_TYPE_SELL;
            param.Quantity        = 1;
            param.Price           = 64.0000m;
            param.OrderType       = Constants.ORDER_TYPE_MARKET;
            param.Product         = Constants.PRODUCT_MIS;

            OrderMarginParams param2 = new OrderMarginParams();

            param2.Exchange       = Constants.EXCHANGE_NFO;
            param2.TradingSymbol  = "NIFTY21JUL15000PE";
            param.TransactionType = Constants.TRANSACTION_TYPE_BUY;
            param2.Quantity       = 75;
            param2.Price          = 300;
            param2.Product        = Constants.PRODUCT_MIS;
            param2.OrderType      = Constants.ORDER_TYPE_LIMIT;

            BasketMargin margins = kite.GetBasketMargins(new List <OrderMarginParams>()
            {
                param, param2
            }, Mode: Constants.MARGIN_MODE_COMPACT);

            Assert.AreEqual(margins.Final.Total, (decimal)22530.2280825);
            Assert.AreEqual(margins.Final.SPAN, (decimal)0);
        }
示例#8
0
 public static void RaiseGiveKiteInstanceEvent(Kite kite)
 {
     if (GiveKiteInstanceEvent != null)
     {
         GiveKiteInstanceEvent(kite);
     }
 }
示例#9
0
        static void Main(string[] args)
        {
            kite = new Kite(MyAPIKey, Debug: true);

            // For handling 403 errors

            kite.SetSessionExpiryHook(OnTokenExpire);

            // Initializes the login flow

            try
            {
                initSession();

                kite.SetAccessToken(MyAccessToken);

                // Initialize ticker

                initTicker();
                Console.ReadKey();

                // Disconnect from ticker
                // ticker.Close();
            }
            catch (Exception e)
            {
                // Cannot continue without proper authentication
                Console.WriteLine(e.Message);
                //Console.ReadKey();
                Environment.Exit(0);
            }
        }
示例#10
0
        public void Initialize(string accessToken)
        {
            Kite = new Kite(apiKey, Debug: false);
            Kite.SetSessionExpiryHook(OnTokenExpire);

            Kite.SetAccessToken(accessToken);
            Ticker = new Ticker(apiKey, accessToken);
        }
示例#11
0
        public Kite GetKite(UserInfo userInfo)
        {
            var kite = new Kite(userInfo.APIKey, Debug: false);

            kite.SetSessionExpiryHook(onTokenExpire);
            Kite.SetAccessToken(MyAccessToken);
            return(kite);
        }
示例#12
0
        public string GetLoginURL()
        {
            Kite = new Kite(MyAPIKey, Debug: true);
            Kite.SetSessionExpiryHook(onTokenExpire);
            var loginURL = Kite.GetLoginURL();

            return(loginURL);
        }
示例#13
0
        public IActionResult Login()
        {
            Kite kc = new Kite("z5xy8uzid74zcvu5");

            ViewData["LoginURL"] = kc.GetLoginURL();

            return(View());
        }
示例#14
0
        public void TestOrders()
        {
            string       json   = File.ReadAllText(@"C:\Users\ssijb\source\repos\ssijbabu\crudify\KiteonnectUnitTest\responses\orders.json", Encoding.UTF8);
            MockServer   ms     = new MockServer("http://localhost:8080/", "application/json", json);
            Kite         kite   = new Kite("apikey", Root: "http://localhost:8080");
            List <Order> orders = kite.GetOrders();

            Assert.Equal(90, orders[0].Price);
        }
        public void TestMFInstruments()
        {
            string              csv         = File.ReadAllText(@"responses\mf_instruments.csv", Encoding.UTF8);
            MockServer          ms          = new MockServer("http://localhost:8080/", "text/csv", csv);
            Kite                kite        = new Kite("apikey", Root: "http://localhost:8080");
            List <MFInstrument> instruments = kite.GetMFInstruments();

            Assert.AreEqual(instruments[0].TradingSymbol, "INF209K01157");
        }
示例#16
0
        public void TestCommodityMargins()
        {
            string     json   = File.ReadAllText(@"C:\Users\ssijb\source\repos\ssijbabu\crudify\KiteonnectUnitTest\responses\equity_margins.json", Encoding.UTF8);
            MockServer ms     = new MockServer("http://localhost:8080/", "application/json", json);
            Kite       kite   = new Kite("apikey", Root: "http://localhost:8080");
            UserMargin margin = kite.GetMargins("commodity");

            Assert.Equal(margin.Net, (decimal)1812.3535);
        }
示例#17
0
        public void TestOHLC()
        {
            string     json = File.ReadAllText(@"C:\Users\ssijb\source\repos\ssijbabu\crudify\KiteonnectUnitTest\responses\ohlc.json", Encoding.UTF8);
            MockServer ms   = new MockServer("http://localhost:8080/", "application/json", json);
            Kite       kite = new Kite("apikey", Root: "http://localhost:8080");
            Dictionary <string, OHLC> ohlcs = kite.GetOHLC(new string[] { "408065", "NSE:INFY" });

            Assert.Equal(ohlcs["408065"].LastPrice, (decimal)966.8);
        }
示例#18
0
        public void TestMFInstruments()
        {
            string              csv         = File.ReadAllText(@"C:\Users\ssijb\source\repos\ssijbabu\crudify\KiteonnectUnitTest\responses\mf_instruments.csv", Encoding.UTF8);
            MockServer          ms          = new MockServer("http://localhost:8080/", "text/csv", csv);
            Kite                kite        = new Kite("apikey", Root: "http://localhost:8080");
            List <MFInstrument> instruments = kite.GetMFInstruments();

            Assert.Equal("INF209K01157", instruments[0].TradingSymbol);
        }
示例#19
0
        public void TestHoldings()
        {
            string         json     = File.ReadAllText(@"C:\Users\ssijb\source\repos\ssijbabu\crudify\KiteonnectUnitTest\responses\holdings.json", Encoding.UTF8);
            MockServer     ms       = new MockServer("http://localhost:8080/", "application/json", json);
            Kite           kite     = new Kite("apikey", Root: "http://localhost:8080");
            List <Holding> holdings = kite.GetHoldings();

            Assert.Single(holdings);
        }
示例#20
0
        public void TestProfile()
        {
            string     json    = File.ReadAllText(@"C:\Users\ssijb\source\repos\ssijbabu\crudify\KiteonnectUnitTest\responses\profile.json", Encoding.UTF8);
            MockServer ms      = new MockServer("http://*****:*****@gmail.com", profile.Email);
        }
示例#21
0
        public void TestMFOrder()
        {
            string     json  = File.ReadAllText(@"C:\Users\ssijb\source\repos\ssijbabu\crudify\KiteonnectUnitTest\responses\mf_order.json", Encoding.UTF8);
            MockServer ms    = new MockServer("http://localhost:8080/", "application/json", json);
            Kite       kite  = new Kite("apikey", Root: "http://localhost:8080");
            MFOrder    order = kite.GetMFOrders("123123");

            Assert.Equal("123123", order.OrderId);
        }
示例#22
0
        public void TestTrades()
        {
            string       json   = File.ReadAllText(@"C:\Users\ssijb\source\repos\ssijbabu\crudify\KiteonnectUnitTest\responses\trades.json", Encoding.UTF8);
            MockServer   ms     = new MockServer("http://localhost:8080/", "application/json", json);
            Kite         kite   = new Kite("apikey", Root: "http://localhost:8080");
            List <Trade> trades = kite.GetOrderTrades("151220000000000");

            Assert.Equal("159918", trades[0].TradeId);
        }
示例#23
0
        public void TestMFSIPs()
        {
            string       json = File.ReadAllText(@"C:\Users\ssijb\source\repos\ssijbabu\crudify\KiteonnectUnitTest\responses\mf_sips.json", Encoding.UTF8);
            MockServer   ms   = new MockServer("http://localhost:8080/", "application/json", json);
            Kite         kite = new Kite("apikey", Root: "http://localhost:8080");
            List <MFSIP> sips = kite.GetMFSIPs();

            Assert.Equal("1234", sips[0].SIPId);
        }
示例#24
0
        public void TestSegmentInstruments()
        {
            string            csv         = File.ReadAllText(@"C:\Users\ssijb\source\repos\ssijbabu\crudify\KiteonnectUnitTest\responses\instruments_nse.csv", Encoding.UTF8);
            MockServer        ms          = new MockServer("http://localhost:8080/", "text/csv", csv);
            Kite              kite        = new Kite("apikey", Root: "http://localhost:8080");
            List <Instrument> instruments = kite.GetInstruments(Constants.EXCHANGE_NSE);

            Assert.Equal(instruments[0].InstrumentToken, (uint)3813889);
        }
        public void TestHoldings()
        {
            string         json     = File.ReadAllText(@"responses\holdings.json", Encoding.UTF8);
            MockServer     ms       = new MockServer("http://localhost:8080/", "application/json", json);
            Kite           kite     = new Kite("apikey", Root: "http://localhost:8080");
            List <Holding> holdings = kite.GetHoldings();

            Assert.AreEqual(holdings.Count, 1);
        }
        public void TestCommodityMargins()
        {
            string     json   = File.ReadAllText(@"responses\equity_margins.json", Encoding.UTF8);
            MockServer ms     = new MockServer("http://localhost:8080/", "application/json", json);
            Kite       kite   = new Kite("apikey", Root: "http://localhost:8080");
            UserMargin margin = kite.GetMargins("commodity");

            Assert.AreEqual(margin.Net, (decimal)1812.3535);
        }
示例#27
0
        public void TestQuote()
        {
            string     json = File.ReadAllText(@"C:\Users\ssijb\source\repos\ssijbabu\crudify\KiteonnectUnitTest\responses\quote.json", Encoding.UTF8);
            MockServer ms   = new MockServer("http://localhost:8080/", "application/json", json);
            Kite       kite = new Kite("apikey", Root: "http://localhost:8080");
            Dictionary <string, Quote> quotes = kite.GetQuote(new string[] { "NSE:INFY" });

            Assert.Equal(quotes["NSE:INFY"].LastPrice, (decimal)1034.25);
        }
示例#28
0
 public void Start(Kite kite)
 {
     _isCancelled = false;
     this.Status  = JobbingStatus.Running;
     UpdateStockActionPrice();
     Kite = kite;
     RaiseStatusPropertyChanged();
     StartJobbing();
 }
示例#29
0
        public static Composite CreateMageInitialize()
        {
            if (SingularRoutine.CurrentWoWContext == WoWContext.Normal || SingularRoutine.CurrentWoWContext == WoWContext.Battlegrounds)
            {
                Kite.CreateKitingBehavior(CreateSlowMeleeBehavior(), null, null);
            }

            return(null);
        }
示例#30
0
        public void TestOrderInfo()
        {
            string       json         = File.ReadAllText(@"C:\Users\ssijb\source\repos\ssijbabu\crudify\KiteonnectUnitTest\responses\orderinfo.json", Encoding.UTF8);
            MockServer   ms           = new MockServer("http://localhost:8080/", "application/json", json);
            Kite         kite         = new Kite("apikey", Root: "http://localhost:8080");
            List <Order> orderhistory = kite.GetOrderHistory("171124000819854");

            Assert.Equal(100, orderhistory[0].PendingQuantity);
        }