46 lines
2.4 KiB
C#
46 lines
2.4 KiB
C#
using BCG;
|
|
|
|
namespace bts.SilverPine {
|
|
/*
|
|
----------------------------------------------------------------------
|
|
*Expression*
|
|
----------------------------------------------------------------------
|
|
//r=FutureHistoricalBars("ES*", "02/01/2024 09:30 AM", "02/01/2024 09:30 PM")
|
|
r=FutureHistoricalBars("ES*","One_Day", 02/01/2024, 02/01/2025)
|
|
r=contractExpander(r,"symbol")
|
|
r=filter(r,"contract_type='FutureSpread'")
|
|
r=aggregate(r,"symbol","volume:Sum","ts_event")
|
|
r=aggregate(r,"volume_sum:Max")
|
|
r=newProject(r,"volume_sum_max:volume symbol !")
|
|
|
|
----------------------------------------------------------------------
|
|
*Schema*
|
|
----------------------------------------------------------------------
|
|
symbol System.String
|
|
id System.Int32
|
|
volume System.Double
|
|
*/
|
|
|
|
[DataStreamUserRespresentation("VolumeAgg")]
|
|
public class VolumeAggregationStream : ViewStream {
|
|
public VolumeAggregationStream(string future_contract, string contract_type, DateTime range_beg, DateTime range_end)
|
|
: this(future_contract, contract_type, range_beg, range_end, ViewStreamDatabase.instance) { }
|
|
|
|
public VolumeAggregationStream(string future_contract, string contract_type, string range_beg, string range_end)
|
|
:
|
|
this(future_contract, contract_type, DateTime.Parse(range_beg), DateTime.Parse(range_end), ViewStreamDatabase.instance) { }
|
|
|
|
public VolumeAggregationStream(string future_contract, string contract_type, DateTime range_beg, DateTime range_end, ViewStreamDatabase db) {
|
|
future_contract = future_contract.EndsWith("*") ? future_contract : future_contract + "*";
|
|
ViewStream r;
|
|
r = new FutureHistoricalBarsStream(future_contract,
|
|
range_beg.ToString(), range_end.ToString());
|
|
r = new ContractExpanderStream(r, "symbol");
|
|
r = new FilterStream(r, $"contract_type='{contract_type}'");
|
|
r = new NonIncGroupByStream(r, "symbol", "volume:Sum", "ts_event");
|
|
r = new NonIncGroupByStream(r, "volume_sum:Max");
|
|
r = new NewProjectStream(r, "volume_sum_max:volume symbol !");
|
|
mySetRealSource(r);
|
|
}
|
|
}
|
|
} |