| | |
| | | } |
| | | } |
| | | |
| | | void CFloatTradeDlg::requestSellResult(string order_ref, CFloatTradeDlg* context, int delayMs) |
| | | void CFloatTradeDlg::requestSellResult(int order_ref, CFloatTradeDlg* context, int delayMs) |
| | | { |
| | | if (delayMs > 0) { |
| | | Sleep(delayMs); |
| | |
| | | |
| | | void CFloatTradeDlg::OnClickedBtnSell() |
| | | { |
| | | bool IS_TEST = FALSE; |
| | | |
| | | if (codePosition.total <= 0) { |
| | | setMsg(L"无持仓", MSG_TYPE_FAIL); |
| | |
| | | return; |
| | | } |
| | | |
| | | |
| | | // 卖 |
| | | try { |
| | | string code = getCode(); |
| | | string result = NetworkApi::sell(code, sell_volume_int, sellPriceType, true); |
| | | //string result = string( StringUtil::cstring2String( L"{\"code\":0,\"data\":{\"orderRef\":123123}}")); |
| | | /*string result = string(StringUtil::cstring2String(L"{\"code\":0,\"data\":{\"sinfo\": \"b_600088_1701739811583\", \"securityID\": \"600088\", \"orderLocalID\": \"0190000205\", \"direction\": \"1\", \"orderSysID\": \"110010190000205\", \"insertTime\": \"09:30 : 11\", \"insertDate\": \"20231205\", \"acceptTime\": \"09 : 30 : 11\", \"cancelTime\": \"\", \"limitPrice\": 15.0, \"accountID\": \"38800001334901\", \"orderRef\": 81740, \"turnover\": 0.0, \"volume\": 200, \"volumeTraded\": 0, \"orderStatus\": \"2\", \"orderSubmitStatus\": \"1\", \"statusMsg\": \"\"}}"));*/ |
| | | CString msg(code.c_str()); |
| | | msg.Append(L":"); |
| | | auto doc = JsonUtil::parseUTF16(result); |
| | |
| | | if (doc[L"data"].HasMember(L"orderRef")) { |
| | | msg.Append(_T("提交卖成功")); |
| | | setMsg(msg, MSG_TYPE_SUCCESS); |
| | | string orderRef = std::to_string(doc[L"data"][L"orderRef"].GetInt()); |
| | | int orderRef = doc[L"data"][L"orderRef"].GetInt(); |
| | | std::thread t1(requestSellResult, orderRef, this, 2000); |
| | | t1.detach(); |
| | | } |
| | | else { |
| | | else if (doc[L"data"].HasMember(L"orderStatusMsg")) { |
| | | msg.Append(doc[L"data"][L"orderStatusMsg"].GetString()); |
| | | setMsg(msg, MSG_TYPE_FAIL); |
| | | } |
| | | } |
| | | else { |
| | | msg.Append(doc[L"msg"].GetString()); |
| | | setMsg(msg, MSG_TYPE_FAIL); |
| | | if (doc.HasMember(L"msg")) { |
| | | msg.Append(doc[L"msg"].GetString()); |
| | | setMsg(msg, MSG_TYPE_FAIL); |
| | | } |
| | | } |
| | | } |
| | | else { |
| | | msg.Append(L"解析结果出错"); |
| | | setMsg(msg, MSG_TYPE_FAIL); |
| | | } |
| | | |
| | | |
| | | } |
| | | catch (wstring st) { |
| | | CString msg(st.c_str()); |
| | |
| | | static void requestCodePosition(string code, CFloatTradeDlg* context,bool showCodeDesc, int delayMs=0); |
| | | |
| | | // 获取卖结果 |
| | | static void requestSellResult(string order_ref, CFloatTradeDlg* context, int delayMs = 0); |
| | | static void requestSellResult(int order_ref, CFloatTradeDlg* context, int delayMs = 0); |
| | | |
| | | // 展示持仓数据 |
| | | void showCodePositionInfo(); |
| | |
| | | listRules.ModifyStyle(LVS_SINGLESEL, LVS_REPORT); |
| | | listRules.SetRowHeigt(24); |
| | | |
| | | CRect rect; |
| | | listRules.GetClientRect(&rect); |
| | | |
| | | int unitSize = (rect.Width() - 5) / 7.5f; |
| | | |
| | | listRules.InsertColumn(0, _T("代码"), LVCFMT_LEFT, 50, 0); |
| | | listRules.InsertColumn(1, _T("买1量(手)"), LVCFMT_LEFT, 80, 1); |
| | | listRules.InsertColumn(2, _T("买1价"), LVCFMT_LEFT, 50, 2); |
| | | listRules.InsertColumn(3, _T("卖量(股)"), LVCFMT_LEFT,60, 3); |
| | | listRules.InsertColumn(4, _T("卖价类型"), LVCFMT_LEFT, 60, 4); |
| | | listRules.InsertColumn(5, _T("结束时间"), LVCFMT_LEFT, 60, 5); |
| | | listRules.InsertColumn(6, _T("状态"), LVCFMT_LEFT, 50, 6); |
| | | listRules.InsertColumn(0, _T("代码"), LVCFMT_LEFT, unitSize*1, 0); |
| | | listRules.InsertColumn(1, _T("买1量(手)"), LVCFMT_LEFT, unitSize * 1.1, 1); |
| | | listRules.InsertColumn(2, _T("买1价"), LVCFMT_LEFT, unitSize * 1, 2); |
| | | listRules.InsertColumn(3, _T("卖量(股)"), LVCFMT_LEFT, unitSize * 1.1, 3); |
| | | listRules.InsertColumn(4, _T("卖价类型"), LVCFMT_LEFT, unitSize * 1.2, 4); |
| | | listRules.InsertColumn(5, _T("结束时间"), LVCFMT_LEFT, unitSize * 1.3, 5); |
| | | listRules.InsertColumn(6, _T("状态"), LVCFMT_LEFT, unitSize * 0.8, 6); |
| | | // listRules.InsertColumn(7, _T("ID"), LVCFMT_LEFT, 50, 7); |
| | | // listRules.InsertColumn(8, _T("创建时间"), LVCFMT_LEFT, 50, 8); |
| | | listRules.AutoColumn(); |
| | |
| | | trade_refresh = 1; |
| | | group_refresh = 0; |
| | | trade_quick_key = 1; |
| | | window_pos = "[-598,406]"; |
| | | window_pos = "[-792,521]"; |
| | | ths_auto_click_positions = "[\n [\n 50,\n 150\n ],\n [\n 50,\n 100\n ],\n [\n 50,\n 300\n ]\n]"; |
| | | ths_auto_click_time_space = 500; |
| | | ths_auto_refresh_time_space = 200; |
| | |
| | | return result; |
| | | } |
| | | |
| | | string NetworkApi::get_sell_result(std::string order_ref) |
| | | string NetworkApi::get_sell_result(int order_ref) |
| | | { |
| | | rapidjson::StringBuffer buf; |
| | | rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(buf); |
| | |
| | | writer.Key("ctype"); |
| | | writer.String("get_sell_result"); |
| | | writer.Key("order_ref"); |
| | | writer.String(order_ref.c_str()); |
| | | writer.Int(order_ref); |
| | | writer.EndObject(); |
| | | writer.EndObject(); |
| | | const char* json_content = buf.GetString(); |
| | |
| | | static string get_code_position_info(std::string code); |
| | | |
| | | // 获取下单的反馈信息 |
| | | static string get_sell_result(std::string order_ref); |
| | | static string get_sell_result(int order_ref); |
| | | |
| | | //刷新交易数据 |
| | | static void sync_trade_data(string type); |