コード例 #1
0
        public static void SetIdentifiers(FI fi, IdentifierType identifierType, string[] identifiers, SymmetryEntities dc)
        {
          IList<FIIdentifier> list = null;
          {
            var currentIDs = fi.FIIdentifiers.Where(x => x.IdentifierType == identifierType);
            if (currentIDs != null && currentIDs.Any())
              list = currentIDs.ToList();
          }

          foreach (var identifier in identifiers)
          {
            if (string.IsNullOrEmpty(identifier)) continue;

            if (list == null)
            {
              fi.FIIdentifiers.Add(new FIIdentifier { IdentifierType = identifierType, Identifier = identifier });
            }
            else if (list.Any(x => string.Compare(x.Identifier, identifier, true) == 0))  // already exists
            {
              list.Remove(list.First(x => string.Compare(x.Identifier, identifier, true) == 0));  // remove from the list of existing
            }
            else
            {
              fi.FIIdentifiers.Add(new FIIdentifier { IdentifierType = identifierType, Identifier = identifier });
            }
          }

          // if we have any left in the original list, then remove them all
          if (list != null && list.Any())
            foreach (var v in list)
              dc.Entry(v).State = EntityState.Deleted;
        }
コード例 #2
0
    private static bool import(SymmetryEntities dc_, IEnumerable<AuctionInfo> infos_)
    {
      if (infos_ == null) return false;

      foreach (var info in infos_.Where(x=>x.HasRequiredInfoForAuctions()))
        import(dc_, info);

      return true;
    }
コード例 #3
0
ファイル: FIHelpers.cs プロジェクト: heimanhon/researchwork
 public static FI GetFIBySymmetryCode(string symmetryCode, SymmetryEntities dc, ThrowBehavior behavior = ThrowBehavior.Throw)
 {
     try
     {
         return dc.FIs.SingleOrDefault(fi => fi.SymmetryCode.Equals(symmetryCode, StringComparison.InvariantCultureIgnoreCase));
     } catch (Exception ex)
     {
         Exceptions.Rethrow("GetFIBySymmetryCode", behavior, ex);
     }
     return null;
 }
コード例 #4
0
ファイル: FIHelpers.cs プロジェクト: heimanhon/researchwork
 public static FI GetFI(int fiid, SymmetryEntities dc, ThrowBehavior behavior = ThrowBehavior.Throw)
 {
     try
     {
         return dc.FIs.SingleOrDefault(f => f.FIID == fiid);
     }
     catch (Exception ex)
     {
         Exceptions.Rethrow("GetFI", behavior, ex);
     }
     return null;
 }
コード例 #5
0
		protected override ValidatedInstrument[] getValidatedInstruments(SymmetryEntities dc_, ExtractionServiceClient dsClient_, CredentialsHeader credentials_)
		{
			var allEDs = dc_.FIs.Where(x =>
				x.InstrumentType == InstrumentType.IRFuture
				&& x.Maturity >= DateTime.Today
				&& x.SymmetryCode.StartsWith("ED"))
				.Where(x => x.Maturity.Value.Month % 3 == 0)
				.OrderBy(x => x.Maturity)
				.Take(12);

			var listOfInstruments = new List<InstrumentIdentifier>();

			// find the market snap to which 
			var marketSnap = QuoteHelpers.GetMarketSnap("CLOSE", m_markDate, dc_, ThrowBehavior.DontThrow);
			if (marketSnap == null) return null;

			var source = QuoteHelpers.GetQuoteSource("SYM", dc_, ThrowBehavior.DontThrow);
			if (source == null) return null;

			foreach (var ed in allEDs)
			{
				EDItem item = new EDItem(ed, dc_, marketSnap, source);

				if (item.CanRequestPrice)
				{
					m_items.Add(item);
					m_ricToOptionItem[item.OptionAbovePrice.ReutersTicker] = item.OptionAbovePrice;
					m_ricToOptionItem[item.OptionBelowPrice.ReutersTicker] = item.OptionBelowPrice;

					listOfInstruments.Add(new InstrumentIdentifier()
					{
						IdentifierValue = item.OptionBelowPrice.ReutersTicker,
						IdentifierType="RIC"
					});

					listOfInstruments.Add(new InstrumentIdentifier()
					{
						IdentifierValue = item.OptionAbovePrice.ReutersTicker,
						IdentifierType="RIC"
					});
				}
			}

			if (listOfInstruments.Count() > 0)
			{
				var v = ServiceHelpers.ValidateInstruments_FindUnValidated(listOfInstruments.ToArray(), dsClient_, ref credentials_);
				m_notValidatedIdentifiers = v.Item2;
				return v.Item1;
			}
			else
				return null;
		}
コード例 #6
0
 public static MarketSnap GetMarketSnap(string marketSnapCode, DateTime snapDate, SymmetryEntities dc, ThrowBehavior behavior = ThrowBehavior.Throw)
 {
     try
     {
         return dc.MarketSnaps.SingleOrDefault(s => s.MarketSnapSchedule.MarketSnapCode.Equals(marketSnapCode, StringComparison.InvariantCultureIgnoreCase) &&
             s.ValueDate == snapDate);
     }
     catch (Exception ex)
     {
         Exceptions.Rethrow("GetMarketSnap", behavior, ex);
     }
     return null;
 }
コード例 #7
0
ファイル: FIHelpers.cs プロジェクト: heimanhon/researchwork
 public static string[] GetFIIdentifiers(string symmetryCode, IdentifierType identifierType, SymmetryEntities dc, ThrowBehavior behavior = ThrowBehavior.Throw)
 {
   try
   {
     return dc.FIIdentifiers.Where(x => x.FI.SymmetryCode.Equals(symmetryCode, StringComparison.InvariantCultureIgnoreCase) && x.IdentifierType == identifierType)
       .Select(x => x.Identifier).ToArray();
   }
   catch (Exception ex_)
   {
     Exceptions.Rethrow("GetFIIdentiers", behavior, ex_);
   }
   return null;
 }
コード例 #8
0
ファイル: FIHelpers.cs プロジェクト: heimanhon/researchwork
 public static string GetFIIdentifier(string symmetryCode, IdentifierType identifierType, SymmetryEntities dc, ThrowBehavior behavior = ThrowBehavior.Throw)
 {
     try
     {
         var fiID = dc.FIIdentifiers.SingleOrDefault(i => i.FI.SymmetryCode.Equals(symmetryCode, StringComparison.InvariantCultureIgnoreCase)
             && i.IdentifierType == identifierType);
         return fiID==null ? null : fiID.Identifier;
     }
     catch (Exception ex)
     {
         Exceptions.Rethrow("GetFIIdentifier", behavior, ex);
     }
     return null;
 }
コード例 #9
0
 public static MarketSnap GetLatestMarketSnapWithValues(string marketSnapCode, DateTime latestDate, SymmetryEntities dc, ThrowBehavior behavior = ThrowBehavior.Throw)
 {
   try
   {
     var snap = dc.MarketSnaps.Where(s => s.MarketSnapSchedule.MarketSnapCode.Equals(marketSnapCode, StringComparison.InvariantCultureIgnoreCase))
         .Where(v => v.ValueDate <= latestDate)
         .OrderByDescending(v => v.ValueDate).FirstOrDefault(v=>v.Quotes.Count>0);
     return snap;
   }
   catch (Exception ex)
   {
     Exceptions.Rethrow("GetLatestMarketSnap", behavior, ex);
   }
   return null;
 }
コード例 #10
0
 public static void CheckDatabase()
 {
     try
     {
         using (var dc = new SymmetryEntities())
         {
             var fi = dc.FIs.First();
             SLog.log.InfoFormat("Connected to the datasource/database: [{0}]/[{1}]", dc.Database.Connection.Database, dc.Database.Connection.DataSource); 
         }
     }
     catch (Exception ex)
     {
         SLog.log.Error("Error connecting to the database", ex);
     }
 }
コード例 #11
0
 public static FI GetFutureByMaturity(string bloombergChain, DateTime maturity, SymmetryEntities dc, ThrowBehavior behavior = ThrowBehavior.Throw)
 {
     try
     {
         var fi = dc.FIs.FirstOrDefault(i =>
             ( i.InstrumentType == InstrumentType.IRFuture || i.InstrumentType == InstrumentType.BondFuture )
             && i.Maturity.HasValue && i.Maturity.Value == maturity && i.SymmetryCode.StartsWith(bloombergChain));
         return fi;
     }
     catch (Exception ex)
     {
         Exceptions.Rethrow("GetFutureByMaturity", behavior, ex);
     }
     return null;
 }
コード例 #12
0
ファイル: FIHelpers.cs プロジェクト: heimanhon/researchwork
 public static FI GetFIByIdentifier(string identifier, IdentifierType identifierType, SymmetryEntities dc, ThrowBehavior behavior = ThrowBehavior.Throw)
 {
     try
     {
         var identifierEntry = dc.FIIdentifiers.SingleOrDefault(i => i.IdentifierType == identifierType && i.Identifier.Equals(identifier, StringComparison.InvariantCultureIgnoreCase));
         if (identifierEntry != null)
         {
             return identifierEntry.FI;
         }
     }
     catch (Exception ex)
     {
         Exceptions.Rethrow("GetFIByIdentifier", behavior, ex);
     }
     return null;
 }
コード例 #13
0
 public static void SetOrUpdateIdentifier(FI fi, IdentifierType identifierType, string identifier, SymmetryEntities dc)
 {
     if (!string.IsNullOrWhiteSpace(identifier))
     {
         var id = fi.FIIdentifiers.SingleOrDefault(i => i.IdentifierType == identifierType);
         if (id == null)
         {
             fi.FIIdentifiers.Add(new FIIdentifier { IdentifierType = identifierType, Identifier = identifier });
         }
         else
         {
             if (id.Identifier != identifier)
             {
                 id.Identifier = identifier;
                 FIChangeTracking.SetModified(id, dc);
             }
         }
     }
 }
コード例 #14
0
    private List<FI> getAllBondsToPrice(SymmetryEntities dc_)
    {
      var superSet = Symmetry.Data.FIHelpers.GetFIByLiveDateAndInstrumentType(
          dc_: dc_,
          liveDate_: DateTime.Today.AddDays(-3d),
          instrumentType_: Data.Enums.InstrumentType.Bond
          );

      // take out inactive bonds
      superSet = superSet.Where(x => x.IsInactive.HasValue == false || x.IsInactive.Value != 1).ToList();

      // get rid of floater bonds

      superSet =
        superSet.Where(x =>
          x.FIBond != null
          && (x.FIBond.IsFloater.HasValue == false || x.FIBond.IsFloater.Value == 0))
          .ToList();

      return superSet.Where(x => m_bondFilter(x)).ToList();
    }
コード例 #15
0
    protected override ValidatedInstrument[] getValidatedInstruments(SymmetryEntities dc_, ExtractionServiceClient dsClient_, CredentialsHeader credentials_)
    {
      var allFixings = getAllSwaps(dc_);

      m_ric_to_FIs = new Dictionary<string, FI>();

      var listOfInstruments = new List<InstrumentIdentifier>();


      foreach (var fi in allFixings)
      {
        string[] rics = FIHelpers.GetFIIdentifiers(fi.SymmetryCode, IdentifierType.RIC, dc_, ThrowBehavior.DontThrow);

        if (rics == null || rics.Length==0)
        {
          SLog.log.WarnFormat("Cannot locate RIC for SymmetryCode:{0}", fi.SymmetryCode);
          continue;
        }
        Array.ForEach(rics, x =>  {
            m_ric_to_FIs.Add(x, fi);
            listOfInstruments.Add(new InstrumentIdentifier()
            {
              IdentifierType="RIC",
              IdentifierValue=x
            });
          }
          );
      }

      var t = ServiceHelpers.ValidateInstruments_FindUnValidated(listOfInstruments.ToArray(), dsClient_, ref credentials_);

      m_notValidatedIdentifiers = t.Item2;

      return t.Item1;

    }
コード例 #16
0
 public static Dictionary<string, int> LookupSwaps(FI fixing, List<string> swapTenors, SymmetryEntities dc)
 {
     var result = new Dictionary<string, int>();
     if (swapTenors != null && swapTenors.Count > 0)
     {
         SortedSet<string> normalizedTenors = new SortedSet<string>(swapTenors.Select(t => (Tenor.FromString(t)).ToString()));
         foreach (var swap in FIHelpers.GetDerivativeInstruments(fixing, InstrumentType.IRSwap, dc))
         {
             try
             {
                 string swapTenorString = (Tenor.FromString(swap.Tenor)).ToString(); // normalize
                 if (normalizedTenors.Contains(swapTenorString))
                 {
                     result.Add(swapTenorString, swap.FIID);
                 }
             }
             catch (Exception)
             {
                 SLog.log.WarnFormat("Ignoring instrument {0} as unable to parse tenor {1}", swap.SymmetryCode, swap.Tenor);
             }
         }
     }
     return result;
 }
コード例 #17
0
 public static Dictionary<string, int> LookupMoneyMarkets(string currency, List<string> moneyMarketsIndices, SymmetryEntities dc)
 {
     var result = new Dictionary<string, int>();
     if (moneyMarketsIndices != null)
     {
         foreach (var index in moneyMarketsIndices)
         {
             var fi = FIHelpers.GetFIBySymmetryCode(index, dc, ThrowBehavior.DontThrow);
             if (fi != null && !string.IsNullOrWhiteSpace(fi.Tenor))
             {
                 result.Add(fi.Tenor, fi.FIID);
             }
         }
     }
     else
     {
         foreach (var fi in FIHelpers.GetFIByTypeAndCurrency(currency, InstrumentType.IRFixing, dc))
         {
             try
             {
                 if (!string.IsNullOrEmpty(fi.Tenor))
                 {
                     if (!result.ContainsKey(fi.Tenor))
                     {
                         result.Add(fi.Tenor, fi.FIID);
                     }
                 }
             }
             catch (Exception ex)
             {
                 SLog.log.WarnFormat("Error accessing instrument {0} for curve inclusion: {1}", fi.SymmetryCode, ex.Message);
             }
         }
     }
     return result;
 }
コード例 #18
0
 public static List<List<object>> CreateConstituentsTable(Dictionary<int, QuoteValues> quotes, List<int> fiOrder, SymmetryEntities dc)
 {
     try
     {
         var constituentsTable = new List<List<object>>();
         constituentsTable.Add(new List<object> { "Symmetry Code", "Maturity", "Tenor", "Quote", "Impl Vol" });
         foreach (var fiid in fiOrder)
         {
             if (quotes.ContainsKey(fiid))
             {
                 var quote = quotes[fiid];
                 try
                 {
                     var fi = FIHelpers.GetFI(fiid, dc);
                     decimal scalar = 1M;
                     if(fi.InstrumentType == InstrumentType.IRFixing || fi.InstrumentType == InstrumentType.IRSwap)
                     {
                         scalar = 100M;
                     }
                     constituentsTable.Add(new List<object> { fi.SymmetryCode, fi.Maturity.HasValue ? (double?)fi.Maturity.Value.ToOADate() : null,                            
                     fi.Tenor, quote.GetValue(QuoteValueType.Price) * scalar,
                         quote.GetValue(QuoteValueType.ImpliedVol) * 100M });
                 }
                 catch (Exception ex)
                 {
                     SLog.log.Warn("Error retrieving instrument info " + fiid, ex);
                 }
             }
         }
         return constituentsTable;
     } catch(Exception ex)
     {
         SLog.log.Error("Error composing constituents table", ex);
     }
     return null;
 }
コード例 #19
0
 public static MarketSnap GetOrCreateMarketSnap(string marketSnapCode, DateTime snapDate, SymmetryEntities dc, ThrowBehavior behavior = ThrowBehavior.Throw)
 {
     try
     {
         var schedule = dc.MarketSnapSchedules.Single(s => s.MarketSnapCode.Equals(marketSnapCode));
         var snap = dc.MarketSnaps.SingleOrDefault(s => s.MarketSnapSchedule.MarketSnapCode.Equals(marketSnapCode, StringComparison.InvariantCultureIgnoreCase) &&
             s.ValueDate == snapDate);
         if (snap == null)
         {
             snap = new MarketSnap
             {
                 ValueDate = snapDate,
                 MarketSnapSchedule = schedule
             };
             dc.MarketSnaps.Add(snap);
         }
         return snap;
     }
     catch (Exception ex)
     {
         Exceptions.Rethrow("GetOrCreateMarketSnap", behavior, ex);
     }
     return null;
 }
コード例 #20
0
    private bool saveValues(IList<ExtractClass> items_, SymmetryEntities dc_, string marketSnapCode_)
    {
      if (items_ == null || !items_.Any())
        return false;

      foreach (var v in items_.Where(x => x.Value.HasValue && x.CloseDate.HasValue))
      {
        try
        {
          MarketSnap snapToUse = QuoteHelpers.GetOrCreateMarketSnap(marketSnapCode_, v.CloseDate.Value.Date, dc_,
              ThrowBehavior.DontThrow);

          decimal adjustedPrice = Convert.ToDecimal(v.Value.Value)/100M;

          var fi = FIHelpers.GetFIByAnyIdentifier(v.RIC, dc_);

          SaveQuote(fi.FIID, QuoteValueType.Price, getQuoteSource(_symmetryQuoteSource, dc_), adjustedPrice, dc_,
            snapToUse);

          SaveQuoteAsMLPMLP(fi.FIID, QuoteValueType.Price, adjustedPrice, dc_, v.CloseDate.Value);
        }
        catch (Exception ex_)
        {
          SLog.log.Error(string.Format("Error saving quote for {0}", v.RIC), ex_);
        }
      }

      return true;
    }
コード例 #21
0
    private static void checkDatabase(SymmetryEntities dc)
    {
      Logger.Info(
        string.Format("about to operate on database {0}.{1}", dc.Database.Connection.DataSource,
          dc.Database.Connection.Database), typeof(USDataUploader));

      Console.WriteLine("continue?");

      Console.ReadLine();

    }
コード例 #22
0
 private IList<FI> getAllSwaps(SymmetryEntities dc_)
 {
   return dc_.FIs.Where(x => x.InstrumentType == InstrumentType.IRSwap).ToList();
 }
コード例 #23
0
    public override bool ProcessRetrievedFTPFile(SymmetryEntities dc_, string marketSnapCode_, DateTime valueDate_, string filePath_)
    {
      var loader = new CSVLoader<ExtractClass>(new Dictionary<string, string>
      {
        {AttributeHelper.GetSingleAttribute<RSSFieldAttribute>(FieldsToReturn.RIC).FieldName, "RIC"},
        {AttributeHelper.GetSingleAttribute<RSSFieldAttribute>(FieldsToReturn.BidPrice).FieldName, "BidPrice"},
        {AttributeHelper.GetSingleAttribute<RSSFieldAttribute>(FieldsToReturn.AskPrice).FieldName, "AskPrice"},
        {AttributeHelper.GetSingleAttribute<RSSFieldAttribute>(FieldsToReturn.BidAskUpdateTime).FieldName,"BidAskDate"},
      });

      var list = loader.Load(filePath_);

      return saveResponses(list, dc_, QuoteHelpers.GetOrCreateMarketSnap(marketSnapCode_, valueDate_, dc_));
    }
コード例 #24
0
 public override ReutersDSS.FTP.InputList BuildFTPInputList(SymmetryEntities dc_, ExtractionServiceClient dsClient_)
 {
   return new ReutersDSS.FTP.InputList()
   {
     InputListAction="Replace",
     Name=ftpInstrumentList.ToString(),
     Instrument=getAllSwaps(dc_)
     .Select(x=>FIHelpers.GetFIIdentifiers(x.SymmetryCode,IdentifierType.RIC,dc_,ThrowBehavior.DontThrow))
     .Where(x=>x!=null && x.Length>0)
     .SelectMany(x=>x)
     .Select(x=>new ReutersDSS.FTP.Instrument()
     {
       IdentifierType="RIC",
       Identifier=x,
     }).ToList()
   };
 }
コード例 #25
0
    private bool saveResponses(IList<ExtractClass> items_, SymmetryEntities dc_, MarketSnap snap_)
    {
      if (items_ == null || !items_.Any())
        return false;

      var symmetryCodeToPrices = new SortedDictionary<string, decimal?[]>();

      int objectLength = Enum.GetValues(typeof(RIC_SOURCE)).Length;

      foreach (var response in items_.Where(x=>x.BidPrice.HasValue && x.AskPrice.HasValue))
      {
        try
        {
          var fi = FIHelpers.GetFIByAnyIdentifier(response.RIC, dc_, ThrowBehavior.Throw);

          // extract bid / ask price from line

          var scaledValue = Convert.ToDecimal(response.BidPrice.Value + response.AskPrice.Value)/2/100;

          // save this particular source of a price

          var ricSource = RICHelper.GetSourceFromRIC(response.RIC);
          SaveQuote(fi.FIID, QuoteValueType.Price, getQuoteSource(ricSource, dc_), scaledValue, dc_, snap_);

          // get array to store

          decimal?[] values;

          if (!symmetryCodeToPrices.ContainsKey(fi.SymmetryCode))
          {
            values = new decimal?[objectLength];
            symmetryCodeToPrices[fi.SymmetryCode] = values;
          }
          else
          {
            values = symmetryCodeToPrices[fi.SymmetryCode];
          }

          // if the bidaskdate isn't the snapDate (i.e. =stale price), then don't want to include it in the average
          if (response.BidAskDate.HasValue && response.BidAskDate.Value.Date < snap_.ValueDate)
          {
            SLog.log.InfoFormat(
              "Not going to include quote with RIC=[{0}] as snapDate is {1} which is stale relative to {2}",
              response.RIC,
              response.BidAskDate.Value,
              snap_.ValueDate);

            continue;
          }

          // store in array to take average later

          RIC_SOURCE src = RICHelper.GetRICsourceFromRIC(response.RIC);
          values[(int) src] = scaledValue;
        }
        catch (Exception ex_)
        {
          SLog.log.Error(
            string.Format("Error extracting {0} pricing values from Datascope response row ({1})", sName, response.RIC),
            ex_);
        }
      }

      foreach (var code in symmetryCodeToPrices.Keys)
      {
        var nonZeros = symmetryCodeToPrices[code].Where(x => x.HasValue);

        if (!nonZeros.Any()) continue;

        decimal averagedValue = nonZeros.Select(x => x.Value).Average();

        var fi = FIHelpers.GetFIBySymmetryCode(code, dc_);

        // save quote to 'SYM' for this market snap
        SaveQuote(
          fiid_: fi.FIID,
          quoteType_: QuoteValueType.Price,
          quoteSource_: getQuoteSource(_symmetryQuoteSource, dc_),
          value_: averagedValue,
          dc_: dc_,
          snap_: snap_);
      }

      return true;
    }
コード例 #26
0
    protected override void processResponsesFromDataScope(SymmetryEntities dc_, MarketSnap snap_, string marketSnapCode_)
    {
      OutputToCSV(m_resultsFromDataScope);

      var list = new List<ExtractClass>();

      foreach(var response in m_resultsFromDataScope)
      {
        foreach(var row in response.Rows)
        {
          try
          {
            var ric = GetValueFromObjectArray<string>((int)FieldsToReturn.RIC, row, ThrowBehavior.Throw);

            // extract bid / ask price from line

            var bid = GetValueFromObjectArray<double>((int)FieldsToReturn.BidPrice, row, ThrowBehavior.Throw);
            var ask = GetValueFromObjectArray<double>((int)FieldsToReturn.AskPrice, row, ThrowBehavior.Throw);

            list.Add(new ExtractClass()
            {
              RIC = ric,
              BidPrice = bid,
              AskPrice = ask
            });
          }
          catch (Exception ex_)
          {
            SLog.log.Error(string.Format("Error extracting {0} pricing values from Datascope response row ({1})", sName, ServiceHelpers.ToCsvLine(row)), ex_);
          }
        }
      }

      saveResponses(list, dc_, snap_);
    }
コード例 #27
0
    private static FIIdentifier findCusipIdentifier(SymmetryEntities dc_, AuctionInfo info_)
    {
      var cusipIdentifier =
  dc_.FIIdentifiers.FirstOrDefault(
    x => string.Compare(info_.Cusip, x.Identifier, StringComparison.OrdinalIgnoreCase) == 0);

      if (cusipIdentifier == null)
      {
        // can we find by assuming that the cusip is contained within the ISIN?....

        var fi =
          dc_.FIs.FirstOrDefault(
            x =>
              x.InstrumentType == Data.Enums.InstrumentType.Bond &&
              x.SymmetryCode.ToUpper().Contains(info_.Cusip.ToUpper()));

        if (fi == null)
        {
          SLog.log.DebugFormat(
            "Couldn't find bond to update for auction info with cusip={0} ; issueDate={1} ; maturity={2}", info_.Cusip,
            info_.IssueDate, info_.Maturity);
          return null;
        }

        // let's take the opportunity to add in the cusip identifier
        cusipIdentifier = new FIIdentifier
        {
          FIID = fi.FIID,
          FI = fi,
          Identifier = info_.Cusip,
          IdentifierType = Data.Enums.IdentifierType.CUSIP
        };

        dc_.FIIdentifiers.Add(cusipIdentifier);
      }

      return cusipIdentifier;
    }
コード例 #28
0
    private static void import(SymmetryEntities dc_, AuctionInfo info_)
    {
      var cusipIdentifier = findCusipIdentifier(dc_, info_);

      if (cusipIdentifier == null) return;

      // take the opportunity to update the coupon if it's different

      if (cusipIdentifier.FI != null 
        && cusipIdentifier.FI.FIBond != null 
        && info_.Coupon.HasValue
        && Math.Abs(Convert.ToDouble(cusipIdentifier.FI.FIBond.Coupon) - info_.Coupon.Value) > 1e-3)
      {
        SLog.log.InfoFormat("Changing coupon of {0} from {1} to {2}", cusipIdentifier.Identifier,
          cusipIdentifier.FI.FIBond.Coupon, info_.Coupon);

        cusipIdentifier.FI.FIBond.Coupon = Convert.ToDecimal(info_.Coupon.Value);
        FIChangeTracking.SetModified(cusipIdentifier.FI.FIBond, dc_);
        dc_.SaveChanges();
      }


      bool found = false;

      foreach (var auction in dc_.FIBondAuctions.Where(x => x.FIID == cusipIdentifier.FIID))
      {

        if (auction.AuctionDate == info_.AuctionDate.Value)
        {
          //SLog.log.DebugFormat("Auction already set up for {0} on {1}", info_.Cusip, info_.AuctionDate.Value);

          if (!auction.EffectiveDate.HasValue)
          {
            SLog.log.InfoFormat("Updating auction effective date to {0}", info_.IssueDate.Value);
            auction.EffectiveDate = info_.IssueDate.Value;
            FIChangeTracking.SetModified(auction, dc_);
          }
          found = true;
          break;
        }
      }

      if (found)
      {
        dc_.SaveChanges();
        return;
      }

      SLog.log.InfoFormat("Setting up auction for {0} on {1}", info_.Cusip, info_.AuctionDate.Value);


      var newAuction = new FIBondAuction()
      {
        FIID = cusipIdentifier.FIID,
        FIBond = dc_.FIBonds.FirstOrDefault(x => x.FIID == cusipIdentifier.FIID),
        AuctionDate = info_.AuctionDate.Value,
        EffectiveDate = info_.IssueDate.Value,
        Term = info_.Term.Value
      };

      dc_.FIBondAuctions.Add(newAuction);
      dc_.SaveChanges();
    }
コード例 #29
0
    public override bool ProcessRetrievedFTPFile(SymmetryEntities dc_, string marketSnapCode_, DateTime valueDate_, string filePath_)
    {
      var loader = new CSVLoader<ExtractClass>(new Dictionary<string, string>
      {
        {AttributeHelper.GetSingleAttribute<RSSFieldAttribute>(FieldsToReturn.RIC).FieldName, "RIC"},
        {AttributeHelper.GetSingleAttribute<RSSFieldAttribute>(FieldsToReturn.UniversalClosePrice).FieldName, "Value"},
        {AttributeHelper.GetSingleAttribute<RSSFieldAttribute>(FieldsToReturn.UniversalClosePriceDate).FieldName, "CloseDate"},
      });

      var extracted = loader.Load(filePath_);

      return saveValues(extracted, dc_, marketSnapCode_);
    }
コード例 #30
0
    protected override void processResponsesFromDataScope(SymmetryEntities dc_, MarketSnap snap_, string marketSnapCode_)
    {
      OutputToCSV(m_resultsFromDataScope);

      var list = new List<ExtractClass>();

      foreach (var response in m_resultsFromDataScope)
      {
        foreach (var row in response.Rows)
        {
          try
          {
            // extract values
            var ric = GetValueFromObjectArray<string>((int)FieldsToReturn.RIC, row, ThrowBehavior.Throw);
            var fi = m_ric_to_FIs[ric];
            var fix = GetValueFromObjectArray<double>((int)FieldsToReturn.UniversalClosePrice, row,ThrowBehavior.Throw);
            var closeDate = GetValueFromObjectArray<DateTime>((int)FieldsToReturn.UniversalClosePriceDate, row, ThrowBehavior.Throw);

            list.Add(new ExtractClass()
            {
              RIC = ric,
              Value = fix,
              CloseDate = closeDate
            });
          }
          catch (Exception ex_)
          {
            SLog.log.Error(string.Format("Error extracting {0} pricing values from Datascope response row ({1})", sName, ServiceHelpers.ToCsvLine(row)), ex_);
          }
        }
      }
      saveValues(list, dc_, snap_.MarketSnapSchedule.MarketSnapCode);
    }