【发布时间】:2011-12-11 13:35:59
【问题描述】:
我曾尝试在“量化金融”上问这个问题,但似乎这是一个更好的地方,因为这个问题更多地是关于编程而不是交易
Indicator接口如何声明?建模“指标”的正确方法是什么?
我正在使用 c#,我想像这样声明Indicator 接口:
interface Indicator
{
double Value { get; }
event Action<Void> ValueUpdated;
}
或者甚至可能是这样的:
interface Indicator
{
event Action<Double> ValueUpdated;
}
我认为“纯价格”也是微不足道的指标:
class PriceIndicator : Indicator {
PriceIndicator(string ticker) {
....
}
}
MA 示例:
class MovingAverage : Indicator {
private PriceIndicator price;
public MovingAverage(PriceIndicator price, int period) {
....
}
// when price.ValueUpdated event occurs need to recalculate MA and raise ValueUpdated event
}
你怎么看?欢迎提出任何建议!
【问题讨论】:
-
好的,但是你的问题是什么?你的代码不起作用吗?
-
我一定遗漏了一些东西——真正的问题是什么?您发布的接口声明很好。
-
问题是如何声明
Indicator接口和对应的实现(例如Moving Average)。将“纯价格”视为指标是否好。使用event通知值已更新好还是使用某种计时器或其他技术更好 -
如果有人知道一些已经在 C# 链接上声明
IndicatorMoving average等的代码的链接,非常欢迎 -
你可能想看看 Ninjatrader 看看它是如何在那里实现的。我不会因为某个事件而使指标自动更新,而是有另一个类来执行它,指标的抽象意味着它知道如何计算一个值,但它不需要知道何时执行它的责任.但如果没有更多关于您的解决方案的背景信息,真的很难说
标签: c# trading algorithmic-trading domain-data-modelling