150 lines
2.9 KiB
C++
150 lines
2.9 KiB
C++
// CPRobotDlg.h : 헤더 파일
|
|
#pragma once
|
|
|
|
#include "afxwin.h"
|
|
#include "EventHandler.h"
|
|
#include <string>
|
|
#include <vector>
|
|
#include <hash_map>
|
|
#include <fstream>
|
|
|
|
using std::vector;
|
|
using stdext::hash_map;
|
|
using std::string;
|
|
using std::ofstream;
|
|
|
|
struct CP_BUYINFO
|
|
{
|
|
string m_Code;
|
|
int m_iBoughtTime;
|
|
float m_fBoughtPrice;
|
|
float m_fHighestPrice;
|
|
|
|
};
|
|
|
|
struct CP_UNITINFO
|
|
{
|
|
string m_Code;
|
|
int m_iCnt;
|
|
float m_fBoughtPrice;
|
|
float m_fHighestPrice;
|
|
CTime m_Time;
|
|
int m_iOrderNum;
|
|
};
|
|
|
|
struct CP_PRICEINFO
|
|
{
|
|
float m_afAskPrice[5];
|
|
float m_afBidPrice[5];
|
|
};
|
|
|
|
|
|
enum CP_STATE
|
|
{
|
|
CPS_WAIT=0,
|
|
CPS_LOOKING,
|
|
CPS_LOOKING_DEAL,
|
|
CPS_BUYING,
|
|
CPS_WAITING_SELL,
|
|
CPS_SELLING
|
|
};
|
|
|
|
// CCPRobotDlg 대화 상자
|
|
class CCPRobotDlg : public CDialog, public IEventHandlerSysDib, public IEventHandlerDib
|
|
{
|
|
// 생성입니다.
|
|
public:
|
|
CCPRobotDlg(CWnd* pParent = NULL); // 표준 생성자입니다.
|
|
|
|
// 대화 상자 데이터입니다.
|
|
enum { IDD = IDD_CPROBOT_DIALOG };
|
|
|
|
afx_msg void OnBnClickedButtonRefreshBalance();
|
|
|
|
afx_msg void OnBnClickedButtonStartDeal();
|
|
afx_msg void OnBnClickedButtonSearch();
|
|
|
|
afx_msg void OnHotKey(UINT nHotKeyId, UINT nKey1, UINT nKey2);
|
|
|
|
afx_msg void OnTimer(UINT_PTR nIDEvent);
|
|
|
|
virtual void ReceivedSysDib();
|
|
virtual void ReceivedDib();
|
|
|
|
protected:
|
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
|
|
virtual BOOL DestroyWindow();
|
|
|
|
// 생성된 메시지 맵 함수
|
|
virtual BOOL OnInitDialog();
|
|
afx_msg void OnPaint();
|
|
afx_msg HCURSOR OnQueryDragIcon();
|
|
DECLARE_MESSAGE_MAP()
|
|
|
|
void SaveToFile(void);
|
|
void LoadFromFile(void);
|
|
|
|
HICON m_hIcon;
|
|
|
|
private:
|
|
CP_STATE m_enState;
|
|
CP_STATE m_enPrevState;
|
|
|
|
CListBox m_ResultList;
|
|
|
|
vector<string> m_OpCodeList;
|
|
CpSysDib::ISysDibPtr m_pOpJpBid;
|
|
CEventHandlerSysDib m_EventHandlerSysDib;
|
|
|
|
|
|
string m_AccountNum;
|
|
|
|
int m_iBalance;
|
|
int m_iAmountSet;
|
|
float m_fMinPriceSet;
|
|
float m_fMaxPriceSet;
|
|
int m_iPlusTick;
|
|
float m_fLossCutTick;
|
|
float m_fTrailingTick;
|
|
int m_iCancelDelay;
|
|
int m_iWindUpDelay;
|
|
BOOL m_bBuyOnBid1;
|
|
BOOL m_bPutOption;
|
|
|
|
string m_CurCode;
|
|
float m_fBoughtPrice;
|
|
float m_fHighestBid1;
|
|
float m_fCurBid1;
|
|
int m_iBoughtCnt;
|
|
int m_iOrderNum;
|
|
CTime m_BoughtT;
|
|
|
|
|
|
vector<CP_UNITINFO> m_OrderList;
|
|
vector<CP_UNITINFO> m_ConclusionList;
|
|
vector<CP_UNITINFO> m_WindUpList;
|
|
hash_map<string, CP_PRICEINFO> m_CurPriceList;
|
|
|
|
CpDib::IDibPtr m_pCpFConclusion;
|
|
CEventHandlerDib m_EventHandlerDib;
|
|
|
|
ATOM m_IdKeyFxCall;
|
|
ATOM m_IdKeyFxPut;
|
|
ATOM m_IdKeyFxStop;
|
|
|
|
ofstream m_LogFile;
|
|
|
|
void Subscribe(void);
|
|
void Unsubscribe(void);
|
|
|
|
void BuyThis(const string& Code, const float fBid1Price, const int iBid1Cnt, float afAskPrice[5]);
|
|
void SellThis(const string& Code);
|
|
void WindUp(const string& Code);
|
|
void CancelOrder(const string& Code);
|
|
|
|
inline void SwitchState(const CP_STATE enState);
|
|
|
|
void CPLog(const string fmt, ...);
|
|
|
|
};
|