Stock.h
上传用户:gkp168
上传日期:2015-03-14
资源大小:334k
文件大小:6k
源码类别:

金融证券系统

开发平台:

Visual C++

  1. typedef struct 
  2. {
  3. BYTE Type;
  4. union ALLSTRUCT
  5. {
  6. struct INDEXANDSTOCK
  7. {
  8. char Code[8];
  9. char Name[10];
  10. DWORD Close;
  11. DWORD Open;
  12. DWORD High;
  13. DWORD Low;
  14. DWORD New;
  15. DWORD Pbuy1;
  16. float Vbuy1;
  17. DWORD Pbuy2;
  18. float Vbuy2;
  19. DWORD Pbuy3;
  20. float Vbuy3;
  21. DWORD Pbuy4;
  22. float Vbuy4;
  23. DWORD Psell1;
  24. float Vsell1;
  25. DWORD Psell2;
  26. float Vsell2;
  27. DWORD Psell3;
  28. float Vsell3;
  29. DWORD Psell4;
  30. float Vsell4;
  31. float Volume;
  32. float Amount;
  33. float Cjbs;
  34. DWORD Syl;
  35. BYTE Reserved[9];
  36. }IndexAndStock;
  37. struct DAYLINE
  38. {
  39. char Code[8];
  40. BYTE Records;
  41. struct DayK
  42. {
  43. time_t Date;
  44. DWORD Open;
  45. DWORD High;
  46. DWORD Low;
  47. DWORD Close;
  48. float Volume;
  49. float Amount;
  50. }Record[4];
  51. char Reserved[6];
  52. }DayLine;
  53. struct INFORMATION
  54. {
  55. BYTE SubType;
  56. time_t Time;
  57. WORD Serial;
  58. BYTE Proviter;
  59. WORD Total;
  60. WORD PacketNumber;
  61. WORD InfoLength;
  62. char Info[110];
  63. char Reserved[3];
  64. }Information;
  65. struct TXTFILE
  66. {
  67. char Name[100];
  68. BYTE FileType;
  69. time_t Time;
  70. char Reserved[22];
  71. }TxtFile;
  72. struct MINUTE
  73. {
  74. char Code[8];
  75. time_t Time;
  76. BYTE Records;
  77. struct MinRec
  78. {
  79. DWORD Price;
  80. float Volume;
  81. float Amount;
  82. }Record[9];
  83. char Reserved[6];
  84. }Minute;
  85. struct WIGHTINTEREST
  86. {
  87. char Code[8];
  88. BYTE Records;
  89. struct Wight
  90. {
  91. time_t Time;
  92. DWORD Give;
  93. DWORD Pei;
  94. DWORD PeiPrice;
  95. DWORD Bonus;
  96. }Record[5];
  97. char Reserved[18];
  98. }WightInterest;
  99. }AllStruct;
  100. }MAINSTRUCT;
  101. struct STOCK
  102. {
  103. char StockCode[10];
  104. char StockName[20];
  105. float fNew;
  106. float fClose;
  107. float fOpen;
  108. float fLow;
  109. float fHigh;
  110. float fAmount;
  111. float fVolume;
  112. DWORD Pbuy1;
  113. float Vbuy1;
  114. DWORD Pbuy2;
  115. float Vbuy2;
  116. DWORD Pbuy3;
  117. float Vbuy3;
  118. DWORD Pbuy4;
  119. float Vbuy4;
  120. DWORD Psell1;
  121. float Vsell1;
  122. DWORD Psell2;
  123. float Vsell2;
  124. DWORD Psell3;
  125. float Vsell3;
  126. DWORD Psell4;
  127. float Vsell4;
  128. };
  129. struct KLine //K线价格结构体
  130. {
  131. float fOpen;
  132. float fClose;
  133. float fLow;
  134. float fHigh;
  135. };
  136. struct KAmount //K线成交金额结构体
  137. {
  138. float Amount;
  139. };
  140. struct KPoint //K线价格对应坐标结构体
  141. {
  142. POINT high;
  143. POINT low;
  144. POINT open;
  145. POINT close;
  146. };
  147. struct KAmountPoint //K线成交金额结构体
  148. {
  149. POINT top;
  150. POINT bottom;
  151. };
  152. class CMyApp : public CWinApp
  153. {
  154. public:
  155. CMyApp();
  156.     virtual BOOL InitInstance();
  157. };
  158. class CMyFrame : public CWnd
  159. {
  160. public:
  161.     CMyFrame();
  162. ~CMyFrame();
  163. protected:
  164. typedef unsigned int __stdcall INITCARD(HWND, UINT Msg);
  165. typedef void __stdcall ENABLEMESSAGE(BOOL flag);
  166. typedef int __stdcall RECEIVEINFO(void);
  167. typedef void __stdcall DATAACQUISITION(void*, int);
  168. //typedef int __stdcall READMYCOUNT(void);
  169. protected: //数据
  170. MAINSTRUCT m_Data; //整个的数据结构
  171. STOCK m_Stock;
  172. HINSTANCE m_hLibrary; //类库句柄
  173. ENABLEMESSAGE* m_EnableMessage; //指向ENABLEMESSAGE(BOOL flag)函数的指针
  174. RECEIVEINFO* m_ReceiveInfo; //指向RECEIVEINFO(void)函数的指针
  175. DATAACQUISITION* m_DataAcquisition; //指向DATAACQUISITION(void*, int)函数的指针
  176. //READMYCOUNT* m_MyCount;
  177. float    Price[240]; //收到的价格
  178. int    Point[240][2];                         //对应的坐标值
  179. int    PointAver[240][2]; //加权平均线的点
  180. int    m; //横坐标(分钟数)
  181. float    M; //最大偏移量
  182. float    VolLast; //上一笔总成交量
  183. float    VolThis; //实时成交量(非总)
  184. float    VolOffset; //上次以前所有的成交量
  185. float    VolMax; //最大实时成交量
  186. //float    VolLastDay; //昨天总成交量
  187. float    Vol[240]; //算出的成交量
  188. int    VPoint[240][2]; //对应的成交量线坐标值
  189. BOOL    bNExit;                             //正常退出,是正常退出吗?
  190. BOOL    bReStart; //是重新开始的吗?
  191. BOOL    bKLine;                                 //是K线吗?
  192. BOOL    bCtrl; //是否按了Ctrl键
  193. CArray <KLine, KLine> KLineArray; //K线价格数据
  194. CArray <KPoint, KPoint> KPointArray; //K线坐标数据
  195. float KHighMax; //最大K线价格
  196. float KLowMin; //最小K线价格
  197. float KDay; //显示的总天数
  198. float KM; //最大最小价格之差
  199. float KBegine; //开始显示的K线索引
  200. CArray <KAmount, KAmount> KAmountArray; //K线成交金额数据
  201. CArray <KAmountPoint, KAmountPoint> KAmountPointArray; //K线成交金额坐标数据
  202. float KAmountMax; //最大成交金额
  203. //float KAmountLastDay; //昨日成交金额
  204. protected:
  205. void ExpandPackage(MAINSTRUCT Data); //拆包函数
  206. void Exchange(); //"分时线" 价格到坐标值的转换
  207.     void ExchangeA( int m ); //"分时线" 价格,成交量到加权平均线坐标的转换
  208. void ExchangeV(); //"分时线" 成交量到坐标值的转换
  209. void ExchangeK(); //"K线" 数据到坐标值的转换
  210. void ExchangeKAmount(); //"K线" 成交金额数据到坐标的转换
  211. void StoreDayLine(); //储存"分时线"数据
  212. void StoreKLine(); //储存"K线"数据
  213. void StoreKAmount(); //储存"K线"成交金额数据
  214. DWORD ReadDayLine(); //读取"分时线"数据
  215. DWORD ReadKLine(); //读取"K线"数据
  216. DWORD ReadKAmount(); //读取"K线"成交金额数据
  217. void ReStart(); //重新开始一天的DayLine
  218. protected: //消息映射
  219. afx_msg void OnCreate();
  220.     afx_msg void OnPaint();
  221. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  222. afx_msg void OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags );
  223. afx_msg void OnKeyUp( UINT nChar, UINT nRepCnt, UINT nFlags );
  224.     afx_msg LRESULT OnIRQSTOCK(WPARAM wParam,LPARAM lParam); //自定义消息
  225. afx_msg void OnDrawDayLine(WPARAM wParam,LPARAM lParam); //自定义消息
  226.     afx_msg void OnDrawKLine(WPARAM wParam,LPARAM lParam);
  227. afx_msg void OnDrawCommon(WPARAM wParam,LPARAM lParam);
  228. afx_msg void OnKLine();
  229.     afx_msg void OnDayLine();
  230. DECLARE_MESSAGE_MAP()  
  231. };