COCO研究院

 找回密碼
 註冊
搜索
查看: 6585|回復: 4

用AmiBroker自動下單:另一選項TWSLINK

[複製鏈接]
發表於 10-1-3 01:29 | 顯示全部樓層 |閱讀模式
trade-commander.com  出產兩TOOL :TWSLINK     MTIBBridge
兩者皆對INTERACTIVE BROKERS 下單

http://trade-commander.com/twslink/twslink.htm

http://trade-commander.com/MTIBBridge/MTIBBridge.htm

  TWSLINK 我兩年前試過可RUN 有點不穩  但FREE
   今天他以收費姿態繼續 是對的 只是 擋了TRY RUN 的路
MTIBBridge 是新產品 試用時發生 將我的CUSTOM INDICATOR 全當STRATEGY
但要RUN的卻ACTIVE  BUT NOT RUN
(需經過STOP AND RESTART 就發生 )

TWSLINK USER GROUPAS FOLLOW:

http://tech.groups.yahoo.com/group/twslink/

我貼一WL EXAMPLE FROM GROUP :


""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Re: Sample Wealth Lab script?
here is a simple script using TWSLink (from samples dir.)
{This sample demonstrates basic Steps to place an Order}

var lib: ComVariant;
var OpResult: integer=0;
var ID_MSFT: integer=0; {Unique Contract ID}
var Count: integer=0; {set to -1 and start the script}
var EntryID: integer=-1; {Order ID}

if(Count = -1) then
begin
{load the com dll}
lib := CreateOleObject('twslink.comif');
{init the com dll}
lib.INITDLL(2, 'c:\twslinkdll_wl.log', 2, 0, 3, 4000);
{register contract}
ID_MSFT := lib.REGISTER_CONTRACT('MSFT', 'STK', 'USD',
'SMART','','','',0.0,'',0,0.0);
{connect to TWS}
OpResult := lib.CONNECT('127.0.0.1', 7496, 4, 5000);
{place new order}
EntryID := lib.PLACE_ORDER(ID_MSFT, 0, 'SELL', 'LMT', 100, 39.77, 0, 'GTC', 1,
-1, '', '', -1);
{modify order -> raise the limit}
EntryID := lib.PLACE_ORDER(ID_MSFT, EntryID, 'SELL', 'LMT', 100, 39.96, 0,
'GTC', 1, -1, '', '', -1);
end;
Count := Count + 1;

as you can see, function

lib.PLACE_ORDER(ID_MSFT, 0, 'SELL', 'LMT', 100, 39.77, 0, 'GTC', 1, -1, '', '',
-1);


places an order. if you look into documentation, you can find
various functions placing an order, like
BUY_STP, SELL_STP etc.
a briefly documentation of all functions can be found
documentation\exported_functions.txt
your job now: to find the appropiate TWSLink functions for
your ordere below and pass the correct paramters to them.

sample:
SellAtStop(bar+1, (priceOpen(bar+1) - (priceHigh(bar) -
priceClose(bar))), LastPosition, 'open-1/2 exit');


int SELL_STP(id_from_register_this_charts_symbol,
0,
int uidorder,
double stopprice,
int Size,
string tif,
int transmit);


wrote:
>
>
> Here is a simple WL script. How do I program TWSLink to send orders to
> IB?
>
> *************************
>
> var Bar: integer;
> for Bar := 2 to BarCount - 2 do
> begin
> if not LastPositionActive then
> begin
> if (priceClose(bar) < priceOpen(bar)) then
> buyAtStop(bar+1, (priceOpen(bar+1) + (priceClose(bar) -
> priceLow(bar))), 'open+1/2 entry');
>
> if (priceClose(bar) > priceOpen(bar)) then
> shortAtStop(bar+1, (priceOpen(bar+1) - (priceHigh(bar) -
> priceClose(bar))), 'open-1/2 entry');
> end
> else
> begin
> if PositionLong(LastPosition) then
> if (priceClose(bar) > priceOpen(bar)) then
> SellAtStop(bar+1, (priceOpen(bar+1) - (priceHigh(bar) -
> priceClose(bar))), LastPosition, 'open-1/2 exit');
>
> if PositionShort(LastPosition) then
> if (priceClose(bar) < priceOpen(bar)) then
> CoverAtStop(bar+1, (priceOpen(bar+1) + (priceClose(bar) -
> priceLow(bar))), LastPosition, 'open+1/2 exit');
> end;
> end;
>
> ********************
>
> Thank you.
>


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
發表於 10-1-3 16:35 | 顯示全部樓層
請問這裡只針對IB嗎?
可以用國內券商的API下單嗎?
 樓主| 發表於 10-1-3 23:12 | 顯示全部樓層
回復 2# 綠茶妹


    只能由IB 下摩台  保證金較難進出
發表於 10-1-12 21:15 | 顯示全部樓層
謝謝分享
發表於 11-3-25 12:14 | 顯示全部樓層
您好!TrendRover,收穫很多。
,謝謝您
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

手機版|Archiver|站長信箱|廣告洽詢|COCO研究院

GMT+8, 24-11-22 17:35

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回復 返回頂部 返回列表
理財討論網站 |