`
guibin
  • 浏览: 363630 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

AioTrade Investigation (Section B: DataContract and Content)

阅读更多
AioTrade Investigation (Section B: DataContract and Content)
guibin.beijing@gmail.com
AioTrade source code: https://github.com/dcaoyuan/aiotrade

The DataContract's source code is located at  https://github.com/dcaoyuan/aiotrade/blob/master/libs/lib.math/src/main/scala/org/aiotrade/lib/math/timeseries/datasource/DataContract.scala. 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: http://wiki.netbeans.org/DevFaqDataObject.

Then we talk a little bit about Descriptor(org.aiotrade.lib.math.timeseries.descriptor.Descriptor), its source code can be found at https://github.com/dcaoyuan/aiotrade/blob/master/libs/lib.math/src/main/scala/org/aiotrade/lib/math/timeseries/descriptor/Descriptor.scala. Descriptor is something like NetBeans' DataObject, it is just a container for service instance, which can be used method createServiceInstance(args: Any*) 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 https://github.com/dcaoyuan/aiotrade/blob/master/libs/lib.math/src/main/scala/org/aiotrade/lib/math/timeseries/descriptor/Content.scala.
Content is actually a container for descriptors. It provides convient method to add, remove, indexOf, clear, lookup the descriptors which are saved in this Content.

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.

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
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics