Ejemplo n.º 1
0
        public FormTrade(IPlugin_MarketTrader trader, IDataNavigate dataNavigater)
        {
            InitializeComponent();

            this.trader = trader;
            this.trader.OnReturnOrder         = OnReturnOrder;
            this.trader.OnReturnTrade         = OnReturnTrade;
            this.trader.OnRspInvestorPosition = OnReturnInvestorPosition;
            this.trader.OnRspOrder            = OnRspOrders;
            this.trader.OnRspTrade            = OnRspTrade;

            this.dataNavigater = dataNavigater;
            this.dataNavigater.OnNavigateTo += RealTimeDataReader_OnNavigateTo;

            this.tbCode.Text                = dataNavigater.Code;
            this.numberPrice.Value          = dataNavigater.Price;
            this.numberPrice.OnStateChange += NumberPrice_OnStateChange;
            this.numberPrice.MinPeriod      = 1;
            this.numberPrice.NormalText     = "当前价";
            this.numberMount.IsInputState   = true;
            this.numberMount.MinValue       = 0;
            this.numberMount.MinPeriod      = 1;

            this.trader.QueryPosition();
            this.trader.QueryOrders();
            this.trader.QueryTrades();
        }
Ejemplo n.º 2
0
 private void DataNavigate_OnNavigateTo(object sender, DataNavigateEventArgs e)
 {
     IDataNavigate dataNavigate = (IDataNavigate)sender;
     if (e.Time >= 20170405.093010)
         dataNavigate.Pause();
     Console.WriteLine(getKLineBar(dataNavigate));
 }
Ejemplo n.º 3
0
 public ChartComponentController(IDataNavigate dataNavigater, ChartComponentData ChartComponentData)
 {
     this.chartComponentData             = ChartComponentData;
     this.prevChartComponentData         = (ChartComponentData)ChartComponentData.Clone();
     this.currentNavigater               = dataNavigater;
     this.currentNavigater.OnNavigateTo += CurrentNavigater_OnNavigateTo;
 }
Ejemplo n.º 4
0
        public void TestNavigate()
        {
            string code = "rb1705";
            double time = 20170405.093001;
            IDataNavigate dataNavigate = DataCenter.Default.DataNavigateFactory.CreateDataNavigate(code, time);

            Assert.AreEqual("20170405.093001,3470,3470,3470,3470,272,943840,731414", dataNavigate.GetKLineData(KLinePeriod.KLinePeriod_1Minute).ToString());

            time = 20170405.093058;
            bool canNav = dataNavigate.NavigateTo(time);
            Assert.IsTrue(canNav);
            Assert.AreEqual("20170405.093058,3470,3470,3463,3463,1062,3681108,731424", dataNavigate.GetKLineData(KLinePeriod.KLinePeriod_1Minute).ToString());

            time = 20170405.093059;
            canNav = dataNavigate.NavigateTo(time);
            Assert.IsTrue(canNav);
            string str = "20170405.093,3470,3470,3463,3463,1062,0,731424";
            Assert.AreEqual(str, dataNavigate.GetKLineData(KLinePeriod.KLinePeriod_1Minute).ToString());

            dataNavigate.Change("rb1710");
            Console.WriteLine(dataNavigate.GetKLineData(KLinePeriod.KLinePeriod_1Minute));
            Assert.AreEqual("20170405.093059,3260,3262,3252,3252,33892,1.104346E+08,2476612", dataNavigate.GetKLineData(KLinePeriod.KLinePeriod_1Minute).ToString());

            dataNavigate.Change("rb1705");
            Assert.AreEqual(str, getKLineBar(dataNavigate));

            bool canForward = dataNavigate.Forward(KLinePeriod.KLinePeriod_5Minute);
            Console.WriteLine(getKLineBar(dataNavigate));

            dataNavigate.NavigateTo(20160603.093000);
            Console.WriteLine(dataNavigate.GetKLineData(KLinePeriod.KLinePeriod_1Minute));
        }
Ejemplo n.º 5
0
        public IDataNavigate GetDataNavigate(string code, double time)
        {
            if (dicDataNavigate.ContainsKey(code))
            {
                return(dicDataNavigate[code]);
            }
            IDataNavigate nav = CreateDataNavigate(code, time);

            dicDataNavigate.Add(code, nav);
            return(nav);
        }
Ejemplo n.º 6
0
        public void Init(IDataCenter dataCenter, string code, double time, KLinePeriod klinePeriod)
        {
            this.dataCenter = dataCenter;
            IDataNavigate      dataNavigater  = dataCenter.DataNavigateFactory.CreateDataNavigate(code, time);
            IKLineData         klineData      = dataNavigater.GetKLineData(klinePeriod);
            int                showKLineIndex = klineData.BarPos;
            ChartComponentData compData       = new ChartComponentData(code, time, klinePeriod, showKLineIndex);

            this.controller = new ChartComponentController(dataNavigater, compData);
            this.drawer     = new ChartComponentDrawer(this, controller);
            //this.drawer.GraphicData_Candle.OnGraphicDataChange += GraphicData_Candle_OnGraphicDataChange;
            this.drawer.GraphicDrawer.AfterGraphicPaint += GraphicDrawer_AfterGraphicPaint;
        }
Ejemplo n.º 7
0
        //[TestMethod]
        public void TestNavigate_Play()
        {
            string code = "rb1710";
            double time = 20170405.093001;
            IDataNavigate dataNavigate = DataCenter.Default.DataNavigateFactory.CreateDataNavigate(code, time);

            dataNavigate.OnNavigateTo += DataNavigate_OnNavigateTo;
            dataNavigate.Play();

            while (dataNavigate.IsPlaying)
            {

            }
        }
Ejemplo n.º 8
0
        public FormTradeBak(IPlugin_MarketTrader trader, IDataNavigate dataNavigater)
        {
            InitializeComponent();
            this.trader = trader;
            this.trader.OnReturnOrder            = OnReturnOrder;
            this.trader.OnReturnTrade            = OnReturnTrade;
            this.trader.OnReturnInvestorPosition = OnReturnInvestorPosition;

            this.dataNavigater = dataNavigater;
            this.dataNavigater.OnNavigateTo += RealTimeDataReader_OnNavigateTo;

            this.tbCode.Text  = dataNavigater.Code;
            this.tbPrice.Text = dataNavigater.Price.ToString();
        }
Ejemplo n.º 9
0
        public FormChartComponentDrawer()
        {
            InitializeComponent();

            string             code           = "rb1710";
            double             time           = 20170601.093055;
            KLinePeriod        klinePeriod    = KLinePeriod.KLinePeriod_1Minute;
            IDataNavigate      dataNavigater  = DataCenter.Default.DataNavigateFactory.CreateDataNavigate(code, time);
            IKLineData         klineData      = dataNavigater.GetKLineData(klinePeriod);
            int                showKLineIndex = klineData.BarPos;
            ChartComponentData compData       = new ChartComponentData(code, time, klinePeriod, showKLineIndex);

            controller = new ChartComponentController(dataNavigater, compData);

            ChartComponentDrawer drawer = new ChartComponentDrawer(this, controller);
            //drawer.RePaint();
        }
Ejemplo n.º 10
0
        public void TestController()
        {
            string                   code           = "rb1710";
            double                   time           = 20170601.093055;
            KLinePeriod              klinePeriod    = KLinePeriod.KLinePeriod_1Minute;
            IDataNavigate            dataNavigater  = DataCenter.Default.DataNavigateFactory.CreateDataNavigate(code, time);
            IKLineData               klineData      = dataNavigater.GetKLineData(klinePeriod);
            int                      showKLineIndex = klineData.BarPos;
            ChartComponentData       compData       = new ChartComponentData(code, time, klinePeriod, showKLineIndex);
            ChartComponentController controller     = new ChartComponentController(dataNavigater, compData);

            IRealTimeData_Code reader       = controller.CurrentRealTimeDataReader_Code;
            IKLineData         currentKLine = reader.GetKLineData(klinePeriod);

            Assert.AreEqual(compData.Code, currentKLine.Code);
            Assert.AreEqual(compData.Time, currentKLine.Time);
            Assert.AreEqual(compData.ShowKLineIndex, currentKLine.BarPos);
            Console.WriteLine(currentKLine);

            controller.Change("rb1801");
            currentKLine = reader.GetKLineData(klinePeriod);
            Assert.AreEqual(compData.Code, currentKLine.Code);
            Assert.AreEqual(compData.Time, currentKLine.Time);
            Assert.AreEqual(compData.ShowKLineIndex, currentKLine.BarPos);
            Console.WriteLine(currentKLine);

            controller.Change(code);
            currentKLine = reader.GetKLineData(klinePeriod);
            Assert.AreEqual(compData.Code, currentKLine.Code);
            Assert.AreEqual(compData.Time, currentKLine.Time);
            Assert.AreEqual(compData.ShowKLineIndex, currentKLine.BarPos);
            Console.WriteLine(currentKLine);
            controller.ChangeChartType(ChartType.TimeLine);
            Console.WriteLine(compData);

            controller.Change(20170601.100531);
            controller.ChangeChartType(ChartType.KLine);
            Console.WriteLine(reader.GetKLineData(compData.KlinePeriod));
            Console.WriteLine(compData);

            controller.Change("rb1801", 20171014.093000, KLinePeriod.KLinePeriod_1Minute);
            Console.WriteLine(compData);
        }
Ejemplo n.º 11
0
        public void TestPlay()
        {
            string                   code           = "rb1710";
            double                   time           = 20170601.093055;
            IDataNavigate            dataNavigater  = DataCenter.Default.DataNavigateFactory.CreateDataNavigate(code, time);
            KLinePeriod              klinePeriod    = KLinePeriod.KLinePeriod_1Minute;
            IKLineData               klineData      = dataNavigater.GetKLineData(klinePeriod);
            int                      showKLineIndex = klineData.BarPos;
            ChartComponentData       compData       = new ChartComponentData(code, time, klinePeriod, showKLineIndex);
            ChartComponentController controller     = new ChartComponentController(dataNavigater, compData);

            controller.OnDataChanged += Controller_OnDataChanged;
            //controller.Play();
            //while (controller.IsPlayIng)
            //{

            //}

            //while(time<2017)
        }
Ejemplo n.º 12
0
 public GraphicOperator_CurrentInfo_Nav(IDataNavigate dataNavigate)
 {
     this.dataNavigate = dataNavigate;
 }
Ejemplo n.º 13
0
 public GraphicDataProvider_RealNav(DataReaderFactory dataReaderFac, IDataNavigate dataNavigate)
 {
     this.dataReaderFac = dataReaderFac;
     this.dataNavigate  = dataNavigate;
 }
Ejemplo n.º 14
0
 private static string getKLineBar(IDataNavigate dataNavigate)
 {
     return dataNavigate.GetKLineData(KLinePeriod.KLinePeriod_1Minute).ToString();
 }