以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://weistock.com/bbs/index.asp) -- 高级功能研发区 (http://weistock.com/bbs/list.asp?boardid=5) ---- 板块同步效果和想象的不一样,请指教。 (http://weistock.com/bbs/dispbbs.asp?boardid=5&id=13524) |
-- 作者:明心 -- 发布时间:2012/8/7 18:27:52 -- 板块同步效果和想象的不一样,请指教。 板块同步效果和想象的不一样,请高手帮忙看看问题出现在哪里? \'全局变量 dtss\'多头系数,自己填写。测试时,可以随便给个数字 ktss\'空头系数,同上 \'-----------------------------------------同步平掉多余的多单 sub tongbu_pingduo() Set b = CreateObject("stock.block") ccsl = order.Holding2() for i =0 to ccsl-1 Call Order.HoldingInfo2(i,BuyHolding,BuyCost,BuyTodayHolding,SellHolding,SellCost,SellTodayHolding,PNL,UseMargin,Code,Market) if BuyHolding > 0 then b.Open "商品多头", 1 mxpc =0 For k = 0 To b.Count - 1 mxcode = b.GetStockCode(k) if code = mxcode then pc = 1 else pc = 0 end if mxpc = mxpc+pc Next if mxpc =0 then Call Order.sell(1,BuyHolding,0,0,Code,Market,"",0) end if if mxpc = 1 and BuyHolding>dtss then Call Order.sell(1,BuyHolding-dtss,0,0,Code,Market,"",0) end if end if next application.MsgOut ccsl&"多余多单已经平掉!" end sub \'-------------------------------------同步平掉多余的空单 sub tongbu_pingkong() Set b = CreateObject("stock.block") ccsl = order.Holding2() for i =0 to ccsl-1 Call Order.HoldingInfo2(i,BuyHolding,BuyCost,BuyTodayHolding,SellHolding,SellCost,SellTodayHolding,PNL,UseMargin,Code,Market) if SellHolding > 0 then b.Open "商品空头", 1 mxpc =0 For k = 0 To b.Count - 1 mxcode = b.GetStockCode(k) if code = mxcode then pc = 1 else pc = 0 end if mxpc = mxpc+pc Next if mxpc =0 then Call Order.sellshort(1,SellHolding,0,0,Code,Market,"",0) end if if mxpc =1 and SellHolding>ktss then Call Order.sellshort(1,SellHolding-ktss,0,0,Code,Market,"",0) end if end if next application.MsgOut ccsl&"多余空单已经平掉!" end sub \'-------------------------------------同步补足多单 sub tongbu_kaiduo() Set b = CreateObject("stock.block") b.Open "商品多头", 1 For k = 0 To b.Count - 1 mxcode = b.GetStockCode(k) ccsl = order.Holding2() mxpc = 0 for i =0 to ccsl-1 Call Order.HoldingInfo2(i,BuyHolding,BuyCost,BuyTodayHolding,SellHolding,SellCost,SellTodayHolding,PNL,UseMargin,Code,Market) if code = mxcode then pc = 1 else pc = 0 end if mxpc = mxpc+pc Next if mxpc =0 then Call Order.buy(1,dtss,0,0,Code,Market,"",0) end if if mxpc =1 and BuyHolding<dtss then Call Order.buy(1,dtss-BuyHolding,0,0,Code,Market,"",0) end if next application.MsgOut ccsl&"多单已补足!" end sub \'-------------------------------------同步补足空单 sub tongbu_kaikong() Set b = CreateObject("stock.block") b.Open "商品空头", 1 For k = 0 To b.Count - 1 mxcode = b.GetStockCode(k) ccsl = order.Holding2() mxpc = 0 for i =0 to ccsl-1 Call Order.HoldingInfo2(i,BuyHolding,BuyCost,BuyTodayHolding,SellHolding,SellCost,SellTodayHolding,PNL,UseMargin,Code,Market) if code = mxcode then pc = 1 else pc = 0 end if mxpc = mxpc+pc Next if mxpc =0 then Call Order.buyshort(1,ktss,0,0,Code,Market,"",0) end if if mxpc =1 and SellHolding<ktss then Call Order.buyshort(1,ktss-SellHolding,0,0,Code,Market,"",0) end if next application.MsgOut ccsl&"空单已补足!" end sub \'------------------------------------同步 sub duichongtongbu() call tongbu_pingduo() call tongbu_pingkong() call tongbu_kaiduo() call tongbu_kaikong() end sub
|
-- 作者:王锋 -- 发布时间:2012/8/7 19:50:35 -- 出什么问题了? |
-- 作者:明心 -- 发布时间:2012/8/8 11:06:54 -- 账户里的品种是能平掉,但是不该平的也平了。板块里有的,开不了仓。总结起来就是板块和账户没有能同步。 |
-- 作者:王锋 -- 发布时间:2012/8/8 11:24:30 -- 这个问题没法帮你解决,只能你自己通过输出日志的办法,自己调试了 |