kilroy 發表於 14-8-8 12:33

skyler 發表於 14-8-8 11:44 static/image/common/back.gif
請教一個問題
DateTime() 要如何轉成 YYYYMMDDHHmmss的格式?
還是只能用 DateNum() + TimeNum() 來組合?


_NowDate   = Now( 1 );
_NowTime   = StrRight( "00" + floor( Now( 4 ) / 10000 ), 2 )
            + ":" + StrRight( "00" + floor( Now( 4 ) / 100 ), 2 )
            + ":" + StrRight( "00" + floor( Now( 4 ) % 100 ), 2 );

_content = _NowDate + " " + _NowTime;



出來的格式是 EX. 2014/08/08 12:31:48





skyler 發表於 14-8-8 15:02

kilroy 發表於 14-8-8 12:33 static/image/common/back.gif
_NowDate   = Now( 1 );
_NowTime   = StrRight( "00" + floor( Now( 4 ) / 10000 ), 2 )
            +...

感謝大大的回覆~
我想說我一直找不到
能將DateTime() format 成 YYYYMMDDHHmmss的格式
所以才來發問一下
看來要自己組合了

另外再請問一下
在 ibc.GetPositionSize( ContractMonth ) != 0 時表示有多單或空單
如果我想要進一步知道目前這張單的損益
不知道有function 嗎?

感謝~


kilroy 發表於 14-8-8 15:49

skyler 發表於 14-8-8 15:02 static/image/common/back.gif
感謝大大的回覆~
我想說我一直找不到
能將DateTime() format 成 YYYYMMDDHHmmss的格式


可以用 GetPositionInfo 來抓
不過只限於在 IB Controller 裡的欄位

ex. GetPositionInfo( contractmonth, "Unrealized PNL");


這樣就可以抓到該商品的未平倉損益



greg 發表於 14-8-8 18:41

K大, 我研究到止損放於交易條件的方法~

TradePrice= StaticVarGet("TradePrice");
stopprice = TradePrice * 0.9 > C ; // 10% STOP LOSS
Sell = sell condition or stopprice ;

ibc.PlaceOrder...
StaticVarSet("TradePrice", BuyPrice);



我遇到另一問題是,有些時候, 在昨天交易時段完結, 第二早上開巿或中午重新開巿時, AB 不會自動更新最新的價格數據, 而是圖表停留在對上一個交易時段完結, 直到我手動到AB 重開圖表 reconnect ,   AB 才會再更新數據, K 大有遇到這情況嗎, 可以怎樣避免 ? 謝謝K 大!

kilroy 發表於 14-8-8 20:06

greg 發表於 14-8-8 18:41 static/image/common/back.gif
K大, 我研究到止損放於交易條件的方法~

TradePrice= StaticVarGet("TradePrice");


請問資料源是什麼

DDE 嗎?


greg 發表於 14-8-8 22:37

k 大 , 我用的是IB data

kilroy 發表於 14-8-8 23:08

greg 發表於 14-8-8 22:37 static/image/common/back.gif
k 大 , 我用的是IB data

我有訂閱 IB 的資料源

不過沒把它接到 AB

---
依照我初淺的使用經驗

以前使用過 DDE 時會遇到像大大說的那種情形

就是隔日開盤時,可能因為券商的系統

隔日必須重新登入才會刷新即時資料


可是目前使用 eSignal 只要有開盤,就會有資料持續送進 AB

所以沒有遇到像大大說的問題

那可能大大要用 IB data 的方式就是開盤前重新開啟 AB



greg 發表於 14-8-9 00:16

kilroy 發表於 14-8-8 23:08 static/image/common/back.gif
我有訂閱 IB 的資料源

不過沒把它接到 AB


謝謝k 大回覆!

請問有沒有 auto it 可以解決?

kilroy 發表於 14-8-9 00:47

greg 發表於 14-8-9 00:16 static/image/common/back.gif
謝謝k 大回覆!

請問有沒有 auto it 可以解決?



;Run AmiBroker
run("C:\Program Files (x86)\AmiBroker\Broker.exe","C:\Program Files (x86)\AmiBroker")
WinWait("","",10)

以上是簡單呼叫

如果是 64-bit 版本,把 (x86) 去掉就可以了

---
使用 windows 內建的工作排程,其實也可以做到

ex. 特定時間關閉或開啟程式

但要確定是否重新開啟 AB 時,會自動回補 IB 的 data feed

如果可以,那就沒問題了



greg 發表於 14-8-9 02:12

K 大, 如果重開 AB 有沒有快方法重置Analysis windows? 謝謝!

kilroy 發表於 14-8-9 02:30

greg 發表於 14-8-9 02:12 static/image/common/back.gif
K 大, 如果重開 AB 有沒有快方法重置Analysis windows? 謝謝!

先把你要用的 analysis windows 設定好

比如說要開啟那個 AFL,週期,掃描間距,掃描期間等

存成 apx 檔 (file -> save)

再搭配 AutoIt 來開啟

這樣就可以了

greg 發表於 14-8-10 23:49

謝謝k 大, 要研究一下~

osdak 發表於 14-8-12 21:22

我記得k大大之前有提到過於ib controller中看個別contract的PnL情況, 但又找不到, 大大可否再分享? 我看ibcontroller的資料, 也只有ibc.GetAccountValue("RealizedPnL")
和 ibc.GetAccountValue("UnrealizedPnL")......沒有個別合同的.

kilroy 發表於 14-8-12 22:25

osdak 發表於 14-8-12 21:22 static/image/common/back.gif
我記得k大大之前有提到過於ib controller中看個別contract的PnL情況, 但又找不到, 大大可否再分享? 我看ibc ...

使用 GetPositionInfo( string Ticker, string Field)

This function retrieves the value of the Field of Ticker symbol held currently in the portfolio


Parameters:
[*]Ticker - string that specifies the symbol of security/contract. The symbol should follow the symbology defined in detail at: http://www.amibroker.com/ib.html
[*]Field - one of column names found in "Portfolio" page of IB Controller. For example "Avg. cost" gives average cost of purchase of given security, "Unrealized PNL" gives unrealized profit and loss.

skyler 發表於 14-8-13 23:05

k大
想跟您請教二個問題
1.
RoundLotSize = 1;
這個是表示最小下單的單位為1口對吧?!
在實際下單時是不是也要加上這行呢?

2.
想請教一下
下限價單的語法是否如下
BuyOrderID = ibc.PlaceOrder( ContractMonth, "BUY", 1, "LMT", BuyPrice, 0, "DAY", True );


SellOrderID = ibc.PlaceOrder( ContractMonth, "SELL", 1, "LMT", ShortPrice, 0, "DAY", True );



謝謝您的回覆
頁: 16 17 18 19 20 21 22 23 24 25 [26] 27 28 29 30 31
查看完整版本: [分享] 用AB踏入外期程式交易