コード例 #1
0
        public static void Fix()
        {
            string SIMcontext = @"Data Source=85.214.244.19;Initial Catalog=ALSI_SIM;User ID=SimLogin;Password=boeboe;MultipleActiveResultSets=True";
            var    dc         = new AlsiSimDataContext(SIMcontext);

            foreach (var v in dc.tblResult_5Min_SSPOPs)
            {
                var c = v.Sequence.IndexOf(',');
                var x = v.Sequence.Substring(c + 1);
                var q = new tblResult_5Min_SSPOP()
                {
                    Notes    = "New",
                    Sequence = x,
                    Profit   = v.Profit,
                };
                try
                {
                    dc.tblResult_5Min_SSPOPs.InsertOnSubmit(q);
                    dc.SubmitChanges();
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Skipping " + q.Sequence);
                }
            }
        }
コード例 #2
0
        public static void Fix()
        {

            string SIMcontext = @"Data Source=85.214.244.19;Initial Catalog=ALSI_SIM;User ID=SimLogin;Password=boeboe;MultipleActiveResultSets=True";
            var dc = new AlsiSimDataContext(SIMcontext);

            foreach (var v in dc.tblResult_5Min_SSPOPs)
            {
                var c = v.Sequence.IndexOf(',');
                var x = v.Sequence.Substring(c + 1);
                var q = new tblResult_5Min_SSPOP()
                {
                    Notes = "New",
                    Sequence = x,
                    Profit = v.Profit,

                };
                try
                {
                    dc.tblResult_5Min_SSPOPs.InsertOnSubmit(q);
                    dc.SubmitChanges();
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Skipping " + q.Sequence);
                }
            }
        }
コード例 #3
0
        private void WriteResultsToDatabase(AlsiSimDataContext dc, tblSequence seq, double profit)
        {
            var r = new tblResult_5Min_D()
            {
                Profit   = profit,
                Sequence = seq.Sequence + " l:" + _Seq.Lookback + " H:" + _Seq.Upper + " L:" + _Seq.Lower,
                Trades   = 0,
                Notes    = " l:" + _Seq.Lookback + " H:" + _Seq.Upper + " L:" + _Seq.Lower,
            };

            dc.tblResult_5Min_Ds.InsertOnSubmit(r);
            dc.SubmitChanges();
        }
コード例 #4
0
        public static string GetRandomSequence()
        {
            string SIMcontext = @"Data Source=85.214.244.19;Initial Catalog=ALSI_SIM;User ID=SimLogin;Password=boeboe;MultipleActiveResultSets=True";
            var    dc         = new AlsiSimDataContext(SIMcontext);

            var    rt = dc.GetRandomTable();
            string q  = "None";

            try
            {
                q = rt.Select(x => x.Sequence).First();
            }
            catch (Exception ex)
            {
            }
            return(q);
        }
コード例 #5
0
        public static void SendDatatoDatabase(long lines)
        {
            var max      = lines;
            var current  = 1;
            var interval = 10000;
            var s        = 0;
            var e        = s + interval;

            string SIMcontext = @"Data Source=85.214.244.19;Initial Catalog=ALSI_SIM;User ID=SimLogin;Password=boeboe;MultipleActiveResultSets=True";
            var    dc         = new AlsiSimDataContext(SIMcontext);

Top:


            if (current < max)
            {
                DataTable MinData = new DataTable("tblSequence");
                MinData.Columns.Add("Sequence", typeof(string));
                MinData.Columns.Add("Completed", typeof(bool));



                var lineCount = 0;
                Console.WriteLine("Start reading File");
                using (var reader = File.OpenText(@"D:\seq.txt"))
                {
                    while (reader.ReadLine() != null)
                    {
                        lineCount++;
                        if (lineCount <= e && lineCount > s)
                        {
                            MinData.Rows.Add(reader.ReadLine(), false);
                        }
                        else
                        if (lineCount > e + 1)
                        {
                            break;
                        }
                    }
                }
                current = e;
                s       = e;
                e       = e + interval;

                Console.WriteLine("Sending data to databse lines " + e);
                Debug.WriteLine("Sending data to databse lines " + e);

                DataSet DataSet = new DataSet("Dataset");
                DataSet.Tables.Add(MinData);
                SqlConnection myConnection = new SqlConnection(SIMcontext);
                myConnection.Open();
                SqlBulkCopy bulkcopy = new SqlBulkCopy(myConnection);
                bulkcopy.BulkCopyTimeout      = 500000;
                bulkcopy.DestinationTableName = "tblSequence";
                bulkcopy.WriteToServer(MinData);
                MinData.Dispose();
                myConnection.Close();

                goto Top;
            }
        }
コード例 #6
0
        public static void SendDatatoDatabase(long lines)
        {
            var max = lines;
            var current = 1;
            var interval = 10000;
            var s = 0;
            var e = s + interval;

            string SIMcontext = @"Data Source=85.214.244.19;Initial Catalog=ALSI_SIM;User ID=SimLogin;Password=boeboe;MultipleActiveResultSets=True";
            var dc = new AlsiSimDataContext(SIMcontext);

        Top:
           

            if (current < max)
            {
                DataTable MinData = new DataTable("tblSequence");
                MinData.Columns.Add("Sequence", typeof(string));              
                MinData.Columns.Add("Completed", typeof(bool));



                var lineCount = 0;
                Console.WriteLine("Start reading File");
                using (var reader = File.OpenText(@"D:\seq.txt"))
                {
                    while (reader.ReadLine() != null)
                    {
                        lineCount++;
                        if (lineCount <= e && lineCount > s)
                            MinData.Rows.Add(reader.ReadLine(), false);
                        else
                            if (lineCount > e + 1)
                                break;
                    }
                }
                current = e;
                s = e;
                e = e + interval;

                Console.WriteLine("Sending data to databse lines " + e);
                Debug.WriteLine("Sending data to databse lines " + e);

                DataSet DataSet = new DataSet("Dataset");
                DataSet.Tables.Add(MinData);
                SqlConnection myConnection = new SqlConnection(SIMcontext);
                myConnection.Open();
                SqlBulkCopy bulkcopy = new SqlBulkCopy(myConnection);
                bulkcopy.BulkCopyTimeout = 500000;
                bulkcopy.DestinationTableName = "tblSequence";
                bulkcopy.WriteToServer(MinData);
                MinData.Dispose();
                myConnection.Close();

                goto Top;
            }
        }
コード例 #7
0
        public static string GetRandomSequence()
        {
            string SIMcontext = @"Data Source=85.214.244.19;Initial Catalog=ALSI_SIM;User ID=SimLogin;Password=boeboe;MultipleActiveResultSets=True";
            var dc = new AlsiSimDataContext(SIMcontext);

            var rt = dc.GetRandomTable();
            string q = "None";
            try
            {
                q = rt.Select(x => x.Sequence).First();
            }
            catch (Exception ex)
            {
                
            }
                return q;
        }
コード例 #8
0
        public void Start(string simcontext)
        {
            SIMCONTEXT = simcontext;


            var Prices = GlobalObjects.Points;



            //for (int rsi = 4; rsi < 30; rsi++)
            //    for (int fastK = 3; fastK < 30; fastK++)
            //        for (int slowK = 3; slowK < 30; slowK++)
            //            for (int slowD = 3; slowD < 30; slowD++)
            //            {
            var dc    = new AlsiSimDataContext(simcontext);
            var m     = dc.tblSequences.Where(x => !x.Started).Count();
            var _skip = Utils.RandomNumber(0, m - 1);

            var _sequence = dc.tblSequences.Where(x => !x.Started).Skip(_skip).First();
            var par       = _sequence.Sequence.Split(',');

            //Might cuase duplicates, but chances are slim
            // _sequence.Started = true;
            // dc.SubmitChanges();

            _Seq = new Seq(_sequence.Sequence);
            var rsi   = _Seq.RSI;
            var fastK = _Seq.Fast_K;
            var slowK = _Seq.Slow_K;
            var slowD = _Seq.Slow_D;

            //START LOOOP
            ClearDictionaries();

            var RSI = AlsiUtils.Factory_Indicator.createRSI(rsi, Prices);
            var SS  = AlsiUtils.Factory_Indicator.createSlowStochastic(fastK, slowK, slowD, Prices);


            //CREATE DICTIONARY
            RSI_DIC = RSI.ToDictionary(x => x.TimeStamp, x => Math.Round(x.RSI, 3));
            SS_DIC  = SS.ToDictionary(x => x.TimeStamp, x => Math.Round(x.D, 3));

            //POPULATE
            foreach (var p in Prices)
            {
                RSI_SS_Price rsp = new RSI_SS_Price()
                {
                    ClosePrice = p.Close,
                    Volume     = p.Volume,
                    Stamp      = p.TimeStamp,
                    RSI        = 0,
                    SS         = 0,
                };
                double r, s;
                RSI_DIC.TryGetValue(p.TimeStamp, out r);
                SS_DIC.TryGetValue(p.TimeStamp, out s);

                if (r != 0 && s != 0)
                {
                    rsp.RSI = r;
                    rsp.SS  = s;
                    RSICC.Add(rsp);
                }
            }

            //RUN CALCS
            int lookback = Utils.RandomNumber(5, 15);

            _Seq.Lookback = lookback;
            SetTriggers_A(lookback);
            var profit = AddTradeslayer();

            Console.WriteLine("{0}  {1} {2} {3} {4} LB:{5} H:{6} L:{7}", profit, rsi, fastK, slowK, slowD, _Seq.Lookback, _Seq.Upper, _Seq.Lower);
            WriteResults();
            // WriteResultsToDatabase(dc,_sequence, profit);

            //  Done(this, new EventArgs());

            //END LOOP
            //}
        }
コード例 #9
0
        public void Start(string simcontext)
        {
            SIMCONTEXT = simcontext;
          
         
                var Prices = GlobalObjects.Points;
             
        

            //for (int rsi = 4; rsi < 30; rsi++)
            //    for (int fastK = 3; fastK < 30; fastK++)
            //        for (int slowK = 3; slowK < 30; slowK++)
            //            for (int slowD = 3; slowD < 30; slowD++)
            //            {
            var dc = new AlsiSimDataContext(simcontext);
            var m = dc.tblSequences.Where(x => !x.Started).Count();
            var _skip = Utils.RandomNumber(0, m - 1);

            var _sequence = dc.tblSequences.Where(x => !x.Started).Skip(_skip).First();
            var par = _sequence.Sequence.Split(',');
            //Might cuase duplicates, but chances are slim
           // _sequence.Started = true;
           // dc.SubmitChanges();

            _Seq = new Seq(_sequence.Sequence);
            var rsi = _Seq.RSI;
            var fastK = _Seq.Fast_K;
            var slowK = _Seq.Slow_K;
            var slowD = _Seq.Slow_D;

            //START LOOOP
            ClearDictionaries();

            var RSI = AlsiUtils.Factory_Indicator.createRSI(rsi, Prices);
            var SS = AlsiUtils.Factory_Indicator.createSlowStochastic(fastK, slowK, slowD, Prices);


            //CREATE DICTIONARY 
            RSI_DIC = RSI.ToDictionary(x => x.TimeStamp, x => Math.Round(x.RSI, 3));
            SS_DIC = SS.ToDictionary(x => x.TimeStamp, x => Math.Round(x.D , 3));

            //POPULATE
            foreach (var p in Prices)
            {
                RSI_SS_Price rsp = new RSI_SS_Price()
                {
                    ClosePrice = p.Close,
                    Volume = p.Volume,
                    Stamp = p.TimeStamp,
                    RSI = 0,
                    SS = 0,
                };
                double r, s;
                RSI_DIC.TryGetValue(p.TimeStamp, out r);
                SS_DIC.TryGetValue(p.TimeStamp, out s);

                if (r != 0 && s != 0)
                {
                    rsp.RSI = r;
                    rsp.SS = s;
                    RSICC.Add(rsp);
                }
            }

            //RUN CALCS
            int lookback = Utils.RandomNumber(5, 15);
            _Seq.Lookback = lookback;
            SetTriggers_A(lookback);
            var profit = AddTradeslayer();

            Console.WriteLine("{0}  {1} {2} {3} {4} LB:{5} H:{6} L:{7}", profit, rsi, fastK, slowK, slowD,_Seq.Lookback,_Seq.Upper,_Seq.Lower );
            WriteResults();
           // WriteResultsToDatabase(dc,_sequence, profit);

          //  Done(this, new EventArgs());
           
            //END LOOP
            //}
        }
コード例 #10
0
 private void WriteResultsToDatabase(AlsiSimDataContext dc,tblSequence seq, double profit)
 {
  
     var r = new tblResult_5Min_D()
     {
         Profit=profit,
         Sequence=seq.Sequence+" l:"+_Seq.Lookback+" H:"+_Seq.Upper+" L:"+_Seq.Lower,
         Trades=0,
         Notes = " l:" + _Seq.Lookback + " H:" + _Seq.Upper + " L:" + _Seq.Lower,
     };
     dc.tblResult_5Min_Ds.InsertOnSubmit(r);
     dc.SubmitChanges();
 }