本文整理汇总了C#中CarbonClient类的典型用法代码示例。如果您正苦于以下问题:C# CarbonClient类的具体用法?C# CarbonClient怎么用?C# CarbonClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CarbonClient类属于命名空间,在下文中一共展示了CarbonClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: populateDates
private async Task populateDates(CarbonClient cc_)
{
var yesterday = await cc_.RollDateAsync(
date: DateTime.Today.ToNodaLocalDate(),
count: -1,
unit: Symmetry.Carbon.Model.DateUnit.Bd,
convention: Symmetry.Carbon.Model.BusinessDayConvention.Following,
calendar: Market.HolidayCode());
var spotSettle = await cc_.RollDateAsync(
date: DateTime.Today.ToNodaLocalDate(),
count: Market.DaysToSpot(),
unit: Symmetry.Carbon.Model.DateUnit.Bd,
convention: Symmetry.Carbon.Model.BusinessDayConvention.Following,
calendar: Market.HolidayCode());
var yesterdaySettle = await cc_.RollDateAsync(
date: yesterday,
count: Market.DaysToSpot(),
unit: Symmetry.Carbon.Model.DateUnit.Bd,
convention: Symmetry.Carbon.Model.BusinessDayConvention.Following,
calendar: Market.HolidayCode());
Today = new AsOfAndSpotSettle(DateTime.Today, spotSettle.ToDateTime());
Yesterday = new AsOfAndSpotSettle(yesterday.ToDateTime(), yesterdaySettle.ToDateTime());
}
示例2: Populate
public async Task Populate(CarbonClient cc_, OrderOverrides orderOv_)
{
if (m_source == null) return;
var dict = new Dictionary<string, LiveExposurePnlMulti>();
foreach (var item in m_source.InnerList)
{
var subItem = item.PnlName.Contains("#") ? item.PnlName.Split('#')[0] : item.PnlName;
if (!dict.ContainsKey(subItem))
{
var newItem = new LiveExposurePnlMulti(subItem) {DisplaySortNumber = await AssetOrder.GetOrder(subItem, cc_)};
if (orderOv_ != null && orderOv_.HasOverrides)
{
newItem.DisplaySortNumber = orderOv_.GetSortOrder(Helper.StripBbgEndings(item.PnlName));
}
dict.Add(subItem, newItem);
}
dict[subItem].Add(item);
}
var items = new List<LiveExposurePnlMulti>(dict.Values);
m_items.AddRange(items.OrderBy(x => x.DisplaySortNumber));
for (int i = 0; i < m_items.Count; ++i)
m_items[i].Index = i;
}
示例3: initiate
private async Task initiate(CarbonClient cc_, BondMeasures listenToThis_)
{
m_fcsCurve = await IRCurveImpl.Get(SwapCurve.GetForecastCurve(), DateContext, cc_);
// if we're doing calcs on the forwards, then don't need to listen to the curve directly
// as the forward price will be updated as a result of a change in curve and will trickle
// through to us as a price update
if (SettleDate == DateContext.SpotSettle)
m_fcsCurveDisp = m_fcsCurve.GetMonitor()/*.Throttle(TimeSpan.FromSeconds(10),Scheduler.Default)*/.Subscribe(handleFcstCurveUpdate);
if (SwapCurve.GetForecastCurve() == SwapCurve.GetDiscountCurve())
{
m_disCurve = m_fcsCurve;
}
else
{
m_disCurve = await IRCurveImpl.Get(SwapCurve.GetForecastCurve(), DateContext, cc_);
if (SettleDate == DateContext.SpotSettle)
m_disCurveDisp = m_disCurve.GetMonitor()/*.Throttle(TimeSpan.FromSeconds(10), Scheduler.Default)*/.Subscribe(handleDiscCurveUpdate);
}
//
var flds = new[] { BondMeasure.Price, BondMeasure.Yield };
Array.ForEach(flds, fld =>
{
var d = listenToThis_.GetValue(fld);
if (d.HasValue)
m_measures.SetValue(fld, d.Value);
});
calcMMS();
calcZSpread();
}
示例4: GoSave
public async Task GoSave(SI.Data.EventDef event_, CarbonClient cc_, bool completeReSave_=false)
{
var dates = getDates(event_);
if (dates == null || dates.Count() == 0)
{
Logger.Debug(string.Format("Could not retrieve dates for {0}", event_), typeof(DateGetterBase));
return;
}
var eventCurrentDates = await event_.GetEvents(TZ.GMT,cc_);
// if doint a complete resave then need to load all, else work from the last point saved
var earliestDate = completeReSave_ || eventCurrentDates == null || eventCurrentDates.Length == 0
? _START_DATE
: eventCurrentDates.Last().AddMinutes(1d);
int updateCount = 0;
// whack in insert statements
foreach (var date in dates.Where(x => x > earliestDate))
{
updateCount += 1;
await event_.AddInGMTDateToLocalCache(date, cc_);
}
if (updateCount>0)
{
Logger.Debug(string.Format("About to save {0} dates for eventID:{1}", updateCount, event_), typeof(DateGetterBase));
await event_.WriteGMTEventsDatesToCarbon(cc_);
//Logger.Debug(string.Format("...{0}", success), typeof(DateGetterBase));
}
}
示例5: GetAllEventsInRange
public Tuple<DateTime, string>[] GetAllEventsInRange(CarbonClient cc_, DateTime start, DateTime end)
{
var eventHandlers = Singleton<EventDefs>.Instance;
var eventCodes = new HashSet<Tuple<DateTime, string>>();
//Parallel.ForEach(eventHandlers, eh =>
//{
// var dates = eh.GetEvents(TZ.LN, cc_).Result;
// if (dates != null && dates.Any(d => d >= start && d <= end))
// eventCodes.Add(eh.EventCode);
//});
eventHandlers.ForEach(eh =>
{
var dates = eh.GetEvents(TZ.LN, cc_).Result;
if (dates != null && dates.Any(d => d >= start && d <= end))
{
var date = dates.Last(d => d <= end);
eh.Date = date;
eventCodes.Add(new Tuple<DateTime, string>(dates.Last(d => d <= end), eh.EventCode));
}
else if (dates != null && dates.Any())
{
DateTime date;
date = dates.FirstOrDefault(d => d >= DateTime.Today);
if (date == default(DateTime))
date = dates.Last();
eh.Date = date;
}
});
return eventCodes.ToArray();
}
示例6: GetEventDates
public DateTime[] GetEventDates(string eventCode, CarbonClient cc_)
{
var eventHandler = Singleton<EventDefs>.Instance.FirstOrDefault(e => e.EventCode == eventCode);
if(eventHandler != null)
return eventHandler.GetEvents(TZ.LN, cc_).Result;
return null;
}
示例7: PopulateData
public async Task PopulateData(CarbonClient cc_)
{
var data = await cc_.GetStaticDataAsync(identifier: Identifier);
if (data == null || data.Count == 0) return;
foreach (var kvp in data[0].Properties)
{
switch (kvp.Key)
{
case "desc":
Description = kvp.Value.AsString();
break;
case "firstTradeDt":
FirstTrade = DateTime.ParseExact(kvp.Value.AsString(), "yyyyMMdd", CultureInfo.InvariantCulture);
break;
case "lastTradeDt":
LastTrade = DateTime.ParseExact(kvp.Value.AsString(), "yyyyMMdd", CultureInfo.InvariantCulture);
break;
case "firstNoticeDt":
FirstNotice = DateTime.ParseExact(kvp.Value.AsString(), "yyyyMMdd", CultureInfo.InvariantCulture);
break;
case "expirationDt":
Expiration = DateTime.ParseExact(kvp.Value.AsString(), "yyyyMMdd", CultureInfo.InvariantCulture);
break;
case "lastDeliveryDt":
LastDelivery = DateTime.ParseExact(kvp.Value.AsString(), "yyyyMMdd", CultureInfo.InvariantCulture);
break;
}
}
}
示例8: Get
public static async Task<DatedDataCollectionGen<double>> Get(string name_, CarbonClient cc_, bool force_ = false)
{
if (_cache.ContainsKey(name_) && !force_)
return _cache[name_];
try
{
var con = await DataFrameHelper.GetDataFrameByRow(
name_: string.Format("ssys.trs.{0}",name_),
keyExtractor_: x => (DateTime) x,
valueExtractor_: (dict, vals) => Convert.ToDouble(vals[0]),
cc_: cc_);
var ddc = new DatedDataCollectionGen<double>(con.Keys.ToArray(), con.GetColumnValues(0));
_cache[name_] = ddc;
return ddc;
}
catch (Exception ex_)
{
_cache[name_] = null;
Logger.Error(string.Format("Error getting timeseries for [{0}]", name_), typeof (TimeSeries), ex_);
return null;
}
}
示例9: Create
public async Task Create(CarbonClient cc_)
{
await interEventsPickOneSide1.Create(cc_);
await interEventsPickOneSide2.Create(cc_);
interEventsPickOneSide1.SelectedChanged += (x, y) =>
{
m_boundList.Clear();
};
interEventsPickOneSide2.SelectedChanged += (x, y) =>
{
m_boundList.Clear();
};
boundInfraGrid1.Bind(m_boundList);
eventPreselectionControlYearQuarter1.Create();
eventPreselectionControlYearQuarter1.PreselectionChanged += (x, y) =>
{
preselect();
};
}
示例10: CalcContToRisk
public async Task<double[]> CalcContToRisk(string[] exposureNames_, double[] exposureValues_, CarbonClient cc_)
{
// get indexes for instruments in covariance
var indexes = new Tuple<int, bool>[exposureNames_.Length];
for (int i = 0; i < indexes.Length; ++i)
indexes[i] = await FindIndexOfInstrument(exposureNames_[i], cc_);
// translate up the exposures into same dimensions as covariance
var exposuresInCovarianceDimensions = new double[Keys.Count];
for (int i = 0; i < indexes.Length; ++i)
{
if (indexes[i] == null) continue;
exposuresInCovarianceDimensions[indexes[i].Item1] = (indexes[i].Item2 ? -1d : 1d) * exposureValues_[i];
}
// calculate contributions to risk
var contToRisk = GetContToVar(exposuresInCovarianceDimensions);
// translate back into porfolio dimensions
var riskInPortfolioDimensions = new double[exposureValues_.Length];
for (int i = 0; i < riskInPortfolioDimensions.Length; ++i)
{
if (indexes[i] == null) continue;
riskInPortfolioDimensions[i] = contToRisk[indexes[i].Item1];
}
return riskInPortfolioDimensions;
}
示例11: GetAsConstruct
public async Task<ConstructGenGen<string, double>> GetAsConstruct(DateTime date_, CarbonClient cc_)
{
var moniker = string.Format("ssys.dashboard.covariance_matrix.15.2.{0}", date_.ToString("yyyyMMdd"));
ConstructGenGen<string, double> con;
try
{
con = await DataFrameHelper.GetDataFrameCellByCell(
name_: moniker,
keyExtractor_: (x) => (string)x,
valueExtractor_: (val) =>
{
double ret = 0d;
if (val is IConvertible)
ret = Convert.ToDouble(val) * 252d;
return ret;
},
cc_: cc_);
}
catch (Exception ex_)
{
Logger.Error(string.Format("Error getting covariance for date [{0}]", date_.ToString("dd-MMM-yyyy")),
typeof(Covariances), ex_);
con = null;
}
return con;
}
示例12: Go
public async Task Go(bool force_ = false, bool backFillFromTStoo_=false)
{
registerAllMongoDocTypes();
using (var cc = new CarbonClient("PRD"))
{
{
// get sets of calendar combinations and gets distinct set
var tups = (from swapCurve in SwapCurveDefinitions.AllDefinitions()
select Tuple.Create(swapCurve.OTHolidayCode, swapCurve.DaysToSpot))
.FindDistinct(x => string.Format("{0}_{1}", x.Item1, x.Item2));
// update for each distinct sets
foreach (var tup in tups)
{
// update records of tenor dates
await DatesWorker.DWInstance().GoAll(
otHolidayCode_: tup.Item1,
daysToSpot_: tup.Item2,
cc_: cc,
force_: force_);
}
}
// update records of discount factors
{
// first, need the distinct set of component curves
// select out all unique required discount factors
var tups = (from swapCurve in SwapCurveDefinitions.AllDefinitions()
from curve in swapCurve.AllCurves
select Tuple.Create(swapCurve.OTHolidayCode, swapCurve.DaysToSpot, curve))
.FindDistinct(x => string.Format("{0}_{1}_{2}", x.Item1, x.Item2, x.Item3.CarbonCurveName))
.ToList();
// now operate on all the sets
foreach (var tup in tups)
{
await DFsWorker.DFInstance().GoAll(tup.Item1, tup.Item2, tup.Item3, cc);
if (backFillFromTStoo_ && !string.IsNullOrEmpty(tup.Item3.SymmetryTSName))
await DFsWorker.DFInstance().BackFillFromSymmetryTS(tup.Item1, tup.Item2, tup.Item3);
}
}
// update constant maturity futures
{
CMFuturesWorker.FutInstance().GoAllSets();
}
// update all stats
{
StatsGenerationWorker.GetInstance().Go();
}
await PersistSetsForDeriveddataWorker.Go(cc);
}
}
示例13: GetAll
public static async Task<IReadOnlyList<InstrumentETF>> GetAll(CarbonClient cc_)
{
if (_list == null)
await populate(cc_);
return _list == null ? null : new ReadOnlyCollection<InstrumentETF>(_list);
}
示例14: Get
public async Task<CovarianceWrapper> Get(DateTime date_, CarbonClient cc_)
{
if (m_cache.ContainsKey(date_))
return m_cache[date_];
var con = await GetAsConstruct(date_, cc_);
if (con == null) return null;
try
{
var asDbl = con.GetAllValues();
if (asDbl.GetLength(0) != asDbl.GetLength(1))
{
throw new Exception("Covariance matrix is not square!");
}
var cov = new CovarianceWrapper(asDbl, con.ColumnHeadings);
m_cache[date_] = cov;
return cov;
}
catch (Exception ex_)
{
Logger.Error(string.Format("Error processing covariance for date [{0}]", date_.ToString("dd-MMM-yyyy")),
typeof(Covariances), ex_);
}
return null;
}
示例15: GetContracts
public async Task<IEnumerable<CarbonFuture>> GetContracts(CarbonClient cc_)
{
if (m_contracts != null) return m_contracts;
await populateData(cc_);
return m_contracts;
}