|
// FloatTradeDlg.h: 头文件
|
//
|
|
#pragma once
|
#include "MyButton.h"
|
#include "CColorStatic.h"
|
#include <string>
|
#include <thread>
|
#include <map>
|
#include <list>
|
#include "SellDlg.h"
|
#include "SellStruct.h"
|
#include "SellManager.h"
|
#include "TipDlg.h"
|
#include "PositionDlg.h"
|
#include <ctime>
|
#include "ThsCodeOCR.h"
|
#include "DealQueueDlg.h"
|
#include "DataStruct.h"
|
|
|
#define WM_FLOAT_MSG (WM_USER + 100)
|
|
#define COLOR_RED RGB(205,54,54)
|
#define COLOR_GREEN RGB(0,230,0)
|
#define COLOR_BLUE RGB(25,6,173)
|
#define COLOR_BLACK RGB(0,0,0)
|
#define COLOR_ORANGE RGB(255,128,32)
|
|
using namespace std;
|
|
|
enum MSG_TYPE{
|
MSG_TYPE_INFO,
|
MSG_TYPE_SUCCESS,
|
MSG_TYPE_SELL_SUCCESS,
|
MSG_TYPE_FAIL,
|
MSG_TYPE_WARNING,
|
};
|
|
// 悬浮消息
|
struct FloatMsg {
|
string msg;
|
MSG_TYPE msgType;
|
int position;
|
int showMS;// 显示的ms数
|
};
|
|
// CFloatTradeDlg 对话框
|
class CFloatTradeDlg : public CDialogEx
|
{
|
private:
|
CFont bigFont;
|
CFont middleFont;
|
CFont smallFont;
|
COLORREF msgColor;
|
std::thread* cancelMsgThread;
|
static bool breakCancelMsg;
|
// 正在请求的代码
|
string requestingCode;
|
// 下单窗口
|
HWND buyWin;
|
// 持仓map
|
map<string, CodePosition> positionMap;
|
|
// 上次点击买的时间戳
|
std::time_t lastBuyClickTime;
|
|
LowSuctionQueue lowSuctionQueue;
|
|
|
SellManager* sellManager;
|
|
map<string, SellDlg*> sellDlgMap;
|
|
// 持仓
|
PositionDlg* positionDialog;
|
|
// 鼠标钩子
|
static HHOOK hMouseHook;
|
|
ThsCodeOCR* thsCodeOCR;
|
|
// 最近一次识别的代码
|
string lastOCRCode;
|
|
// 代码识别的截止时间
|
static long ocrCodeExpireTimestamp;
|
|
// 是否可以识别
|
bool canOCRCode;
|
|
// 成交队列
|
DealQueueDlg* dealQueueDlg;
|
|
void initView();
|
|
void initData();
|
|
string getCode();
|
|
void setMsg(CString msg, MSG_TYPE msgType, bool autoCancel=TRUE);
|
|
void showTips(CString str, int textColorType, int delayMs=2000, int position = TipDlg::POSITION_NORMAL);
|
|
// 获取交易状态
|
static void getTradeState(CFloatTradeDlg* context);
|
|
static void getAutoCancelSellMode(CFloatTradeDlg* context,string code);
|
|
// 获取续买信息
|
static void getContinueBuyInfo(CFloatTradeDlg* context, string code);
|
|
static void setContinueBuyMoney(CFloatTradeDlg* context, string code, int money);
|
|
//获取交易模式
|
static void getTradeMode(CFloatTradeDlg* context);
|
//清除消息
|
static void clearMsg(CFloatTradeDlg* context);
|
|
static void getCodeDesc(string code,CFloatTradeDlg* context);
|
|
|
// 获取代码持仓状态
|
static void requestCodePosition(string code, CFloatTradeDlg* context,bool showCodeDesc, int delayMs=0);
|
|
// 更新持仓
|
static void updateCodePosition(string code, CFloatTradeDlg* context);
|
|
// 获取卖结果
|
static void requestSellResult(int order_ref, CFloatTradeDlg* context, int delayMs = 0);
|
|
//定时更新持仓信息
|
static void regularUpdatePositionInfo(CFloatTradeDlg* context);
|
|
// 消息接收器心跳包发送
|
static void runPushMsgHeart(CFloatTradeDlg* context, SOCKET socket);
|
|
// 运行推送消息接收器
|
static void runPushMsgReceiver(CFloatTradeDlg* context);
|
|
// 开始震动
|
static void startShake(CFloatTradeDlg* context,CString text);
|
|
// 展示持仓数据
|
void showCodePositionInfo();
|
|
// 量的分配
|
list<UINT> distributeVolume(UINT total, UINT percent);
|
// 计算量索引
|
UINT computeSellVolume(list<UINT> volumeList, list<int> sell_volumes);
|
|
CString formatListResult(std::list<wstring> wlist);
|
|
// 设置卖视图
|
void initSellSettingView();
|
|
|
// 获取输入的代码
|
string getInputCode();
|
|
// 卖回调
|
static void OnSellCallback(string code, CWnd* context);
|
// 关闭卖回调
|
static void OnSellCloseCallback(string code, CWnd* context);
|
|
|
|
static void sell(string code, CFloatTradeDlg* context);
|
// 填充卖资金根据量
|
void fillSellMoney(string code, int volume);
|
|
int sellMoneyToVolume(string code, int money);
|
|
void buy();
|
|
static void showFloatMsg(CFloatTradeDlg *context, CString msg,MSG_TYPE msgType,int showMS=2000, int position=TipDlg::POSITION_NORMAL);
|
|
static void requestAllPositions(CFloatTradeDlg *context);
|
|
// 填充预设金额
|
void fillMoneys();
|
|
static void runTHSCodeOCR(CFloatTradeDlg* context);
|
|
// 设置目标代码
|
void setTargetCode(string code);
|
|
|
// 设置锁定信息
|
void setLockInfo(string code, bool lock, int lockMoney);
|
|
// 设置锁定买入金额
|
void setLockBuyInfo(string code, bool lock, int lockMoney);
|
|
|
// 请求低吸下单待确认记录
|
static void requestReadLSPlaceOrderRecords(CFloatTradeDlg* context);
|
|
static void runReadLSPlaceOrderRecords(CFloatTradeDlg* context);
|
|
|
// 构造
|
public:
|
CFloatTradeDlg(CWnd* pParent = nullptr); // 标准构造函数
|
|
// 对话框数据
|
#ifdef AFX_DESIGN_TIME
|
enum { IDD = IDD_TRADE };
|
#endif
|
|
protected:
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
|
|
|
// 实现
|
protected:
|
HICON m_hIcon;
|
|
// 生成的消息映射函数
|
virtual BOOL OnInitDialog();
|
void OnHotKey(UINT nHotKeyId, UINT nKey, UINT nModifiers);
|
afx_msg void OnPaint();
|
afx_msg HCURSOR OnQueryDragIcon();
|
DECLARE_MESSAGE_MAP()
|
|
static LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam);
|
|
public:
|
afx_msg void OnClickedBtnAlreadyCanceled();
|
afx_msg void OnClickedBtnBlack();
|
afx_msg void OnClickedBtnCloseBuy();
|
afx_msg void OnClickedBtnOpenBuy();
|
afx_msg void OnClickedBtnPauseBuy();
|
afx_msg void OnClickedBtnPauseBuyRemove();
|
afx_msg void OnClickedBtnRemoveBlack();
|
afx_msg void OnClickedBtnRemoveWhite();
|
afx_msg void OnClickedBtnSell();
|
afx_msg void OnClickedBtnWantBuy();
|
afx_msg void OnClickedBtnWantBuyRemove();
|
afx_msg void OnClickedBtnWhite();
|
afx_msg void OnClickedCheckAutoClick();
|
afx_msg void OnClickedCheckAutoRefresh();
|
afx_msg void OnClickedCheckTradeQuickKey();
|
afx_msg LRESULT OnFloatMsg(WPARAM wParam, LPARAM lParam);
|
|
CStatic labelAtrribute;
|
CButton btnSell;
|
CButton btnCancelBuy;
|
CButton btnCloseBuy;
|
CButton btnOpenBuy;
|
//CButton btnBuyModeWant;
|
//CButton btnBuyModeAll;
|
CButton checkAutoRefresh;
|
CButton checkAutoCancelSell;
|
CButton checkTradeQuickKey;
|
CButton whiteList;
|
CButton blackList;
|
afx_msg BOOL OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct);
|
afx_msg void OnBnClickedwantlist();
|
afx_msg void OnBnClickedpausebuylist();
|
afx_msg void OnBnClickedblacklist();
|
afx_msg void OnBnClickedwhitelist();
|
CEdit editCode;
|
afx_msg void OnClose();
|
afx_msg void OnBnClickedbuy();
|
afx_msg void OnBnClickedconfig();
|
//CButton btnBuy;
|
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
|
afx_msg void OnBnClickedcodetradeinfo();
|
afx_msg void OnBnClickedButtonSellVolume1();
|
CStatic labelTotalPosition;
|
CStatic labelSelledVolume;
|
CEdit editSellMoney;
|
CComboBox comboSellPriceType;
|
CButton btnSellRule;
|
afx_msg void OnBnClickedButtonRefresh();
|
afx_msg void OnBnClickedmustlist();
|
afx_msg void OnBnClickedmust();
|
afx_msg void OnBnClickedremovefrommust();
|
CButton checkLockVolume;
|
afx_msg void OnBnClickedCheckLockSellVolume();
|
afx_msg void OnBnClickedCheckMarketSituation();
|
afx_msg void OnBnClickedButtonAddWant();
|
afx_msg void OnBnClickedButtonRemoveWant();
|
afx_msg void OnBnClickedButtonWantList();
|
afx_msg void OnBnClickedButtonGetPositions();
|
afx_msg void OnDeltaposSpinVolume(NMHDR* pNMHDR, LRESULT* pResult);
|
CButton checkLockBuyVolume;
|
CEdit editBuyMoney;
|
afx_msg void OnBnClickedCheckLockBuyVolume();
|
virtual BOOL PreTranslateMessage(MSG* pMsg);
|
afx_msg void OnBnClickedcodetradeupdatewatchbuy1();
|
afx_msg void OnBnClickedButtonAddGreen();
|
afx_msg void OnBnClickedButtonRemoveGreen();
|
afx_msg void OnBnClickedButtonGreenList();
|
CStatic labelCodeInfo;
|
CButton btnBuy;
|
CComboBox comboBuyPriceType;
|
afx_msg void OnBnClickedaddwatchlimitupforsell();
|
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
|
afx_msg void OnClickedCheckOcrCode();
|
afx_msg void OnDestroy();
|
afx_msg void OnStnClickedStaticTotalPosition();
|
|
|
static void sellByVolume(string code, int volume, CFloatTradeDlg* context);
|
afx_msg void OnStnClickedStaticLsCodeName();
|
afx_msg void OnBnClickedButtonLsAddForbidden();
|
afx_msg void OnBnClickedButtonLsBuy();
|
afx_msg void OnBnClickedButtonLsNotBuy();
|
afx_msg void OnStnClickedStaticLsPlates();
|
|
afx_msg void OnCbnSelchangeComboContinueBuyList();
|
|
afx_msg void OnBnClickedContinueBuy();
|
};
|