搜索
12
返回列表 发新帖
楼主: 不想停留

[大盘交流] 求助啊。。。。

[复制链接]
发表于 2011-6-1 12:43 | 显示全部楼层

飞狐交易师接口格式,与分析家相同:

////////////////////////////////////////////////////////////////////////////////////////
//jao01fei: 飞狐接口主程序->声明头部分
////////////////////////////////////////////////////////////////////////////////////////
//内容说明------------------------------------------------------------------------------
//1.数据结构; 2.元素结构; 3.参数结构
//--------------------------------------------------------------------------------------
#ifndef __JAO01FEI_H_INCLUDED
#define __JAO01FEI_H_INCLUDED
#ifdef  __cplusplus
extern  "C" {
#endif//__cplusplus

////////////////////////////////////////////////////////////////////////////////////////
//jao01fei: 飞狐接口主程序->声明体部分
////////////////////////////////////////////////////////////////////////////////////////
//======================================================================================
//1.数据结构
//--------------------------------------------------------------------------------------
//基本数据(普通成交明细表):
typedef struct tagSTKDATA
{
  time_t m_time;   //时间,UCT
  float  m_fOpen;  //开盘
  float  m_fHigh;  //最高
  float  m_fLow;   //最低
  float  m_fClose; //收盘
  float  m_fVolume;//成交量
  float  m_fAmount;//成交额
  union
  {
    struct//仅个股有效
    {
      float m_pOutside;//外盘
    };
    struct//仅大盘有效
    {
      WORD  m_wAdvance;//上涨家数
      WORD  m_wDecline;//下跌家数
    };
  };
} STKDATA;
//--------------------------------------------------------------------------------------
//扩展数据(分笔成交买卖盘):
typedef union tagSTKDATAEx
{
  struct
  {
    float m_fBuyPrice[3]; //买1--买3价
    float m_fBuyVol[3];   //买1--买3量
    float m_fSellPrice[3];//卖1--卖3价
    float m_fSellVol[3];  //卖1--卖3量
  };
  float m_fDataEx[12];    //保留
} STKDATAEx;
//--------------------------------------------------------------------------------------
//分析周期(时间关键字列表):
enum DATA_TYPE
{
  TICK_DATA=2,//分笔成交
  MIN1_DATA,  //1分钟线
  MIN5_DATA,  //5分钟线
  MIN15_DATA, //15分钟线
  MIN30_DATA, //30分钟线
  MIN60_DATA, //60分钟线
  DAY_DATA,   //日线
  WEEK_DATA,  //周线
  MONTH_DATA, //月线
  MULTI_DATA  //多日线
};
//--------------------------------------------------------------------------------------
/*财务数据(在输入参数内,m_pfFinData元素中,顺序存储最新数据):
  序号     内容
  0        总股本(万股),
  1        国家股,
  2        发起人法人股,
  3        法人股,
  4        B股,
  5        H股,
  6        流通A股,
  7        职工股,
  8        A2转配股,
  9        总资产(千元),
  10       流动资产,
  11       固定资产,
  12       无形资产,
  13       长期投资,
  14       流动负债,
  15       长期负债,
  16       资本公积金,
  17       每股公积金,
  18       股东权益,
  19       主营收入,
  20       主营利润,
  21       其他利润,
  22       营业利润,
  23       投资收益,
  24       补贴收入,
  25       营业外收支,
  26       上年损益调整,
  27       利润总额,
  28       税后利润,
  29       净利润,
  30       未分配利润,
  31       每股未分配,
  32       每股收益,
  33       每股净资产,
  34       调整每股净资,
  35       股东权益比,
  36       净资收益率*/

//======================================================================================
//2.元素结构(参数结构内数据元素结构):
typedef struct tagCALCPARAM
{
  union
  {
    const float* m_pfParam;    //序列参数,指向一个浮点型数组
    const float  m_fParam;     //数值参数
                                   //上面如取消const常数定义,亦只可在函数内临时使用
  };
  const int      m_nParamStart;//序列参数有效起始位置
} CALCPARAM;

//======================================================================================
//3.参数结构:
typedef struct tagCALCINFO
{
//--------------------------------------------------------------------------------------
/*以下与分析家兼容
1.函数调用参数由m_pfParam1--m_pfParam4带入,若为NULL则表示该参数无效.
2.当一个参数无效时,则其后的所有参数均无效.
  如:m_pfParam2为NULL,则m_pfParam3,m_pfParam4一定为NULL.
3.参数1可以是常数参数或序列数参数,其余参数只能为常数参数.
4.若m_nParam1Start<0, 则参数1为常数参数,其值为*m_pfParam1;
5.若m_nParam1Start>=0,则参数1为序列数参数,m_pfParam1指向一个浮点型数组,
  数组大小为m_nNumData,数据有效范围为m_nParam1Start至m_nNumData-1.
  在时间上m_pData[x] 与 m_pfParam1[x]是一致的*/
  const DWORD      m_dwSize;      //结构大小
  const DWORD      m_dwVersion;   //调用软件版本(V2.10:0x210)
  const DWORD      m_dwSerial;    //调用软件序列号
  const char*      m_strStkLabel; //股票代码
  const BOOL       m_bIndex;      //大盘

  const int        m_nNumData;    //参数1的数据数量(pData,pDataEx,pResultBuf数据数量)
  const STKDATA*   m_pData;       //基本数据,注意:当m_nNumData==0时可能为NULL->具体见前
  const STKDATAEx* m_pDataEx;     //扩展数据,分笔成交买卖盘,注意:可能为NULL->具体见前

  const int        m_nParam1Start;//参数1有效起始位置
  const float*     m_pfParam1;    //调用参数1//取消const
  const float*     m_pfParam2;    //调用参数2
  const float*     m_pfParam3;    //调用参数3
  const float*     m_pfParam4;    //调用参数4

        float*     m_pResultBuf;  //结果缓冲区
  enum  DATA_TYPE  m_dataType;    //分析周期->具体见前
  const float*     m_pfFinData;   //财务数据->具体见前
金币:
奖励:
热心:
注册时间:
2005-10-20

回复 使用道具 举报

发表于 2011-6-1 12:44 | 显示全部楼层

对外接口程序头:

////////////////////////////////////////////////////////////////////////////////////////
//jao01mai.c: 用户接口主程序->程序头部分
////////////////////////////////////////////////////////////////////////////////////////
#ifndef __JAO01MAI_C_INCLUDED
#define __JAO01MAI_C_INCLUDED
#ifdef  __cplusplus
extern  "C" {
#endif//__cplusplus
#include "jao01def.h"
#include "jao01fei.h"
#include "jao01buf.h"
#include "jao01ma2.h"
#include "jao01ma3.h"
#include "jao01mai.h"

////////////////////////////////////////////////////////////////////////////////////////
//jao01mai.c: 用户接口主程序->程序体部分
////////////////////////////////////////////////////////////////////////////////////////
//======================================================================================
//jao01mai::JAO01MAI(): 用户接口主函数(一级监视)
//输入:CALCINFO* pdata=数据指针
//输出:int            =返回值
int __declspec(dllexport) WINAPI JAO01MAI(const CALCINFO* pdata)
//WINAPI为C语言专用,函数大写为与上级软件兼容
{
  //------------------------------------------------------------------------------------
  //开始:
  char npc[]="jao01mai"; char nfc[]="JAO01MAI"; char nfn[]="用户接口主函数";

  unsigned int icontrol;     //控制代码

  unsigned int isysclockstart=0;//系统时钟初始数
  unsigned int(*pgetclockpass)(const unsigned int,
                               const unsigned int)=NULL;//取得时钟累计数函数指针

  unsigned int ilevel=1;     //系统运行层次
  jao01buf*    pbuf  =NULL;  //缓冲区指针,声明时置空
  
  HINSTANCE    hsec  =NULL;  //用户接口次程序句柄
  fJAO01SEC    fsec  =NULL;  //用户接口次函数指针

  mNPCPD;//检查上级数据区指针是否为空
金币:
奖励:
热心:
注册时间:
2005-10-20

回复 使用道具 举报

 楼主| 发表于 2011-6-1 12:45 | 显示全部楼层

回复 #20 股民阿甘 的帖子

非常感谢。

研究研究。
金币:
奖励:
热心:
注册时间:
2011-5-19

回复 使用道具 举报

发表于 2011-6-1 12:48 | 显示全部楼层

下面为函数举例:

参数b为子序列开始位置,

参数e为子序列结束位置,

实际调用时截取十根K线即可。
金币:
奖励:
热心:
注册时间:
2005-10-20

回复 使用道具 举报

发表于 2011-6-1 12:49 | 显示全部楼层
//======================================================================================
//jao01mat::fMathHhv: 计算简单移动最大值
//输入:const unsigned int ilevel =运行层次
//      const float*       x      =数组指针
//      const unsigned int b      =起始位置
//      const unsigned int e      =终结位置
//      const unsigned int n      =周期参数
//      float* const       y      =结果指针
//输出:无
void jao01mat::fMathHhv(const unsigned int ilevel,
                        const float*       x,
                        const unsigned int b,
                        const unsigned int e,
                        const unsigned int n,
                        float* const       y)
{
  //------------------------------------------------------------------------------------
  //开始:
  char npc[]="jao01mat"; char nfc[]="fMathHhv"; char nfn[]="计算简单移动最大值";
  unsigned int i=0;
  int          j=0;
  float        r=0;
  unsigned int s=0;
  sSLOG2ST;
  //------------------------------------------------------------------------------------
  //过程:
  for(i=b; i<=e; i++)
  {
    j=i; r=x; s=0;
    while(j>=(int)*pFirst)
    {
      if(x[j]>r) r=x[j]; s++; if(s>=n) break;//首次为冗余性比较
      j=j-1;
    }
    y=r;
  }
  //------------------------------------------------------------------------------------
  //结束:
  sSLOG3ED;
}

//======================================================================================
//jao01mat::fMathLlv: 计算简单移动最小值
//输入:const unsigned int ilevel =运行层次
//      const float*       x      =数组指针
//      const unsigned int b      =起始位置
//      const unsigned int e      =终结位置
//      const unsigned int n      =周期参数
//      float* const       y      =结果指针
//输出:无
void jao01mat::fMathLlv(const unsigned int ilevel,
                        const float*       x,
                        const unsigned int b,
                        const unsigned int e,
                        const unsigned int n,
                        float* const       y)
{
  //------------------------------------------------------------------------------------
  //开始:
  char npc[]="jao01mat"; char nfc[]="fMathLlv"; char nfn[]="计算简单移动最小值";
  unsigned int i=0;
  int          j=0;
  float        r=0;
  unsigned int s=0;
  sSLOG2ST;
  //------------------------------------------------------------------------------------
  //过程:
  for(i=b; i<=e; i++)
  {
    j=i; r=x; s=0;
    while(j>=(int)*pFirst)
    {
      if(x[j]<r) r=x[j]; s++; if(s>=n) break;//首次为冗余性比较
      j=j-1;
    }
    y=r;
  }
  //------------------------------------------------------------------------------------
  //结束:
  sSLOG3ED;
}

//======================================================================================
//jao01mat::fMathMa: 计算算术移动平均值
//输入:const unsigned int ilevel =运行层次
//      const float*       x      =数组指针
//      const unsigned int b      =起始位置
//      const unsigned int e      =终结位置
//      const unsigned int n      =周期参数
//      float* const       y      =结果指针
//输出:无
void jao01mat::fMathMa(const unsigned int ilevel,
                       const float*       x,
                       const unsigned int b,
                       const unsigned int e,
                       const unsigned int n,
                       float* const       y)
{
  //------------------------------------------------------------------------------------
  //开始:
  char npc[]="jao01mat"; char nfc[]="fMathMa"; char nfn[]="计算算术移动平均值";
  unsigned int i=0;
  int          j=0;
  float        r=0;
  unsigned int s=0;
  sSLOG2ST;
  //------------------------------------------------------------------------------------
  //过程:
  j=b; r=0; s=0;
  while(j>=(int)*pFirst)
  {
    r=r+x[j]; s++; if(s>=n) break;
    j=j-1;
  }
  y=r/s;
  for(i=b+1; i<=e; i++)
  {
    r=r+x; if(s<n) s++; else r=r-x[i-s];
    y=r/s;
  }
  //------------------------------------------------------------------------------------
  //结束:
  sSLOG3ED;
}

//======================================================================================
//jao01mat::fMathEma: 计算平滑移动平均值
//输入:const unsigned int ilevel =运行层次
//      const float*       x      =数组指针
//      const unsigned int b      =起始位置
//      const unsigned int e      =终结位置
//      const unsigned int n      =周期参数
//      float* const       y      =结果指针
//输出:无
void jao01mat::fMathEma(const unsigned int ilevel,
                        const float*       x,
                        const unsigned int b,
                        const unsigned int e,
                        const unsigned int n,
                        float* const       y)
{
  //------------------------------------------------------------------------------------
  //开始:
  char npc[]="jao01mat"; char nfc[]="fMathEma"; char nfn[]="计算平滑移动平均值";
  unsigned int i=0;
  int          j=0;
  float        r=0;
  unsigned int s=0;
  int          m1=0;
  int          m2=0;
  sSLOG2ST;
  //------------------------------------------------------------------------------------
  //过程:
  j=b; r=0; s=0;
  while(j>=(int)*pFirst)
  {
    r=r+x[j]; s++; if(s>=n) break;
    j=j-1;
  }
  y=r/s;  
  for(i=b+1,m1=n-1,m2=n+1; i<=e; i++)
  {
    y=(2*x+m1*y[i-1])/m2;
  }
  //------------------------------------------------------------------------------------
  //结束:
  sSLOG3ED;
}

//======================================================================================
//jao01mat::fMathSma: 计算加权移动平均值
//输入:const unsigned int ilevel =运行层次
//      const float*       x      =数组指针
//      const unsigned int b      =起始位置
//      const unsigned int e      =终结位置
//      const unsigned int n      =周期参数
//      const unsigned int m      =权重参数
//      float* const       y      =结果指针
//输出:无
void jao01mat::fMathSma(const unsigned int ilevel,
                        const float*       x,
                        const unsigned int b,
                        const unsigned int e,
                        const unsigned int n,
                        const unsigned int m,
                        float* const       y)
{
  //------------------------------------------------------------------------------------
  //开始:
  char npc[]="jao01mat"; char nfc[]="fMathSma"; char nfn[]="计算加权移动平均值";
  unsigned int i=0;
  int          j=0;
  float        r=0;
  unsigned int s=0;
  int          m2=0;
  sSLOG2ST;
  //------------------------------------------------------------------------------------
  //过程:
  j=b; r=0; s=0;
  while(j>=(int)*pFirst)
  {
    r=r+x[j]; s++; if(s>=n) break;
    j=j-1;
  }
  y=r/s;  
  for(i=b+1,m2=n-m; i<=e; i++)
  {
    y=(m*x+m2*y[i-1])/n;
  }
  //------------------------------------------------------------------------------------
  //结束:
  sSLOG3ED;
}

//======================================================================================
//jao01mat::fMathStd: 计算移动平均方差值
//输入:const unsigned int ilevel =运行层次
//      const float*       x1     =数组指针
//      const float*       x2     =均值指针
//      const unsigned int b      =起始位置
//      const unsigned int e      =终结位置
//      const unsigned int n      =周期参数
//      const unsigned int m      =倍数参数
//      float* const       y      =结果指针
//输出:无
void jao01mat::fMathStd(const unsigned int ilevel,
                        const float*       x1,
                        const float*       x2,
                        const unsigned int b,
                        const unsigned int e,
                        const unsigned int n,
                        const unsigned int m,
                        float* const       y)
{
  //------------------------------------------------------------------------------------
  //开始:
  char npc[]="jao01mat"; char nfc[]="fMathStd"; char nfn[]="计算移动平均方差值";
  unsigned int i=0; //循环变量
  unsigned int j=0;
  int          p1=0;//轨道起始位置
  int          p2=0;//均线起始位置
  float        r=0; //价格合值
  unsigned int s=0; //价格计数
  float        t=0; //样本差值
  float        u=0; //样本方和
  sSLOG2ST;
  //------------------------------------------------------------------------------------
  //过程:
  p1=b-n+1;  if(p1<(int)*pFirst) p1=*pFirst;//样本方和的起始位置
  p2=p1-n+1; if(p2<(int)*pFirst) p2=*pFirst;//其前均线的起始位置               
  for(i=(unsigned int)p1,r=0,s=0,t=0,u=0;
      i<=b;
      i++)//轨道起始位置,合值计数差值方和清零
  {
    if(i==(unsigned int)p1)
    {
      for(j=p2; j<=i; j++){r=r+x1[j]; s++; }//其前均线起始位置      
    }
    else
    {
      r=r+x1; if(s<n) s++; else if(i-p2>=s) r=r-x1[i-s];
      //if(i-p2>=s)为冗余性判断,因为价格数不足,则s值亦不足,即不影响运算结果
    }
    t=x1-r/s;  //样本差值
    pTemporary1=t*t;//样本值方
    u=u+pTemporary1;//样本方和
  }
  if(s>1) y=(float)sqrt(u/(s-1))*m; else y=0;//方和开方之倍
  for(i=b+1; i<=e; i++)
  {
    t=x1-x2;
    pTemporary1=t*t;
    u=u+pTemporary1; if(s<n) s++; else if(i-p1>=s) u=u-pTemporary1[i-s];
    //if(i-p1>=s)为必须性判断,因为方和数不足,但s值已足,则不判断将导致运算错误
    if(s>1) y=(float)sqrt(u/(s-1))*m; else y=0;
  }
  //------------------------------------------------------------------------------------
  //结束:
  sSLOG3ED;
}
金币:
奖励:
热心:
注册时间:
2005-10-20

回复 使用道具 举报

发表于 2011-6-1 12:51 | 显示全部楼层

请注意上面举例函数中的下面两个传入参数:

//      const unsigned int b      =起始位置
//      const unsigned int e      =终结位置
楼主在具体编写算法时,更改函数内的算法即可,更详细的信息可查阅飞狐交易师或分析家的相关说明文件,用C的好处是速度极快,既然楼主要求速度,就不贴VBScript的方法了,使用VBScript也可以解决,但速度难以忍受的。
金币:
奖励:
热心:
注册时间:
2005-10-20

回复 使用道具 举报

 楼主| 发表于 2011-6-1 12:53 | 显示全部楼层
难。。。

看来要简化算法,看看。。。。。。


多谢。。
金币:
奖励:
热心:
注册时间:
2011-5-19

回复 使用道具 举报

发表于 2011-6-1 12:54 | 显示全部楼层
这几个函数都是较常用的中间截算运算函数,相信楼主可能会用到,同时有举例作用,因此发上来了。
金币:
奖励:
热心:
注册时间:
2005-10-20

回复 使用道具 举报

 楼主| 发表于 2011-6-1 12:57 | 显示全部楼层
感觉软件应该加以改进,功能太平面了。
金币:
奖励:
热心:
注册时间:
2011-5-19

回复 使用道具 举报

签到天数: 42 天

发表于 2011-6-1 13:47 | 显示全部楼层
循环语句计算起来超慢
强烈建议开放更多的语言接口
金币:
奖励:
热心:
注册时间:
2005-6-1

回复 使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

本站声明:MACD仅提供交流平台,请交流人员遵守法律法规。
值班电话:18209240771   微信:35550268

举报|意见反馈|手机版|MACD俱乐部

GMT+8, 2025-5-16 19:39 , Processed in 0.025639 second(s), 9 queries , MemCached On.

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表