This commit is contained in:
2013-07-17 03:29:34 +00:00
parent d77f19cb16
commit 328618ed56
7 changed files with 193 additions and 57 deletions

View File

@@ -16,7 +16,7 @@
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// 한국어 resources
// Korean resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_KOR)
#ifdef _WIN32
@@ -85,14 +85,14 @@ FONT 9, "MS Shell Dlg", 0, 0, 0x1
BEGIN
CONTROL "매도호가",IDC_RADIO_BID,"Button",BS_AUTORADIOBUTTON | WS_GROUP,7,7,43,10
CONTROL "매수호가",IDC_RADIO_ASK,"Button",BS_AUTORADIOBUTTON,7,19,43,10
EDITTEXT IDC_EDIT_ORDERINGPRICE,88,14,67,12,ES_AUTOHSCROLL | ES_NUMBER
EDITTEXT IDC_EDIT_ORDERINGPRICE,88,14,67,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER
PUSHBUTTON "잔고 확인",IDC_BUTTON_REFRESH_BALANCE,262,7,50,14
EDITTEXT IDC_EDIT_ORDERING_TICK_MIN,7,37,67,12,ES_AUTOHSCROLL | ES_NUMBER
EDITTEXT IDC_EDIT_ORDERING_TICK_MAX,101,37,67,12,ES_AUTOHSCROLL | ES_NUMBER
EDITTEXT IDC_EDIT4,14,85,22,12,ES_AUTOHSCROLL | ES_NUMBER
EDITTEXT IDC_EDIT5,93,85,22,12,ES_AUTOHSCROLL | ES_NUMBER
EDITTEXT IDC_EDIT6,172,85,22,12,ES_AUTOHSCROLL | ES_NUMBER
EDITTEXT IDC_EDIT7,251,85,22,12,ES_AUTOHSCROLL | ES_NUMBER
EDITTEXT IDC_EDIT_ORDERING_TICK_MIN,7,37,67,12,ES_RIGHT | ES_AUTOHSCROLL
EDITTEXT IDC_EDIT_ORDERING_TICK_MAX,101,37,67,12,ES_RIGHT | ES_AUTOHSCROLL
EDITTEXT IDC_EDIT_SELL_TICK,14,85,22,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER
EDITTEXT IDC_EDIT_LOSS_CUT_TICK,93,85,22,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER
EDITTEXT IDC_EDIT_TRAING_TICK,172,85,22,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER
EDITTEXT IDC_EDIT_CANCEL_DELAY,251,85,22,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER
CONTROL "콜옵션",IDC_RADIO_CALLOP,"Button",BS_AUTORADIOBUTTON | WS_GROUP,93,124,37,10
CONTROL "풋옵션",IDC_RADIO_PUTOP,"Button",BS_AUTORADIOBUTTON,139,124,37,10
PUSHBUTTON "검색",IDC_BUTTON_SEARCH,190,123,50,14
@@ -169,7 +169,7 @@ BEGIN
END
#endif // APSTUDIO_INVOKED
#endif // 한국어 resources
#endif // Korean resources
/////////////////////////////////////////////////////////////////////////////

View File

@@ -17,11 +17,16 @@ CCPRobotDlg::CCPRobotDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCPRobotDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_pDataMgr = NULL;
m_pOpCode = NULL;
m_pOpMst = NULL;
}
void CCPRobotDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST_ITEMS, m_ResultList);
}
BEGIN_MESSAGE_MAP(CCPRobotDlg, CDialog)
@@ -31,6 +36,11 @@ BEGIN_MESSAGE_MAP(CCPRobotDlg, CDialog)
ON_BN_CLICKED(IDC_BUTTON_REFRESH_BALANCE, &CCPRobotDlg::OnBnClickedButtonRefreshBalance)
ON_WM_CREATE()
ON_WM_DESTROY()
ON_BN_CLICKED(IDC_BUTTON_START_DEAL, &CCPRobotDlg::OnBnClickedButtonStartDeal)
ON_BN_CLICKED(IDC_BUTTON_SEARCH, &CCPRobotDlg::OnBnClickedButtonSearch)
ON_BN_CLICKED(IDC_RADIO_BID, &CCPRobotDlg::OnBnClickedRadioBid)
ON_BN_CLICKED(IDC_RADIO_ASK, &CCPRobotDlg::OnBnClickedRadioAsk)
ON_EN_CHANGE(IDC_EDIT_ORDERINGPRICE, &CCPRobotDlg::OnEnChangeEditOrderingprice)
END_MESSAGE_MAP()
@@ -55,32 +65,41 @@ int CCPRobotDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
return -1;
// TODO: Add your specialized creation code here
CoInitialize(NULL);
CoInitializeEx(NULL, COINIT_MULTITHREADED);
g_pTdUtil.CreateInstance(__uuidof(CpTdUtil));
short iInitResult = g_pTdUtil->TradeInit(0);
switch(iInitResult)
{
case -1:
MessageBox("TradeInit 오류");
return -2;
break;
//short iInitResult = g_pTdUtil->TradeInit(0);
//switch(iInitResult)
//{
//case -1:
// MessageBox("TradeInit 오류");
// return -2;
// break;
case 1:
MessageBox("업무 키 잘못 입력됨");
return -2;
break;
//case 1:
// MessageBox("업무 키 잘못 입력됨");
// return -2;
// break;
case 2:
MessageBox("계좌 비밀번호 잘못 입력됨");
return -2;
break;
//case 2:
// MessageBox("계좌 비밀번호 잘못 입력됨");
// return -2;
// break;
//case 3:
// MessageBox("취소됨");
// return -2;
// break;
//}
//OnBnClickedButtonRefreshBalance();
m_pDataMgr = new CDataMgr();
m_pDataMgr->LoadFromFile();
m_pOpCode.CreateInstance(__uuidof(CpOptionCode));
m_pOpMst.CreateInstance(CLSID_OptionMst);
case 3:
MessageBox("취소됨");
return -2;
break;
}
return 0;
}
@@ -90,14 +109,16 @@ void CCPRobotDlg::OnDestroy()
CDialog::OnDestroy();
// TODO: Add your message handler code here
g_pTdUtil.Release();
CoUninitialize();
m_pOpMst.Release();
m_pOpCode.Release();
SAFE_DELETE(m_pDataMgr);
}
BOOL CCPRobotDlg::DestroyWindow()
{
// TODO: Add your specialized code here and/or call the base class
g_pTdUtil.Release();
CoUninitialize();
return CDialog::DestroyWindow();
}
@@ -131,38 +152,121 @@ void CCPRobotDlg::OnPaint()
}
}
// 사용자가 최소화된 창을 끄는 동안에 커서가 표시되도록 시스템에서
// 이 함수를 호출합니다.
// 사용자가 최소화된 창을 끄는 동안에 커서가 표시되도록 시스템에서 이 함수를 호출합니다.
HCURSOR CCPRobotDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void CCPRobotDlg::UpdateDataCustom(const BOOL bWndToVariable)
{
if(bWndToVariable == TRUE)
{
m_pDataMgr->m_bSell = (((CButton*)GetDlgItem(IDC_RADIO_BID))->GetCheck() == 1);
m_pDataMgr->m_iAmountSet = GetDlgItemInt(IDC_EDIT_ORDERINGPRICE);
m_pDataMgr->m_iMinPriceSet = GetDlgItemInt(IDC_EDIT_ORDERING_TICK_MIN);
m_pDataMgr->m_iMaxPriceSet = GetDlgItemInt(IDC_EDIT_ORDERING_TICK_MAX);
m_pDataMgr->m_iSellTick = GetDlgItemInt(IDC_EDIT_SELL_TICK);
m_pDataMgr->m_iLossCutTick = GetDlgItemInt(IDC_EDIT_LOSS_CUT_TICK);
m_pDataMgr->m_iTrailingTick = GetDlgItemInt(IDC_EDIT_TRAING_TICK);
m_pDataMgr->m_iCancelDelay = GetDlgItemInt(IDC_EDIT_CANCEL_DELAY);
m_pDataMgr->m_bCallOption = (((CButton*)GetDlgItem(IDC_RADIO_CALLOP))->GetCheck() == 1);
}
else
{
((CButton*)GetDlgItem(IDC_RADIO_BID))->SetCheck(m_pDataMgr->m_bSell);
SetDlgItemInt(IDC_EDIT_ORDERINGPRICE, m_pDataMgr->m_iAmountSet);
SetDlgItemInt(IDC_EDIT_ORDERING_TICK_MIN, m_pDataMgr->m_iMinPriceSet);
SetDlgItemInt(IDC_EDIT_ORDERING_TICK_MAX, m_pDataMgr->m_iMaxPriceSet);
SetDlgItemInt(IDC_EDIT_SELL_TICK, m_pDataMgr->m_iSellTick);
SetDlgItemInt(IDC_EDIT_LOSS_CUT_TICK, m_pDataMgr->m_iLossCutTick);
SetDlgItemInt(IDC_EDIT_TRAING_TICK, m_pDataMgr->m_iTrailingTick);
SetDlgItemInt(IDC_EDIT_CANCEL_DELAY, m_pDataMgr->m_iCancelDelay);
((CButton*)GetDlgItem(IDC_RADIO_CALLOP))->SetCheck(m_pDataMgr->m_bCallOption);
}
}
void CCPRobotDlg::OnBnClickedButtonRefreshBalance()
{
// TODO: Add your control notification handler code here
UpdateDataCustom(TRUE);
ICpTdDibPtr pTd0721 = NULL;
pTd0721.CreateInstance(__uuidof(CpTd0721F));
pTd0721->SetInputValue(0, "117126165");
pTd0721->SetInputValue(0, "412120700");
//pTd0721->SetInputValue(0, "412120700");
pTd0721->SetInputValue(1, "50");
pTd0721->SetInputValue(2, "50");
pTd0721->SetInputValue(3, "10");
CString Message;
do
{
pTd0721->BlockRequest();
m_pDataMgr->m_iBalance = pTd0721->GetHeaderValue(9);
Message = "현금주문가능액 : ";
Message += pTd0721->GetHeaderValue(9);
Message.Format("현금주문가능액 : %d", m_pDataMgr->m_iBalance);
SetDlgItemText(IDC_STATIC_BALANCE, Message.GetString());
} while (pTd0721->Continue);
pTd0721.Release();
}
void CCPRobotDlg::OnBnClickedButtonSearch()
{
// TODO: Add your control notification handler code here
//m_ResultList.
short iCodeCnt = m_pOpCode->GetCount();
CString Code;
float afSellingPrice[5];
float afBuyingPrice[5];
CString Msg;
for(int i=0; i<iCodeCnt; i++)
{
Code = (LPCSTR)(_bstr_t)m_pOpCode->GetData(0, i);
m_pOpMst->SetInputValue(0, (LPCSTR)Code);
m_pOpMst->BlockRequest();
afSellingPrice[0] = m_pOpMst->GetHeaderValue(58);
afBuyingPrice[0] = m_pOpMst->GetHeaderValue(59);
Msg.Format("%s/%d/%d", Code, afSellingPrice[0], afBuyingPrice[0]);
m_ResultList.AddString(Msg);
}
}
void CCPRobotDlg::OnBnClickedButtonStartDeal()
{
// TODO: Add your control notification handler code here
}
void CCPRobotDlg::OnBnClickedRadioBid()
{
// TODO: Add your control notification handler code here
m_pDataMgr->m_bSell = (((CButton*)GetDlgItem(IDC_RADIO_BID))->GetCheck() == 1);
}
void CCPRobotDlg::OnBnClickedRadioAsk()
{
// TODO: Add your control notification handler code here
m_pDataMgr->m_bSell = (((CButton*)GetDlgItem(IDC_RADIO_BID))->GetCheck() == 1);
}
void CCPRobotDlg::OnEnChangeEditOrderingprice()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}

View File

@@ -2,7 +2,8 @@
//
#pragma once
#include "DataMgr.h"
#include "afxwin.h"
// CCPRobotDlg 대화 상자
class CCPRobotDlg : public CDialog
@@ -14,22 +15,35 @@ public:
// 대화 상자 데이터입니다.
enum { IDD = IDD_CPROBOT_DIALOG };
afx_msg void OnBnClickedButtonRefreshBalance();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnDestroy();
afx_msg void OnBnClickedButtonStartDeal();
afx_msg void OnBnClickedButtonSearch();
afx_msg void OnBnClickedRadioBid();
afx_msg void OnBnClickedRadioAsk();
afx_msg void OnEnChangeEditOrderingprice();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
virtual BOOL DestroyWindow();
// 구현입니다.
protected:
HICON m_hIcon;
// 생성된 메시지 맵 함수
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedButtonRefreshBalance();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnDestroy();
HICON m_hIcon;
private:
void UpdateDataCustom(const BOOL bWndToVariable);
CListBox m_ResultList;
CDataMgr* m_pDataMgr;
ICpOptionCodePtr m_pOpCode;
IDibPtr m_pOpMst;
};

View File

@@ -3,22 +3,35 @@
CDataMgr::CDataMgr()
{
m_bSell = TRUE;
m_iAmountSet = 0;
m_iBalance = 0;
m_iMinPriceSet = 0;
m_iMaxPriceSet = 0;
m_iSellTick = 0;
m_iLossCutTick = 0;
m_iTrailingTick = 0;
m_iCancelDelay = 0;
m_bCallOption = TRUE;
}
CDataMgr::~CDataMgr()
{
SaveToFile();
}
void CDataMgr::SaveToFile(void);
void CDataMgr::SaveToFile(void)
{
FILE* fp = fopen("setting.ini", "w");
FILE* fp = NULL;
fopen_s(&fp, "setting.ini", "w");
fclose(fp);
fp = NULL;
}
void CDataMgr::LoadFromFile(void)
{
FILE* fp = fopen("setting.ini", "r");
FILE* fp = NULL;
fopen_s(&fp, "setting.ini", "r");
fclose(fp);
fp = NULL;
}

View File

@@ -10,18 +10,17 @@ public:
void SaveToFile(void);
void LoadFromFile(void);
private:
bool m_bSell;
int m_iAmountSet;
int m_iAmountCur;
int m_iBalance;
int m_iMinPriceSet; // tick
int m_iMaxPriceSet; // tick
int m_iSellTick;
int m_iStopLossTick;
int m_iLossCutTick;
int m_iTrailingTick;
int m_iCancelDelay;
bool m_bCallOption;
};
#endif

View File

@@ -13,9 +13,14 @@
#define IDC_BUTTON_REFRESH_BALANCE 1005
#define IDC_RADIO_BID 1006
#define IDC_EDIT4 1007
#define IDC_EDIT_SELL_TICK 1007
#define IDC_EDIT5 1008
#define IDC_EDIT_LOSS_CUT_TICK 1008
#define IDC_EDIT6 1009
#define IDC_EDIT_TRAING_TICK 1009
#define IDC_EDIT7 1010
#define IDC_EDIT_HAVE_TIME_MAX 1010
#define IDC_EDIT_CANCEL_DELAY 1010
#define IDC_STATIC_BALANCE 1011
#define IDC_RADIO_CALLOP 1012
#define IDC_RADIO_PUTOP 1013

View File

@@ -36,7 +36,8 @@
//#include <comdef.h>
#import "c:\daishin\CYBOSPLUS\cpdib.dll" no_namespace named_guids
#import "c:\daishin\cybosplus\cpdib.dll" no_namespace named_guids
#import "c:\daishin\cybosplus\cptrade.dll" no_namespace named_guids
#import "c:\daishin\cybosplus\cputil.dll" no_namespace named_guids
#define SAFE_DELETE(p) { if(p) delete p; p = NULL; }