Beispiel #1
0
        static void Main(string[] args)
        {
            string API_Key    = "z5xy8uzid74zcvu5";
            string API_Secret = "yhy9sgcjflq45goxjul3c763dvgncvuw";
            string User_ID    = "DS0416";

            kc = new KC.Kite(API_Key, Debug: true);

            //Clean up the Redis Server.
            Console.WriteLine("Setting up Redis...");
            CleanRedis();

            Console.WriteLine("Generating request token from Kite.");
            //Generate Kite Login URL.
            GenerateURL();

            //Generate Tokens
            GenerateTokens(API_Secret);
            Console.WriteLine();

            //Write all the token into cache
            WriteToCache("api_key", API_Key, DateTime.Parse("11:30 PM"));
            WriteToCache("api_secret", API_Secret, DateTime.Parse("11:30 PM"));
            WriteToCache("user_id", User_ID, DateTime.Parse("11:30 PM"));
        }
 public BuySellStockOnSignal(BuySellOnSignalSymbolConfig config, KiteConnect.Kite kite, SignalSettingInfo signalSettingInfo)
 {
     _config            = config;
     _kite              = kite;
     _signalSettingInfo = signalSettingInfo;
     if (config.ReversalInfoes != null && config.ReversalInfoes.Any())
     {
         _reversalMultiplier = config.ReversalInfoes.GroupBy(s => s.ReversalNumber).ToDictionary(key => key.Key, value => value.FirstOrDefault().Multiplier);
     }
 }
 public async void Start(TimeSpan interval, KiteConnect.Kite kite, IEnumerable <string> instruments)
 {
     _kite            = kite;
     this.instruments = instruments.ToList();
     symbolsInChunlk  = GetStockSymbolsInChunk(this.instruments, 200);
     if (_isCancelled)
     {
         _isCancelled = false;
         await CheckHighLowTick();
     }
 }
        public void Start(BuySellOnSignalSymbolConfig stock, KiteConnect.Kite kite, SignalSettingInfo settingInfo)
        {
            var clonnedStock = stock.DeepCopy <BuySellOnSignalSymbolConfig>();

            clonnedStock.StartTime = stock.StartTime;
            var clonnedSetting = settingInfo != null?settingInfo.DeepCopy <SignalSettingInfo>() : new SignalSettingInfo();

            BuySellStockOnSignal signal = new BuySellStockOnSignal(clonnedStock, kite, clonnedSetting);

            var addedstock = _configuresStocks.FirstOrDefault(s => s.IsMatchSymbol(clonnedStock.Exchange, clonnedStock.Symbol));

            if (addedstock != null)
            {
                addedstock.Reset();
                _configuresStocks.Remove(addedstock);
            }
            _kite = kite;
            signal.Start();

            _configuresStocks.Add(signal);
        }
Beispiel #5
0
        public async Task <ActionResult> Index(LoginViewmodel model)
        {
            if (ModelState.IsValid)
            {
                kite = new KiteConnect.Kite(APIKey: model.ApiKey, Debug: true);

                User user             = kite.GenerateSession(model.RequestToken, model.ApiSecret);
                var  userSessionModel = new UserSessionModel()
                {
                    AccessToken = user.AccessToken,
                    ApiKey      = model.ApiKey,
                    AppSecret   = model.ApiSecret,
                    UserId      = model.ZerodhaUserId,
                    PublicToken = user.PublicToken
                };
                await _userSessionService.SetCurrentSession(userSessionModel);

                Session["userSession"] = userSessionModel;
                return(RedirectToAction("Index", "Home"));
            }
            ModelState.AddModelError("Something went wrong", "please contact admin");
            return(View(model));
        }
 private void Events_GiveKiteInstanceEvent(Kite kite)
 {
     _kite = kite;
     Events.GiveKiteInstanceEvent -= Events_GiveKiteInstanceEvent;
 }
 public ZerodhaBroker(UserSessionModel userSession)
 {
     _kite               = new KiteConnect.Kite(userSession.ApiKey, userSession.AccessToken);
     _userSession        = userSession;
     _brokerOrderService = new BrokerOrderService();
 }