本文整理汇总了C#中ConstructGen.SetColumnValues方法的典型用法代码示例。如果您正苦于以下问题:C# ConstructGen.SetColumnValues方法的具体用法?C# ConstructGen.SetColumnValues怎么用?C# ConstructGen.SetColumnValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConstructGen
的用法示例。
在下文中一共展示了ConstructGen.SetColumnValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Refresh
public void Refresh()
{
// going to get historical values from our database
ConstructGen<double> hist = new ConstructGen<double>(m_tickers.Count<string>());
for (int i = 0; i < m_tickers.Length; ++i)
{
var histvalues = BbgTalk.HistoryRequester.GetHistory(SI.Data.DataConstants.DATA_START, m_tickers[i],
"PX_LAST", false, null);
//histvalues = histvalues.unwind_1d();
hist.SetColumnValues(i, histvalues);
}
hist.SortKeys();
// initialise 'today's' values to previous day
hist.SetValues(DateTime.Today, (double[])hist.GetValues(hist.LastDate).Clone());
double[] avgs = new double[m_windowLength];
// initialise the avgs array NOTE: today's value is in item with index 0
for (int i = 0; i < m_windowLength; ++i)
avgs[i] = hist.GetValues(hist.Dates[hist.Dates.Count - 1 - i]).Average();
m_avgs = avgs;
m_liveValues = hist.GetValues(DateTime.Today);
}
示例2: ATMVolsRankGroup
protected ATMVolsRankGroup(FXGroup group_)
{
var currencies = Singleton<FXIDs>.Instance.Where(x => x.IsGroup(group_)).ToArray();
var oneWeek = new ConstructGen<double>(currencies.Select(x => x.Code).ToArray());
var oneMonth = new ConstructGen<double>(currencies.Select(x => x.Code).ToArray());
for (int i = 0; i < currencies.Length; ++i)
{
{
var vols = BbgTalk.HistoryRequester.GetHistory(DataConstants.DATA_START, currencies[i].AtTheMoneyVolTicker_1W, "PX_LAST", false);
oneWeek.SetColumnValues(i, vols);
}
{
var vols = BbgTalk.HistoryRequester.GetHistory(DataConstants.DATA_START, currencies[i].AtTheMoneyVolTicker_1M, "PX_LAST", false);
oneMonth.SetColumnValues(i, vols);
}
}
{
oneWeek.SortKeys();
var avg1W = oneWeek.AvgRows();
ATM_1W_Avg = avg1W;
ATM_1W_o6M = avg1W.ToPercentileRanked(126);
ATM_1W_o1Y = avg1W.ToPercentileRanked(252);
}
{
oneMonth.SortKeys();
var avg1M = oneMonth.AvgRows();
ATM_1M_Avg = avg1M;
ATM_1M_o6M = avg1M.ToPercentileRanked(126);
ATM_1M_o1Y = avg1M.ToPercentileRanked(252);
}
}
示例3: TestOnCT
public static ConstructGen<double> TestOnCT()
{
var str = KnownStructure.US_WN;
var comps = new[]
{
new ChartComponent(),
new ChartComponent(),
new ChartComponent(),
};
var bondsRollMonthly = Generator.Go(cashBondRollOption_: Generator.CashBondRolling.Monthly);
var spreadsRollMonthly = new Dictionary<BondCurves, List<CTDLine<BondSpreads>>>();
spreadsRollMonthly[BondCurves.USD3mLibor] = Generator.GetSpreads(bondsRollMonthly, BondCurves.USD3mLibor, Generator.CashBondRolling.Monthly);
var cdRollMonthly = new ChartDataSource(comps, spreadsRollMonthly, bondsRollMonthly);
var impl = StructureFactory.GetStructure(str);
impl.Configure(comps);
var data = cdRollMonthly.GetData().SmoothedData.GetEndValues(650);
var con = new ConstructGen<double>(1);
con.SetColumnValues(0, data);
return con;
}
示例4: getOHLCSeriesFromBbg
public static ConstructGen<double> getOHLCSeriesFromBbg(DateTime firstDate_, string ticker_, bool insertNan_ = true)
{
var ret = new ConstructGen<double>(new string[] { "PX_OPEN", "PX_HIGH", "PX_LOW", "PX_CLOSE_1D" });
DateTime[] bbgDates = null;
for (int i = 0; i < ret.ColumnHeadings.Length; ++i)
{
DateTime start;
if (i == 3)
start = firstDate_.AddDays(1);
else
start = firstDate_;
var b = BbgTalk.HistoryRequester.GetHistory(start, ticker_, ret.ColumnHeadings[i], false);
if (b == null || b.Length == 0)
{
throw new Exception(string.Format("No data retrieved for given ticker '{0}'", ticker_.ToUpper()));
}
else
b = HelperMethods.ensureAllWeekdays(b, insertNan_);
if (i == 3)
{
var closeData = bbgDates.Length > b.Dates.Length ? b.Data : b.Data.Skip(1).ToArray();
ret.SetColumnValues(i, bbgDates.SkipLast().ToArray(), closeData);
}
else
{
ret.SetColumnValues(i, b.Dates, b.Data);
bbgDates = b.Dates;
}
}
foreach (var d in ret.Dates.OrderByDescending(d => d))
{
if (ret.GetValue(d, 3) == 0)
{
ret.RemoveValues(d);
}
else break;
}
return ret;
}
示例5: CalculateWeights
public static ConstructGen<PairTrade> CalculateWeights(ComID[] commodities_)
{
// calculate the weighting
var con = new ConstructGen<PairTrade>(commodities_.Select(x => x.Name).ToArray());
for (int i = 0; i < con.ArrayLength; ++i)
con.SetColumnValues(i, CalculateWeights(commodities_[i]));
if (con.NeedsToSortKeys())
con.SortKeys();
return con;
}
示例6: Collate
public static void Collate(BondMarket market_=BondMarket.US)
{
var allTenors = SI.ExtensionMethods.CreateArray(1, 30, x => x + 1);
var con = new ConstructGen<double>(allTenors.Select(x => string.Format("cmt_{0}", x)).ToArray());
for (int i = 0; i < allTenors.Length; ++i)
{
var cr = Get(market_, allTenors[i]);
if (cr == null) continue;
con.SetColumnValues(i, cr.Values.GetColumnValuesAsDDC((int) CMTCarry.ColPosition.Carry));
}
con.WriteToCSV(string.Format(@"e:\temp\CMTCarry_{0}.csv", market_));
}
示例7: expandToFullUniverse
private static ConstructGen<double> expandToFullUniverse(ConstructGen<double> input_)
{
if (input_.ArrayLength == Singleton<FXIDs>.Instance.Count)
return input_;
System.Diagnostics.Debug.Assert(input_.ColumnHeadings != null, "Column Headings not set on ConstructGen<double> wts, therefore can't ascertain securities");
ConstructGen<double> ret = new ConstructGen<double>(Singleton<FXIDs>.Instance.Count);
ret.ColumnHeadings = Singleton<FXIDs>.Instance.ColumnHeadings;
for (int i = 0; i < input_.ArrayLength; ++i)
{
Currency c = Singleton<FXIDs>.Instance[input_.ColumnHeadings[i]];
ret.SetColumnValues(c.ArrayIndex, input_.Dates.ToArray<DateTime>(), input_.GetColumnValues(i));
}
return ret;
}
示例8: doPnl
protected override SI.ReturnsEval.DataSeriesEvaluator doPnl(TraderArgs args_, ConstructGen<double> wts_)
{
ConstructGen<double> allCcys = new ConstructGen<double>(Singleton<FXIDs>.Instance.ColumnHeadings);
for (int i = 0; i < args_.Products.Count; ++i)
{
ProductFX prod = (ProductFX)args_.Products[i];
allCcys.SetColumnValues(prod.CoreProduct.ArrayIndex, wts_.Dates.ToArray(), wts_.GetColumnValues(i));
}
var result = ReturnsFromFXWeights.DoIt_DailyWeights(allCcys);
var eval = new ReturnsEval.DataSeriesEvaluator("FX pnl", ReturnsEval.DataSeriesType.Returns);
if (args_.WtIndicators.Any())
eval.Name = string.Format("FX : {0}", args_.WtIndicators[0].ToString());
eval.AddInnerSeries(result.CombinedPnl.Dates.ToArray(), result.CombinedPnl.ToArray(), result.CombinedPnl.ColumnHeadings);
return eval;
}
示例9: GetTestData
public static ConstructGen<double> GetTestData()
{
var ret = new ConstructGen<double>(new string[] {"PX_OPEN", "PX_HIGH", "PX_LOW", "PX_CLOSE_1D"});
for (int i = 0; i < ret.ColumnHeadings.Length; ++i)
{
var s = BbgTalk.HistoryRequester.GetHistory(new DateTime(2015, 1, 1), "EUR CMPL CURNCY", ret.ColumnHeadings[i], false);
if (i == 3)
{
s = unwind_1d(s);
}
ret.SetColumnValues(i, s.Dates, s.Data);
}
ret.Dates.Remove(DateTime.Today);
return ret;
}
示例10: GoMulti
public static void GoMulti()
{
var data = DataRetriever.GetData(indexStart_: "ES", suffix_: "Index", contractIndex_: 1);
var listOfEvals = new List<ReturnsEval.DataSeriesEvaluator>();
foreach (var firstWindow in new[] {5, 10, 15, 20, 25, 50, })
{
var indic = new SI.Research.Technicals.MACross(firstWindow, firstWindow * 2);
var signals = indic.GenerateWeightSeries(data, null);
for (int i = 0; i < signals.Length; ++i)
signals.Data[i] = signals.Data[i] < 0d ? -1d : 1d;
signals = CollapseToChanges(signals);
if (false)
{
var con = new ConstructGen<double>(new[] { "Signal", "CleanPrice" });
con.SetColumnValues(0, signals);
foreach (var date in con.Dates)
con.SetValue(date, 1, data.ValueOnExactDate(date));
con.DisplayInGrid("changes with price levels");
}
//signals.DisplayInGrid("changes");
var pnl = GeneratePnl(data, signals);
var eval = new ReturnsEval.DataSeriesEvaluator(pnl.Dates, pnl.Data, string.Format("ES_{0}", firstWindow), ReturnsEval.DataSeriesType.Returns);
listOfEvals.Add(eval);
}
listOfEvals.Display("blah");
}
示例11: btnCombinePnl_Click
private void btnCombinePnl_Click(object sender, EventArgs e)
{
var all = spreadWeightGeneratorCollectionGrid1.ListOfGenerators;
if (all.Count() == 0) return;
ConstructGen<double> con = new ConstructGen<double>(all.Count());
con.ColumnHeadings = new string[con.ArrayLength];
for (int i = 0; i < con.ArrayLength; ++i)
{
var item = all.ElementAt(i);
con.ColumnHeadings[i] = item.ToString();
con.SetColumnValues(i, item.GetSimplePnl());
}
if (con.NeedsToSortKeys())
con.SortKeys();
var eval = new ReturnsEval.DataSeriesEvaluator("Combined", ReturnsEval.DataSeriesType.Returns);
eval.AddInnerSeries(con.Dates.ToArray(), con.ToArray(), con.ColumnHeadings);
eval.Display("Combined");
}
示例12: ConstructTickerTrueSpreads
private static void ConstructTickerTrueSpreads(List<RollResults> results, ref ConstructGen<string> ticker, ref ConstructGen<double> spreads,
Func<RollResults, RollResultContractItem> GetResults, string headingTickerPostfix, string headingValuePostfix)
{
var resultItem = results.Where(r => GetResults(r) != null).ToArray();
if (resultItem.Any())
{
var content =
resultItem.Select(r => new { r.Identifier, GetResults(r).TrueSpread }).ToLookup(l => l.Identifier);
var lookupHeader = resultItem.Select(r => r.Identifier).ToArray();
ticker = new ConstructGen<string>(content.Count)
{
ColumnHeadings = resultItem.Select(r => r.Identifier + " " + headingTickerPostfix).ToArray()
};
spreads = new ConstructGen<double>(content.Count)
{
ColumnHeadings = resultItem.Select(r => r.Identifier + " " + headingValuePostfix).ToArray()
};
for (int i = 0; i < ticker.ArrayLength; i++)
{
var series = content[lookupHeader[i]].First().TrueSpread;
if (series != null)
{
ticker.SetColumnValues(i, series.Dates, series.Data.Select(x => x.Name).ToArray());
spreads.SetColumnValues(i, series.Dates, series.Data.Select(x => x.Value).ToArray());
}
}
}
}
示例13: GetInvoiceSpreadsAsConstruct
public static ConstructGen<double> GetInvoiceSpreadsAsConstruct()
{
var configs = invoiceSpreadConfigs().ToArray();
var con = new ConstructGen<double>(
configs.Select(x => string.Format("{0}_{1}_{2}", x.Future, x.Series + 1, x.Curve.ToString())).ToArray());
for (int i = 0; i < configs.Length; ++i)
{
var spreads = getInvoiceSpreadsCollectionFromMongo(configs[i]);
con.SetColumnValues(i,
new DatedDataCollectionGen<double>(spreads.Lines.Select(x => x.Date).ToArray(),
spreads.Lines.Select(x => x.InvoiceSpread ?? 0d).ToArray()));
}
if (con.NeedsToSortKeys())
con.SortKeys();
// feed forward missing values
{
var values = con.GetValues(con.Dates[0]);
for (int i = 1; i < con.Dates.Count; ++i)
{
var date = con.Dates[i];
var todayValues = con.GetValues(date);
for (int j = 0; j < todayValues.Length; ++j)
{
if (todayValues[j] == 0d)
todayValues[j] = values[j];
}
values = todayValues;
}
}
return con;
}
示例14: GetFlow
public static ConstructGen<double> GetFlow(ConstructGen<double> wts_)
{
var ret = new ConstructGen<double>(wts_.ColumnHeadings);
for (int i = 0; i < wts_.ArrayLength; ++i)
{
ret.SetColumnValues(i, wts_.GetColumnValuesAsDDC(i).ToDifferences().ToAbs());
}
return ret;
}
示例15: AllConstantMaturityPrices
public ConstructGen<double> AllConstantMaturityPrices()
{
if (m_allFuturePrices != null)
return m_allFuturePrices;
// get the quarterlyin contracts
var allIMMs = Underlying.IMM_Contracts();
// build up the list of prices for all contracts
ConstructGen<double> subCon;
{
var con = new ConstructGen<double>(allIMMs.Select(x => x.SymmetryCode).ToArray());
{
for (int i = 0; i < con.ArrayLength; ++i)
con.SetColumnValues(i, allIMMs[i].GetPrices(marketSnapCode_:MarketSnapCode,quoteSource_:QuoteSourceCode,priceType_:1));
con.SortKeys();
}
var dates = SI.Strategy.RatesSpreads.DateHelper.GetBusinessDates(CurveNames.USD3M);
subCon = new ConstructGen<double>(con.ColumnHeadings);
foreach (var date in dates)
if (con.Dates.Contains(date))
subCon.SetValues(date, con.GetValues(date));
}
// create the construct that will hode the constant maturity prices
// is NumContracts+1 as first column will be interest rate fixing
m_allFuturePrices =
new ConstructGen<double>(
ExtensionMethods.CreateArrayRep(Underlying.FutureStart, NumContracts+1)
.Select((x, i) => string.Format("{0}cm{1}", x.ToUpper(), i))
.ToArray());
foreach (var date in subCon.Dates)
{
// set the fixing
m_allFuturePrices.SetValue(date, 0, Underlying.FixingInstrmnet.GetPrices().ValueOnDate(date)*100d);
for (int pointIndex = 0; pointIndex < NumContracts; ++pointIndex)
{
var daysForward = Convert.ToDouble(pointIndex + 1)*DaysSpan;
var forwardDate = date.AddDays(daysForward);
int beforeIndex=-1, afterIndex=-1;
for (int i = 0; i < allIMMs.Count-1; ++i)
{
if(allIMMs[i].Maturity.Value==forwardDate)
{
beforeIndex = i;
afterIndex = i;
break;
}
else if (allIMMs[i].Maturity.Value < forwardDate && allIMMs[i+1].Maturity.Value > forwardDate)
{
beforeIndex = i;
afterIndex = i + 1;
}
}
// were the indexes of the contract that straddle the forward date found?
if (beforeIndex >= 0)
{
if (beforeIndex == afterIndex)
{
m_allFuturePrices.SetValue(date, pointIndex+1, 100d-subCon.GetValue(date, beforeIndex));
}
else
{
var beforeValue = subCon.GetValue(date, beforeIndex);
var afterValue = subCon.GetValue(date, afterIndex);
if (beforeValue == 0d || afterValue == 0d)
continue;
var width = allIMMs[afterIndex].Maturity.Value - allIMMs[beforeIndex].Maturity.Value;
var w1 = forwardDate - allIMMs[beforeIndex].Maturity.Value;
var propAfter = w1.TotalDays/width.TotalDays;
var interpValue = (afterValue*propAfter) + (beforeValue*(1d - propAfter));
m_allFuturePrices.SetValue(date, pointIndex+1, 100d-interpValue);
}
}
}
}
return m_allFuturePrices;
}