C#实现COM接口的编程原理介绍和WEALTHLAB插件DEMO

Discussion in 'Wealth-Lab Developer' started by tom_sh, Sep 23, 2005.

  1. 对照:

    CreateDataSource(无入口参数,返回值为字符串);

    CreateDataSource方法:收集有关证券代码的信息,如存储目录、代码表等,可以为其他三项方法做些设置方面的准备工作。返回一个表示本数据源的字符串。
    在我们的DEMO中将简单地返回一个“STDEMO”表示我们的静态数据源。

    就能理解其意了。
     
  2. 对照:

    1。GetSecurityName(入口参数为字符串,返回值为字符串)

    GetSecurityName方法:根据具体的代码查找其名字全称,即如入口参数为“600000”,则返回值应为“浦发银行”。在DEMO中,这个方法无须实现,返回一个空值。实用程序中可以建立一个字典,把股票代码和股票名称进行一一对应。

    2。function GetSecurityName(Symbol: BSTR): BSTR;
    Implement this method to return a security name for the specified symbol. If you don't have access to a security name, return a blank string.

    3。public string GetSecurityName(string Symbol)
    {
    // TODO: 添加 WLDST.GetSecurityName 实现
    return null;
    }

    能理解其意了。
     
  3. 对照:
    1。FillSymbols方法:根据本数据源的代表字符串,如“STDEMO”,把本数据源负责采集或维护的所有代码(例如沪深股票)全部存储到一个IWealthLabStrings3

    2。procedure FillSymbols(DSString: BSTR; Symbols: IWealthLabStrings3);
    This method is responsible for populating a list of symbols based on the DataSource String supplied in the DSString parameter. The DSString is the same string that was returned when the DataSource was first created (the return value of CreateDataSource). The method should populate the symbols using the Symbols parameter, which is an instance of the IWealthLabStrings3 interface. Call the Symbols.Add method for each symbol that is contained in the DataSource.
    3。The IWealthLabEOD3.FillSymbols method contains parameter that is an instance of this interface. Use this instance to populate the symbols of a DataSource.

    procedure Add( Value: BSTR );
    Call this method once for each symbol that is contained in the DataSource.



    对照理解即可。
     
  4. 此项相当于填写简历的各个规定项,不同的人各项的值是不一样的。
    Switch ......Case......结构很好地完成了根据不的代码(SYMBLE),ADD不同股票数据的功能。

    相关资料参考:
    1。LoadSymbol方法:这个方法向有关的图表提供静态日末数据。在DEMO中,我们仅使用600000和000001两个股票的五个交易日数据(直接用常数数组)。实用程序可以从互联网、文本文件、动态行情源的补日线接口或其他股票软件数据文件中读历史交易数据。

    2。标准格式:
    public void LoadSymbol(string DSString, string Symbol, IWealthLabBars3 Bars, DateTime StartDate, DateTime EndDate, int
    MaxBars)
    {
    // TODO: 添加 WLDST.LoadSymbol 实现
    }

    3。procedure LoadSymbol(DSString: BSTR; Symbol: BSTR; Bars: IWealthLabBars3; StartDate: DATE; EndDate: DATE; MaxBars: long);
    This method is responsible for populating the bars of a chart for the specified Symbol.

    The DSString parameter contains the string that identifies the DataSource (as above).

    StartDate and EndDate may contain date values that specify a range of data to be loaded. If StartDate is non-zero, you should not load bars that are prior to that date. If EndDate is non-zero, you should not load dates that are after that date. It's not strictly necessary to observe these values. WLD will filter the data after the fact if your Adapter doesn't.

    MaxBars will contain the maximum number of bars that should be loaded, or zero if all bars should be loaded. Once again, you don't necessarily have to observe this parameter, but you should do so if it could save a significant amount of loading time.

    The Bars parameter is an instance of the IWealthLabBars3 interface. For each bar of data, call the Bars.Add method to add the date, open, high, low, close and volume. If you also have open interest data you can call Bars.AddOpenInterest instead. Be sure to load data in chronological order, oldest first.

    4。procedure Add(Date: Date; Open: double; High: double; Low: double; Close: double; Volume: long);
    Call this method once for every bar of data that should be loaded. Be sure to load the bars from earliest to latest.
     
  5. 就此已讲完了用VC#制作COM的全部主要过程。任何COM都要包含以上的基本结构,在此基本结构上可加入更多的方法以使COM更加复杂与处理更多数据。以实现设计此COM的最初想法,即完成WLDSCRIPT不能完成的复杂计算或复杂功能。以扩展WLD的功能。最终实现用户的IDEA和将IDEA转化成PROFIT的终极目的。
     
  6. 创建一描述文件,让其它使用上COM的人对所用的COM有过最基本的了解。其它建立描述文件的格式都是标准的格式:

    相关的参考:

    Below is the contents of the Descriptor File for our example Adapter. The file name is StaticAdapter_Sample.txt.

    Name=Sample Adapter
    DLL=WLSampleEOD3.DLL
    ComClassName=WLSampleEOD3.NativeEOD
    Desc=This is an example of a Static DataSource created with the Wealth-Lab Adapter API. The sample Adapter loads data in Wealth-Lab's native format (*.WL). Full source code for this Adapter is available for download at the page above.
    URL=http://www.wealth-lab.com/cgi-bin/WealthLab.DLL/kbase?id=25
    Bitmap=Sample.bmp
     
  7. 请问项目经理此句是什么意思呢?

    C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\regasm /tlb /codebase WLDAdapter.dll

    是在注册吗? 能解释一下吗?是否是在完成

    Deploying a Static Adapter on the User's System
    The only files required to deploy a Static Adapter are the DLL, the Description File, and the optional Bitmap. These files must all be installed into the user's WLD folder. The next time the user starts WLD the new DataSource type will be available. Note that WLD automatically registers the Adapter DLL, so calling Regsvr32 is not required.

    即最后的配置呢?
     
  8. 如何能够把演示的flash文件弄下来?
     
  9. .net 生成的DLL文件需要用.net framework工具REGASM注册为COM组件。而普通C++编译生成的DLL文件如WLD参考所说可以直接为WLD注册。
     
  10. 感谢tom_sh和思迷思提供的这样的学习C#的机会!明日得空试试
     
  11. 我的目的是想弄以下三个地址里边的swf文件,呵呵,因为他们的形式相同。
    既然hylt兄能追查到上边的地址,应该也可以弄到下边的吧。是tradingblox builder的使用演示。先谢了。

    http://www.tradingblox.com/tradingblox/TutorialMovies/Tutorial.html

    http://www.tradingblox.com/tradingblox/TutorialMovies/IndicatorAdd.html

    http://www.tradingblox.com/tradingblox/TutorialMovies/MultiSystemSuites.html