示例#1
0
        private void btnOpen_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog ofd = new OpenFileDialog();
                Stream str = null;
                XmlSerializer xs = new XmlSerializer(typeof(Session));

                ofd.Filter = "spread profiles (*.xml)|*.xml";
                ofd.FilterIndex = 1;
                ofd.RestoreDirectory = true;

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    if ((str = ofd.OpenFile()) != null)
                    {
                        using (str)
                            session = (Session)xs.Deserialize(str);

                        pgInstrumentA.SelectedObject = session.instrumentA;
                        pgInstrumentB.SelectedObject = session.instrumentB;
                        pgSpread.SelectedObject = session.spread;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#2
0
文件: Session.cs 项目: axs/ezspreader
        public static Session getInstance()
        {
            if (instance == null)
                instance = new Session();

            return instance;
        }
示例#3
0
        public void Connect(Session s)
        {
            productOne = new InstrumentProc(s.instrumentA);
            productTwo = new InstrumentProc(s.instrumentB);

            instruments = new List<Instrument>();
            instruments.Add(s.instrumentA);
            instruments.Add(s.instrumentB);

            productOne.init(TTInstrNotify);
            productTwo.init(TTInstrNotify);

            //setup the events
            TTGate.OnStatusUpdate += new XTAPI._ITTGateEvents_OnStatusUpdateEventHandler(this.OnStatusUpdate);

            productOne.ttOrderSet.OnOrderFillData += new XTAPI._ITTOrderSetEvents_OnOrderFillDataEventHandler(this.OnOrderFillData);
            TTInstrNotify.OnNotifyFound += new XTAPI._ITTInstrNotifyEvents_OnNotifyFoundEventHandler(productOne.OnNotifyFound);
            TTInstrNotify.OnNotifyFound += new XTAPI._ITTInstrNotifyEvents_OnNotifyFoundEventHandler(productTwo.OnNotifyFound);
            TTInstrNotify.OnNotifyUpdate += new XTAPI._ITTInstrNotifyEvents_OnNotifyUpdateEventHandler(this.OnNotifyUpdate);

            productTwo.ttOrderSet.OnOrderFillData += new XTAPI._ITTOrderSetEvents_OnOrderFillDataEventHandler(this.OnOrderFillData);

            if (log.IsInfoEnabled)
            {

                log.Info("trading started for spread");
            }

            setLogname();

            /*
            XTAPI.InstrCollection colInst = (XTAPI.InstrCollection)TTGate.Instruments;
            for (int i = 1; i <= colInst.Count; ++i)
            {
                XTAPI.TTInstrObj instr = (XTAPI.TTInstrObj)colInst[i];
               }
            */
        }
示例#4
0
 public void resetStrategy(Session session)
 {
     signal.resetparams( new object[] { session.spread.Threshold
                                       ,session.spread.TrendFollow
                                       ,session.spread.PriceLength
                                       ,session.spread.Signal });
     spread = session.spread;
 }
示例#5
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                session = Session.getInstance();
                XmlSerializer xs = new XmlSerializer(typeof(Session));

                using (Stream str = File.OpenRead(this.Config))
                    session = (Session)xs.Deserialize(str);

                procSpread = SpreadProc.getInstance();
                procSpread.OnUpdate += new EventHandler<UpdateEventArgs>(procSpread_OnUpdate);

                procStrategy = StrategyProc.getInstance(session.spread);

                //procStrategy.OnZscoreEvt += this.OnZscore;

                pgInstrumentA.SelectedObject = session.instrumentA;
                pgInstrumentB.SelectedObject = session.instrumentB;
                pgSpread.SelectedObject = session.spread;

            }
            catch(Exception ex){
                MessageBox.Show(ex.Message);
            }
        }