public void Remove(NinjaTrader.Strategy.FixConnector fixc)
        {
            if (fixc == null)
                return;

            lock (locker_)
            {
                m_providers.RemoveAll(mdd => mdd.fixConnector == fixc);
            }
        }
        public void Add(NinjaTrader.Strategy.FixConnector fixc)
        {
            if (fixc == null)
                return;

            lock (locker_)
            {
                m_providers.AddRange(fixc.GetSymbols());
            }
        }
        public static List<MarketDataDef> Read(NinjaTrader.Strategy.FixConnector f, string input)
        {
            List<MarketDataDef> limdd = new List<MarketDataDef>(f.Instruments.Select(i => new MarketDataDef(f, i.FullName)));
            limdd.AddRange(
                input.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                .ToList()
                .ConvertAll(s => new MarketDataDef(f, s.Trim()))
                );

            for (int i = 0; i < limdd.Count;i++)
                limdd[i].internal_barinprogress=i;

            return limdd;
        }
 public OrderFixBridge(NinjaTrader.Cbi.IOrder p_order, string quickfix_id, QuickFix.SessionID sessionid)
 {
     Order = p_order;
     QuickFixId = quickfix_id;
     OrderSessionID = sessionid;
 }
 public MarketDataDef(NinjaTrader.Strategy.FixConnector pfixConnector, string psymbol)
 {
     fixConnector = pfixConnector;
     symbol = psymbol;
 }
예제 #6
0
 public static int GetSlope(NinjaTrader.Strategy.Strategy strat, DataSeries series, int index)
 {
     return !series.ContainsValue(3) ? 0 : (int)((57.295779513082323 * Math.Atan(((series.Get(index) - ((series.Get(index + 1) + series.Get(index + 2)) / 2.0)) / 1.5) / strat.TickSize)) * -1.0);
 }
 public static void OnTermination(NinjaTrader.Strategy.FixConnector fixConnector)
 {
     lock (locker_)
     {
         s_fixConnectors.Remove(fixConnector);
         if (s_fixConnectors.Empty)
         {
             s_fixConnectors.Info(Name, "No more FixConnectors : stopping.");
             KillFix();
         }
     }
 }
        /*
         *
         * instrument quickfix_id => list of fixconnectors
         */
        public static void OnStartUp(NinjaTrader.Strategy.FixConnector fixConnector)
        {
            lock (locker_)
            {
            // adding anyway
            s_fixConnectors.Add(fixConnector);

            try
            {
                // start ?
                if (string.IsNullOrEmpty(ConfigFileName))
                {

                    if (string.IsNullOrEmpty(fixConnector.ConfigFileName))
                    {
                        // cannot start
                        s_fixConnectors.Warn(Name, "No config file name set to start QuickFix server. FixConnector enqueued but inactive for now ...");
                        return;
                    }

                    // a configfile is set, let's spin that shit
                    ConfigFileName = fixConnector.ConfigFileName;
                    s_fixConnectors.Info(Name, "[OnStartUp] Creating FIX session with file " + ConfigFileName);
                    QuickFix.SessionSettings sessionSettings = new QuickFix.SessionSettings(ConfigFileName);

                    s_fixConnectors.Info(Name, "[OnStartUp] Creating socket acceptor");
                    m_acceptor = new QuickFix.ThreadedSocketAcceptor(
                        m_app=new NinjaTrader_FixBridge.QuickFixApp(s_fixConnectors),
                        new QuickFix.FileStoreFactory(sessionSettings),
                        sessionSettings,
                        new QuickFix.FileLogFactory(sessionSettings)
                        );

                    sessionSettings = null;

                    s_fixConnectors.Info(Name, "[OnStartUp] Starting FixBridge ...");
                    m_acceptor.Start();
                    s_fixConnectors.Info(Name, "[OnStartUp] FixBridge started !");
                }
            }
            catch (Exception e)
            {
                s_fixConnectors.Error(Name, "[OnStartUp] Exception OnStartUp : " + e.Message + ", source:" + e.Source);
                s_fixConnectors.Error(Name, "[OnStartUp] Exception OnStartUp : " + e.ToString());
                s_fixConnectors.Error(Name, "[OnStartUp] Exception OnStartUp : " + e.StackTrace);
                s_fixConnectors.Error(Name, "[OnStartUp]  => destroying FIX layer");

                KillFix();
                throw e;
            }
            }
        }