AioTrade Investigation (Section B: DataContract and Content)

AioTrade Investigation (Section B: DataContract and Content)
guibin.beijing@gmail.com
AioTrade source code: [url]https://github.com/dcaoyuan/aiotrade[/url]

The DataContract's source code is located at [url]https://github.com/dcaoyuan/aiotrade/blob/master/libs/lib.math/src/main/scala/org/aiotrade/lib/math/timeseries/datasource/DataContract.scala[/url]. In order to understand the concept of DataContract, lets review the concept of DataObject in NetBeans firstly.

DataObjects wrap FileObjects. A FileObject is just a container for data; it happens to have a MIME type, but like java.io.File, it doesn't know or care what kind of file it represents, or what data it contains.
A DataObject represents one or more (typically only one) FileObjects. A DataObject knows what kind of a file it represents. It may represent the parsed contents of a file such as a .java file. Or, as in the case of InstanceDataObject, the file name may have semantic meaning. Reference about DataObject: [url]http://wiki.netbeans.org/DevFaqDataObject[/url].

Then we talk a little bit about Descriptor(org.aiotrade.lib.math.timeseries.descriptor.Descriptor), its source code can be found at [url]https://github.com/dcaoyuan/aiotrade/blob/master/libs/lib.math/src/main/scala/org/aiotrade/lib/math/timeseries/descriptor/Descriptor.scala[/url]. Descriptor is something like NetBeans' DataObject, it is just a container for service instance, which can be used method [u]createServiceInstance(args: Any*)[/u] to create or lookup one. Descriptor has the information about service class name, frequent, isActive. It use the service class name to create the service instance, and the isActive is to mark whether the Descriptor is active. The frequent is an attribute of the Descritor, the frequently-used value can be ONE_SEC, ONE_MIN, ONE_HOUR, DAILY, WEEKLY, MONTHLY, ONE_YEAR. Details about TFreq please refer to org.aiotrade.lib.math.timeseries.TFreq.

Let's go back to talk about DataContract. The DataContract simply inherits the Descriptor. It is assumed that the binding class(that is service class) provides the data service for the DataContract.

Finally, we have to say something about Content(org.aiotrade.lib.math.timeseries.descriptor.Content), its source code is at [url]https://github.com/dcaoyuan/aiotrade/blob/master/libs/lib.math/src/main/scala/org/aiotrade/lib/math/timeseries/descriptor/Content.scala[/url].
[b]Content is actually a container for descriptors.[/b] It provides convient method to add, remove, indexOf, clear, lookup the descriptors which are saved in this Content.

[color=red]The Content provides a relationship between the DataServer(the data source service via DataContract's service class) and the Indicator(the descriptor which is added into the Content) which can be computed via the data originated from the data server.[/color]

So, when initializing the Sec(org.aiotrade.lib.securities.model.Sec), firstly get the Content form the sec.content, then add the TickerContract, QuoteContract, MoneyFlowContract to the content use content.addDescriptor, finally add the Indicators' descirptor to the content.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值