Files
CPRobot/CPRobotDlg.h
2013-09-13 03:46:48 +00:00

162 lines
3.2 KiB
C++

// CPRobotDlg.h : 헤더 파일
#pragma once
#include "afxwin.h"
#include "EventHandler.h"
#include <string>
#include <vector>
#include <map>
#include <fstream>
using std::vector;
using std::map;
using std::string;
using std::ofstream;
struct CP_UNITINFO
{
string m_Code;
int m_iCnt;
float m_fBoughtPrice;
float m_fHighestPrice;
CTime m_Time;
int m_iOrderNum;
};
struct CP_PRICEINFO
{
bool m_bUpdated;
float m_afAskPrice[5];
int m_aiAskCnt[5];
float m_afBidPrice[5];
int m_aiBidCnt[5];
};
enum CP_ORDER_STATE
{
CPOS_NONE=0,
CPOS_RECEIPTION,
CPOS_CORRECTION,
CPOS_CANCEL,
CPOS_CONCLUTION,
CPOS_DENY
};
enum CP_ORDER_TYPE
{
CPOT_NONE=0,
CPOT_ASK,
CPOT_BID
};
struct CP_CONCLUSIONINFO
{
string m_Code;
int m_iOrderNum;
int m_iOrgOrderNum;
double m_dPrice;
int m_iCnt;
CP_ORDER_STATE m_enState;
CP_ORDER_TYPE m_enOrderType;
};
// 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();
afx_msg LRESULT OnProcPrice(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnProcConclusion(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
void SaveToFile(void);
void LoadFromFile(void);
HICON m_hIcon;
private:
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;
int m_iWindUpTick;
BOOL m_bBuyOnBid1;
BOOL m_bPutOption;
BOOL m_bLookingDeal;
CTime m_DealStartT;
vector<CP_UNITINFO> m_BidOrderList; // 매수 요청한 리스트
vector<CP_UNITINFO> m_AskOrderList; // 매도 요청한 리스트
map<string, CP_PRICEINFO> m_CurPriceList;
vector<CP_CONCLUSIONINFO> m_ConclusionList;
bool m_bUsingConclusion;
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(CP_UNITINFO& AskInfo);
void WindUp(const CP_UNITINFO& Unit);
void CancelOrder(const CP_UNITINFO& Unit);
void CheckPrice(const string Code);
void CheckConclusion(const CP_CONCLUSIONINFO& ConclusionInfo);
void CPLog(const string fmt, ...);
};