Exemplo n.º 1
0
        protected override void OnSetPortfolio(Account.PortfolioVM portfVm)
        {
            ScalperSetting settings = (ScalperSetting)portfVm.StrategySetting;

            this.Threshold           = settings.Threshold;
            this.PriceTick           = settings.PriceTick;
            this.CaseGE4Tick         = settings.CaseGE4Tick;
            this.CaseLE2Tick         = settings.CaseLE2Tick;
            this.CaseLE3Tick         = settings.CaseLE3Tick;
            this.CaseNoChange        = settings.CaseNoChange;
            this.StopLossCloseMethod = settings.StopLossCloseMethod;
            this.RetryTimes          = settings.RetryTimes;
            this.OpenTimeout         = settings.OpenTimeout;
        }
Exemplo n.º 2
0
        public override void CopyFrom(StrategySetting settings)
        {
            ScalperSetting strategySettings = (ScalperSetting)settings;

            Threshold           = strategySettings.Threshold;
            PriceTick           = strategySettings.PriceTick;
            CaseLE2Tick         = strategySettings.CaseLE2Tick;
            CaseLE3Tick         = strategySettings.CaseLE3Tick;
            CaseGE4Tick         = strategySettings.CaseGE4Tick;
            CaseNoChange        = strategySettings.CaseNoChange;
            StopLossCloseMethod = strategySettings.StopLossCloseMethod;
            RetryTimes          = strategySettings.RetryTimes;
            OpenTimeout         = strategySettings.OpenTimeout;
        }
Exemplo n.º 3
0
        protected override void OnApplySetting()
        {
            ScalperSetting settings = (ScalperSetting)CurrentPortfolio.StrategySetting;

            settings.Threshold           = this.Threshold;
            settings.PriceTick           = this.PriceTick;
            settings.CaseGE4Tick         = this.CaseGE4Tick;
            settings.CaseLE2Tick         = this.CaseLE2Tick;
            settings.CaseLE3Tick         = this.CaseLE3Tick;
            settings.CaseNoChange        = this.CaseNoChange;
            settings.StopLossCloseMethod = this.StopLossCloseMethod;
            settings.RetryTimes          = this.RetryTimes;
            settings.OpenTimeout         = this.OpenTimeout;

            base.OnApplySetting();
        }
Exemplo n.º 4
0
        public static StrategySetting Create(string name)
        {
            StrategySetting setting = null;

            switch (name)
            {
            case ArbitrageStrategyName:
                setting = new ArbitrageStrategySetting();
                break;

            case ChangePositionStrategyName:
                setting = new ChangePositionSetting();
                break;

            case ScalperStrategyName:
                setting = new ScalperSetting();
                break;

            case MACDHistSlopeStrategyName:
                setting = new MACDHistSlopeStrategySetting();
                break;

            case WMATrendStrategyName:
                setting = new WMATrendStrategySettings();
                break;

            case LinerRegressionStrategyName:
                setting = new LinerRegStrategySettings();
                break;

            case ASCTrendStrategyName:
                setting = new ASCTrendStrategySettings();
                break;

            case RangeTrendStrategyName:
                setting = new RangeTrendStrategySettings();
                break;

            case ManualStrategyName:
                setting = new ManualStrategySetting();
                break;

            default:
                throw new ArgumentException(string.Format("Unexpected strategy setting ({0})", name));
            }
            return(setting);
        }
Exemplo n.º 5
0
        public static StrategySetting Create(string name)
        {
            if (name == ArbitrageStrategyName)
            {
                ArbitrageStrategySetting setting = new ArbitrageStrategySetting();
                setting.Direction         = entity.PosiDirectionType.LONG;
                setting.OpenCondition     = CompareCondition.LESS_EQUAL_THAN;
                setting.OpenThreshold     = 0;
                setting.StopGainCondition = CompareCondition.GREATER_THAN;
                setting.StopGainThreshold = 0;
                setting.StopLossCondition = CompareCondition.GREATER_THAN;
                setting.StopLossThreshold = 0;
                return(setting);
            }
            else if (name == ChangePositionStrategyName)
            {
                ChangePositionSetting setting = new ChangePositionSetting();
                setting.TriggerCondition = CompareCondition.GREATER_EQUAL_THAN;
                setting.Threshold        = 100;

                return(setting);
            }
            else if (name == ScalperStrategyName)
            {
                ScalperSetting setting = new ScalperSetting();
                setting.Threshold           = 0;
                setting.PriceTick           = 0.2;
                setting.CaseLE2Tick         = entity.DirectionDepends.ON_SMALL_SIZE;
                setting.CaseLE3Tick         = entity.DirectionDepends.ON_BIG_SIZE;
                setting.CaseGE4Tick         = entity.DirectionDepends.ON_SMALL_CHANGE;
                setting.CaseNoChange        = entity.DirectionDepends.ON_BIG_SIZE;
                setting.StopLossCloseMethod = entity.StopLossCloseMethods.BASED_ON_NEXT_QUOTE;
                setting.RetryTimes          = 8;
                setting.OpenTimeout         = 100;
                return(setting);
            }
            else
            {
                throw new ArgumentException(string.Format("Unexpected strategy type - {0}", name));
            }
        }
Exemplo n.º 6
0
        public static StrategySetting Load(string name, string xmlText)
        {
            if (name == ArbitrageStrategyName)
            {
                ArbitrageStrategySetting setting = new ArbitrageStrategySetting();

                XElement elem = XElement.Parse(xmlText);

                XAttribute attr = elem.Attribute("direction");
                if (attr != null)
                {
                    setting.Direction = (entity.PosiDirectionType)Enum.Parse(typeof(entity.PosiDirectionType), attr.Value);
                }

                XElement elemOpen = elem.Element("open");
                attr = elemOpen.Attribute("condition");
                if (attr != null)
                {
                    setting.OpenCondition = (CompareCondition)Enum.Parse(typeof(CompareCondition), attr.Value);
                }
                attr = elemOpen.Attribute("threshold");
                if (attr != null)
                {
                    setting.OpenThreshold = double.Parse(attr.Value);
                }

                XElement elemStopGain = elem.Element("stopGain");
                attr = elemStopGain.Attribute("condition");
                if (attr != null)
                {
                    setting.StopGainCondition = (CompareCondition)Enum.Parse(typeof(CompareCondition), attr.Value);
                }
                attr = elemStopGain.Attribute("threshold");
                if (attr != null)
                {
                    setting.StopGainThreshold = double.Parse(attr.Value);
                }

                XElement elemStopLoss = elem.Element("stopLoss");
                attr = elemStopLoss.Attribute("condition");
                if (attr != null)
                {
                    setting.StopLossCondition = (CompareCondition)Enum.Parse(typeof(CompareCondition), attr.Value);
                }
                attr = elemStopLoss.Attribute("threshold");
                if (attr != null)
                {
                    setting.StopLossThreshold = double.Parse(attr.Value);
                }

                return(setting);
            }
            else if (name == ChangePositionStrategyName)
            {
                ChangePositionSetting setting = new ChangePositionSetting();

                XElement elem = XElement.Parse(xmlText);

                XAttribute attr = elem.Attribute("closeLeg");
                if (attr != null)
                {
                    setting.CloseLeg = attr.Value;
                }

                attr = elem.Attribute("side");
                if (attr != null)
                {
                    setting.CloseLegSide = (entity.PosiDirectionType)Enum.Parse(typeof(entity.PosiDirectionType), attr.Value);
                }

                attr = elem.Attribute("triggerCondition");
                if (attr != null)
                {
                    setting.TriggerCondition = (CompareCondition)Enum.Parse(typeof(CompareCondition), attr.Value);
                }

                attr = elem.Attribute("threshold");
                if (attr != null)
                {
                    setting.Threshold = double.Parse(attr.Value);
                }

                return(setting);
            }
            else if (name == ScalperStrategyName)
            {
                ScalperSetting setting = new ScalperSetting();
                XElement       elem    = XElement.Parse(xmlText);
                XAttribute     attr    = elem.Attribute("threshold");
                if (attr != null)
                {
                    setting.Threshold = double.Parse(attr.Value);
                }
                attr = elem.Attribute("prickTick");
                if (attr != null)
                {
                    setting.PriceTick = double.Parse(attr.Value);
                }
                attr = elem.Attribute("caseLE2Tick");
                if (attr != null)
                {
                    setting.CaseLE2Tick = (entity.DirectionDepends)Enum.Parse(typeof(entity.DirectionDepends), attr.Value);
                }
                attr = elem.Attribute("caseLE3Tick");
                if (attr != null)
                {
                    setting.CaseLE3Tick = (entity.DirectionDepends)Enum.Parse(typeof(entity.DirectionDepends), attr.Value);
                }
                attr = elem.Attribute("caseGE4Tick");
                if (attr != null)
                {
                    setting.CaseGE4Tick = (entity.DirectionDepends)Enum.Parse(typeof(entity.DirectionDepends), attr.Value);
                }
                attr = elem.Attribute("caseNoChange");
                if (attr != null)
                {
                    setting.CaseNoChange = (entity.DirectionDepends)Enum.Parse(typeof(entity.DirectionDepends), attr.Value);
                }
                attr = elem.Attribute("stopLossCloseStrategy");
                if (attr != null)
                {
                    setting.StopLossCloseMethod = (entity.StopLossCloseMethods)Enum.Parse(typeof(entity.StopLossCloseMethods), attr.Value);
                }
                attr = elem.Attribute("retryTimes");
                if (attr != null)
                {
                    setting.RetryTimes = int.Parse(attr.Value);
                }
                attr = elem.Attribute("openTimeout");
                if (attr != null)
                {
                    setting.OpenTimeout = int.Parse(attr.Value);
                }
                return(setting);
            }
            else
            {
                throw new ArgumentException(string.Format("Unexpected strategy setting ({0})", name));
            }
        }
Exemplo n.º 7
0
 protected override StrategySetting CreateSettings()
 {
     _settings = new ScalperSetting();
     _settings.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(settings_PropertyChanged);
     return(_settings);
 }