Exemple #1
0
        public MarkingTheCloseBreach(
            IFactorValue factorValue,
            ISystemProcessOperationContext operationContext,
            string correlationId,
            TimeSpan window,
            FinancialInstrument security,
            MarketOpenClose marketClose,
            ITradePosition tradingPosition,
            IMarkingTheCloseEquitiesParameters equitiesParameters,
            VolumeBreach dailyBreach,
            VolumeBreach windowBreach,
            string description,
            string caseTitle,
            DateTime universeDateTime)
        {
            this.FactorValue = factorValue;

            this.Window   = window;
            this.Security = security ?? throw new ArgumentNullException(nameof(security));

            this.MarketClose        = marketClose ?? throw new ArgumentNullException(nameof(marketClose));
            this.Trades             = tradingPosition ?? new TradePosition(new List <Order>());
            this.EquitiesParameters = equitiesParameters ?? throw new ArgumentNullException(nameof(equitiesParameters));

            this.DailyBreach  = dailyBreach;
            this.WindowBreach = windowBreach;

            this.RuleParameterId   = equitiesParameters?.Id ?? string.Empty;
            this.SystemOperationId = operationContext.Id.ToString();
            this.CorrelationId     = correlationId;
            this.RuleParameters    = equitiesParameters;
            this.Description       = description ?? string.Empty;
            this.CaseTitle         = caseTitle ?? string.Empty;
            this.UniverseDateTime  = universeDateTime;
        }
Exemple #2
0
        public SpoofingRuleBreach(
            IFactorValue factorValue,
            ISystemProcessOperationContext operationContext,
            string correlationId,
            TimeSpan window,
            ITradePosition fulfilledTradePosition,
            ITradePosition cancelledTradePosition,
            FinancialInstrument security,
            Order mostRecentTrade,
            ISpoofingRuleEquitiesParameters spoofingEquitiesParameters,
            string description,
            string caseTitle,
            DateTime universeDateTime)
        {
            this.FactorValue = factorValue;

            this.Window          = window;
            this.Security        = security;
            this.MostRecentTrade = mostRecentTrade;

            var totalTrades = fulfilledTradePosition.Get().ToList();

            totalTrades.AddRange(cancelledTradePosition.Get());
            this.Trades = new TradePosition(totalTrades);
            this.TradesInFulfilledPosition = fulfilledTradePosition;
            this.CancelledTrades           = cancelledTradePosition;

            this.RuleParameterId   = spoofingEquitiesParameters?.Id ?? string.Empty;
            this.SystemOperationId = operationContext.Id.ToString();
            this.CorrelationId     = correlationId;
            this.RuleParameters    = spoofingEquitiesParameters;
            this.Description       = description ?? string.Empty;
            this.CaseTitle         = caseTitle ?? string.Empty;
            this.UniverseDateTime  = universeDateTime;
        }
Exemple #3
0
 public LayeringRuleBreach(
     IFactorValue factorValue,
     ISystemProcessOperationContext operationContext,
     string correlationId,
     ILayeringRuleEquitiesParameters equitiesParameters,
     TimeSpan window,
     ITradePosition trades,
     FinancialInstrument security,
     RuleBreachDescription bidirectionalTradeBreach,
     RuleBreachDescription dailyVolumeTradeBreach,
     RuleBreachDescription windowVolumeTradeBreach,
     RuleBreachDescription priceMovementBreach,
     string description,
     string caseTitle,
     DateTime universeDateTime)
 {
     this.FactorValue              = factorValue;
     this.EquitiesParameters       = equitiesParameters;
     this.Window                   = window;
     this.Trades                   = trades;
     this.Security                 = security;
     this.BidirectionalTradeBreach = bidirectionalTradeBreach;
     this.DailyVolumeTradeBreach   = dailyVolumeTradeBreach;
     this.WindowVolumeTradeBreach  = windowVolumeTradeBreach;
     this.PriceMovementBreach      = priceMovementBreach;
     this.RuleParameterId          = equitiesParameters?.Id ?? string.Empty;
     this.SystemOperationId        = operationContext.Id.ToString();
     this.CorrelationId            = correlationId;
     this.RuleParameters           = equitiesParameters;
     this.Description              = description ?? string.Empty;
     this.CaseTitle                = caseTitle ?? string.Empty;
     this.UniverseDateTime         = universeDateTime;
 }
        public void MapContextBuildsExpectedAbsoluteProfitExchangeWeightedBreachRuleBreach()
        {
            var mapper = this.BuildMapper();
            var fi     = new FinancialInstrument {
                Name = "GILT 5 YEAR MATURITY"
            };

            A.CallTo(() => this.ruleBreachContext.Security).Returns(fi);
            A.CallTo(() => this.ruleBreachContext.UniverseDateTime).Returns(new DateTime(2019, 01, 01, 15, 03, 0));

            A.CallTo(() => this.parameters.UseCurrencyConversions).Returns(true);
            A.CallTo(() => this.parameters.HighProfitAbsoluteThreshold).Returns(12000m);
            A.CallTo(() => this.parameters.HighProfitCurrencyConversionTargetCurrency).Returns("GBP");

            A.CallTo(() => this.judgementContext.FixedIncomeParameters).Returns(this.parameters);
            A.CallTo(() => this.judgementContext.HasAbsoluteProfitBreach).Returns(true);
            A.CallTo(() => this.judgementContext.AbsoluteProfits).Returns(new Money(12341m, "GBP"));
            A.CallTo(() => this.judgementContext.RaiseRuleViolation).Returns(true);
            A.CallTo(() => this.judgementContext.RuleBreachContext).Returns(this.ruleBreachContext);
            A.CallTo(() => this.judgementContext.ExchangeRateProfits).Returns(this.profitBreakdown);

            A.CallTo(() => this.profitBreakdown.FixedCurrency).Returns(new Currency("GBP"));
            A.CallTo(() => this.profitBreakdown.VariableCurrency).Returns(new Currency("USD"));
            A.CallTo(() => this.profitBreakdown.AbsoluteAmountDueToWer()).Returns(9001);
            A.CallTo(() => this.profitBreakdown.PositionCostWer).Returns(0.12m);
            A.CallTo(() => this.profitBreakdown.PositionRevenueWer).Returns(0.32m);
            A.CallTo(() => this.profitBreakdown.RelativePercentageDueToWer()).Returns(0.99m);

            var result = mapper.Map(this.judgementContext);

            Assert.AreEqual("Automated Fixed Income High Profit Rule Breach Detected", result.CaseTitle);
            Assert.AreEqual("High profit rule breach detected for GILT 5 YEAR MATURITY. There was a high profit of 12341 (GBP) which exceeded the configured profit limit of 12000(GBP). The position was acquired with a currency conversion between (GBP/USD) rate at a weighted exchange rate of 0.12 and sold at a weighted exchange rate of 0.32. The impact on profits from exchange rate movements was 99.00% and the absolute amount of profits due to exchange rates is () 9001.", result.Description);
        }
        /// <summary>
        /// The advanced micro devices
        /// </summary>
        /// <returns>
        /// The <see cref="SecurityMarketPair"/>.
        /// </returns>
        private SecurityMarketPair Amd()
        {
            var identifiers = new InstrumentIdentifiers(
                "AMD",
                "RD01D",
                "RD01D",
                "Advanced Micro Devices nasdaq",
                "2007849",
                "US0079031078",
                "BBG00KFWP7B3",
                string.Empty,
                "AMD",
                string.Empty,
                "Advanced Micro Devices Inc",
                string.Empty);

            var financialInstrument = new FinancialInstrument(
                InstrumentTypes.Equity,
                identifiers,
                "AMD",
                "entspb",
                "USD",
                "Advanced Micro Devices Inc");

            var market = this.Nasdaq();

            return(new SecurityMarketPair {
                Instrument = financialInstrument, Market = market
            });
        }
Exemple #6
0
        public PlacingOrderWithNoIntentToExecuteRuleRuleBreach(
            TimeSpan window,
            ITradePosition trades,
            FinancialInstrument security,
            IFactorValue factorValue,
            decimal meanPrice,
            decimal sdPrice,
            IReadOnlyCollection <ProbabilityOfExecution> probabilityForOrders,
            IPlacingOrderWithNoIntentToExecuteRuleEquitiesParameters parameters,
            ISystemProcessOperationRunRuleContext ctx,
            string description,
            string caseTitle,
            DateTime universeDateTime)
        {
            this.Window   = window;
            this.Trades   = trades;
            this.Security = security;

            this.FactorValue = factorValue;
            this.Parameters  = parameters;

            this.MeanPrice = meanPrice;
            this.StandardDeviationPrice = sdPrice;
            this.ProbabilityForOrders   = probabilityForOrders ?? new List <ProbabilityOfExecution>();

            this.RuleParameterId   = parameters.Id;
            this.SystemOperationId = ctx.Id();
            this.CorrelationId     = ctx.CorrelationId();
            this.RuleParameters    = parameters;
            this.Description       = description ?? string.Empty;
            this.CaseTitle         = caseTitle ?? string.Empty;
            this.UniverseDateTime  = universeDateTime;
        }
        /// <summary>
        /// The UK government bond secondary market.
        /// </summary>
        /// <returns>
        /// The <see cref="SecurityMarketPair"/>.
        /// </returns>
        private SecurityMarketPair UkGovernmentBondSecondaryMarket()
        {
            var identifiers = new InstrumentIdentifiers(
                "UKGovtBond",
                "RD01D",
                "RD01D",
                "UNITED KINGDOM OF GREAT BRITAI  0%32",
                string.Empty,
                "GB00B3D4VD98",
                "BBG0000VN0M0",
                "G924502U1",
                "UKTI 1.25 11/22/32 3MO Govt",
                string.Empty,
                "UKTI 1.25 11/22/32 3MO Govt",
                string.Empty);

            var financialInstrument = new FinancialInstrument(
                InstrumentTypes.Bond,
                identifiers,
                "UKGovtBond",
                "dbftfb",
                "GBX",
                "Government of United Kingdom");

            var market = this.Diversity();

            return(new SecurityMarketPair {
                Instrument = financialInstrument, Market = market
            });
        }
        /// <summary>
        /// The chip maker corporation.
        /// </summary>
        /// <returns>
        /// The <see cref="SecurityMarketPair"/>.
        /// </returns>
        private SecurityMarketPair Nvidia()
        {
            var identifiers = new InstrumentIdentifiers(
                "Nvidia",
                "RD01D",
                "RD01D",
                "Nvidia Corp nasdaq",
                "2379504",
                "US67066G1040",
                "BBG00JSC5XF7",
                string.Empty,
                "Nvidia",
                string.Empty,
                "Nvidia Corp Inc",
                string.Empty);

            var financialInstrument = new FinancialInstrument(
                InstrumentTypes.Equity,
                identifiers,
                "Nvidia",
                "entspb",
                "USD",
                "Nvidia Corp Inc");

            var market = this.Nasdaq();

            return(new SecurityMarketPair {
                Instrument = financialInstrument, Market = market
            });
        }
        /// <summary>
        /// The micron technology market.
        /// </summary>
        /// <returns>
        /// The <see cref="SecurityMarketPair"/>.
        /// </returns>
        private SecurityMarketPair Micron()
        {
            var identifiers = new InstrumentIdentifiers(
                "Micron Technology Inc",
                "RD01D",
                "RD01D",
                "Micron Technology nasdaq",
                "2588184",
                "US5951121038",
                "BBG000DQNYH9",
                string.Empty,
                "Micron",
                string.Empty,
                "Micron Technology Inc",
                string.Empty);

            var financialInstrument = new FinancialInstrument(
                InstrumentTypes.Equity,
                identifiers,
                "Micron",
                "entspb",
                "USD",
                "Micron Technology Inc");

            var market = this.Nasdaq();

            return(new SecurityMarketPair {
                Instrument = financialInstrument, Market = market
            });
        }
        /// <summary>
        /// The constructor for bank security.
        /// </summary>
        /// <returns>
        /// The <see cref="SecurityMarketPair"/>.
        /// </returns>
        private SecurityMarketPair Barclays()
        {
            var identifiers = new InstrumentIdentifiers(
                "Barclays",
                "RD01D",
                "RD01D",
                "Barclays ln",
                "3134865",
                "GB0031348658",
                "BBG000NC8KY7",
                string.Empty,
                "BARC",
                "G5GSEF7VJP5I7OUK5573",
                "Barclays Lon",
                string.Empty);

            var financialInstrument = new FinancialInstrument(
                InstrumentTypes.Equity,
                identifiers,
                "Barclays",
                "entspb",
                "GBX",
                "Barclays plc");

            var market = this.LondonStockExchange();

            return(new SecurityMarketPair {
                Instrument = financialInstrument, Market = market
            });
        }
        /// <summary>
        /// The european phone maker security.
        /// </summary>
        /// <returns>
        /// The <see cref="SecurityMarketPair"/>.
        /// </returns>
        private SecurityMarketPair Vodafone()
        {
            var identifiers = new InstrumentIdentifiers(
                "Voda",
                "RD00D",
                "RD00D",
                "vodafone ln",
                "BH4HKS3",
                "GB00BH4HKS39",
                "BBG000N8D298",
                string.Empty,
                "VOD",
                "213800WP8QQ8YTL6MH84",
                "Vodafone Lon",
                string.Empty);

            var financialInstrument = new FinancialInstrument(
                InstrumentTypes.Equity,
                identifiers,
                "Vodafone",
                "entspb",
                "GBX",
                "Vodafone plc");

            var market = this.LondonStockExchange();

            return(new SecurityMarketPair {
                Instrument = financialInstrument, Market = market
            });
        }
        /// <summary>
        /// The british aerospace
        /// </summary>
        /// <returns>
        /// The <see cref="SecurityMarketPair"/>.
        /// </returns>
        private SecurityMarketPair Bae()
        {
            var identifiers = new InstrumentIdentifiers(
                "BAE",
                "RD01D",
                "RD01D",
                "BAE Systems Ln",
                "0263494",
                "GB0002634946",
                "BBG000H342V1",
                string.Empty,
                "BAE",
                "549300D72VDDRVGKSH48",
                "BAE Systems Plc",
                string.Empty);

            var financialInstrument = new FinancialInstrument(
                InstrumentTypes.Equity,
                identifiers,
                "BAE",
                "entspb",
                "GBX",
                "BAE Systems Plc");

            var market = this.LondonStockExchange();

            return(new SecurityMarketPair {
                Instrument = financialInstrument, Market = market
            });
        }
        public WashTradeRuleBreach(
            TimeSpan windowSize,
            IFactorValue factorValue,
            ISystemProcessOperationContext operationContext,
            string correlationId,
            IWashTradeRuleParameters equitiesParameters,
            ITradePosition tradePosition,
            FinancialInstrument security,
            WashTradeAveragePositionBreach averagePositionBreach,
            WashTradeClusteringPositionBreach clusteringPositionBreach,
            string description,
            string caseTitle,
            DateTime universeDateTime)
        {
            this.FactorValue        = factorValue;
            this.EquitiesParameters = equitiesParameters ?? throw new ArgumentNullException(nameof(equitiesParameters));

            this.Window   = windowSize;
            this.Trades   = tradePosition;
            this.Security = security;

            this.AveragePositionBreach =
                averagePositionBreach ?? throw new ArgumentNullException(nameof(averagePositionBreach));
            this.ClusteringPositionBreach = clusteringPositionBreach
                                            ?? throw new ArgumentNullException(nameof(clusteringPositionBreach));

            this.RuleParameterId   = equitiesParameters?.Id ?? string.Empty;
            this.SystemOperationId = operationContext.Id.ToString();
            this.CorrelationId     = correlationId;
            this.RuleParameters    = equitiesParameters;
            this.Description       = description ?? string.Empty;
            this.CaseTitle         = caseTitle ?? string.Empty;
            this.UniverseDateTime  = universeDateTime;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="RuleBreach"/> class.
 /// </summary>
 /// <param name="window">
 /// The window.
 /// </param>
 /// <param name="trades">
 /// The trades.
 /// </param>
 /// <param name="security">
 /// The security.
 /// </param>
 /// <param name="isBackTestRun">
 /// The is back test run.
 /// </param>
 /// <param name="ruleParameterId">
 /// The rule parameter id.
 /// </param>
 /// <param name="systemOperationId">
 /// The system operation id.
 /// </param>
 /// <param name="correlationId">
 /// The correlation id.
 /// </param>
 /// <param name="factorValue">
 /// The factor value.
 /// </param>
 /// <param name="ruleParameter">
 /// The rule parameter.
 /// </param>
 /// <param name="universeDateTime">
 /// The universe date time.
 /// </param>
 /// <param name="description">
 /// The description.
 /// </param>
 /// <param name="caseTitle">
 /// The case title.
 /// </param>
 public RuleBreach(
     TimeSpan window,
     ITradePosition trades,
     FinancialInstrument security,
     bool isBackTestRun,
     string ruleParameterId,
     string systemOperationId,
     string correlationId,
     IFactorValue factorValue,
     IRuleParameter ruleParameter,
     DateTime universeDateTime,
     string description,
     string caseTitle)
 {
     this.Window            = window;
     this.Trades            = trades;
     this.Security          = security;
     this.IsBackTestRun     = isBackTestRun;
     this.RuleParameterId   = ruleParameterId;
     this.SystemOperationId = systemOperationId;
     this.CorrelationId     = correlationId;
     this.FactorValue       = factorValue;
     this.RuleParameters    = ruleParameter;
     this.UniverseDateTime  = universeDateTime;
     this.Description       = description;
     this.CaseTitle         = caseTitle;
 }
 public RampingRuleBreach(
     TimeSpan window,
     ITradePosition trades,
     FinancialInstrument security,
     string ruleParameterId,
     string systemOperationId,
     string correlationId,
     IFactorValue factorValue,
     IRampingStrategySummaryPanel summaryPanel,
     IRampingRuleEquitiesParameters parameters,
     string description,
     string caseTitle,
     DateTime universeDateTime)
 {
     this.Window            = window;
     this.Trades            = trades;
     this.Security          = security;
     this.RuleParameterId   = ruleParameterId ?? string.Empty;
     this.SystemOperationId = systemOperationId ?? string.Empty;
     this.CorrelationId     = correlationId ?? string.Empty;
     this.FactorValue       = factorValue;
     this.SummaryPanel      = summaryPanel;
     this.RuleParameters    = parameters;
     this.Description       = description ?? string.Empty;
     this.CaseTitle         = caseTitle ?? string.Empty;
     this.UniverseDateTime  = universeDateTime;
 }
Exemple #16
0
        private EquityIntraDayTimeBarCollection Frame()
        {
            var stockExchange = new Domain.Core.Markets.Market("1", "XLON", "London Stock Exchange", MarketTypes.STOCKEXCHANGE);

            var securityIdentifiers = new InstrumentIdentifiers(string.Empty, string.Empty, "stan", "stan", "st12345", "sta123456789", "stan", "sta12345", "stan", "stan", "STAN", "stanRic");

            var security = new FinancialInstrument(
                InstrumentTypes.Equity,
                securityIdentifiers,
                "Standard Chartered",
                "CFI",
                "USD",
                "Standard Chartered Bank");

            var securities = new List <EquityInstrumentIntraDayTimeBar>
            {
                new EquityInstrumentIntraDayTimeBar(
                    security,
                    new SpreadTimeBar(new Money(100, "GBP"), new Money(101, "GBP"), new Money(100.5m, "GBP"), new Volume(1000)),
                    new DailySummaryTimeBar(
                        1000000,
                        "USD",
                        new IntradayPrices(new Money(90, "GBP"), new Money(85, "GBP"), new Money(105, "GBP"), new Money(84, "GBP")),
                        1000,
                        new Volume(10000),
                        DateTime.UtcNow),
                    DateTime.UtcNow,
                    stockExchange)
            };

            return(new EquityIntraDayTimeBarCollection(stockExchange, DateTime.UtcNow, securities));
        }
Exemple #17
0
        //[TestMethod]
        public void test_deals()
        {
            FinancialInstrument instr    = controller.get_instrument("SPFB_LKOH_140101_140331.txt");
            TradingStrategy     strategy = controller.get_strategy("Test5").Originator;

            ForecastingModule forecastingModule = new ForecastingModule(strategy, instr);
            ForecastResult    result            = forecastingModule.run();

            int      numDeal = 5;
            TypeDeal expType = TypeDeal.Sell;
            DateTime expDateOpen = new DateTime(14, 2, 12, 12, 35, 0);
            DateTime expDateClose = new DateTime(14, 2, 12, 12, 36, 0);
            double   expOpenPrice = 20430, expClosePrice = 20438;

            TradeDeal tradeDeal = result.get_deal(numDeal);

            double actOpenPrice  = tradeDeal.OpeningPrice;
            double actClosePrice = tradeDeal.ClosingPrice;

            Assert.AreEqual(
                true,
                tradeDeal.Opening == false &&
                tradeDeal.Type == expType &&
                actOpenPrice == expOpenPrice
                //&& tradeDeal.DateTimeOpen.Equals(expDateOpen)
                //&& tradeDeal.DateTimeClose == expDateClose
                && actClosePrice == expClosePrice
                );
        }
Exemple #18
0
        public static Order Random(this Order frame, int?price = 20)
        {
            var fi = new FinancialInstrument(
                InstrumentTypes.Equity,
                new InstrumentIdentifiers(
                    string.Empty,
                    "reddeer-id",
                    null,
                    "client-identifier",
                    "sedol",
                    "isin",
                    "figi",
                    "cusip",
                    "xlon",
                    "lei",
                    "bloomberg",
                    "ric"),
                "random-security",
                "ENTSPB",
                "USD",
                "Random Inc");

            var market = new Market("1", "XLON", "London Stock Exchange", MarketTypes.STOCKEXCHANGE);

            return(new Order(
                       fi,
                       market,
                       null,
                       "order-1",
                       DateTime.UtcNow.Date,
                       "version-1",
                       "version-1",
                       "version-1",
                       DateTime.UtcNow.Date,
                       DateTime.UtcNow.Date,
                       null,
                       null,
                       null,
                       null,
                       OrderTypes.MARKET,
                       OrderDirections.BUY,
                       new Currency("GBP"),
                       new Currency("GBP"),
                       OrderCleanDirty.NONE,
                       null,
                       new Money(price.GetValueOrDefault(20), "GBP"),
                       new Money(price.GetValueOrDefault(20), "GBP"),
                       1000,
                       1000,
                       "trader id",
                       "trader one",
                       "clearing agent",
                       "dealer-instructions",
                       new OrderBroker(string.Empty, string.Empty, "Mr Broker", DateTime.Now, true),
                       null,
                       null,
                       OptionEuropeanAmerican.NONE,
                       new DealerOrder[0]));
        }
Exemple #19
0
        private Order BuildOrder()
        {
            var instrument = new FinancialInstrument(
                InstrumentTypes.Equity,
                new InstrumentIdentifiers(
                    "1",
                    "1",
                    "1",
                    "1",
                    "abcdefg",
                    "123456789012",
                    "123456789012",
                    "123456",
                    "abc",
                    null,
                    null,
                    null),
                "mock-instrument",
                "entspb",
                "GBP",
                "mock-bank");

            var market = new Market("1", "XLON", "London Stock Exchange", MarketTypes.STOCKEXCHANGE);

            return(new Order(
                       instrument,
                       market,
                       null,
                       "order-1",
                       DateTime.UtcNow,
                       "order-v1",
                       "order-v1-link",
                       "order-group-1",
                       DateTime.UtcNow,
                       DateTime.UtcNow,
                       DateTime.UtcNow,
                       null,
                       null,
                       DateTime.UtcNow,
                       OrderTypes.MARKET,
                       OrderDirections.BUY,
                       new Currency("GBP"),
                       null,
                       OrderCleanDirty.NONE,
                       null,
                       null,
                       new Money(100, "GBP"),
                       0,
                       0,
                       "trader-one",
                       "trader-1",
                       "clearing-agent",
                       "deal asap",
                       new OrderBroker(string.Empty, string.Empty, "Mr Broker", DateTime.Now, true),
                       null,
                       null,
                       OptionEuropeanAmerican.NONE,
                       null));
        }
Exemple #20
0
        private void SeedFinancialInstrument()
        {
            var dbFinInst = new FinancialInstrument
            {
                Id           = 0,
                CurrentPrice = 14.25
            };

            _dbContext.FinancialInstrument.Add(dbFinInst);
            _dbContext.SaveChanges();
        }
 public FixedIncomeInstrumentInterDayTimeBar(
     FinancialInstrument security,
     DailySummaryTimeBar dailySummaryTimeBar,
     DateTime timeStamp,
     Market market)
 {
     this.Security            = security;
     this.TimeStamp           = timeStamp;
     this.Market              = market;
     this.DailySummaryTimeBar = dailySummaryTimeBar;
 }
Exemple #22
0
 public IEnumerable <Asset> GetAssetsByFinancialInstrumentAndIndustry(FinancialInstrument fi, Industry ind)
 {
     try
     {
         var assets = _context.Assets.Where(r => r.FinancialInstrument == fi && r.Industry == ind).ToList();
         return(assets);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemple #23
0
 public EquityInstrumentIntraDayTimeBar(
     FinancialInstrument security,
     SpreadTimeBar spreadTimeBar,
     DailySummaryTimeBar dailySummaryTimeBar,
     DateTime timeStamp,
     Market market)
 {
     this.Security            = security;
     this.SpreadTimeBar       = spreadTimeBar;
     this.TimeStamp           = timeStamp;
     this.Market              = market;
     this.DailySummaryTimeBar = dailySummaryTimeBar;
 }
Exemple #24
0
        public void TickSecurity_UpdatesWithNewTickData_Printing100IterationWalk()
        {
            var strategy    = new MarkovEquityStrategy();
            var identifiers = new InstrumentIdentifiers(
                string.Empty,
                string.Empty,
                string.Empty,
                "MSFT",
                "MS12345",
                "MSF123456789",
                "MSFT",
                "MSF12341234",
                "MSFT",
                "MSFT",
                "MSFT",
                "MSFT");
            var security = new FinancialInstrument(
                InstrumentTypes.Equity,
                identifiers,
                "Microsoft",
                "CFI",
                "USD",
                "Microsoft Company");
            var spread = new SpreadTimeBar(
                new Money(66, "GBP"),
                new Money(65, "GBP"),
                new Money(65, "GBP"),
                new Volume(200000));

            var tick = new EquityInstrumentIntraDayTimeBar(
                security,
                spread,
                new DailySummaryTimeBar(1000, "USD", null, 1000, new Volume(200000), DateTime.UtcNow),
                DateTime.UtcNow,
                new Market("1", "NASDAQ", "NASDAQ", MarketTypes.STOCKEXCHANGE));

            var printableInitialSecurity = JsonConvert.SerializeObject(security);

            Console.WriteLine(printableInitialSecurity);

            for (var i = 0; i < 99; i++)
            {
                tick = strategy.AdvanceFrame(tick, DateTime.UtcNow, true);

                var printableGeneratedSecurity = JsonConvert.SerializeObject(security);
                Console.WriteLine(printableGeneratedSecurity);

                Assert.IsTrue(tick.SpreadTimeBar.Bid.Value >= tick.SpreadTimeBar.Ask.Value);
            }
        }
        public void Ctor_AssignsVariables_Correctly()
        {
            var fi     = new FinancialInstrument();
            var prices = new IntradayPrices(null, null, null, null);
            var dates  = DateTime.UtcNow;

            var dailyTb = new DailySummaryTimeBar(100, "USD", prices, 123, new Volume(123), dates);

            var market        = new Market("1", "XLON", "London Stock Exchange", MarketTypes.DealerBooks);
            var equityTimeBar = new EquityInstrumentInterDayTimeBar(fi, dailyTb, dates, market);

            Assert.AreEqual(fi, equityTimeBar.Security);
            Assert.AreEqual(dailyTb, equityTimeBar.DailySummaryTimeBar);
            Assert.AreEqual(dates, equityTimeBar.TimeStamp);
            Assert.AreEqual(market, equityTimeBar.Market);
        }
Exemple #26
0
        public void FinancialInstruments_Ctor_AssignsValuesCorrectly()
        {
            var instrument         = InstrumentTypes.Bond;
            var identifiers        = InstrumentIdentifiers.Null();
            var name               = "test-instrument";
            var cfi                = "a-cfi";
            var currency           = "GBP";
            var issuerId           = "ISO-1000";
            var underlyingName     = "u-name";
            var underlyingCfi      = "u-cfi";
            var underlyingIssuerId = "u-issuer-id";
            var sectorCode         = "sect-100";
            var indCode            = "ind-100";
            var regCode            = "reg-100";
            var countryCode        = "count-100";

            var fi = new FinancialInstrument(
                instrument,
                identifiers,
                name,
                cfi,
                currency,
                issuerId,
                underlyingName,
                underlyingCfi,
                underlyingIssuerId,
                sectorCode,
                indCode,
                regCode,
                countryCode);

            Assert.AreEqual(fi.Type, instrument);

            Assert.AreNotEqual(fi.Identifiers, identifiers);
            Assert.AreEqual(fi.Name, name);
            Assert.AreEqual(fi.Cfi, cfi);
            Assert.AreEqual(fi.SecurityCurrency, currency);
            Assert.AreEqual(fi.IssuerIdentifier, issuerId);

            Assert.AreEqual(fi.UnderlyingName, underlyingName);
            Assert.AreEqual(fi.UnderlyingCfi, underlyingCfi);
            Assert.AreEqual(fi.UnderlyingIssuerIdentifier, underlyingIssuerId);
            Assert.AreEqual(fi.SectorCode, sectorCode);
            Assert.AreEqual(fi.IndustryCode, indCode);
            Assert.AreEqual(fi.RegionCode, regCode);
            Assert.AreEqual(fi.CountryCode, countryCode);
        }
Exemple #27
0
 public decimal Calculate(FinancialInstrument instrument)
 {
     if (instrument == null)
     {
         throw new ArgumentNullException();
     }
     else if (instrument is Bond)
     {
         return(instrument.MarketValue * 0.02m);
     }
     else if (instrument is Equity)
     {
         return(instrument.MarketValue * 0.005m);
     }
     else
     {
         return(0);
     }
 }
Exemple #28
0
        private Order OrderMultiple(FinancialInstrument financialInstrument, Market exch)
        {
            var orderDates = DateTime.UtcNow;

            var order = new Order(
                financialInstrument,
                exch,
                null,
                Guid.NewGuid().ToString(),
                DateTime.UtcNow,
                "order-v1",
                "order-v1-link",
                "order-group-v1",
                orderDates,
                orderDates,
                orderDates,
                orderDates,
                orderDates,
                orderDates,
                OrderTypes.MARKET,
                OrderDirections.BUY,
                new Currency("GBP"),
                new Currency("USD"),
                OrderCleanDirty.CLEAN,
                null,
                new Money(100, "GBP"),
                new Money(100, "GBP"),
                1000,
                1000,
                "trader-1",
                "trader one",
                "clearing-agent",
                "deal asap",
                null,
                null,
                null,
                OptionEuropeanAmerican.NONE,
                new DealerOrder[0]);

            return(order);
        }
Exemple #29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FixedIncomeHighVolumeJudgementContext"/> class.
 /// </summary>
 /// <param name="judgement">
 /// The judgement.
 /// </param>
 /// <param name="raiseRuleViolation">
 /// The raise rule violation.
 /// </param>
 /// <param name="ruleBreachContext">
 /// The rule breach context.
 /// </param>
 /// <param name="fixedIncomeParameters">
 /// The fixed income parameters.
 /// </param>
 /// <param name="totalOrdersTradedInWindow">
 /// The total orders traded in window.
 /// </param>
 /// <param name="security">
 /// The security.
 /// </param>
 /// <param name="isIssuanceBreach">
 /// The is issuance breach.
 /// </param>
 /// <param name="tradePosition">
 /// The trade Position.
 /// </param>
 /// <param name="venue">
 /// The venue.
 /// </param>
 public FixedIncomeHighVolumeJudgementContext(
     IFixedIncomeHighVolumeJudgement judgement,
     bool raiseRuleViolation,
     IRuleBreachContext ruleBreachContext,
     IHighVolumeIssuanceRuleFixedIncomeParameters fixedIncomeParameters,
     decimal totalOrdersTradedInWindow,
     FinancialInstrument security,
     bool isIssuanceBreach,
     TradePosition tradePosition,
     Market venue)
 {
     this.Judgement                 = judgement;
     this.RaiseRuleViolation        = raiseRuleViolation;
     this.RuleBreachContext         = ruleBreachContext;
     this.FixedIncomeParameters     = fixedIncomeParameters;
     this.TotalOrdersTradedInWindow = totalOrdersTradedInWindow;
     this.Security         = security;
     this.IsIssuanceBreach = isIssuanceBreach;
     this.TradePosition    = tradePosition;
     this.Venue            = venue;
 }
Exemple #30
0
        public async Task <int> NewFinancialInstrument(FinInstrumentDTO finInst)
        {
            var dbFinInst = await _dbContext.FinancialInstrument
                            .SingleOrDefaultAsync(x => x.Id == finInst.Id);

            if (dbFinInst == null)
            {
                dbFinInst = new FinancialInstrument
                {
                    CurrentPrice = finInst.Price,
                };

                await _dbContext.AddAsync(dbFinInst);

                await _dbContext.SaveChangesAsync();

                return(dbFinInst.Id);
            }

            return(-1);
        }