1 Star 1 Fork 5

liuyang/XAPI2

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ApiProcess.cpp 1.90 KB
一键复制 编辑 原始数据 按行查看 历史
伍侃 提交于 2015-11-20 17:05 +08:00 . 初次提交
#include "stdafx.h"
#include "ApiProcess.h"
void InitBidAsk(DepthMarketDataNField* pField)
{
pField->Size = sizeof(DepthMarketDataNField);
pField->BidCount = 0;
}
int AddBid(DepthMarketDataNField* pField, PriceType price, VolumeType volume, VolumeType Count)
{
char* p = ((char*)pField) + pField->Size;
DepthField* pDF = (DepthField*)p;
pDF->Price = price;
pDF->Size = volume;
pDF->Count = Count;
pField->Size += sizeof(DepthField);
++pField->BidCount;
return 0;
}
int AddAsk(DepthMarketDataNField* pField, PriceType price, VolumeType volume, VolumeType Count)
{
char* p = ((char*)pField) + pField->Size;
DepthField* pDF = (DepthField*)p;
pDF->Price = price;
pDF->Size = volume;
pDF->Count = Count;
pField->Size += sizeof(DepthField);
return 0;
}
DepthField* GetBid(DepthMarketDataNField* pField, int Pos)
{
if (Pos <= 0 || Pos>pField->BidCount)
return nullptr;
char* p = ((char*)pField) + sizeof(DepthMarketDataNField);
DepthField* pDF = (DepthField*)p;
return pDF + Pos - 1;
}
DepthField* GetAsk(DepthMarketDataNField* pField, int Pos)
{
int count = (pField->Size - sizeof(DepthMarketDataNField)) / sizeof(DepthField);
int AskCount = count - pField->BidCount;
if (Pos <= 0 || Pos>AskCount)
return nullptr;
char* p = ((char*)pField) + sizeof(DepthMarketDataNField);
DepthField* pDF = (DepthField*)p;
return pDF + pField->BidCount + (Pos - 1);
}
char* ExchangeType_2_String(ExchangeType exchange)
{
switch (exchange)
{
case ExchangeType_SHFE:
return "SHFE";
case ExchangeType_DCE:
return "DCE";
case ExchangeType_CZCE:
return "CZCE";
case ExchangeType_CFFEX:
return "CFFEX";
case ExchangeType_INE:
return "INE";
case ExchangeType_SSE:
return "SSE";
case ExchangeType_SZSE:
return "SZSE";
case ExchangeType_SGE:
return "SGE";
case ExchangeType_NEEQ:
return "NEEQ";
case ExchangeType_HKEx:
return "HKEx";
case ExchangeType_Undefined:
default:
return "Undefined";
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ctosoft/XAPI2.git
git@gitee.com:ctosoft/XAPI2.git
ctosoft
XAPI2
XAPI2
master

搜索帮助