Exemple #1
0
        public TA(Monitor monitor, TAInfo taInfo, string dllName)
        {
            this.monitor = monitor;

            this.TickTA = new TickTA(monitor);

            // Create KLines storage
            dictKS = new Dictionary<int, RList<KLine>>() 
            { 
                { 0, new RList<KLine>() }       // 缺省有日线
            };                              
            foreach (int p in TAInfo.Periods)
            {
                dictKS[p] = new RList<KLine>();
            }

            // create Formula in taInfo's List
            Assembly assembly = Assembly.LoadFrom(dllName + ".DLL");
            FList = new List<FormulaInfo>();
            foreach (FormulaInfo fi in taInfo.FList)
            {
                FormulaInfo fiClone = fi.Copy();

                Type type = assembly.GetType(string.Format("{0}.{1}_Formula", dllName, fi.Name));
                fiClone.Formula = (TAFormula)Activator.CreateInstance(type, fi.Parameters);

                FList.Add(fiClone);
            }

            BPList = taInfo.BuyPoints;
        }
Exemple #2
0
        private void dgvPool_CellEnter(object sender, DataGridViewCellEventArgs e)
        {
            if (dgvPool.Rows[e.RowIndex].Tag != null)
            { 
                Monitor m = (Monitor)dgvPool.Rows[e.RowIndex].Tag;
                if (currentMonitor != m)
                {
                    currentMonitor = m;
                    currentMonitor.SetFocus();

                    DrawChart(currentMonitor, currentKType);

                    // tickUC and BarUC 
                    tickUC.OnTickArrived(currentMonitor.TA.TickTA);
                    barUC.Clear();
                }
            }
        }
Exemple #3
0
        private void PushPeriodBars(string dtString, Monitor m, Bar bar, float factor)
        {
            // add klines of this symbol
            string symbol = string.Format("{0}.{1}", bar.exchange, bar.sec_id);
            List<Bar> bars = symbolBars[symbol];

            // process periods
            Dictionary<int, Zone> pZone = symbolPeriods[symbol];
            foreach (int p in pZone.Keys)
            {
                int minutes = Utils.GetLastingMinutes(Utils.UtcToDateTime(bar.utc_time));
                if (bars.Count > 0 && minutes - pZone[p].lastM >= p)
                {
                    m.PushBar(SumBars(p, bars, pZone[p].x), factor);

                    pZone[p].x = bars.Count;
                    pZone[p].lastM = (minutes / p) * p;
                }
            }

            m.PushBar(bar, factor);
            bars.Add(bar);
        }
Exemple #4
0
        private void PushPeriodKLines(string dtString, Monitor m, KLine k)
        {
            // add klines of this symbol
            List<KLine> klines = symbolKs[k.Symbol];

            // process periods
            Dictionary<int, Zone> pZone = symbolPeriods[k.Symbol];
            foreach (int p in pZone.Keys)
            {
                int minutes = Utils.GetLastingMinutes(Utils.UtcToDateTime(k.UTC));
                if (klines.Count > 0 && minutes - pZone[p].lastM >= p)
                {
                    m.TA.PushKLine(p, SumKLines(klines, pZone[p].x));

                    pZone[p].x = klines.Count;
                    pZone[p].lastM = (minutes / p) * p;
                }
            }

            m.TA.PushKLine(1, k);
            klines.Add(k);
        }
Exemple #5
0
 private void DrawChart(Monitor m, int ktype)
 {
     object tag = dgvPool.Columns[dgvPool.CurrentCell.ColumnIndex].Tag;
     if (tag == null)
     {
          chartUC.DrawChart(m.TA.GetKLines(ktype), ktype, new List<RList<double>>(), null);
     }
     else
     {
         KeyValuePair<string, List<string>> pair = (KeyValuePair<string, List<string>>)tag;
         chartUC.DrawChart(m.TA.GetKLines(ktype), ktype, m.TA.GetScalarValues(pair.Key, ktype), pair.Value);
     }
 }
Exemple #6
0
 public TickTA(Monitor monitor)
 {
     this.monitor = monitor;
 }
Exemple #7
0
        public MonitorUC(Monitor mon)
        {
            InitializeComponent();

            this.mon = mon;
        }
Exemple #8
0
        // Create
        public MyStrategy(TStrategy s, TLogin login)
        {
            strategyT = s;
            this.gmLogin = login;

            // pm manager
            pm = (PoolManager)Activator.CreateInstance(strategyT.Pool.ManagerType, this, strategyT.Pool);
            // monitors
            TAInfo info = new TAInfo(strategyT.TAInfoParameters);           
            monitors = new Dictionary<string, Monitor>();
            foreach (TInstrument ins in strategyT.Instruments)
            {
                Monitor monitor = new Monitor(this, ins, info, strategyT.DLLName);

                symbols += ins.Symbol + ",";
                monitors.Add(ins.Symbol, monitor);

                if (monitor.Target.Symbol == pm.SymbolBench)
                    monitor.IsBench = true;
            }

            // RiskM
            riskM = new RiskM(this, strategyT.RiskMInfoParameters);

            // heartTimer
            heartTimer = new System.Timers.Timer();
            heartTimer.Elapsed += new System.Timers.ElapsedEventHandler(heartTimer_Elapsed);
            heartTimer.Interval = 1000;     // 1s
        }