用家可以自己寫程式(例如 VBA,JAVA,C#) 從外部控制 SPARK 的 策略. 方法是用家的程式把策略的參數寫入一個簡單的文字檔.
檔案名每天不同. 定為 ExtStrategies-YYMMDD.txt 如今天日期是 2017年 1 月 10 日, 檔案名便是 ExtStrategies-170110.txt 這檔案要放在 SparkSetup 資料夾內的 ORDERS資料夾內
檔案內容為:
[Protocol] Name=External Strategies File Version=1.00 Description=External Strategies File [Strategies] [Modify Strategies] [Delete Strategies]
如何增加新策略
例如要增加一個新限價策略, 只需加一行在 [Strategies]下面
20170110-001=Type=BARRIER~Product ID=HSIZ5~Is Simulation=FALSE~Is Bullish=NO~Barrier=21770~Take Profit Adj=20~Stop Loss Adj=40~Not Filled Cancel Seconds=55~Quantity=-1~Open Toler=-40~Close Toler=4~Start Time 1=09:15:00~End Time 1=11:57:00~Force Close Time 1=11:58:00~Start Time 2=15:58:00~End Time 2=16:10:00~Force Close Time 2=16:12:00~Start Time 3=23:25:00~End Time 3=23:30:00~Force Close Time 3=23:40:00~After Loss Wait Seconds=300~After Profit Wait Seconds=60
The above is a very long line, make sure you drag to the right most to see all of it. The blue part is a unique ID you give this strategy. The ~ symbol is a separator between each field. Each field is in the format of Field_Name=Field_Value
The field Type=BARRIER specifies the type of the strategy. Different types of strategies contains different fields. e.g.
For Barrier, this field means a bearish barrier strategy: "Is Bullish=NO"
Most strategies supports this field "Take Profit Adj=20" which means to place an OCO Stop Loss order of taking 20 points profit. The Stop Loss Level is specified by the field "Stop Loss Adj=40"
Copy Fields to Clipboard
There is a button "Copy Fields to Clipboard" in every strategy. Clicking it will copy the field values of the current strategy user controls to the clipboard, which you can then paste to add Strategy Text Control file. You can use it to learn the field names and format of this strategy.
Feedback File
Your program or Excel VBA can constantly read back the feedback file ExtStrategies_Feedback-YYMMDD.txt (e..g. SparkORDERSExtStrategies_Feedback-151210.txt )
[Protocol] Name=External Strategies Feedback File Version=1.00 Description=External Strategies Feedback File [Strategies] 20151509-009=[Feedback]~Status=Active~Status At=15-12-10 09:49:52.775~~
This file will be updated when Spark receives or rejects your new Strategy. If the new strategy is accepted, the feedback line will be like
20151509-009=[Feedback]~Status=Active~Status At=15-12-10 09:49:52.775~~
If the addition is rejected, an audio warning will be played and the feedback line will be like:
20151509-010=[Feedback]~Status=ERROR~Error=Cannot find Subscribed Ticker Product "HSIH6"~Status At=15-12-10 09:54:28.860~~
In the above example, the product code is HSIH6 which is not on the Spark Subscription List, so it cannot find it and rejected the new strategy.
Modify Strategy
If you want to modify the Barrier price level, add a line under [Modify Strategies] e.g.
001=ID=20151509-009~Barrier=21830
The blue part is a unique number that you give to each modification. Even it you are modifying the same strategy for the second time, you need to give a new unique number.
The modification will be shown in the feedback file, under [Strategies]
[Strategies]
20151509-009=[Feedback]~Status=Triggered Open~Status At=15-12-10 09:57:51.604~Modify History=001~~[Feedback-Open]~Order ID=2C5-095751.12709
Once an Open Order is triggered, you cannot modify the strategy fields except Take Profit Adj and Stop Loss Adj and Close Toler.
However, you can modify the open order via Spark User interface or External Order Control by specifying the Order ID given to you in the feedback.
Delete Strategy
To delete a strategy, add a line under [Delete Strategies] , put = after the Strategy ID. e.g.
[Delete Strategies] 20151509-009=
Check the feedback line of [Delete Strategies] for the deletion status
[Delete Strategies] 20151509-013=[Feedback]~Status=DELETED~Status At=15-12-10 15:28:39.841~~
Click here for External Order Control Details
Click here for Other Functions of Spark
You can see our demo videos on this youtube channel https://www.youtube.com/channel/UCjRm7a2sez6kUwmiAj58KFg
Email us at inq@dde-rtd.com or whatsapp 3502 1457 or LINE (Line ID: spark-spapi) to get a FREE TRIAL
Line ID : spark-spapi