1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/dolphindb-Tutorials_CN

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
entrust数据处理.dos 1.6 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
LiXiaojuan-DolphinDB Отправлено 28.04.2023 13:11 87167b6
idate=2022.04.14
entrustTB=select * from loadTable("dfs://level_2", "entrust")where DateTime.date()=2022.04.14 and SecurityID in ["000001.SZ","000040.SZ"]
tradeTB=select * from loadTable("dfs://level_2", "trade")where DateTime.date()=2022.04.14 and SecurityID in ["000001.SZ","000040.SZ"] and ExecType!=52
/*
* 计算深交所股票每分钟的买卖委托金额
*/
defg calcSZOrderValue(side, price, orderQty, tradePrice, orderType, bsFlag){
price_ = iif(orderType =="50",price,NULL).nullFill(tradePrice)
return sum(iif(side==bsFlag,price_*orderQty,NULL)).nullFill(0)
}
res=select calcSZOrderValue(side,price,orderQty,tradePrice,orderType,"B") as BuyOrderValue,
calcSZOrderValue(side,price,orderQty,tradePrice,orderType,"S") as SellOrderValue
from aj(entrustTB,tradeTB,`SecurityID`ApplSeqNum) group by SecurityID,bar(DateTime,1m) as DateTime
/*
* 买卖撤单金额
*/
entrustTB=select * from loadTable("dfs://level_2", "entrust")where DateTime.date()=2022.04.14 and SecurityID in ["000001.SZ","000040.SZ"]
tradeTB=select * from loadTable("dfs://level_2", "trade")where DateTime.date()=2022.04.14 and SecurityID in ["000001.SZ","000040.SZ"]
trade=select SecurityID,DateTime, max(BidApplSeqNum,OfferApplSeqNum) as ApplSeqNum,TradeQty from tradeTB where ExecType=52
entrust=select SecurityID,ApplSeqNum, Price,Side from entrustTB
select sum(iif(side=="B",Price*TradeQty,NULL)).nullFill(0) as buywithdrawOrderValue,
sum(iif(side=="S",Price*TradeQty,NULL)).nullFill(0) as sellwithdrawOrderValue
from lsj(trade,entrust,`SecurityID`ApplSeqNum) group by SecurityID,bar(DateTime,1m) as DateTime

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/dolphindb-Tutorials_CN.git
git@api.gitlife.ru:oschina-mirror/dolphindb-Tutorials_CN.git
oschina-mirror
dolphindb-Tutorials_CN
dolphindb-Tutorials_CN
master