Exemplo n.º 1
0
        public static void InstrumentFactory_StoreInstrumentsInMap(string baseName)
        {
            InstrumentFactory factory = ObjectMap.InstrumentFactories[baseName];

            foreach (string key in factory.IrSwaps.Keys)
            {
                ObjectMap.LinearRateInstruments[key] = factory.IrSwaps[key];
            }

            foreach (string key in factory.OisSwaps.Keys)
            {
                ObjectMap.LinearRateInstruments[key] = factory.OisSwaps[key];
            }

            foreach (string key in factory.BasisSwaps.Keys)
            {
                ObjectMap.LinearRateInstruments[key] = factory.BasisSwaps[key];
            }

            foreach (string key in factory.Futures.Keys)
            {
                ObjectMap.LinearRateInstruments[key] = factory.Futures[key];
            }

            foreach (string key in factory.Fras.Keys)
            {
                ObjectMap.LinearRateInstruments[key] = factory.Fras[key];
            }

            foreach (string key in factory.Deposits.Keys)
            {
                ObjectMap.LinearRateInstruments[key] = factory.Deposits[key];
            }
        }
Exemplo n.º 2
0
        public static void CurveCalibrationProblem_Make(string baseName, string instrumentFactoryName, string[] identifiers, double[] quotes)
        {
            InstrumentFactory      factory          = ObjectMap.InstrumentFactories[instrumentFactoryName];
            List <InstrumentQuote> instrumentQuotes = CreateInstrumentList(instrumentFactoryName, identifiers, quotes);

            ObjectMap.CurveCalibrationProblems[baseName] = new CurveCalibrationProblem(factory, instrumentQuotes);
        }
Exemplo n.º 3
0
        public static void InstrumentFactory_UpdateAllInstrumentsToPar(string baseName, string modelHandle)
        {
            LinearRateModel   model   = ObjectMap.LinearRateModels[modelHandle];
            InstrumentFactory factory = ObjectMap.InstrumentFactories[baseName];

            factory.UpdateAllInstrumentsToParGivenModel(model);
        }
 public FestivalController(IStage stage)
 {
     this.stage             = stage;
     this.setFactory        = new SetFactory();
     this.instrumentFactory = new InstrumentFactory();
     this.performerFactory  = new PerformerFactory();
     this.songFactory       = new SongFactory();
 }
        public void CreateInstrumetTest_Create_FlowdownSpread_Test()
        {
            var        factory         = new InstrumentFactory();
            var        instrumentState = Substitute.For <ITTInstrumentState>();
            var        def             = new InstrDef("CME", "ZN", "SPREAD", "CME Reduced Tick Spread: 1xZN Dec15:-1xMar16", "+ZNZ5-ZNH6", "FlowdownSpread");
            Instrument instrument      = factory.CreateInstrument(def, instrumentState);

            Assert.IsType <InstrumentSpreadFlowdown>(instrument);
        }
        public void CreateInstrumetTest_Create_SpreadImpliedNonlinearModel_Test()
        {
            var        factory         = new InstrumentFactory();
            var        instrumentState = Substitute.For <ITTInstrumentState>();
            var        def             = new InstrDef("CME", "ZN", "FUTURE", "Dec15", "ZNZ5", "SpreadImpliedNonlinear");
            Instrument instrument      = factory.CreateInstrument(def, instrumentState);

            Assert.IsType <InstrumentFutureSpreadImplied>(instrument);
        }
Exemplo n.º 7
0
    public void TryToCreateInstrument()
    {
        var instrumentFactory = new InstrumentFactory();

        var instrument = instrumentFactory.CreateInstrument("TestGuitar");

        Assert.That(instrument, Is.Not.Null, "Instrument wasn't created correctly!");
        Assert.That(instrument, Is.TypeOf <TestGuitar>(), "Created instrument isn't of the correct type!");
    }
Exemplo n.º 8
0
        public static void Main(string[] args)
        {
            IStage              stage              = new Stage();
            ISetFactory         setFactory         = new SetFactory();
            IInstrumentFactory  instrumentFactory  = new InstrumentFactory();
            ISetController      setController      = new SetController(stage);
            IReader             reader             = new ConsoleReader();
            IWriter             writer             = new ConsoleWriter();
            IFestivalController festivalController = new FestivalController(stage, setFactory, setController, instrumentFactory);
            IEngine             engine             = new Engine(reader, writer, festivalController, setController);

            engine.Run();
        }
    public static void Main(string[] args)
    {
        InstrumentFactory trumpetFactory = FactoryCreator.createTrumpetFactory();
        InstrumentFactory drumFactory    = FactoryCreator.createDrumFactory();
        InstrumentFactory guitarFactory  = FactoryCreator.createGuitarFactory();

        Instrument trumpet = trumpetFactory.createInstrument();
        Instrument drum    = drumFactory.createInstrument();
        Instrument guitar  = guitarFactory.createInstrument();

        trumpet.play();
        drum.play();
        guitar.play();
    }
Exemplo n.º 10
0
        public List <Instrument> GenerateInstruments()
        {
            var randomGen  = new Random();
            var instNumber = randomGen.Next(5, 20); // random number of instruments
            var instList   = new List <Instrument>();

            for (var i = 0; i < instNumber; i++)
            {
                var instType = randomGen.Next(this._types.Length);
                instList.Add(InstrumentFactory.GetInstrument(this._types[instType]));
            }

            return(instList);
        }
Exemplo n.º 11
0
        public static void Main(string[] args)
        {
            IReader             reader             = new ConsoleReader();
            IWriter             writer             = new ConsoleWriter();
            IStage              stage              = new Stage();
            IInstrumentFactory  instrumentFactory  = new InstrumentFactory();
            IPerformerFactory   performerFactory   = new PerformerFactory();
            ISongFactory        songFactory        = new SongFactory();
            IFestivalController festivalController = new FestivalController(stage, instrumentFactory, performerFactory, songFactory);
            ISetController      setController      = new SetController(stage);

            var engine = new Engine(reader, writer, stage, festivalController, setController);

            engine.Run();
        }
Exemplo n.º 12
0
        private void AddToList()
        {
            var instrument = new InstrumentFactory().Create(_instrumentInfo);

            if (_index > 0)
            {
                _instruments[_index] = instrument;
            }
            else
            {
                _instruments.Add(instrument);
            }

            OnListChanged();
        }
Exemplo n.º 13
0
        private void StartTrackingInstrumentForLot(Lot createdLot)
        {
            var existingInstrument = _instrumentRepository.GetById(createdLot.InstrumentInfo.Symbol);

            if (existingInstrument != null)
            {
                existingInstrument.AttachLotId(createdLot.Id);
                _instrumentRepository.Update(existingInstrument);
            }
            else
            {
                var newInstrument = InstrumentFactory.NewInstrumentByInfo(createdLot.InstrumentInfo);
                newInstrument.AttachLotId(createdLot.Id);
                _instrumentRepository.Add(newInstrument);
            }
        }
Exemplo n.º 14
0
        private void InstrumentToolStripButton_Click(object sender, System.EventArgs e)
        {
            var clickedBtn = (InstrumentToolStripButton)sender;

            if (!clickedBtn.Checked)
            {
                _instrument = InstrumentFactory.Create(clickedBtn.InstrumentType);
                _instrument.Init(Box, _color);
                _instrument.SetWidth(_lineWidth);
                foreach (var btn in MainToolStrip.Items)
                {
                    var button = btn as InstrumentToolStripButton;
                    if (button != null)
                    {
                        button.Checked = false;
                    }
                }
                clickedBtn.Checked = true;
            }
        }
Exemplo n.º 15
0
        public static void Main(string[] args)
        {
            IList <ISet>       sets       = new List <ISet>();
            IList <ISong>      songs      = new List <ISong>();
            IList <IPerformer> performers = new List <IPerformer>();

            Stage stage = new Stage(sets, songs, performers);

            IReader            reader            = new ConsoleReader();
            IWriter            writer            = new ConsoleWriter();
            ISetFactory        setFactory        = new SetFactory();
            IInstrumentFactory instrumentFactory = new InstrumentFactory();
            IPerformerFactory  performerFactory  = new PerformerFactory();
            ISongFactory       songFactory       = new SongFactory();

            IFestivalController festivalController = new FestivalController(stage, setFactory, instrumentFactory, performerFactory, songFactory);
            ISetController      setController      = new SetController(stage);

            var engine = new Engine(reader, writer, festivalController, setController);

            engine.Run();
        }
Exemplo n.º 16
0
        public BasisPriceCurve(TO_BasisPriceCurve transportObject, ICurrencyProvider currencyProvider, ICalendarProvider calendarProvider)
        {
            Instruments = transportObject.Instruments
                          .Select(x => (IAssetInstrument)InstrumentFactory.GetInstrument(x, currencyProvider, calendarProvider))
                          .ToList();

            Pillars       = transportObject.Pillars;
            DiscountCurve = new IrCurve(transportObject.DiscountCurve, currencyProvider);
            //need to re-link via the active model
            Curve        = PriceCurveFactory.GetPriceCurve(transportObject.Curve, currencyProvider, calendarProvider);
            BaseCurve    = PriceCurveFactory.GetPriceCurve(transportObject.BaseCurve, currencyProvider, calendarProvider);
            Name         = transportObject.Name;
            AssetId      = transportObject.AssetId;
            BuildDate    = transportObject.BuildDate;
            PillarLabels = transportObject.PillarLabels;
            Currency     = currencyProvider.GetCurrencySafe(transportObject.Currency);
            SpotCalendar = calendarProvider.GetCalendarSafe(transportObject.SpotCalendar);
            if (transportObject.SpotLag != null)
            {
                SpotLag = new Frequency(transportObject.SpotLag);
            }
            CurveType = transportObject.CurveType;
        }
Exemplo n.º 17
0
 void Start()
 {
     m_instance = this;
     m_source   = GlobalConfig.Instance.ProjectSourceName;
 }