主動回報
訂閱委託回報
- Python
- Node.js
- C#
# A callback to receive order data
def on_order(code, content):
print("==Order==")
print(code)
print(content)
# print(content.seq_no) # 印出委託單流水號
print("========")
sdk.set_on_order(on_order)
info
詳細回傳內容,可參照OrderResult Object
//Callback to receive order data
sdk.setOnOrder(function(code, content)
{ console.log("====order===\n",code, content)});
info
詳細回傳內容,可參照OrderResult Object
public void OnOrder(string code, OrderResult data)
{
if(data != null)
{
response = data.ToString();
Console.WriteLine("On Order" + response);
}
}
或使用下方方法
sdk.OnOrder += (code, ordeResult) =>
{
Console.WriteLine(code + ordeResult.ToString());
}
info
詳細回傳內容,可參照OrderResult Object
訂閱改價/改量/刪單回報
- Python
- Node.js
- C#
def on_order_changed(code, content):
print("=Modified==")
print(code)
print(content)
# print(content.seq_no) # 印出委託單流水號
print("========")
sdk.set_on_order_changed(on_order_changed)
info
詳細回傳內容,可參照OrderResult Object
//Callback to receive Modified data
sdk.setOnOrderChanged(function(code, content)
{ console.log("===Modified===\n", code, content)});
info
詳細回傳內容,可參照OrderResult Object
public void OnOrderChanged(string code, OrderResult data)
{
if(data != null)
{
response = data.ToString();
Console.WriteLine(code);
Console.WriteLine("Modified" + response);
}
}
或使用下方方法
sdk.OnOrderChanged += (code, ordeResult) =>
{
Console.WriteLine(code + ordeResult.ToString());
}
info
詳細回傳內容,可參照OrderResult Object
訂閱成交回報
- Python
- Node.js
- C#
def on_filled(code, content):
print("==Filled==")
print(code)
print(content)
# print(content.filled_no) # 印出成交流水號
print("========")
sdk.set_on_filled(on_filled)
info
詳細回傳內容,可參照FilledData Object
sdk.setOnFilled(function(code, content)
{ console.log("===Filled===\n",code, content)})
info
詳細回傳內容,可參照FilledData Object
public void OnFilled(string code, FilledData data)
{
if(data != null)
{
response = data.ToString();
Console.WriteLine(code);
Console.WriteLine("Filled" + response);
}
}
或使用下方方法
sdk.OnFilled += (code, filledData) =>
{
Console.WriteLine(code + filledData.ToString());
}
info
詳細回傳內容,可參照FilledData Object
訂閱事件通知
- Python
- Node.js
- C#
def on_event(code, content):
print("===event=====")
print(code)
print(content)
print("========")
sdk.set_on_event(on_event)
sdk.setOnEvent(function(code, content)
{ console.log("===Event===\n",code, content)})
public void OnEvent(String code, String data)
{
response = data.ToString();
Console.WriteLine(code);
Console.WriteLine("Event" + response);
}
或使用下方方法
sdk.OnEvent += (code, msg) =>
{
Console.WriteLine(code + msg );
};
事件包含以下情況回傳
回傳代碼 | 意義 |
---|---|
100 | 連線建立成功 |
200 | 登入成功 |
201 | 登 入警示 , Ex : 90天未更換密碼 |
300 | 斷線 |
301 | 未收到連線pong回傳 |
302 | 登出 , 並斷線 |
500 | 錯誤 |
訂閱範例
使用者可訂閱不同的callback,來接收系統主動發送的委託及成交通知。
- Python
- Node.js
- C#
# A callback to receive order data
def on_order(code, content):
print("==Order==")
print(code)
print(content)
print("========")
sdk.set_on_order(on_order)
# A callback to receive Modified data
def on_order_changed(code, content):
print("=Modified==")
print(code)
print(content)
print("========")
sdk.set_on_order_changed(on_order_changed)
def on_filled(code, content):
print("==Filled==")
print(code)
print(content)
print("========")
sdk.set_on_filled(on_filled)
# A callback to receive Event data
def on_event(code, content):
print("===event=====")
print(code)
print(content)
print("========")
sdk.set_on_event(on_event)
info
詳細回傳內容,可參照SDK Reference 參數對照表
//Callback to receive order data
sdk.setOnOrder(function(code, content)
{ console.log("====order===\n",code, content)});
//Callback to receive Modified data
sdk.setOnOrderChanged(function(code, content)
{ console.log("===Modified===\n", code, content)});
//Callback to receive Filled data
sdk.setOnFilled(function(code, content)
{ console.log("===Filled===\n",code, content)})
//Callback to receive Event data
sdk.setOnEvent(function(code, content)
{ console.log("===Event===\n",code, content)})
info
詳細回傳內容,可參照SDK Reference 參數對照表
public class MyCallback : Callback
{
public string code ="";
public string response = "";
//Callback to receive order data
public void OnOrder(string code, OrderResult data)
{
if(data != null)
{
response = data.ToString();
Console.WriteLine("On Order" + response);
}
}
//Callback to receive Modified data
public void OnOrderChanged(string code, OrderResult data)
{
if(data != null)
{
response = data.ToString();
Console.WriteLine(code);
Console.WriteLine("Modified" + response);
}
}
//Callback to receive Filled data
public void OnFilled(string code, FilledData data)
{
if(data != null)
{
response = data.ToString();
Console.WriteLine(code);
Console.WriteLine("Filled" + response);
}
}
//Callback to receive Event data
public void OnEvent(String code, String data)
{
response = data.ToString();
Console.WriteLine(code);
Console.WriteLine("Event" + response);
}
}
var callback = new MyCallback();
sdk.RegisterCallback(callback);
或使用下方方法分別訂閱
sdk.OnEvent += (code, msg) =>
{
Console.WriteLine(code + msg );
};
sdk.OnOrder += (code, ordeResult) =>
{
Console.WriteLine(code + ordeResult.ToString());
}
sdk.OnOrderChanged += (code, ordeResult) =>
{
Console.WriteLine(code + ordeResult.ToString());
}
sdk.OnFilled += (code, filledData) =>
{
Console.WriteLine(code + filledData.ToString());
}
info
詳細回傳內容,可參照SDK Reference 參數對照表