37 lines
1.5 KiB
C#
37 lines
1.5 KiB
C#
namespace bts.SilverPine {
|
|
using BCG;
|
|
|
|
[DataStreamUserRespresentation("OHLCVPriceDiff")]
|
|
public class OHLCVPriceDiffStream : ViewStream {
|
|
// TODO, abstract this out
|
|
private static ViewStream _get_ohlcv_steam(string symbol_or_contract, DateTime d1, DateTime d2) {
|
|
var tup = ContractUtils.get_symbol_category(symbol_or_contract);
|
|
var ohlcv_params = OHLCVStream.get_params(d1, d2);
|
|
var cont_cat = tup.Item1;
|
|
string symbol = tup.Item2;
|
|
ViewStream rs = new OHLCVStream(symbol, ohlcv_params);
|
|
switch (cont_cat) {
|
|
case ContractUtils.ContractCategory.FutureString:
|
|
case ContractUtils.ContractCategory.SpreadString:
|
|
rs = new FilterStream(rs, $"contract = '{symbol_or_contract}'");
|
|
break;
|
|
case ContractUtils.ContractCategory.Symbol:
|
|
rs = new FuturesActiveContractStream(rs);
|
|
break;
|
|
}
|
|
return rs;
|
|
}
|
|
|
|
public OHLCVPriceDiffStream(string symbol_or_contract, DateTime d1, DateTime d2)
|
|
: this(symbol_or_contract, d1, d2, "close") { }
|
|
|
|
public OHLCVPriceDiffStream(string symbol_or_contract, DateTime d1, DateTime d2, string col) {
|
|
ViewStream rs = _get_ohlcv_steam(symbol_or_contract, d1, d2);
|
|
rs = new ColumnDifferenceStream(rs, r => d1.Equals(r.get_datetime("ts_event")),
|
|
r => d2.Equals(r.get_datetime("ts_event")), col, col);
|
|
rs = new NewProjectStream(rs, "diff !");
|
|
mySetRealSource(rs);
|
|
}
|
|
|
|
}
|
|
} |