锐英源软件
第一信赖

精通

英语

开源

擅长

开发

培训

胸怀四海 

第一信赖

当前位置:锐英源 / 外包精品 / 股票软件 / 锐英源软件软件开发外包精品股票软件和股票行情软件,股票软件二次开发和股票软件定制开发基地
服务方向
人工智能数据处理
人工智能培训
kaldi数据准备
小语种语音识别
语音识别标注
语音识别系统
语音识别转文字
kaldi开发技术服务
软件开发
运动控制卡上位机
机械加工软件
软件开发培训
Java 安卓移动开发
VC++
C#软件
汇编和破解
驱动开发
联系方式
固话:0371-63888850
手机:138-0381-0136
Q Q:396806883
微信:ryysoft

股票指标公式


本软件在处理指标上有鲜明特点的,对于客户选股会提供指导性强的帮助。指标的表现是结合图形的,对于行情数据能够在指标公式的计算下生成行情图形,进而可以指导选股。指标公式是保存在文件里,在程序启动时加载到内存里进行使用。本软件可以添加新的指标公式,删除指标公式和修改指标公式。下面分四个部分对代码进行描述:

2. 指标公式的加载和保存


2.1 指标公式对应类的类声明(行数100)

#define LEN_BYTE 192
struct FLOAT11
{
float fValue[11];
};
struct ADDITIONAL_BUYSELL
{
int nEnterPoint[4]; //进入点
COLORREF nColorPoint[4]; //进入点颜色
BYTE bLose; //使用最大利润损失率
BYTE bWin; //使用最大利润盈利率
BYTE bMaxDays; ///使用最大天数
BYTE bSubstractFee; //使用扣除手续费
BYTE bAddPreProfit; //加入前一次的盈利进行计算
BYTE bUseInitFinace; //使用初始资金
BYTE bRes1;
BYTE bRes2;
float fMaxLose; //最大利润损失率
float fMaxWin; //最大利润盈利率
float fMaxDays; //最大天数
float fInitFinace; //初始资金数
float fRes1;
float fRes2;
float fRes3;
float fRes4;
};
// CFormularContent command target
class CTaiShanDoc ;
class CFormularContent : public CObject
{
// protected constructor used by dynamic creation
// Attributes
public:
CFormularContent();
union
{
struct
{
float max[8] ; //最大值
float min[8] ; // 最小值
float defaultVal[8]; //缺省值
//0:HS 1:MIN1 2:MIN5 3:MIN15 4:MIN30 5:MIN60 6:DAY (MANYDAY ) 7:WEEK //8:MONTH 9:YEAR
float stepLen[8] ; //步长
float posX[8] ; //Y坐标轴的横线的数值
float fReserved ; //
int nKindPeriod; //
//0:HS 1:MIN1 2:MIN5 3:MIN15 4:MIN30 5:MIN60 6:DAY 7:WEEK //8:MONTH 9:YEAR 10:MANYDAY
int nPeriodsUsed:1[16]; //the kline period that is valid
BOOL isSystem; //是否是系统指标
BOOL isOfen ; //是否是常用指标
BOOL isProtected; //是否密码保护
BYTE isMainFiguer; //是否是主图叠加(0为副图,1为
主图,2为不可用)
BYTE numPara; //参数个数
BYTE posFlag ; //Y坐标轴的横线的式样(0为自动,1为
定制(可有7条),2为不可用)
BYTE byteRes ; //bool
};
BYTE btMemData[LEN_BYTE];
};
ADDITIONAL_BUYSELL * pAdditionalBS;//买卖附加条件
CArray<FLOAT11,FLOAT11&> defaultValArray;//不同时间周期的缺省参数 CString name; //技术分析指标名字(最多9个字符)
CString password ; //密码
CString explainBrief; // 指标说明
CString explainParam; // 参数说明
CString namePara[8] ; //参数名字(最多15个字符)
CString fomular ; //公式
CString help ; //帮助注释
//YHH ADD -----专家系统中的买进和卖出条件---------
CString buyStr ; //买入的条件
CString sellStr ; //卖出的条件
CString buyStrKong ; //买入的条件
CString sellStrKong ; //卖出的条件
//YHH ADD
//CTaiKline add ,3.13
CString subKindJiShu; //the kind of 技术分析指标,the default value is ""
CString subKindJiShuTime; //技术分析指标的时间周期分类
CString strReserved; //
static bool m_bVer20;
static CStringArray m_strArrayKind[4];
}

2.2 指标公式的读写(行数100)

类CFormularContent的接口:
void CFormularContent:: ReadWriteIndex (CTaiShanDoc *pDoc, int nKind, bool bRead)
功能说明:读写技术指标文件。
输入参数:
pDoc:文档对象指针;
nKind:技术指标数据的种类(0为技术分析指标数据,1为条件选股指标数据,2为K线组合指标数据);
bRead l:是读还是写。
输出参数:无。
代码如下:
if(pDoc==NULL)
return;
m_bVer20 = false;
CString sName = g_zbgs_hz;//
Formu_Array1* pArray = &(pDoc->m_formuar_index );
if(nKind==1)
{
sName = g_tixg_hz;
pArray = &(pDoc->m_formuar_choose) ;
}
else if(nKind==2)
{
sName = g_kxzh_hz;
pArray = &(pDoc->m_formuar_kline );
}
//DeviceIoControl
try
{
if(bRead == false)
{
CFile gsfile;

m_bVer20 = true;
gsfile.Open(sName+"备份",CFile::modeCreate|CFile::modeWrite);
CArchive ar(&gsfile,CArchive::store);
int length = -1;//=pDoc->m_formuar_index.GetSize();
ar<<length;
length=pArray->GetSize();
int ii = 0;
//来自服务器的指标不写入文件
for(int i = 0;i<length;i++)
{
if(pArray->GetAt (i)->m_nIsFromServer != 33134999)
ii++;
}
ar<<ii;
for(i=0;i<length;i++)
{
CFormularContent * jishu;
jishu=pArray->GetAt(i);
//only 1 times
if(jishu->m_nIsFromServer != 33134999)
ar<<jishu;
}
ar.Close();
gsfile.Close();
::DeleteFile (sName);
CFile::Rename(sName+ "备份", sName);
}
else
{
CFile gsfile;
gsfile.Open(sName,CFile::modeRead);
CFileStatus status;
gsfile.GetStatus(status);
if(status.m_size>0)//by shw 20090731
{
int length;//=pDoc->m_formuar_index.GetSize();
CArchive ar(&gsfile,CArchive::load);
ar>>length;
if(length==-1)
{
m_bVer20 = true;
ar>>length;
}
m_strArrayKind[nKind].RemoveAll();
m_strArrayKind[nKind].Add("其它");
for(int i=0;i<length;i++)
{
CFormularContent * jishu;
ar>>jishu;
pArray->Add(jishu);//GetAt(i);
AddKindName(jishu->subKindIndex , nKind);
}
ar.Close();
gsfile.Close();
}
}
}
catch(...)
{
}
m_bVer20 = false;

2.3 导出指标公式的函数(行数150)

bool CFormularContent::ExportFormular(Formu_Array1 *pArr, int nArr,CString fileName,BOOL bCompleteSecret, BOOL bPassword, CString strPassword)
{
int nTotal = 0;
for(int i = 0;i<nArr;i++)
{
nTotal+=pArr[i].GetSize ();
}
if(nTotal==0)
return false;
CTaiShanDoc* pDoc=((CMainFrame*)(AfxGetApp()->m_pMainWnd))->m_taiShanDoc ;

CString defaultname=""; //对话框的缺省名字
int ncurtab=0;
CString sArray="*.ts"; //指标公式 //条件选股公式 //K线模式公式
CFormularContent::m_bVer20 = false;
{
CString filename=fileName;
if(filename.Find('.') == -1)
{
CString temp = sArray;
temp.TrimLeft ("*");
filename+=temp;
}
CFile file;
if(file.Open(filename,CFile::modeRead)!=0)
{
if(AfxMessageBox(filename+"文件已存在,要覆盖吗?",MB_YESNO|MB_ICONQUESTION)==IDNO)
{
file.Close();
//::SetCurrentDirectory (CMainFrame::m_taiShanDoc ->m_CurrentWorkDirectory);
return false;
}
file.Close();
}
CFormularContent::m_bVer20 = true;
file.Open(filename,CFile::modeCreate|CFile::modeWrite);
CArchive ar(&file,CArchive::store);
int selectcount=0;
ar<<selectcount;
ar<<selectcount;
int nOut = 0;
Formu_Array1* pArray = pArr;
int nOutAll = 0;
for(int j =0;j<nArr;j++)
{
nOut = 0;
for(i=0;i<pArray[j].GetSize ();i++)
{
//此处代码有省略
}
nOutAll+=nOut;
ar<<nOut;
ar<<j;
for(i=0;i<pArray[j].GetSize ();i++)
{
CFormularContent *jishu;
jishu=pArray[j].GetAt(i); //指标公式
CString buyStr = jishu->buyStr;
if(buyStr=="" && jishu->sellStr == "")
{
int isProt = jishu->isProtected;
CString sP = jishu->password;
CString sOut = jishu->sellStr ;
if(bPassword)
{
//此处代码有省略
}
if(bCompleteSecret)
{
jishu->sellStr = "dls";
jishu->isProtected = 1;
if(jishu->password == "")
{
for(int k = 0; k<108; k++)
{
char ch = (char)((rand()+128)%255+1);
CString s(ch);

jishu->password += s;
}
}
}
ar<<jishu;
jishu->isProtected = isProt;
jishu->password = sP;
jishu->sellStr = sOut;
}
}
}
CString lengthstr;
lengthstr.Format("%d",nOutAll);
if(nTotal>nOutAll)
AfxMessageBox("部分完全加密的公式不允许导出!");
AfxMessageBox("一共在文件里写了"+lengthstr+"个公式");
ar.Close();
file.Close();
CFormularContent::m_bVer20 = false;
if(nOutAll<=0)
return false;
if(bCompleteSecret)
{
if(file.Open(filename,CFile::modeReadWrite))
{
int nLen = file.GetLength ();
if(nLen<=0)
nLen = 1;
BYTE * byt = new BYTE[nLen];
file.Read (byt,nLen);
for(int j = 0;j<nLen-7;j+=7)
{
for(int k = 0;k<7/2;k++)
{
BYTE tmp = byt[j+k];
byt[j+k] = byt[j+6-k];
byt[j+6-k] = tmp;
}
}
char ch[32] = "YBW SECRET FILE1.0";
file.SeekToBegin ();
file.Write (ch,32);
file.Write (byt,nLen);
file.Close();
}
}
}
return true;
}

2.4 导入指标公式的函数(行数170)

bool CFormularContent::InstallIndicatorCwd(CString sFilePathName,bool bPromp,bool bFromServer)
{
CTaiShanDoc* pDoc=CMainFrame::m_taiShanDoc ;
CString filename=sFilePathName;//m_filedia.GetPathName();
CFile file;
if(file.Open(filename,CFile::modeReadWrite))
{
char ch[32] ;
file.Read (ch,32);
ch[31] = 0;
CString ss = ch;
if(ss == "YBW SECRET FILE1.0")
{
int nLen = file.GetLength ();
if(nLen<=0)
nLen = 1;
BYTE * byt = new BYTE[nLen-32];
file.Read (byt,nLen-32);
for(int j = 0;j<nLen-7-32;j+=7)
{
for(int k = 0;k<7/2;k++)
{
BYTE tmp = byt[j+k];
byt[j+k] = byt[j+6-k];
byt[j+6-k] = tmp;
}
}
file.SeekToBegin ();
file.Write (byt,nLen-32);
}
}
else
{
if(bPromp == true)
AfxMessageBox("文件不存在或文件只读!请把文件设为可写属性!");
return false;
}
file.SeekToBegin ();
CArchive ar(&file,CArchive::load);
int selectcount,ncurtab;
ar>>selectcount;
int nTotalKind = 1;
if(selectcount > 0)
{
CFormularContent::m_bVer20 = false;
ar>>ncurtab;
}
else
{
nTotalKind = 3;
CFormularContent::m_bVer20 = true;
ar>>selectcount;
ar>>selectcount;
ar>>ncurtab;
}

Formu_Array1* pArray[] = {&(pDoc->m_formuar_index ),&(pDoc->m_formuar_choose ),&(pDoc->m_formuar_kline )};

int isoverwrite=0;
for(int k = 0;k<nTotalKind;k++)
{
int readpos=0;
for(int i=0;i<selectcount;i++)
{
if(isoverwrite == 0)
isoverwrite=1;
BOOL isfind=FALSE;
CFormularContent *jishu=NULL;//new CFormularContent;
ar>>jishu;
//来自服务器端的指标
if(bFromServer == true)
{
//此处代码有省略
}
AddKindName(jishu->subKindIndex, ncurtab);

//test product code
if(jishu->buyStr .GetLength () >0)
{
int nLen2 = jishu->buyStr.GetLength ();
CString ss = pDoc->m_strSerial;
// if(nLen2 == 8)
// ss = g_chMachineID;
if(jishu->buyStr .CompareNoCase ( ss)!=0)
{
if(bPromp == true) AfxMessageBox("此公式不能用于您的软件!");
continue;
}
else
{
//此处代码有省略
}
}
CString name=jishu->name;
int k,length;
length=pArray[ncurtab]->GetSize();
for( k=0;k<length;k++)
{
int result=name.Compare(pArray[ncurtab]->GetAt(k)->name);
if(result>0)
continue;
else
if(result==0)
{
isfind=TRUE;
if(bPromp == true && isoverwrite <2)
{
CFxjOverWriteF dlg;
dlg.m_s1 = name+"公式已存在,是否要覆盖?";
dlg.DoModal ();
isoverwrite = dlg.m_nResponse ;
}
break;
}
else
break;
}
if(isfind)
{
if(isoverwrite)
{
CFormularContent *jishutodel=pArray[ncurtab]->GetAt(k);
delete jishutodel;
pArray[ncurtab]->SetAt(k,jishu);
}
}
else
{
pArray[ncurtab]->InsertAt(k,jishu);
if(ncurtab == 0)
{
//加入到键盘精灵中
CString name=jishu->name;
CTaiKeyBoardAngelDlg dlg;
dlg.AddIndicatorName(name);
}
}
readpos=k; //保存更新的位置
}
if(k == nTotalKind-1) break;
ar>>selectcount;
ar>>ncurtab;
}
ar.Close();
file.Close();
CFormularContent::m_bVer20 = false;
return true;
}

3. 指标公式的使用

3.1 常用指标菜单的生成和显示(行数110)
3.2 绘制指标图形(行数110)
3.3 指标公式显示树形的初始化(行数170)

4. 指标公式的管理

4.1 公式管理对话框代码(行数361)

4.2 添加修改:公式编辑器对话框代码(行数1320)

5. 指标公式的计算

5.1 计算主函数(行数560)
5.2 计算辅助函数词法检查(行数480)

友情链接
版权所有 Copyright(c)2004-2021 锐英源软件
公司注册号:410105000449586 豫ICP备08007559号 最佳分辨率 1024*768
地址:郑州大学北校区院(文化路97号院)内