'买入条件量比你可以直接用股票池选股选出来然后放到自选股分类的TEST板块中去,然后用下面vba程序去做买入动作
dim num
'每只股票投入资金量
dim money
money = 100000
'最大持有股票数量
dim max_holding
max_holding = 10
Set b = CreateObject("Stock.Block")
'第一个计时器建立头寸
call application.SetTimer(0,5000)
'第二个计时器10秒发单,直到money市值
call application.SetTimer(1,10000)
Sub APPLICATION_Timer(ID)
if ID = 0 then
for i = 0 to b.count-1
buynum = marketdata.GetReportData(b.GetStockCode(i),b.GetStockMarket(i)).SellVolume1*0.5
Result = Order.HoldingInfoByCode2(b.GetStockCode(i),b.GetStockMarket(i),BuyHolding,BuyCost,BuyTodayHolding,SellHolding,SellCost,SellTodayHolding,PNL,UseMargin,"")
cond_first = BuyHolding<1 and Result <>1
if num+order.Holding2 + order.OrderNum2 <=max_holding and cond_first then
num = num+1
call order.buy(1,buynum,0,0,b.GetStockCode(i),b.GetStockMarket(i),"",0)
end if
next
end if
if ID = 1 then
for i = 0 to order.Holding2-1
Result = Order.HoldingInfo2(i,BuyHolding,BuyCost,BuyTodayHolding,SellHolding,SellCost,SellTodayHolding,PNL,UseMargin ,Code,Market)
buynum = marketdata.GetReportData(Code,Market).SellVolume1*0.5
price = marketdata.GetReportData(Code,Market).NewPrice
if BuyHolding<money/price then
call order.buy(1,buynum,0,0,Code,Market,"",0)
end if
next
end if
End Sub
'
Sub APPLICATION_VBAEnd()
call application.KillTimer(0)
call application.KillTimer(1)
set b = nothing
End Sub
Sub APPLICATION_VBAStart()
num = 0
End Sub
买入条件量比你可以直接用股票池选股选出来然后放到自选股分类的TEST板块中去,你这句等于是我要手动添加股票吗,而且你们VBA怎么去监控股票池我不知道
利用股票池选股后添加到板块中去,vba代码去对这个板块进行循环遍历就行了。
本例是利用股票池和vba结合的使用,简化算法代码
我用你们的程序买股票结果买了11只不是10只