admin
2024-05-17 495cd025f02ad9a0261cffdd10b01b7c558cd894
功能修改
11个文件已修改
504 ■■■■■ 已修改文件
FloatTrade/CSettingDlg.cpp 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
FloatTrade/CSettingDlg.h 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
FloatTrade/FloatTrade.aps 补丁 | 查看 | 原始文档 | blame | 历史
FloatTrade/FloatTrade.rc 补丁 | 查看 | 原始文档 | blame | 历史
FloatTrade/FloatTradeDlg.cpp 315 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
FloatTrade/FloatTradeDlg.h 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
FloatTrade/SellDlg.cpp 106 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
FloatTrade/SellDlg.h 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
FloatTrade/SellManager.cpp 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
FloatTrade/config.cfg 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
FloatTrade/resource.h 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
FloatTrade/CSettingDlg.cpp
@@ -6,6 +6,7 @@
#include "CSettingDlg.h"
#include "afxdialogex.h"
#include "../common/StringUtil.h"
#include "../common/NetworkApi.h"
#include "ConfigUtil.h"
#include <iostream>
#include <string>
@@ -33,11 +34,13 @@
    DDX_Control(pDX, edit_trade_refresh_space_time, editRefreshSpaceTime);
    DDX_Control(pDX, edit_trade_group_space_time, editGroupSpaceTime);
    DDX_Control(pDX, edit_group_pos, editGroupPos);
    DDX_Control(pDX, edit_per_code_buy_money, editPerCodeBuyMoney);
}
BEGIN_MESSAGE_MAP(CSettingDlg, CDialogEx)
    ON_BN_CLICKED(btn_sure, &CSettingDlg::OnBnClickedsure)
    ON_BN_CLICKED(btn_sure_network, &CSettingDlg::OnBnClickedsurenetwork)
END_MESSAGE_MAP()
@@ -113,6 +116,34 @@
    int rt = ConfigUtil::getThsAutoRefreshTimeSpace();
    editRefreshSpaceTime.SetWindowTextW(CString(std::to_string(rt).c_str()));
    try {
        int money = NetworkApi::get_per_code_buy_money();
        editPerCodeBuyMoney.SetWindowTextW(to_wstring(money).c_str());
    }
    catch (... ) {
    }
    return TRUE;  // return TRUE unless you set the focus to a control
                  // 异常: OCX 属性页应返回 FALSE
}
void CSettingDlg::OnBnClickedsurenetwork()
{
    CString cmoney;
    editPerCodeBuyMoney.GetWindowTextW(cmoney);
    string money = StringUtil::cstring2String(cmoney);
    if (!StringUtil::isNumber(money)) {
        AfxMessageBox(L"输入内容格式错误");
        return;
    }
    try {
         NetworkApi::set_per_code_buy_money(stoi(money.c_str()));
         MessageBox(L"设置成功",L"提示");
    }
    catch (wstring st) {
        AfxMessageBox(st.c_str());
    }
}
FloatTrade/CSettingDlg.h
@@ -16,6 +16,7 @@
    enum { IDD = IDD_SETTINGS };
#endif
protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持
@@ -26,4 +27,6 @@
    CEdit editGroupSpaceTime;
    CEdit editGroupPos;
    virtual BOOL OnInitDialog();
    CEdit editPerCodeBuyMoney;
    afx_msg void OnBnClickedsurenetwork();
};
FloatTrade/FloatTrade.aps
Binary files differ
FloatTrade/FloatTrade.rc
Binary files differ
FloatTrade/FloatTradeDlg.cpp
@@ -213,36 +213,6 @@
    }
}
void CFloatTradeDlg::selectSellRateIndex(string code, int percent)
{
    if (code.length() != 6) {
        return;
    }
    int  v_ids[] = { IDC_BUTTON_SELL_VOLUME_1,IDC_BUTTON_SELL_VOLUME_2,IDC_BUTTON_SELL_VOLUME_3,IDC_BUTTON_SELL_VOLUME_4,IDC_BUTTON_SELL_VOLUME_5 };
    int length = sizeof(v_ids) / sizeof(v_ids[0]);
    // 选中当前的数据
    for (int i = 0; i < length; i++) {
        CButton* pButton = (CButton*)GetDlgItem(v_ids[i]);
        CString st;
        st.Append(L"1/");
        st.Append(to_wstring((i + 1)).c_str());
        if ((i + 1) == percent) {
            st.Append(L"※");
        }
        pButton->SetWindowTextW(st);
    }
    sellManager->init(code);
    (sellManager->getSellSetting(code))->mode1_rate_index = percent;
    sellManager->syncSettingToFile(code);
    int money = sellManager->computeCurrentMoney(code);
    editSellMoney.SetWindowTextW(to_wstring( money).c_str());
}
void CFloatTradeDlg::requestCodePosition(string code, CFloatTradeDlg* context, bool showCodeDesc, int delayMs)
{
    if (delayMs > 0) {
@@ -341,7 +311,17 @@
    else {
        context->comboSellPriceType.SetCurSel(0);
    }
    if ((context->sellManager->getSellSetting(code))->lock) {
    SellSetting* sellSetting = context->sellManager->getSellSetting(code);
    if (sellSetting->lockBuyMoney > 0) {
        context->editBuyMoney.SetWindowTextW(to_wstring(sellSetting->lockBuyMoney).c_str());
    }
    else {
        context->editBuyMoney.SetWindowTextW(L"");
    }
    if (sellSetting->lock) {
        context->checkLockVolume.SetCheck(TRUE);
    }
    else {
@@ -386,7 +366,7 @@
                }
            }
            else {
                showFloatMsg(context,doc[L"msg"].GetString(), MSG_TYPE_FAIL);
                showFloatMsg(context, doc[L"msg"].GetString(), MSG_TYPE_FAIL);
            }
        }
    }
@@ -424,7 +404,7 @@
void CFloatTradeDlg::runPushMsgHeart(CFloatTradeDlg* context, SOCKET socket)
{
    while (TRUE) {
        rapidjson::StringBuffer buf;
        rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(buf);
@@ -446,7 +426,7 @@
        catch (...) {
            break;
        }
        Sleep(5*1000);
        Sleep(5 * 1000);
    }
}
@@ -495,7 +475,7 @@
                                st.Append(L" 即将买入:");
                                st.Append(data[L"msg"].GetString());
                                std::thread t1(context->showFloatMsg, context, st, MSG_TYPE_WARNING,5000, TipDlg::POSITION_RIGHT_BOTTOM);
                                std::thread t1(context->showFloatMsg, context, st, MSG_TYPE_WARNING, 5000, TipDlg::POSITION_RIGHT_BOTTOM);
                                t1.detach();
                            }
                        }
@@ -553,7 +533,7 @@
        btnSellRule.SetWindowTextW(L"条件单");
    }
    CString totalStr ;
    CString totalStr;
    totalStr.Append(L"¥");
    totalStr.Append(std::to_wstring((int)(codePosition->total * codePosition->costPrice * 100) / 100).c_str());
    labelTotalPosition.SetWindowTextW(totalStr);
@@ -566,19 +546,6 @@
    labelSelledVolume.SetWindowTextW(availableStr);
    fillSellMoney(code, codePosition->available);
    if (sellSetting->setting_mode == SETTING_MODE_RATE) {
        selectSellRateIndex(code, sellSetting->mode1_rate_index);
        radioSell1.SetCheck(TRUE);
        radioSell2.SetCheck(FALSE);
    }
    else {
        int money = sellManager->computeCurrentMoney(code);
        editSellMoney.SetWindowTextW(to_wstring(money).c_str());
        comboSellFirst.SetCurSel(sellSetting->mode2_first_index);
        comboSellLeft.SetCurSel(sellSetting->mode2_left_index);
        radioSell1.SetCheck(FALSE);
        radioSell2.SetCheck(TRUE);
    }
    checkLockBuyVolume.SetCheck(sellSetting->lockBuy);
    if (sellSetting->lockBuy) {
        if (sellSetting->lockBuyMoney > 0) {
@@ -657,10 +624,6 @@
    DDX_Control(pDX, IDC_COMBO_SELL_PRICE, comboSellPriceType);
    DDX_Control(pDX, btn_code_trade_info, btnSellRule);
    DDX_Control(pDX, IDC_CHECK_LOCK_SELL_VOLUME, checkLockVolume);
    DDX_Control(pDX, IDC_COMBO_SELL_FIRST, comboSellFirst);
    DDX_Control(pDX, IDC_COMBO_SELL_LEFT, comboSellLeft);
    DDX_Control(pDX, IDC_RADIO1, radioSell1);
    DDX_Control(pDX, IDC_RADIO2, radioSell2);
    DDX_Control(pDX, IDC_CHECK_MARKET_SITUATION, checkMarketSituation);
    DDX_Control(pDX, IDC_MFCBUTTON_FLASH_INFO, mfcBtnFlashInfo);
    DDX_Control(pDX, IDC_CHECK_LOCK_BUY_VOLUME, checkLockBuyVolume);
@@ -703,18 +666,20 @@
    ON_BN_CLICKED(IDC_BUTTON_SELL_VOLUME_3, &CFloatTradeDlg::OnBnClickedButtonSellVolume1)
    ON_BN_CLICKED(IDC_BUTTON_SELL_VOLUME_4, &CFloatTradeDlg::OnBnClickedButtonSellVolume1)
    ON_BN_CLICKED(IDC_BUTTON_SELL_VOLUME_5, &CFloatTradeDlg::OnBnClickedButtonSellVolume1)
    ON_BN_CLICKED(IDC_BUTTON_SELL_VOLUME_6, &CFloatTradeDlg::OnBnClickedButtonSellVolume1)
    ON_BN_CLICKED(IDC_BUTTON_SELL_VOLUME_7, &CFloatTradeDlg::OnBnClickedButtonSellVolume1)
    ON_BN_CLICKED(IDC_BUTTON_SELL_VOLUME_8, &CFloatTradeDlg::OnBnClickedButtonSellVolume1)
    ON_BN_CLICKED(IDC_BUTTON_SELL_VOLUME_9, &CFloatTradeDlg::OnBnClickedButtonSellVolume1)
    ON_BN_CLICKED(IDC_BUTTON_SELL_VOLUME_10, &CFloatTradeDlg::OnBnClickedButtonSellVolume1)
    ON_BN_CLICKED(IDC_BUTTON_SELL_VOLUME_11, &CFloatTradeDlg::OnBnClickedButtonSellVolume1)
    ON_BN_CLICKED(IDC_BUTTON_SELL_VOLUME_13, &CFloatTradeDlg::OnBnClickedButtonSellVolume1)
    ON_BN_CLICKED(IDC_BUTTON_REFRESH, &CFloatTradeDlg::OnBnClickedButtonRefresh)
    ON_BN_CLICKED(IDC_BUTTON_MUST_LIST, &CFloatTradeDlg::OnBnClickedmustlist)
    ON_BN_CLICKED(IDC_BUTTON_ADD_MUST, &CFloatTradeDlg::OnBnClickedmust)
    ON_BN_CLICKED(IDC_BUTTON_REMOVE_MUST, &CFloatTradeDlg::OnBnClickedremovefrommust)
    ON_MESSAGE(WM_FLOAT_MSG, &CFloatTradeDlg::OnFloatMsg)
    ON_BN_CLICKED(IDC_CHECK_LOCK_SELL_VOLUME, &CFloatTradeDlg::OnBnClickedCheckLockSellVolume)
    ON_BN_CLICKED(IDC_RADIO2, &CFloatTradeDlg::OnBnClickedRadio2)
    ON_BN_CLICKED(IDC_RADIO1, &CFloatTradeDlg::OnBnClickedRadio1)
    ON_BN_CLICKED(IDC_CHECK_MARKET_SITUATION, &CFloatTradeDlg::OnBnClickedCheckMarketSituation)
    ON_CBN_SELCHANGE(IDC_COMBO_SELL_FIRST, &CFloatTradeDlg::OnCbnSelchangeComboSellFirst)
    ON_CBN_SELCHANGE(IDC_COMBO_SELL_LEFT, &CFloatTradeDlg::OnCbnSelchangeComboSellLeft)
    ON_BN_CLICKED(IDC_BUTTON_ADD_WANT, &CFloatTradeDlg::OnBnClickedButtonAddWant)
    ON_BN_CLICKED(IDC_BUTTON_REMOVE_WANT, &CFloatTradeDlg::OnBnClickedButtonRemoveWant)
    ON_BN_CLICKED(IDC_BUTTON_WANT_LIST, &CFloatTradeDlg::OnBnClickedButtonWantList)
@@ -813,27 +778,6 @@
    comboSellPriceType.AddString(_T("买5价"));
    comboSellPriceType.SetCurSel(0);
    for (int i = 0; i < 10; i++) {
        CString st = L"";
        st.Append(to_wstring((i + 1) * 10).c_str());
        st.Append(L"%");
        comboSellFirst.AddString(st);
    }
    comboSellFirst.SetCurSel(4);
    for (int i = 0; i < 10; i++) {
        CString st = L"";
        st.Append(to_wstring((i + 1)).c_str());
        st.Append(L"笔卖");
        comboSellLeft.AddString(st);
    }
    comboSellLeft.SetCurSel(1);
    radioSell2.SetCheck(TRUE);
    comboSellFirst.EnableWindow(FALSE);
    radioSell1.EnableWindow(FALSE);
    radioSell2.EnableWindow(FALSE);
    std::thread thread_ru(regularUpdatePositionInfo, this);
    thread_ru.detach();
@@ -1154,10 +1098,10 @@
            sell_volume_int = 100;
        }
        // 获取持仓
        CodePosition*  pos = sellManager->getCodePosition(code);
        CodePosition* pos = sellManager->getCodePosition(code);
        if (pos != nullptr) {
            if (pos->available > 0 && sell_volume_int > pos->available) {
                // 卖剩余的所有
                // 卖剩余的所有
                sell_volume_int = pos->available;
            }
        }
@@ -1342,14 +1286,6 @@
void CFloatTradeDlg::initSellSettingView()
{
    SellSettingView sellSettingView;
    int mode = 0;
    if (radioSell1.GetCheck()) {
        mode = 1;
    }
    else if (radioSell2.GetCheck()) {
        mode = 2;
    }
    string code = "";
    try {
        code = getInputCode();
@@ -1357,77 +1293,6 @@
    catch (...) {
        return;
    }
    // ---设置UI参数---
    CodePosition* codePosition = sellManager->getCodePosition(code);
    if (codePosition->sell_orders.size() > 0) {
        sellSettingView.mode = FALSE;
    }
    else {
        sellSettingView.mode = TRUE;
    }
    if (codePosition->sell_orders.size() >= 1 || mode != 2) {
        sellSettingView.mode2_first = FALSE;
    }
    else {
        sellSettingView.mode2_first = TRUE;
    }
    if (codePosition->sell_orders.size() >= 2 || mode != 2) {
        sellSettingView.mode2_left = FALSE;
    }
    else {
        sellSettingView.mode2_left = TRUE;
    }
    if (mode != 1 || codePosition->sell_orders.size() > 0) {
        sellSettingView.mode1_percent = FALSE;
    }
    else {
        sellSettingView.mode1_percent = TRUE;
    }
    // ---更新UI---
    if (sellSettingView.mode) {
        radioSell1.EnableWindow(TRUE);
        radioSell2.EnableWindow(TRUE);
    }
    else {
        radioSell1.EnableWindow(FALSE);
        radioSell2.EnableWindow(FALSE);
    }
    int  v_ids[] = { IDC_BUTTON_SELL_VOLUME_1,IDC_BUTTON_SELL_VOLUME_2,IDC_BUTTON_SELL_VOLUME_3,IDC_BUTTON_SELL_VOLUME_4,IDC_BUTTON_SELL_VOLUME_5 };
    int length = sizeof(v_ids) / sizeof(v_ids[0]);
    for (int i = 0; i < length; i++) {
        CWnd* pButtonWnd = GetDlgItem(v_ids[i]);
        if (sellSettingView.mode1_percent) {
            pButtonWnd->EnableWindow(TRUE);
        }
        else {
            pButtonWnd->EnableWindow(FALSE);
        }
    }
    if (sellSettingView.mode2_first) {
        comboSellFirst.EnableWindow(TRUE);
    }
    else {
        comboSellFirst.EnableWindow(FALSE);
    }
    if (sellSettingView.mode2_left) {
        comboSellLeft.EnableWindow(TRUE);
    }
    else {
        comboSellLeft.EnableWindow(FALSE);
    }
}
@@ -1528,7 +1393,7 @@
void CFloatTradeDlg::fillSellMoney(string code, int volume)
{
    CodePosition* codePosition = sellManager->getCodePosition(code);
    editSellMoney.SetWindowTextW(to_wstring( (int)(codePosition->costPrice * volume * 100) / 100).c_str());
    editSellMoney.SetWindowTextW(to_wstring((int)(codePosition->costPrice * volume * 100) / 100).c_str());
}
int CFloatTradeDlg::sellMoneyToVolume(string code, int money)
@@ -1767,14 +1632,19 @@
void CFloatTradeDlg::OnBnClickedButtonSellVolume1()
{
    int nID = ((CButton*)GetFocus())->GetDlgCtrlID();
    int  v_ids[] = { IDC_BUTTON_SELL_VOLUME_1,IDC_BUTTON_SELL_VOLUME_2,IDC_BUTTON_SELL_VOLUME_3,IDC_BUTTON_SELL_VOLUME_4,IDC_BUTTON_SELL_VOLUME_5 };
    int length = sizeof(v_ids) / sizeof(v_ids[0]);
    CString num_str;
    GetDlgItem(nID)->GetWindowTextW(num_str);
    editSellMoney.SetWindowTextW(num_str);
    for (int i = 0; i < length; i++) {
        if (v_ids[i] == nID) {
            selectSellRateIndex(getInputCode(), i + 1);
            break;
        }
    try {
        string code = getInputCode();
        int sellMoney_int = stoi(StringUtil::cstring2String(num_str).c_str());
        SellSetting* sellSetting = sellManager->getSellSetting(code);
        sellSetting->lockMoney = sellMoney_int;
        sellManager->syncSettingToFile(code);
    }
    catch (wstring msg) {
        AfxMessageBox(msg.c_str());
    }
}
@@ -1819,48 +1689,10 @@
        sellManager->syncSettingToFile(code);
    }
    catch (wstring msg) {
        checkLockVolume.SetCheck(!checkLockVolume.GetCheck());
        AfxMessageBox(msg.c_str());
    }
}
void CFloatTradeDlg::OnBnClickedRadio2()
{
    radioSell1.SetCheck(FALSE);
    initSellSettingView();
    try {
        string code = getInputCode();
        sellManager->init(code);
        SellSetting* sellSetting = sellManager->getSellSetting(code);
        comboSellFirst.SetCurSel(sellSetting->mode2_first_index);
        comboSellLeft.SetCurSel(sellSetting->mode2_left_index);
        sellSetting->setting_mode = SETTING_MODE_PERCENT;
        sellManager->syncSettingToFile(code);
        showCodePositionInfo();
    }
    catch (wstring msg) {
        AfxMessageBox(msg.c_str());
    }
}
void CFloatTradeDlg::OnBnClickedRadio1()
{
    radioSell2.SetCheck(FALSE);
    initSellSettingView();
    try {
        string code = getInputCode();
        sellManager->init(code);
        SellSetting* sellSetting = sellManager->getSellSetting(code);
        sellSetting->setting_mode = SETTING_MODE_RATE;
        selectSellRateIndex(code, sellSetting->mode1_rate_index);
    }
    catch (wstring msg) {
        AfxMessageBox(msg.c_str());
    }
}
void CFloatTradeDlg::OnBnClickedCheckMarketSituation()
@@ -1875,38 +1707,6 @@
    }
    catch (wstring msg) {
        checkMarketSituation.SetCheck(!checkMarketSituation.GetCheck());
        AfxMessageBox(msg.c_str());
    }
}
void CFloatTradeDlg::OnCbnSelchangeComboSellFirst()
{
    try {
        string code = getInputCode();
        sellManager->init(code);
        SellSetting* sellSetting = sellManager->getSellSetting(code);
        sellSetting->mode2_first_index = comboSellFirst.GetCurSel();
        sellManager->syncSettingToFile(code);
        showCodePositionInfo();
    }
    catch (wstring msg) {
        AfxMessageBox(msg.c_str());
    }
}
void CFloatTradeDlg::OnCbnSelchangeComboSellLeft()
{
    try {
        string code = getInputCode();
        sellManager->init(code);
        SellSetting* sellSetting = sellManager->getSellSetting(code);
        sellSetting->mode2_left_index = comboSellLeft.GetCurSel();
        sellManager->syncSettingToFile(code);
        showCodePositionInfo();
    }
    catch (wstring msg) {
        AfxMessageBox(msg.c_str());
    }
}
@@ -2037,7 +1837,7 @@
        CString buyMoneyw;
        editBuyMoney.GetWindowTextW(buyMoneyw);
        string buyMoney = StringUtil::cstring2String(buyMoneyw);
        if (buyMoney.length()==0|| !StringUtil::isNumber(buyMoney)) {
        if (buyMoney.length() == 0 || !StringUtil::isNumber(buyMoney)) {
            throw wstring(L"请输入正确的金额");
        }
        int buyMoney_int = stoi(buyMoney);
@@ -2083,29 +1883,28 @@
        }
        else if (CWnd::GetFocus() == GetDlgItem(IDC_EDIT_BUY_VOLUME))
        {
            if (checkLockBuyVolume.GetCheck()) {
                // 保存锁定的金额
                try {
                    string code = getInputCode();
                    CString buyMoneyw;
                    editBuyMoney.GetWindowTextW(buyMoneyw);
                    string buyMoney = StringUtil::cstring2String(buyMoneyw);
                    if (!StringUtil::isNumber(buyMoney)) {
                        throw wstring(L"请输入正确的金额");
                    }
                    int buyMoney_int = stoi(buyMoney);
                    SellSetting* sellSetting = sellManager->getSellSetting(code);
                    sellSetting->lockBuyMoney = buyMoney_int;
                    sellManager->syncSettingToFile(code);
            // 保存锁定的金额
            try {
                string code = getInputCode();
                CString buyMoneyw;
                editBuyMoney.GetWindowTextW(buyMoneyw);
                string buyMoney = StringUtil::cstring2String(buyMoneyw);
                if (!StringUtil::isNumber(buyMoney)) {
                    throw wstring(L"请输入正确的金额");
                }
                catch (wstring msg) {
                    AfxMessageBox(msg.c_str());
                }
                int buyMoney_int = stoi(buyMoney);
                SellSetting* sellSetting = sellManager->getSellSetting(code);
                sellSetting->lockBuyMoney = buyMoney_int;
                sellSetting->lockBuy = true;
                checkLockBuyVolume.SetCheck(true);
                sellManager->syncSettingToFile(code);
            }
            catch (wstring msg) {
                AfxMessageBox(msg.c_str());
            }
        }
        return TRUE;
        return TRUE;
    }
    return CDialogEx::PreTranslateMessage(pMsg);
FloatTrade/FloatTradeDlg.h
@@ -87,8 +87,6 @@
    static void getCodeDesc(string code,CFloatTradeDlg* context);
    //选择卖量
    void selectSellRateIndex(string code, int percent);
    // 获取代码持仓状态 
    static void requestCodePosition(string code, CFloatTradeDlg* context,bool showCodeDesc, int delayMs=0);
@@ -223,16 +221,8 @@
    afx_msg void OnBnClickedremovefrommust();
    CButton checkLockVolume;
    afx_msg void OnBnClickedCheckLockSellVolume();
    CComboBox comboSellFirst;
    CComboBox comboSellLeft;
    CButton radioSell1;
    CButton radioSell2;
    afx_msg void OnBnClickedRadio2();
    afx_msg void OnBnClickedRadio1();
    CButton checkMarketSituation;
    afx_msg void OnBnClickedCheckMarketSituation();
    afx_msg void OnCbnSelchangeComboSellFirst();
    afx_msg void OnCbnSelchangeComboSellLeft();
    CMFCButton mfcBtnFlashInfo;
    afx_msg void OnBnClickedButtonAddWant();
    afx_msg void OnBnClickedButtonRemoveWant();
FloatTrade/SellDlg.cpp
@@ -5,6 +5,7 @@
#include "SellDlg.h"
#include "afxdialogex.h"
#include "../common/NetworkApi.h"
#include "../common/JsonUtil.h"
#include <thread>
@@ -23,15 +24,69 @@
    context->btnClose.SetBitmap(hBitmap);
}
void SellDlg::requestCurrentPriceInfo(SellDlg* context)
{
    while (TRUE) {
        try
        {
            if (context->killed) {
                break;
            }
            string result = NetworkApi::get_l2_deal_price(context->code);
            auto doc = JsonUtil::parseUTF16(result);
            if (context->killed) {
                break;
            }
            if (doc.IsObject()) {
                if (doc.HasMember(L"code") && doc[L"code"].GetInt() == 0) {
                    auto data = doc[L"data"].GetObjectW();
                    if (data.HasMember(L"rate")) {
                        float rate = ((int)(data[L"rate"].GetDouble() * 10000)) / 100.f;
                        if (rate > 0)
                        {
                            context->rateColor = RGB(205, 54, 54);
                        }
                        else if (rate < 0) {
                            context->rateColor = RGB(0, 230, 0);
                        }
                        else {
                            context->rateColor = RGB(0, 0, 0);
                        }
                        std::ostringstream oss;
                        oss << std::fixed << std::setprecision(2) << rate;
                        CString priceRateStr = CString(oss.str().c_str());
                        priceRateStr.Append(L"%");
                        context->labelPriceRate.SetWindowTextW(priceRateStr);
                        context->labelPriceRate.Invalidate();
                    }
                }
                else {
                    context->rateColor = RGB(0, 0, 0);
                    context->labelPriceRate.SetWindowTextW(L"-");
                    context->labelPriceRate.Invalidate();
                }
            }
        }
        catch (...)
        {
        }
        Sleep(1000);
    }
}
void SellDlg::SetBtnSellText()
{
    // 设置卖信息
    CString st = L"卖-";
    CString st = L"";
    st.Append(codeName);
    st.Append(L"-");
    st.Append(to_wstring(position.total - position.available).c_str());
    st.Append(L"/");
    st.Append(to_wstring(position.total).c_str());
    //st.Append(L"-");
    //st.Append(to_wstring(position.total - position.available).c_str());
    //st.Append(L"/");
    //st.Append(to_wstring(position.total).c_str());
    btnSell.SetWindowTextW(st);
}
@@ -62,6 +117,7 @@
    CDialogEx::DoDataExchange(pDX);
    DDX_Control(pDX, IDC_MFCBUTTON_SELL, btnSell);
    DDX_Control(pDX, IDC_BUTTON_CLOSE, btnClose);
    DDX_Control(pDX, IDC_STATIC_RATE, labelPriceRate);
}
@@ -69,6 +125,7 @@
    ON_WM_NCHITTEST()
    ON_BN_CLICKED(IDC_BUTTON_CLOSE, &SellDlg::OnBnClickedButtonClose)
    ON_BN_CLICKED(IDC_MFCBUTTON_SELL, &SellDlg::OnBnClickedMfcbuttonSell)
    ON_WM_CTLCOLOR()
END_MESSAGE_MAP()
@@ -88,16 +145,34 @@
{
    CDialogEx::OnInitDialog();
    // 设置对话框背景颜色
    //SetBackgroundColor(RGB(0,0,0));
    SetBackgroundColor(RGB(0,0,0));
    SetBtnSellText();
    int scale = GetDpiForSystem();
    font.CreateFont(27, 0, 0, 0, FW_NORMAL, 0, 0, 0, 0, 0, 0, 0, 0, L"微软雅黑");
    // 设置透明度(0透明,255完全不透明)
    ModifyStyleEx(0, WS_EX_LAYERED);
    BYTE opacity = 255; // 透明度值取值范围为0~255
    SetLayeredWindowAttributes(RGB(0, 0, 0), opacity, LWA_ALPHA);
    //设置字体
    labelPriceRate.SetFont(&font, FALSE);
    killed = FALSE;
    std::thread t1(initView, this);
    t1.detach();
    std::thread t2(requestCurrentPriceInfo, this);
    t2.detach();
    return TRUE;
}
void SellDlg::OnBnClickedButtonClose()
{
    killed = TRUE;
    this->closeCallback(code, this->pParent);
}
@@ -108,3 +183,22 @@
}
HBRUSH SellDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
    HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
    if (nCtlColor == CTLCOLOR_STATIC) {
        int nID = pWnd->GetDlgCtrlID();
        switch (nID) {
        case IDC_STATIC_RATE:
            pDC->SetTextColor(rateColor);
            break;
        }
    }
    return hbr;
}
FloatTrade/SellDlg.h
@@ -25,8 +25,17 @@
    SellCallbackFunc sellCallback;
    CloseCallbackFunc closeCallback;
    CWnd* pParent;
    COLORREF rateColor;
    CFont font;
    bool killed;
    static void initView(SellDlg *context);
    /// <summary>
    /// 请求当前成交价
    /// </summary>
    /// <param name="context"></param>
    static void requestCurrentPriceInfo(SellDlg* context);
    void SetBtnSellText();
@@ -36,6 +45,7 @@
    // 设置持仓信息
    void SetPositionInfo(int total,int avaiable);
// 对话框数据
#ifdef AFX_DESIGN_TIME
@@ -56,4 +66,6 @@
    afx_msg void OnBnClickedMfcbuttonSell();
    afx_msg void OnMouseMove(UINT nFlags, CPoint point);
    afx_msg void OnNcMouseMove(UINT nHitTest, CPoint point);
    CStatic labelPriceRate;
    afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
};
FloatTrade/SellManager.cpp
@@ -294,7 +294,7 @@
            setting = new SellSetting();
            setting->lock = true;
            setting->lockMoney = 5000;
            setting->lockBuy = false;
            setting->lockBuy = true;
            setting->lockBuyMoney = 0;
            setting->setting_mode = SETTING_MODE_RATE;
            setting->mode1_rate_index = 4;
FloatTrade/config.cfg
@@ -1,6 +1,6 @@
window_pos = "[288,316]";
window_pos = "[670,245]";
trade_quick_key = 1;
sell_rule_show_pos = "-788,258";
sell_rule_show_pos = "-733,208";
ths_auto_click_time_space = 2000;
ths_auto_refresh_time_space = 2000;
ths_auto_click_positions = "[]";
@@ -57,3 +57,8 @@
sell_setting-20240228-600830 = "{\n    \"setting_mode\": 0,\n    \"lock\": true,\n    \"lockMoney\": 5000,\n    \"lockBuy\": false,\n    \"lockBuyMoney\": 0,\n    \"mode1_rate_index\": 4,\n    \"mode2_first_index\": 0,\n    \"mode2_left_index\": 0\n}";
sell_setting-20240228-603798 = "{\n    \"setting_mode\": 0,\n    \"lock\": true,\n    \"lockMoney\": 5000,\n    \"lockBuy\": false,\n    \"lockBuyMoney\": 0,\n    \"mode1_rate_index\": 4,\n    \"mode2_first_index\": 0,\n    \"mode2_left_index\": 0\n}";
sell_setting-20240228-002902 = "{\n    \"setting_mode\": 0,\n    \"lock\": true,\n    \"lockMoney\": 5000,\n    \"lockBuy\": false,\n    \"lockBuyMoney\": 0,\n    \"mode1_rate_index\": 4,\n    \"mode2_first_index\": 0,\n    \"mode2_left_index\": 0\n}";
sell_setting-20240304-603776 = "{\n    \"setting_mode\": 0,\n    \"lock\": true,\n    \"lockMoney\": 40000,\n    \"lockBuy\": true,\n    \"lockBuyMoney\": 1000,\n    \"mode1_rate_index\": 4,\n    \"mode2_first_index\": 0,\n    \"mode2_left_index\": 0\n}";
sell_setting-20240304-002786 = "{\n    \"setting_mode\": 0,\n    \"lock\": true,\n    \"lockMoney\": 2000,\n    \"lockBuy\": true,\n    \"lockBuyMoney\": 3000,\n    \"mode1_rate_index\": 4,\n    \"mode2_first_index\": 0,\n    \"mode2_left_index\": 0\n}";
sell_setting-20240304-603912 = "{\n    \"setting_mode\": 0,\n    \"lock\": true,\n    \"lockMoney\": 5000,\n    \"lockBuy\": true,\n    \"lockBuyMoney\": 8000,\n    \"mode1_rate_index\": 4,\n    \"mode2_first_index\": 0,\n    \"mode2_left_index\": 0\n}";
sell_setting-20240304-603380 = "{\n    \"setting_mode\": 0,\n    \"lock\": true,\n    \"lockMoney\": 5000,\n    \"lockBuy\": true,\n    \"lockBuyMoney\": 1000,\n    \"mode1_rate_index\": 4,\n    \"mode2_first_index\": 0,\n    \"mode2_left_index\": 0\n}";
sell_setting-20240305-603380 = "{\n    \"setting_mode\": 0,\n    \"lock\": true,\n    \"lockMoney\": 40000,\n    \"lockBuy\": true,\n    \"lockBuyMoney\": 0,\n    \"mode1_rate_index\": 4,\n    \"mode2_first_index\": 0,\n    \"mode2_left_index\": 0\n}";
FloatTrade/resource.h
@@ -39,7 +39,10 @@
#define edit_trade_group_space_time     1026
#define edit_group_pos                  1027
#define btn_code_trade_info             1028
#define edit_per_code_buy_money         1028
#define btn_sure                        1029
#define btn_sure2                       1030
#define btn_sure_network                1030
#define edit_price                      1031
#define edit_money                      1032
#define IDC_EDIT_CODE                   1048
@@ -64,6 +67,7 @@
#define IDC_BUTTON_SELL_VOLUME_3        1063
#define IDC_EDIT_BUY1_PRICE2            1063
#define IDC_BUTTON_DELETE2              1064
#define IDC_BUTTON_SELL_VOLUME_7        1064
#define IDC_BUTTON_ADD2                 1065
#define IDC_BUTTON_UPDATE               1066
#define IDC_BUTTON_SELL_VOLUME_4        1067
@@ -74,13 +78,16 @@
#define IDC_BUTTON_SELL_VOLUME_5        1069
#define IDC_STATIC_ID3                  1069
#define IDC_EDIT_BUY1_VOLUME2           1070
#define IDC_BUTTON_SELL_VOLUME_6        1070
#define IDC_STATIC_TOTAL_POSITION       1071
#define IDC_BUTTON_FILL_VOLUME2         1071
#define IDC_STATIC_ALREADY_SELL         1072
#define IDC_EDIT_END_TIME3              1072
#define IDC_STATIC_MSG                  1073
#define IDC_BUTTON_CLEAR3               1073
#define IDC_BUTTON_SELL_VOLUME_8        1073
#define IDC_COMBO_SELL_PRICE_TYPE       1074
#define IDC_BUTTON_SELL_VOLUME_9        1074
#define IDC_BUTTON_REFRESH              1075
#define IDC_COMBO_SELL_PRICE_TYPE2      1075
#define IDC_BUTTON_MUST_LIST            1076
@@ -91,12 +98,16 @@
#define IDC_BUTTON_UPDATE3              1078
#define IDC_CHECK_LOCK_SELL_VOLUME      1079
#define IDC_RADIO1                      1080
#define IDC_BUTTON_SELL_VOLUME_10       1080
#define IDC_RADIO2                      1081
#define IDC_COMBO_SELL_FIRST            1082
#define IDC_BUTTON_SELL_VOLUME_12       1082
#define IDC_BUTTON_SELL_VOLUME_11       1082
#define IDC_COMBO2                      1083
#define IDC_BUTTON_ADD_WANT             1083
#define IDC_CHECK_MARKET_SITUATION      1084
#define IDC_COMBO_SELL_LEFT             1085
#define IDC_BUTTON_SELL_VOLUME_13       1085
#define IDC_BUTTON_REMOVE_WANT          1086
#define IDC_BUTTON_WANT_LIST            1087
#define IDC_MFCBUTTON1                  1088
@@ -111,6 +122,7 @@
#define IDC_BUTTON_GET_POSITION         1094
#define IDC_STATIC_POSITION             1095
#define IDC_BUTTON_GET_POSITION2        1096
#define IDC_STATIC_RATE                 1096
#define IDC_STATIC_POSITION2            1097
#define IDC_STATIC_POSITION3            1098
#define IDC_STATIC_BUY1_MONEY           1098
@@ -119,9 +131,9 @@
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        154
#define _APS_NEXT_RESOURCE_VALUE        156
#define _APS_NEXT_COMMAND_VALUE         32771
#define _APS_NEXT_CONTROL_VALUE         1096
#define _APS_NEXT_CONTROL_VALUE         1097
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif