欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件程序化交易实盘俱乐部 → [原创]根据当日涨跌判断进行交易

   

欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。    


  共有10412人关注过本帖平板打印复制链接

主题:[原创]根据当日涨跌判断进行交易

帅哥哟,离线,有人找我吗?
wangwatercup
  1楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游侠 帖子:103 积分:532 威望:0 精华:0 注册:2010/11/8 18:27:01
[原创]根据当日涨跌判断进行交易  发帖心情 Post By:2011/1/2 17:06:06 [只看该作者]

 (1)采用SVM、CART和PNN进行股指期货涨跌预测,预测当日涨跌。其中输入变量为沪深300收益率、振幅、市场热度、成交额、资金净流入、趋势、道琼斯指数收益率等。
(2)根据涨跌预测,进行当日交易,规则如下:
    (2.1)开盘即买入或卖出,同时2个机制下单,争取在开盘后以最快的速度成交;
     (2.2) 2% 止损;
     (2.3) 如果未成交,则撤单之后继续在开盘价的微小区间之内追单
     (2.4) 设置滑点,默认0.2
     (2.5) 3点10分不惜一切,平仓
(3)代码如下

dim dmHY,dmJYS,signal,buy_amount,IDaccount,RangeTick,RangeStoploss,Stoploss,NumberStoploss,Slide

dim orderid
dim ConSign
dim Filled
dim Remaining
dim Action
dim OrderType
dim LmtPrice
dim Account
dim Kaiping

dim BuyHoding
dim BuyCost
dim BuyTodayHoding
dim SellHoding
dim SellCost
dim SellTodayHoding
dim PNL
dim UseMargin

dim FirstTrade,StatusFirstTrade

sub b0()    '设置参数
'一定要在开盘之前运行本程序,
signal=1    '1 买 2 卖空
buy_amount=9    '开仓数量
IDaccount="40009975"    '帐号

dmHY="if01"        '合约
dmJYS="zj"        '交易所
RangeTick=.005  '报价与开盘价之间价差变动范围百分比
RangeStoploss=.02   '止损百分比

NumberStoploss=0
Slide=.2
end sub

Sub APPLICATION_VBAStart()
    FirstTrade=1                       
'一定要在未建仓之前运行本程序;
'如果想在开盘时最先成交,一定在9点14分之前启动本程序
    call b0
    call Application.SetTimer(1,5000) '1S触发一次
    call application.SetTimer (2,50)
    call marketdata.RegReportNotify(dmHY,dmJYS)
    msgbox "启动"
End Sub

Sub APPLICATION_Close()
    call Application.KillTimer(1)
    call marketdata.UnRegReportNotify(dmHY,dmJYS)   
End Sub

Sub APPLICATION_Timer(ID)
select case ID
    case 1
        call b3
    case 2
        call b1
end select
End Sub

Sub ORDER_OrderStatusEx(oOrderID,oStatus,oFilled,oRemaining,oPrice,oCode,oMarket,oOrderType,oAspect,oKaiping)
    StatusFirstTrade = oStatus
   
    if oAspect = 0 and oKaiping = 0 then
        oTrade = 1                                '开多
    elseif  oAspect = 1 and oKaiping = 1 then
        oTrade = -.5                             '平多
    elseif  oAspect = 1 and oKaiping = 0 then
        oTrade = -1                                '开空
    elseif  oAspect = 0 and oKaiping = 1 then
        oTrade = .5                                '平空
    end if
       
'filled 是全部成交
'tradeing 已成交部分
End Sub

Sub MARKETDATA_ReportNotify(ReportData) '争取在启动的时候下单
timePart=time
if timePart<=timevalue("09:14:30") or (timePart>timevalue("11:30:10") and timePart<=timevalue("12:59:50")) then
    exit sub
end if

if FirstTrade=1 and (isempty(StatusFirstTrade) or StatusFirstTrade="Cancelled" or StatusFirstTrade="Inactive") then
    Set rpt = marketdata.GetReportData(dmHY,dmJYS)'得到这个品种的行情报价
    PriceOpen=rpt.Open
    select case signal
        case 1
            Ssx_Price_Buy=rpt.SellPrice1+Slide
            if abs((Ssx_Price_Buy-PriceOpen)/PriceOpen)<=RangeTick then
                call Order.Buy(0,buy_amount,Ssx_Price_Buy,0,dmHY,dmJYS,"",0)   
            end if       
        case 2
            Ssx_Price_Sell=rpt.BuyPrice1-Slide
            if abs((Ssx_Price_Sell-PriceOpen)/PriceOpen)<=RangeTick then
                call Order.BuyShort(0,buy_amount,Ssx_Price_Sell,0,dmHY,dmJYS,"",0)
            end if
    end select
    if StatusFirstTrade ="Filled" or StatusFirstTrade ="Tradeing" or StatusFirstTrade ="Submitted" or  StatusFirstTrade ="PreSubmitted" then
        FirstTrade = 0    '不会存在下了指令却无法成为委托的情况,因为如果能获得注册的品种发出的价格,则一定是在交易时间
        call document.WritePrivateProfileFloat("operation", "timePartReportNotify", timePart, "C:\out.ini")
    end if
end if
end sub

sub b1()    '争取在开盘的时候下第一单
timePart=time
if timePart<=timevalue("09:14:40") or timePart>=timevalue("9:15:10") then
    exit sub
end if

if FirstTrade=1 and (isempty(StatusFirstTrade) or StatusFirstTrade="Cancelled" or StatusFirstTrade="Inactive") then
    Set rpt = marketdata.GetReportData(dmHY,dmJYS)'得到这个品种的行情报价
    PriceOpen=rpt.open
    select case signal
        case 1
            Ssx_Price_Buy=rpt.SellPrice1+Slide
            if abs((Ssx_Price_Buy-PriceOpen)/PriceOpen)<=RangeTick then
                call Order.Buy(0,buy_amount,Ssx_Price_Buy,0,dmHY,dmJYS,"",0)   
            end if       
        case 2
            Ssx_Price_Sell=rpt.BuyPrice1-Slide
            if abs((Ssx_Price_Sell-PriceOpen)/PriceOpen)<=RangeTick then
                call Order.BuyShort(0,buy_amount,Ssx_Price_Sell,0,dmHY,dmJYS,"",0)
            end if
    end select
    if StatusFirstTrade ="Filled" or StatusFirstTrade ="Tradeing" or StatusFirstTrade ="Submitted" or  StatusFirstTrade ="PreSubmitted" then
        FirstTrade = 0    '不会存在下了指令却无法成为委托的情况,因为如果能获得注册的品种发出的价格,则一定是在交易时间
        call document.WritePrivateProfileFloat("operation", "timePart", timePart, "C:\out.ini")
    end if
end if

end sub

sub b3()
if FirstTrade<>0 then '若下单未成功,则退出
    exit sub
end if

timePart=time       
if (timePart>timevalue("09:14:30") and timePart<=timevalue("11:30:00")) or (timePart>=timevalue("13:00:00") and timePart<=timevalue("15:10:00")) then    '是否成交
    select case signal
        case 1
            call b31
        case 2
            call b32
    end select   
elseif timePart>timevalue("15:10:00") then    '平仓
    select case signal
        case 1
            call b41
        case 2
            call b42
    end select
end if       
end sub


[此贴子已经被作者于2011-1-2 17:30:01编辑过]

版主评定:好评,获得5个金币奖励好评,获得5个金币奖励
(理由:好文章)
 回到顶部
总数 11 1 2 下一页