示例#1
0
        void IAdvisorProxy.SetParameter(int token, string key, string value)
        {
            RemoteAdvisor rmAdvisor = rmAdvisors[token];

            if (rmAdvisor != null)
            {
                rmAdvisor.SetParameter(key, value);
            }
        }
示例#2
0
        void IAdvisorProxy.SetCmdResult(int token, object result)
        {
            RemoteAdvisor rmAdvisor = rmAdvisors[token];

            if (rmAdvisor != null)
            {
                rmAdvisor.SetCommandResult(result);
            }
        }
示例#3
0
        void IAdvisorProxy.SetInit(int token)
        {
            RemoteAdvisor rmAdvisor = rmAdvisors[token];

            if (rmAdvisor != null)
            {
                ThreadPool.QueueUserWorkItem(new WaitCallback(rmAdvisor.AsyncInit));
            }
        }
示例#4
0
        int IAdvisorProxy.GetNextCommand(int token)
        {
            RemoteAdvisor rmAdvisor = rmAdvisors[token];

            if (rmAdvisor != null && rmAdvisor.Command != null)
            {
                return((int)rmAdvisor.Command.Name);
            }
            return(-2);
        }
示例#5
0
        int IAdvisorProxy.GetCommandParamCount(int token)
        {
            RemoteAdvisor rmAdvisor = rmAdvisors[token];

            if (rmAdvisor != null && rmAdvisor.Command != null)
            {
                return((int)rmAdvisor.Command.ParamCount);
            }
            return(-2);
        }
示例#6
0
        private object GetCommandParam(int token)
        {
            RemoteAdvisor rmAdvisor = rmAdvisors[token];

            if (rmAdvisor == null || rmAdvisor.Command == null)
            {
                return(null);
            }
            return(rmAdvisor.Command.getNextParam());
        }
示例#7
0
        void IAdvisorProxy.OnTick(int token, double bid, double ask, int dateTime)
        {
            RemoteAdvisor rmAdvisor = rmAdvisors[token];

            if (rmAdvisor != null)
            {
                rmAdvisor.Ask = ask;
                rmAdvisor.Bid = bid;
                rmAdvisor.LastTickDateTime = Convertor.SecondsToDateTime(dateTime);
                ThreadPool.QueueUserWorkItem(new WaitCallback(rmAdvisor.AsyncStart));
            }
        }
示例#8
0
 void IAdvisorProxy.EndSession(int token)
 {
     lock (_syncAdvisorCollection)
     {
         RemoteAdvisor rmAdvisor = rmAdvisors[token];
         if (rmAdvisor != null)
         {
             ThreadPool.QueueUserWorkItem(new WaitCallback(rmAdvisor.AsyncDeinit));
             rmAdvisors.Remove(token);
         }
     }
 }
示例#9
0
        internal override void OnRemmoteAdvisorInit(RemoteAdvisor rmAdviser)
        {
            try
            {
                Meta = rmAdviser;
                ForexAPI fAPI = new ForexAPI(Meta, rmAdviser.MagicNumber);

                OrderOperation = fAPI;
                Account        = fAPI;
                History        = fAPI;
                this.Symbol    = rmAdviser.Symbol();

                if (this.param != null)
                {
                    throw new ApplicationException("Param was initalized");
                }
                this.param = new StrategyParameter();

                foreach (string paramKey in rmAdviser.Parameters.Keys)
                {
                    if (paramKey == "NewsFilePath")
                    {
                        this.param.NewsFilePath = rmAdviser.Parameters[paramKey];
                        continue;
                    }
                    if (paramKey.EndsWith("String"))
                    {
                        this.param.Add(paramKey, rmAdviser.Parameters[paramKey]);
                        continue;
                    }
                    if (paramKey == "InvertedMetaStrategy")
                    {
                        rmAdviser.IsInverted = rmAdviser.Parameters[paramKey] == "1" || rmAdviser.Parameters[paramKey] == "true";
                        continue;
                    }

                    this.param[paramKey] = Int32.Parse(rmAdviser.Parameters[paramKey]);
                }


                this.logger = new MetaStrategyLogger(Meta);

                onStart(0);
                this.Meta.Print("onStart finidshed successfully");
            }
            catch (Exception exc)
            {
                string excString = "Start up exception: " + exc.ToString();
                Meta.Comment(excString);
                Meta.Print(excString);
            }
        }
示例#10
0
 int IAdvisorProxy.StartSession(string markeId)
 {
     //todo update for external advisor
     lock (_syncAdvisorCollection)
     {
         int           id        = idSeed++;
         RemoteAdvisor rmAdvisor = CreateRemoteAdvisor();
         rmAdvisor.MarketId = markeId;
         id             = rmAdvisor.Init(this);
         rmAdvisors[id] = rmAdvisor;
         return(id);
     }
 }
示例#11
0
        internal override void OnRemoteAdvisorStart(RemoteAdvisor rmAdviser)
        {
            try
            {
                Tick <int> newTick = new Tick <int>();
                newTick.Ask      = Convertor.TranslateToPipPrice(rmAdviser.Symbol(), rmAdviser.Ask);
                newTick.Bid      = Convertor.TranslateToPipPrice(rmAdviser.Symbol(), rmAdviser.Bid);
                newTick.DateTime = rmAdviser.LastTickDateTime;

                UpdateProperties();

                onTick(newTick);
                _currentTicks++;
            }
            catch (Exception exc)
            {
                string excString = "Exception: " + exc.ToString();
                Meta.Comment(excString);
                //Meta.Print("excString");
            }
        }
示例#12
0
 internal override void OnRemmoteAdvisorDeinit(RemoteAdvisor rmAdviser)
 {
     onEnd();
 }
示例#13
0
 internal abstract void OnRemoteAdvisorStart(RemoteAdvisor rmAdviser);
示例#14
0
 internal abstract void OnRemmoteAdvisorDeinit(RemoteAdvisor rmAdviser);