TB程序化接口是由软件商开拓者所研发设计的程序化交易平台,它是一款支持证券、期货实盘交易的量化交易工具,功能之强大也不需要小编多说了,今日我们就来分享一套TB程序化接口源码,希望可以帮助到有需要的投资者。
Bool bInitStatues(false); // 初始化标志,修改初始仓位时需设置为True
Numeric InitMyRealMp(0); // 初始化当前仓位,正数表示多单,负数表示空单
Numeric FirstGrid(30); // 第一笔交易的间距,最小跳动;
Numeric AddGrid(5); // 加仓间距,最小跳动
Numeric TotalGrids(10); // 最大交易次数
Numeric TrailingGrid(30); // 移动止损间距,最小跳动
Numeric EveryLots(1); // 每次开仓手数
Numeric OffSet(1); // 委托价偏差,默认买卖价偏差为1个滑点
Numeric ExitOnCloseMins(14.58); //收盘平仓时间
Vars
Numeric HighAfterLongEntry;
Numeric LowAfterShortEntry;
Numeric MyRealMp(0);
Numeric MinPoint;
Numeric tmpPrice;
Numeric tmpLots;
Begin
MinPoint=Minmove*PriceScale;
MyRealMp=GetGlobalVar(0);
HighAfterLongEntry=GetGlobalVar(1);
LowAfterShortEntry=GetGlobalVar(2);
if (BarStatus0 And (MyRealMpInvalidNumeric || bInitStatues))
{
MyRealMp=InitMyRealMp;
}
if (Date<>Date[1])
{
HighAfterLongEntry=High;
LowAfterShortEntry=Low;
MyRealMp=0;
}Else
{
HighAfterLongEntry=Max(HighAfterLongEntry,High);
LowAfterShortEntry=Min(Low,LowAfterShortEntry);
}
If (Time<ExitOnCloseMins/100)
{
If ( MyRealMp>0 And HighAfterLongEntry-Low>=TrailingGrid*MinPoint
And(High-Low<TrailingGridMinPoint Or(High-Low>=TrailingGridMinPoint And close<Open)))
{
tmpPrice=Max(HighAfterLongEntry-(TrailingGrid-OffSet)*MinPoint,Low);
tmpLots=Abs(MyRealMp*EveryLots);
Sell(tmpLots,tmpPrice);
MyRealMp=0;
LowAfterShortEntry=Low;
}Else
If ( MyRealMp<0 And High-LowAfterShortEntry>=TrailingGrid*MinPoint
And(High-Low<TrailingGridMinPoint Or(High-Low>=TrailingGridMinPoint And close>Open)))
{
tmpPrice=Min(LowAfterShortEntry+(TrailingGrid+OffSet)*MinPoint,High);
tmpLots=Abs(MyRealMp*EveryLots);
BuyToCover(tmpLots,tmpPrice);
MyRealMp=0;
HighAfterLongEntry=0;
}
// 第一笔多单开仓
if (MyRealMp==0 And High-LowAfterShortEntry>=FirstGrid*MinPoint)
{
tmpPrice=Min(LowAfterShortEntry+(FirstGrid+OffSet)*MinPoint,High);
tmpLots=EveryLots;
Buy(tmpLots,tmpPrice);
MyRealMp=1;
HighAfterLongEntry=High;
}Else
// 多单加仓
if (MyRealMp> 0 And MyRealMp =(FirstGrid+MyRealMp*AddGrid)
*MinPoint)
{
tmpPrice=Min(LowAfterShortEntry+(FirstGrid+MyRealMp*AddGrid+OffSet)*MinPoint,High);
tmpLots=EveryLots;
Buy(tmpLots,tmpPrice);
MyRealMp=MyRealMp+1;
}Else
// 第一笔空单开仓
if (MyRealMp==0 And HighAfterLongEntry-Low>=TrailingGrid*MinPoint )
{
tmpPrice=Max(HighAfterLongEntry-(FirstGrid-OffSet)*MinPoint,Low);;
tmpLots=EveryLots;
SellShort(tmpLots,tmpPrice);
MyRealMp=-1;
LowAfterShortEntry=Low ;
}Else
// 空单加仓
if (MyRealMp< 0 And -1MyRealMp =(FirstGrid+MyRealMpAddGrid)
*MinPoint)
{
tmpPrice=Max(HighAfterLongEntry-(FirstGrid-Abs(MyRealMp*AddGrid)-OffSet)*MinPoint,High);
tmpLots=EveryLots;
SellShort(tmpLots,tmpPrice);
MyRealMp=MyRealMp-1;
}
}Else
If (Time>ExitOnCloseMins/100)
{
If (MyRealMp>0)
{
tmpLots=Abs(MyRealMp*EveryLots);
tmpPrice=Close;
Sell(tmpLots,tmpPrice);
MyRealMp=0;
}
If(MyRealMp<0)
{
tmpLots=Abs(MyRealMp*EveryLots);
tmpPrice=Close;
BuyToCover(tmpLots,tmpPrice);
MyRealMp=0;
}
}
SetGlobalVar(0,MyRealMp);
SetGlobalVar(1,HighAfterLongEntry);
SetGlobalVar(2,LowAfterShortEntry);
Commentary(“MyRealMp=”+Text(MyRealMp));
Commentary(“HighAfterLongEntry=”+Text(HighAfterLongEntry));
Commentary(“LowAfterShortEntry=”+Text(LowAfterShortEntry));
//SetExitOnClose;
End
其实关于TB程序化接口的更多信息,我们都可以在他们的官网上找到,一般会用到TB程序化接口的投资者都是以做期货为主的,这款程序化接口可以直接绑定交易账户,除了实盘操作以外,还能实现模拟操作和风控测试等功能。最重要的是,TB程序化接口价格并不高,适合绝大部分期货投资者,即使是初学者也可以无障碍使用。
如果你觉得TB程序化接口不能满足你的需求,其实市场上还有很多其他程序化接口可供大家选择的,国内的像是ctp、飞马、恒生等都是比较多人用的,大家根据自己的需求选择适合自己的产品就可以了,而且这些程序化接口大多价格都还算可以接受,在方面大家也无需太过忧虑。
文章为作者独立观点,不代表股票量化交易软件接口观点
宏源期货董晓妮2023-10-25
每个人都有故事呀,我的故事,首轮95年开户,10个月赔了15万,含本人本金3万,欠股票公司12万,修养生息,还债8年,二次入市2013年投资30万港币,2007牛市顶峰480万港币,没撤退,2008年10月92万港币,2010年10月460万港币,撤退370万港币,股市留90万港币,2011年贷款150万,2011年5月股市90万港币+300万人民币2011年9月,股市760万港币,2023年12月30号1600万人民币,2005年12月5号8000万人民币……撤退,股市留1420万港币….断断续续至今…..)念旧是ー场噩梦°2023-10-17
想要超过他,你需要在三个条件之上,再满足一个先决条件,就是炒的是股票,以及投胎的是一个终其一生,都在蒸蒸日上的美国。