以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://www.weistock.com/bbs/index.asp) -- 高级功能研发区 (http://www.weistock.com/bbs/list.asp?boardid=5) ---- 怎么保存交易记录和成交记录到Access或者Excel (http://www.weistock.com/bbs/dispbbs.asp?boardid=5&id=4696) |
-- 作者:guotx2010 -- 发布时间:2011/1/3 17:11:05 -- 怎么保存交易记录和成交记录到Access或者Excel 我想使用一个后台程序自动记录下单时的委托记录和成交后的成交记录到Access或者Excel中,供分析之用,请问前辈们,我该如何实现呢?
|
-- 作者:z7c9 -- 发布时间:2011/1/3 17:20:22 -- 以下内容为程序代码:
1 Sub Stat() 2 3 dim date 4 dim code 5 dim market 6 dim ordertype 7 dim action 8 dim price 9 dim volume 10 dim kaiping 11 12 set oexcel=createobject("excel.application") 13 oexcel.visible=true 14 oexcel.workbooks.add 15 16 oexcel.cells(1,1).value="日期" 17 oexcel.cells(1,2).value="合约" 18 oexcel.cells(1,3).value="时间" 19 oexcel.cells(1,4).value="方向" 20 oexcel.cells(1,5).value="价格" 21 oexcel.cells(1,6).value="手数" 22 oexcel.cells(1,7).value="类型" 23 24 for i=1 to order.tradecount2 25 call order.tradedetalied2(i-1,date,code,market,ordertype,action,price,volume,kaiping,"666666") 26 27 oexcel.cells(i+1,1).value=left(date,9) 28 oexcel.cells(i+1,2).value=code 29 oexcel.cells(i+1,3).value=right(date,8) 30 31 if action=0 then 32 oexcel.cells(i+1,4).value="买" 33 elseif action=1 then 34 oexcel.cells(i+1,4).value="卖" 35 end if 36 37 oexcel.cells(i+1,5).value=price 38 oexcel.cells(i+1,6).value=volume 39 40 if kaiping=0 then 41 oexcel.cells(i+1,7).value="开" 42 elseif kaiping=1 then 43 oexcel.cells(i+1,7).value="平" 44 end if 45 next 46 End Sub [此贴子已经被作者于2011-1-3 17:20:59编辑过]
|
-- 作者:guotx2010 -- 发布时间:2011/1/3 17:59:15 -- 非常感谢,我把这个代码放在一个模块里了,可是我在哪里触发这段代码呢?是不是在PlaceOrder里? Sub ORDER_PleaceOrder(Mode, Code, Market, OrderType, Action, Price, Vol, Result) |
-- 作者:guotx2010 -- 发布时间:2011/1/3 18:40:05 -- 我用一个宏调用这段代码,可是提示:编译器错误(28),堆栈溢出,运行不了,excel也没有打开? |
-- 作者:夏小飞 -- 发布时间:2011/1/4 9:24:26 -- EXCEL里的我还没试过 放在INI的天天用 也不必使用什么宏 直接在FUNCATION里 Sub ORDER_OrderStatusEx(OrderID, Status, Filled, Remaining, Price, Code, Market, OrderType, Aspect, Kaiping) end if |
-- 作者:guotx2010 -- 发布时间:2011/1/7 11:18:34 -- Sub ORDER_OrderStatusEx(OrderID, Status, Filled, Remaining, Price, Code, Market, OrderType, Aspect, Kaiping) End Sub
[此贴子已经被作者于2011-1-7 11:18:54编辑过]
|