| | |
| | | #include "../common/StringUtil.h" |
| | | #include "../common/NetworkApi.h" |
| | | #include "../common/JsonUtil.h" |
| | | #include "../common/TimeUtil.h" |
| | | #include "ConfigUtil.h" |
| | | #include <iostream> |
| | | #include <string> |
| | |
| | | #include <regex> |
| | | #include <iconv.h> |
| | | #include <thread> |
| | | #include "CCBBuyDlg.h" |
| | | |
| | | #include "win32_screen_shots.h" |
| | | #include "ThsCodeOCR.h" |
| | | |
| | | using namespace std; |
| | | |
| | | // CSettingDlg 对话框 |
| | |
| | | ON_BN_CLICKED(btn_sure_network, &CSettingDlg::OnBnClickedsurenetwork) |
| | | ON_BN_CLICKED(btn_radical_buy_block_count_sure, &CSettingDlg::OnBnClickedradicalbuyblockcountsure) |
| | | ON_BN_CLICKED(btn_sure_trade_params_setting, &CSettingDlg::OnBnClickedsuretradeparamssetting) |
| | | ON_BN_CLICKED(btn_sure_ocr, &CSettingDlg::OnBnClickedsureocr) |
| | | ON_BN_CLICKED(btn_sure_ocr_test, &CSettingDlg::OnBnClickedsureocrtest) |
| | | ON_BN_CLICKED(IDC_BUTTON_BUY_CB, &CSettingDlg::OnBnClickedButtonBuyCb) |
| | | ON_BN_CLICKED(IDC_BUTTON1, &CSettingDlg::OnBnClickedButton1) |
| | | END_MESSAGE_MAP() |
| | | |
| | | |
| | |
| | | |
| | | ConfigUtil::setVolumesSetting(volumeList); |
| | | ConfigUtil::setThsAutoRefreshTimeSpace(stoi(StringUtil::cstring2String(refreshSpace))); |
| | | |
| | | // 获取买入/卖出默认金额 |
| | | CString buyMoney, sellMoney; |
| | | |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_DEFAULT_BUY_MONEY))->GetWindowTextW(buyMoney); |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_DEFAULT_SELL_MONEY))->GetWindowTextW(sellMoney); |
| | | if (buyMoney.IsEmpty() || sellMoney.IsEmpty()) { |
| | | AfxMessageBox(L"请设置默认买入/卖出金额"); |
| | | return; |
| | | } |
| | | ConfigUtil::setBuyMoney(stoi(StringUtil::cstring2String( buyMoney).c_str())); |
| | | ConfigUtil::setSellMoney(stoi(StringUtil::cstring2String(sellMoney).c_str())); |
| | | AfxMessageBox(L"保存成功", MB_ICONINFORMATION); |
| | | } |
| | | |
| | |
| | | auto normal = data["normal"].GetArray();; |
| | | auto radical = data["radical"].GetArray(); |
| | | auto moneys_enum = data["moneys"].GetArray(); |
| | | auto default_buy_money = data["default_buy_money"].GetInt(); |
| | | |
| | | |
| | | settings.normalCount = normal[0].GetInt(); |
| | | settings.radicalCount = radical[0].GetInt(); |
| | | settings.defaultBuyMoney = default_buy_money; |
| | | auto money_list = normal[1].GetArray(); |
| | | for (int i = 0; i < money_list.Size(); i++) { |
| | | auto item = money_list[i].GetArray(); |
| | | settings.normalMoneyList.push_back(TimeMoney({ CString(item[0].GetString()),item[1].GetInt(), item[2].GetInt() })); |
| | | settings.normalMoneyList.push_back(TimeMoney({ CString(item[0].GetString()),item[1].GetInt(), item[2].GetInt(), item[3].GetInt() })); |
| | | } |
| | | |
| | | money_list = radical[1].GetArray(); |
| | | for (int i = 0; i < money_list.Size(); i++) { |
| | | auto item = money_list[i].GetArray(); |
| | | settings.radicalMoneyList.push_back(TimeMoney({ CString(item[0].GetString()),item[1].GetInt(), item[2].GetInt() })); |
| | | settings.radicalMoneyList.push_back(TimeMoney({ CString(item[0].GetString()),item[1].GetInt(), item[2].GetInt(), item[3].GetInt() })); |
| | | } |
| | | |
| | | |
| | | int moneys[] = { combo_normal_buy_money_1 ,combo_normal_buy_money_2 ,combo_normal_buy_money_3,combo_radical_buy_money_1 ,combo_radical_buy_money_2 ,combo_radical_buy_money_3 }; |
| | | for (int i = 0; i < 6; i++) { |
| | | int moneys[] = { combo_normal_buy_money_1 ,combo_normal_buy_money_2 ,combo_normal_buy_money_3,combo_radical_buy_money_1 ,combo_radical_buy_money_2 ,combo_radical_buy_money_3, combo_default_buy_money }; |
| | | for (int i = 0; i < 7; i++) { |
| | | CComboBox* box = (CComboBox*)GetDlgItem(moneys[i]); |
| | | for (int i = 0; i < moneys_enum.Size(); i++) { |
| | | box->AddString(to_wstring(moneys_enum[i].GetInt()).c_str()); |
| | |
| | | |
| | | } |
| | | |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_DEFAULT_BUY_MONEY))->SetWindowTextW(to_wstring(ConfigUtil::getBuyMoney()).c_str()); |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_DEFAULT_SELL_MONEY))->SetWindowTextW(to_wstring(ConfigUtil::getSellMoney()).c_str()); |
| | | |
| | | try { |
| | | |
| | | requestRadicalBuyBlockCount(); |
| | |
| | | comboTradeMode.Clear(); |
| | | comboTradeMode.AddString(L"买所有"); |
| | | comboTradeMode.AddString(L"只买想买"); |
| | | comboTradeMode.AddString(L"只买辨识度"); |
| | | |
| | | std::thread t1(requestTradeMode, this); |
| | | std::thread t1(requestTradeParamsSettings, this); |
| | | t1.detach(); |
| | | |
| | | // 设置截图参数 |
| | | int ids[] = { IDC_EDIT_OCR_WINDOW_PARAMS_TOP, IDC_EDIT_OCR_WINDOW_PARAMS_WIDTH, IDC_EDIT_OCR_WINDOW_PARAMS_HEIGHT, IDC_EDIT_OCR_WINDOW_PARAMS_SCALE }; |
| | | // 设置默认参数 |
| | | ((CEdit*)GetDlgItem(ids[0]))->SetWindowTextW(L"10"); |
| | | ((CEdit*)GetDlgItem(ids[1]))->SetWindowTextW(L"300"); |
| | | ((CEdit*)GetDlgItem(ids[2]))->SetWindowTextW(L"50"); |
| | | ((CEdit*)GetDlgItem(ids[3]))->SetWindowTextW(L"1"); |
| | | |
| | | try { |
| | | OCRWindowParams params = ConfigUtil::getOCRWindowParams(); |
| | | ((CEdit*)GetDlgItem(ids[0]))->SetWindowTextW(to_wstring(params.top).c_str()); |
| | | ((CEdit*)GetDlgItem(ids[1]))->SetWindowTextW(to_wstring(params.width).c_str()); |
| | | ((CEdit*)GetDlgItem(ids[2]))->SetWindowTextW(to_wstring(params.height).c_str()); |
| | | ((CEdit*)GetDlgItem(ids[3]))->SetWindowTextW(CString( StringUtil::to_string(params.scale).c_str())); |
| | | } |
| | | catch (...) { |
| | | |
| | | |
| | | } |
| | | |
| | | return TRUE; // return TRUE unless you set the focus to a control |
| | | // 异常: OCX 属性页应返回 FALSE |
| | |
| | | writer.String(StringUtil::cstring2String(timeMoney.time).c_str()); |
| | | writer.Int(timeMoney.money); |
| | | writer.Int(timeMoney.count); |
| | | writer.Int(timeMoney.defaultCount); |
| | | writer.EndArray(); |
| | | } |
| | | |
| | |
| | | writer1.String(StringUtil::cstring2String(timeMoney.time).c_str()); |
| | | writer1.Int(timeMoney.money); |
| | | writer1.Int(timeMoney.count); |
| | | writer1.Int(timeMoney.defaultCount); |
| | | writer1.EndArray(); |
| | | } |
| | | |
| | | writer1.EndArray(); |
| | | const char* radicalMoneyJson = buf1.GetString(); |
| | | NetworkApi::set_buy_money_and_count(settings.normalCount, string(normalMoneyJson), settings.radicalCount, string(radicalMoneyJson)); |
| | | NetworkApi::set_buy_money_and_count(settings.normalCount, string(normalMoneyJson), settings.radicalCount, string(radicalMoneyJson), settings.defaultBuyMoney); |
| | | MessageBox(L"设置成功", L"提示"); |
| | | } |
| | | catch (CString st) { |
| | |
| | | int normal_times[] = { edit_normal_buy_money_time_1 ,edit_normal_buy_money_time_2 ,edit_normal_buy_money_time_3 }; |
| | | int normal_moneys[] = { combo_normal_buy_money_1 ,combo_normal_buy_money_2 ,combo_normal_buy_money_3 }; |
| | | int normal_counts[] = { edit_normal_buy_count_1 ,edit_normal_buy_count_2 ,edit_normal_buy_count_3 }; |
| | | int default_normal_counts[] = { edit_normal_buy_default_count_1 ,edit_normal_buy_default_count_2 ,edit_normal_buy_default_count_3 }; |
| | | |
| | | int radical_times[] = { edit_radical_buy_money_time_1 ,edit_radical_buy_money_time_2 ,edit_radical_buy_money_time_3 }; |
| | | int radical_moneys[] = { combo_radical_buy_money_1 ,combo_radical_buy_money_2 ,combo_radical_buy_money_3 }; |
| | | int radical_counts[] = { edit_radical_buy_count_1 ,edit_radical_buy_count_2 ,edit_radical_buy_count_3 }; |
| | | int default_radical_counts[] = { edit_radical_buy_default_count_1 ,edit_radical_buy_default_count_2 ,edit_radical_buy_default_count_3 }; |
| | | |
| | | |
| | | CString normalCount; |
| | |
| | | CString time; |
| | | CString money; |
| | | CString count; |
| | | CString defaultCount; |
| | | ((CEdit*)GetDlgItem(normal_times[i]))->GetWindowTextW(time); |
| | | |
| | | CComboBox* moneyCombo = ((CComboBox*)GetDlgItem(normal_moneys[i])); |
| | |
| | | } |
| | | ((CEdit*)GetDlgItem(normal_counts[i]))->GetWindowTextW(count); |
| | | |
| | | ((CEdit*)GetDlgItem(default_normal_counts[i]))->GetWindowTextW(defaultCount); |
| | | |
| | | if (!time.IsEmpty() && !money.IsEmpty() && !count.IsEmpty()) { |
| | | if (!validTime(time)) { |
| | |
| | | if (!StringUtil::isNumber(StringUtil::cstring2String(count))) { |
| | | throw CString(L"最大买入数量格式错误(必须为正整数)"); |
| | | } |
| | | settings.normalMoneyList.push_back(TimeMoney({ time,stoi(StringUtil::cstring2String(money).c_str()),stoi(StringUtil::cstring2String(count).c_str()) })); |
| | | if (!StringUtil::isNumber(StringUtil::cstring2String(defaultCount))) { |
| | | throw CString(L"默认金额买入数量格式错误(必须为正整数)"); |
| | | } |
| | | settings.normalMoneyList.push_back(TimeMoney({ time,stoi(StringUtil::cstring2String(money).c_str()),stoi(StringUtil::cstring2String(count).c_str()),stoi(StringUtil::cstring2String(defaultCount).c_str()) })); |
| | | } |
| | | } |
| | | |
| | |
| | | CString time; |
| | | CString money; |
| | | CString count; |
| | | CString defaultCount; |
| | | ((CEdit*)GetDlgItem(radical_times[i]))->GetWindowTextW(time); |
| | | CComboBox* moneyCombo = ((CComboBox*)GetDlgItem(radical_moneys[i])); |
| | | if (moneyCombo->GetCurSel() >= 0) { |
| | |
| | | } |
| | | |
| | | ((CEdit*)GetDlgItem(radical_counts[i]))->GetWindowTextW(count); |
| | | |
| | | ((CEdit*)GetDlgItem(default_radical_counts[i]))->GetWindowTextW(defaultCount); |
| | | |
| | | |
| | | if (!time.IsEmpty() && !money.IsEmpty() && !count.IsEmpty()) { |
| | |
| | | if (!StringUtil::isNumber(StringUtil::cstring2String(count))) { |
| | | throw CString(L"最大买入数量格式错误(必须为正整数)"); |
| | | } |
| | | settings.radicalMoneyList.push_back(TimeMoney({ time,stoi(StringUtil::cstring2String(money).c_str()),stoi(StringUtil::cstring2String(count).c_str()) })); |
| | | |
| | | if (!StringUtil::isNumber(StringUtil::cstring2String(defaultCount))) { |
| | | throw CString(L"默认金额买入数量格式错误(必须为正整数)"); |
| | | } |
| | | |
| | | settings.radicalMoneyList.push_back(TimeMoney({ time,stoi(StringUtil::cstring2String(money).c_str()),stoi(StringUtil::cstring2String(count).c_str()),stoi(StringUtil::cstring2String(defaultCount).c_str()) })); |
| | | } |
| | | } |
| | | CString default_buy_money; |
| | | CComboBox* moneyCombo = ((CComboBox*)GetDlgItem(combo_default_buy_money)); |
| | | if (moneyCombo->GetCurSel() >= 0) { |
| | | moneyCombo->GetLBText(moneyCombo->GetCurSel(), default_buy_money); |
| | | } |
| | | |
| | | settings.defaultBuyMoney = stoi(StringUtil::cstring2String(default_buy_money).c_str()); |
| | | |
| | | return settings; |
| | | } |
| | | |
| | |
| | | int normal_times[] = { edit_normal_buy_money_time_1 ,edit_normal_buy_money_time_2 ,edit_normal_buy_money_time_3 }; |
| | | int normal_moneys[] = { combo_normal_buy_money_1 ,combo_normal_buy_money_2 ,combo_normal_buy_money_3 }; |
| | | int normal_counts[] = { edit_normal_buy_count_1 ,edit_normal_buy_count_2 ,edit_normal_buy_count_3 }; |
| | | int default_normal_counts[] = { edit_normal_buy_default_count_1 ,edit_normal_buy_default_count_2 ,edit_normal_buy_default_count_3 }; |
| | | |
| | | int radical_times[] = { edit_radical_buy_money_time_1 ,edit_radical_buy_money_time_2 ,edit_radical_buy_money_time_3 }; |
| | | int radical_moneys[] = { combo_radical_buy_money_1 ,combo_radical_buy_money_2 ,combo_radical_buy_money_3 }; |
| | | int radical_counts[] = { edit_radical_buy_count_1 ,edit_radical_buy_count_2 ,edit_radical_buy_count_3 }; |
| | | int default_radical_counts[] = { edit_radical_buy_default_count_1 ,edit_radical_buy_default_count_2 ,edit_radical_buy_default_count_3 }; |
| | | |
| | | editNormalBuyCount.SetWindowTextW(to_wstring(setting.normalCount).c_str()); |
| | | editRadicalBuyCount.SetWindowTextW(to_wstring(setting.radicalCount).c_str()); |
| | | int index = 0; |
| | |
| | | } |
| | | } |
| | | ((CEdit*)GetDlgItem(normal_counts[index]))->SetWindowTextW(to_wstring(timeMoney.count).c_str()); |
| | | |
| | | ((CEdit*)GetDlgItem(default_normal_counts[index]))->SetWindowTextW(to_wstring(timeMoney.defaultCount).c_str()); |
| | | |
| | | index++; |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | ((CEdit*)GetDlgItem(radical_counts[index]))->SetWindowTextW(to_wstring(timeMoney.count).c_str()); |
| | | |
| | | ((CEdit*)GetDlgItem(default_radical_counts[index]))->SetWindowTextW(to_wstring(timeMoney.defaultCount).c_str()); |
| | | |
| | | index++; |
| | | } |
| | | |
| | | // 设置默认买入金额 |
| | | CComboBox* box = (CComboBox*)GetDlgItem(combo_default_buy_money); |
| | | int nCount = box->GetCount(); |
| | | for (int i = 0; i < nCount; i++) |
| | | { |
| | | CString strItem; |
| | | box->GetLBText(i, strItem); |
| | | if (stoi(StringUtil::cstring2String(strItem).c_str()) == setting.defaultBuyMoney) { |
| | | box->SetCurSel(i); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | void CSettingDlg::requestTradeMode(CSettingDlg* context) |
| | | void CSettingDlg::requestTradeParamsSettings(CSettingDlg* context) |
| | | { |
| | | try { |
| | | int mode = NetworkApi::get_buy_mode(); |
| | |
| | | } |
| | | catch (...) { |
| | | |
| | | } |
| | | |
| | | try { |
| | | string result = NetworkApi::get_place_order_settings(); |
| | | auto root = JsonUtil::parseUTF8(result); |
| | | if (root.IsObject()) { |
| | | if (root["code"].GetInt() == 0) { |
| | | auto data = root["data"].GetObject(); |
| | | auto radical_buy = data["radical_buy"].GetObject(); |
| | | auto prices = radical_buy["price"].GetArray(); |
| | | auto zyltgb = radical_buy["zyltgb"].GetArray(); |
| | | auto market_strong = radical_buy["top_block_count_by_market_strong"].GetArray(); |
| | | auto special_codes_rank = radical_buy["special_codes_max_block_in_rank"].GetInt(); |
| | | auto ignore_block_in_market_strong = radical_buy["ignore_block_in_money_market_strong"].GetInt(); |
| | | // 买首封 |
| | | auto buy_first_limit_up = radical_buy["buy_first_limit_up"].GetInt(); |
| | | |
| | | ((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_PRICE_MIN))->SetWindowTextW(to_wstring(prices[0].GetInt()).c_str()); |
| | | ((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_PRICE_MAX))->SetWindowTextW(to_wstring(prices[1].GetInt()).c_str()); |
| | | |
| | | ((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_ZYLTGB_MIN))->SetWindowTextW(to_wstring(zyltgb[0][0].GetArray()[0].GetInt()).c_str()); |
| | | ((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_ZYLTGB_MAX))->SetWindowTextW(to_wstring(zyltgb[0][0].GetArray()[1].GetInt()).c_str()); |
| | | ((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_PRICE_MIN_1))->SetWindowTextW(to_wstring(zyltgb[0][1].GetArray()[0].GetInt()).c_str()); |
| | | ((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_PRICE_MAX_1))->SetWindowTextW(to_wstring(zyltgb[0][1].GetArray()[1].GetInt()).c_str()); |
| | | |
| | | |
| | | |
| | | ((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_ZYLTGB_MIN2))->SetWindowTextW(to_wstring(zyltgb[1][0].GetArray()[0].GetInt()).c_str()); |
| | | ((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_ZYLTGB_MAX2))->SetWindowTextW(to_wstring(zyltgb[1][0].GetArray()[1].GetInt()).c_str()); |
| | | ((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_PRICE_MIN_2))->SetWindowTextW(to_wstring(zyltgb[1][1].GetArray()[0].GetInt()).c_str()); |
| | | ((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_PRICE_MAX_2))->SetWindowTextW(to_wstring(zyltgb[1][1].GetArray()[1].GetInt()).c_str()); |
| | | |
| | | ((CEdit*)context->GetDlgItem(IDC_EDIT_IGNORE_BLOCK_IN_MARKET_STRONG))->SetWindowTextW(to_wstring(ignore_block_in_market_strong).c_str()); |
| | | |
| | | if (market_strong.Size() > 0) { |
| | | ((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MIN_1))->SetWindowTextW(to_wstring(market_strong[0][0].GetInt()).c_str()); |
| | | ((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MAX_1))->SetWindowTextW(to_wstring(market_strong[0][1].GetInt()).c_str()); |
| | | ((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_BLOCK_IN_RANK_1))->SetWindowTextW(to_wstring(market_strong[0][2].GetInt()).c_str()); |
| | | } |
| | | if (market_strong.Size() > 1) { |
| | | ((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MIN_2))->SetWindowTextW(to_wstring(market_strong[1][0].GetInt()).c_str()); |
| | | ((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MAX_2))->SetWindowTextW(to_wstring(market_strong[1][1].GetInt()).c_str()); |
| | | ((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_BLOCK_IN_RANK_2))->SetWindowTextW(to_wstring(market_strong[1][2].GetInt()).c_str()); |
| | | } |
| | | |
| | | if (market_strong.Size() > 2) { |
| | | ((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MIN_3))->SetWindowTextW(to_wstring(market_strong[2][0].GetInt()).c_str()); |
| | | ((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MAX_3))->SetWindowTextW(to_wstring(market_strong[2][1].GetInt()).c_str()); |
| | | ((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_BLOCK_IN_RANK_3))->SetWindowTextW(to_wstring(market_strong[2][2].GetInt()).c_str()); |
| | | } |
| | | |
| | | if (market_strong.Size() > 3) { |
| | | ((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MIN_4))->SetWindowTextW(to_wstring(market_strong[3][0].GetInt()).c_str()); |
| | | ((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MAX_4))->SetWindowTextW(to_wstring(market_strong[3][1].GetInt()).c_str()); |
| | | ((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_BLOCK_IN_RANK_4))->SetWindowTextW(to_wstring(market_strong[3][2].GetInt()).c_str()); |
| | | } |
| | | if (market_strong.Size() > 4) { |
| | | ((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MIN_5))->SetWindowTextW(to_wstring(market_strong[4][0].GetInt()).c_str()); |
| | | ((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MAX_5))->SetWindowTextW(to_wstring(market_strong[4][1].GetInt()).c_str()); |
| | | ((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_BLOCK_IN_RANK_5))->SetWindowTextW(to_wstring(market_strong[4][2].GetInt()).c_str()); |
| | | } |
| | | |
| | | ((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_SPECIAL_BLOCK_IN_RANK))->SetWindowTextW(to_wstring(special_codes_rank).c_str()); |
| | | |
| | | if (buy_first_limit_up > 0) { |
| | | ((CButton*)context->GetDlgItem(IDC_CHECK_BUY_FIRST_LIMIT_UP))->SetCheck(true); |
| | | } |
| | | else { |
| | | ((CButton*)context->GetDlgItem(IDC_CHECK_BUY_FIRST_LIMIT_UP))->SetCheck(false); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | catch (...) { |
| | | } |
| | | |
| | | try { |
| | | string result = NetworkApi::get_buy_open_limit_up_codes(); |
| | | auto root = JsonUtil::parseUTF8(result); |
| | | if (root.IsObject()) { |
| | | if (root["code"].GetInt() == 0) { |
| | | auto data = root["data"].GetArray(); |
| | | CString codes; |
| | | for (int i = 0; i < data.Size(); i++) { |
| | | string code = data[i].GetString(); |
| | | codes.Append(CString(code.c_str())); |
| | | if (i < data.Size() - 1) { |
| | | codes.Append(L","); |
| | | } |
| | | } |
| | | ((CEdit*)context->GetDlgItem(IDC_EDIT_BUY_OPEN_LIMIT_UP_CODES))->SetWindowTextW(codes); |
| | | } |
| | | |
| | | } |
| | | } |
| | | catch (...) { |
| | | } |
| | | |
| | | |
| | |
| | | int mode = comboTradeMode.GetCurSel(); |
| | | try { |
| | | NetworkApi::set_buy_mode(mode); |
| | | MessageBox(L"设置成功",L"提示"); |
| | | // 价格与只有流通市值 |
| | | CString minPrice, maxPrice, minZyltgb, maxZyltgb, minZyltgbPrice, maxZyltgbPrice, minZyltgb2, maxZyltgb2, minZyltgbPrice2, maxZyltgbPrice2; |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_PRICE_MIN))->GetWindowText(minPrice); |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_PRICE_MAX))->GetWindowText(maxPrice); |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_ZYLTGB_MIN))->GetWindowText(minZyltgb); |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_ZYLTGB_MAX))->GetWindowText(maxZyltgb); |
| | | |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_PRICE_MIN_1))->GetWindowText(minZyltgbPrice); |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_PRICE_MAX_1))->GetWindowText(maxZyltgbPrice); |
| | | |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_ZYLTGB_MIN2))->GetWindowText(minZyltgb2); |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_ZYLTGB_MAX2))->GetWindowText(maxZyltgb2); |
| | | |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_PRICE_MIN_2))->GetWindowText(minZyltgbPrice2); |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_PRICE_MAX_2))->GetWindowText(maxZyltgbPrice2); |
| | | |
| | | if (!StringUtil::isNumber(StringUtil::cstring2String(minPrice)) || !StringUtil::isNumber(StringUtil::cstring2String(maxPrice))) { |
| | | throw wstring(L"价格必须为整数"); |
| | | } |
| | | |
| | | if (!StringUtil::isNumber(StringUtil::cstring2String(minZyltgb)) || !StringUtil::isNumber(StringUtil::cstring2String(maxZyltgb))) { |
| | | throw wstring(L"自由流通市值必须为整数"); |
| | | } |
| | | |
| | | // 市场强度与辨识度 |
| | | CString strong_min_1, strong_max_1, strong_block_in_max_1, |
| | | strong_min_2, strong_max_2, strong_block_in_max_2, |
| | | strong_min_3, strong_max_3, strong_block_in_max_3, |
| | | strong_min_4, strong_max_4, strong_block_in_max_4, |
| | | strong_min_5, strong_max_5, strong_block_in_max_5; |
| | | CString special_codes_rank, ignore_block_in_market_strong; |
| | | |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MIN_1))->GetWindowText(strong_min_1); |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MAX_1))->GetWindowText(strong_max_1); |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_BLOCK_IN_RANK_1))->GetWindowText(strong_block_in_max_1); |
| | | |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MIN_2))->GetWindowText(strong_min_2); |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MAX_2))->GetWindowText(strong_max_2); |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_BLOCK_IN_RANK_2))->GetWindowText(strong_block_in_max_2); |
| | | |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MIN_3))->GetWindowText(strong_min_3); |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MAX_3))->GetWindowText(strong_max_3); |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_BLOCK_IN_RANK_3))->GetWindowText(strong_block_in_max_3); |
| | | |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MIN_4))->GetWindowText(strong_min_4); |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MAX_4))->GetWindowText(strong_max_4); |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_BLOCK_IN_RANK_4))->GetWindowText(strong_block_in_max_4); |
| | | |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MIN_5))->GetWindowText(strong_min_5); |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MAX_5))->GetWindowText(strong_max_5); |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_BLOCK_IN_RANK_5))->GetWindowText(strong_block_in_max_5); |
| | | |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_SPECIAL_BLOCK_IN_RANK))->GetWindowText(special_codes_rank); |
| | | |
| | | ((CEdit*)GetDlgItem(IDC_EDIT_IGNORE_BLOCK_IN_MARKET_STRONG))->GetWindowText(ignore_block_in_market_strong); |
| | | |
| | | bool can_buy_first_limit_up = ((CButton*)GetDlgItem(IDC_CHECK_BUY_FIRST_LIMIT_UP))->GetCheck(); |
| | | |
| | | |
| | | |
| | | rapidjson::StringBuffer buf; |
| | | rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(buf); |
| | | writer.StartObject(); |
| | | writer.Key("price"); |
| | | writer.StartArray(); |
| | | writer.Int(stoi(StringUtil::cstring2String(minPrice))); |
| | | writer.Int(stoi(StringUtil::cstring2String(maxPrice))); |
| | | writer.EndArray(); |
| | | |
| | | writer.Key("zyltgb"); |
| | | writer.StartArray(); |
| | | |
| | | writer.StartArray(); |
| | | writer.StartArray(); |
| | | writer.Int(stoi(StringUtil::cstring2String(minZyltgb))); |
| | | writer.Int(stoi(StringUtil::cstring2String(maxZyltgb))); |
| | | writer.EndArray(); |
| | | writer.StartArray(); |
| | | writer.Int(stoi(StringUtil::cstring2String(minZyltgbPrice))); |
| | | writer.Int(stoi(StringUtil::cstring2String(maxZyltgbPrice))); |
| | | writer.EndArray(); |
| | | writer.EndArray(); |
| | | |
| | | |
| | | writer.StartArray(); |
| | | writer.StartArray(); |
| | | writer.Int(stoi(StringUtil::cstring2String(minZyltgb2))); |
| | | writer.Int(stoi(StringUtil::cstring2String(maxZyltgb2))); |
| | | writer.EndArray(); |
| | | writer.StartArray(); |
| | | writer.Int(stoi(StringUtil::cstring2String(minZyltgbPrice2))); |
| | | writer.Int(stoi(StringUtil::cstring2String(maxZyltgbPrice2))); |
| | | writer.EndArray(); |
| | | writer.EndArray(); |
| | | |
| | | |
| | | writer.EndArray(); |
| | | |
| | | |
| | | writer.Key("top_block_count_by_market_strong"); |
| | | writer.StartArray(); |
| | | |
| | | if (!strong_min_1.IsEmpty() && !strong_max_1.IsEmpty() && !strong_block_in_max_1.IsEmpty()) { |
| | | writer.StartArray(); |
| | | writer.Int(stoi(StringUtil::cstring2String(strong_min_1))); |
| | | writer.Int(stoi(StringUtil::cstring2String(strong_max_1))); |
| | | writer.Int(stoi(StringUtil::cstring2String(strong_block_in_max_1))); |
| | | writer.EndArray(); |
| | | } |
| | | |
| | | if (!strong_min_2.IsEmpty() && !strong_max_2.IsEmpty() && !strong_block_in_max_2.IsEmpty()) { |
| | | writer.StartArray(); |
| | | writer.Int(stoi(StringUtil::cstring2String(strong_min_2))); |
| | | writer.Int(stoi(StringUtil::cstring2String(strong_max_2))); |
| | | writer.Int(stoi(StringUtil::cstring2String(strong_block_in_max_2))); |
| | | writer.EndArray(); |
| | | } |
| | | |
| | | |
| | | if (!strong_min_3.IsEmpty() && !strong_max_3.IsEmpty() && !strong_block_in_max_3.IsEmpty()) { |
| | | writer.StartArray(); |
| | | writer.Int(stoi(StringUtil::cstring2String(strong_min_3))); |
| | | writer.Int(stoi(StringUtil::cstring2String(strong_max_3))); |
| | | writer.Int(stoi(StringUtil::cstring2String(strong_block_in_max_3))); |
| | | writer.EndArray(); |
| | | } |
| | | |
| | | |
| | | if (!strong_min_4.IsEmpty() && !strong_max_4.IsEmpty() && !strong_block_in_max_4.IsEmpty()) { |
| | | writer.StartArray(); |
| | | writer.Int(stoi(StringUtil::cstring2String(strong_min_4))); |
| | | writer.Int(stoi(StringUtil::cstring2String(strong_max_4))); |
| | | writer.Int(stoi(StringUtil::cstring2String(strong_block_in_max_4))); |
| | | writer.EndArray(); |
| | | } |
| | | |
| | | |
| | | if (!strong_min_5.IsEmpty() && !strong_max_5.IsEmpty() && !strong_block_in_max_5.IsEmpty()) { |
| | | writer.StartArray(); |
| | | writer.Int(stoi(StringUtil::cstring2String(strong_min_5))); |
| | | writer.Int(stoi(StringUtil::cstring2String(strong_max_5))); |
| | | writer.Int(stoi(StringUtil::cstring2String(strong_block_in_max_5))); |
| | | writer.EndArray(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | writer.EndArray(); |
| | | |
| | | writer.Key("special_codes_max_block_in_rank"); |
| | | writer.Int(stoi(StringUtil::cstring2String(special_codes_rank))); |
| | | |
| | | |
| | | writer.Key("ignore_block_in_money_market_strong"); |
| | | writer.Int(stoi(StringUtil::cstring2String(ignore_block_in_market_strong))); |
| | | |
| | | writer.Key("buy_first_limit_up"); |
| | | writer.Int(can_buy_first_limit_up?1:0); |
| | | |
| | | |
| | | writer.EndObject(); |
| | | |
| | | const char* radicalJson = buf.GetString(); |
| | | auto result = NetworkApi::set_place_order_settings(radicalJson); |
| | | auto doc = JsonUtil::parseUTF16(result); |
| | | if (!doc.IsObject()) { |
| | | throw wstring(L"网络请求错误"); |
| | | } |
| | | if (doc[L"code"].GetInt() != 0) { |
| | | throw wstring(doc[L"msg"].GetString()); |
| | | } |
| | | |
| | | |
| | | } |
| | | catch (wstring msg) { |
| | | AfxMessageBox(msg.c_str()); |
| | | } |
| | | |
| | | try { |
| | | CString st; |
| | | ((CEdit *)GetDlgItem(IDC_EDIT_BUY_OPEN_LIMIT_UP_CODES))->GetWindowText(st); |
| | | string codes = StringUtil::cstring2String(st); |
| | | std::stringstream ss(codes); |
| | | std::string token; |
| | | list<string> tokens; |
| | | |
| | | // 使用 std::stringstream 分隔字符串 |
| | | while (std::getline(ss, token, ',')) { |
| | | tokens.push_back(token); |
| | | } |
| | | string result = NetworkApi::set_buy_open_limit_up_codes(tokens); |
| | | auto doc = JsonUtil::parseUTF16(result); |
| | | if (!doc.IsObject()) { |
| | | throw wstring(L"网络请求错误"); |
| | | } |
| | | if (doc[L"code"].GetInt() != 0) { |
| | | throw wstring(doc[L"msg"].GetString()); |
| | | } |
| | | |
| | | MessageBox(L"设置成功", L"提示"); |
| | | |
| | | } |
| | | catch (wstring msg) { |
| | | AfxMessageBox(msg.c_str()); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | void CSettingDlg::OnBnClickedsureocr() |
| | | { |
| | | int ids[] = { IDC_EDIT_OCR_WINDOW_PARAMS_TOP, IDC_EDIT_OCR_WINDOW_PARAMS_WIDTH, IDC_EDIT_OCR_WINDOW_PARAMS_HEIGHT, IDC_EDIT_OCR_WINDOW_PARAMS_SCALE }; |
| | | |
| | | CString top, width, height, scale; |
| | | ((CEdit*)GetDlgItem(ids[0]))->GetWindowTextW(top); |
| | | ((CEdit*)GetDlgItem(ids[1]))->GetWindowTextW(width); |
| | | ((CEdit*)GetDlgItem(ids[2]))->GetWindowTextW(height); |
| | | ((CEdit*)GetDlgItem(ids[3]))->GetWindowTextW(scale); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | try { |
| | | if (!StringUtil::isNumber(StringUtil::cstring2String(top))) { |
| | | throw CString(L"上边距格式错误"); |
| | | } |
| | | |
| | | if (!StringUtil::isNumber(StringUtil::cstring2String(width))) { |
| | | throw CString(L"宽度格式错误"); |
| | | } |
| | | |
| | | if (!StringUtil::isNumber(StringUtil::cstring2String(height))) { |
| | | throw CString(L"高度格式错误"); |
| | | } |
| | | |
| | | if (scale.IsEmpty()) { |
| | | throw CString(L"请填写缩放比"); |
| | | } |
| | | |
| | | OCRWindowParams params; |
| | | params.top = stoi(StringUtil::cstring2String(top)); |
| | | params.width = stoi(StringUtil::cstring2String(width)); |
| | | params.height = stoi(StringUtil::cstring2String(height)); |
| | | params.scale = stof(StringUtil::cstring2String(scale)); |
| | | ConfigUtil::setOCRWindowParams(params); |
| | | MessageBox(L"保存成功", L"提示"); |
| | | } |
| | | catch (CString st) { |
| | | AfxMessageBox(st); |
| | | } |
| | | |
| | | |
| | | catch (...) { |
| | | AfxMessageBox(L"保存失败"); |
| | | } |
| | | } |
| | | |
| | | |
| | | void CSettingDlg::OnBnClickedsureocrtest() |
| | | { |
| | | |
| | | |
| | | try { |
| | | |
| | | RECT rect; |
| | | cv::Mat mat = ThsCodeOCR::capture(ConfigUtil::getOCRWindowParams()); |
| | | |
| | | cv::imwrite("D:/test_origin.jpg", mat); |
| | | |
| | | mat = ThsCodeOCR::splitForCodeImg(mat); |
| | | |
| | | cv::imwrite("D:/test.jpg", mat); |
| | | string code; |
| | | |
| | | ThsCodeOCR *ocr = new ThsCodeOCR(); |
| | | auto start_time = GetTickCount64(); |
| | | for (int i = 0; i < 10; i++) { |
| | | code = ocr->ocrCode(); |
| | | cout << code << endl; |
| | | } |
| | | |
| | | int subTime = GetTickCount64() - start_time; |
| | | CString msg; |
| | | msg.Append(CString(code.c_str())); |
| | | msg.Append(L":耗时"); |
| | | msg.Append(to_wstring(subTime).c_str()); |
| | | msg.Append(L"ms"); |
| | | delete ocr; |
| | | MessageBox(msg, L"识别结果"); |
| | | |
| | | /* cv::Mat mat = cv::imread("D:/test_origin_1.jpg", cv::IMREAD_GRAYSCALE); |
| | | mat = ThsCodeOCR::splitForCodeImg(mat); |
| | | ThsCodeOCR* ocr = new ThsCodeOCR(); |
| | | string code = ocr->ocrCode(mat); |
| | | MessageBox(CString(code.c_str()), L"识别结果");*/ |
| | | |
| | | } |
| | | catch (string st) { |
| | | AfxMessageBox(CString(st.c_str())); |
| | | } |
| | | catch (...) { |
| | | AfxMessageBox(L"发生其他错误"); |
| | | } |
| | | } |
| | | |
| | | |
| | | void CSettingDlg::OnBnClickedButtonBuyCb() |
| | | { |
| | | // 打开可转债买入 |
| | | CCBBuyDlg dlg; |
| | | INT_PTR nResponse = dlg.DoModal(); |
| | | } |
| | | |
| | | |
| | | void CSettingDlg::OnBnClickedButton1() |
| | | { |
| | | NetworkApi::test_place_order("002387"); |
| | | } |