트레일링, 손절 추가
This commit is contained in:
72
ULTrader.cs
72
ULTrader.cs
@@ -15,6 +15,9 @@ namespace upper_limit_crawler
|
||||
|
||||
string[] m_astrAccounts = null;
|
||||
|
||||
object lockBuy = new object();
|
||||
object lockSell = new object();
|
||||
|
||||
public ULTrader()
|
||||
{
|
||||
m_Util.TradeInit();
|
||||
@@ -111,50 +114,59 @@ namespace upper_limit_crawler
|
||||
|
||||
public void Buy(string strCode, int iUnitPrice, int iBidAmount)
|
||||
{
|
||||
int iCnt = iBidAmount/ iUnitPrice;
|
||||
iCnt = 1;
|
||||
lock(lockBuy)
|
||||
{
|
||||
int iCnt = iBidAmount / iUnitPrice;
|
||||
iCnt = 1;
|
||||
|
||||
m_Td0311Bid.SetInputValue(0, "2");
|
||||
m_Td0311Bid.SetInputValue(1, m_astrAccounts[0]);
|
||||
m_Td0311Bid.SetInputValue(3, strCode);
|
||||
m_Td0311Bid.SetInputValue(4, iCnt); // 수량
|
||||
m_Td0311Bid.SetInputValue(5, iUnitPrice); // 단가
|
||||
m_Td0311Bid.SetInputValue(7, "0");
|
||||
m_Td0311Bid.SetInputValue(8, "03");
|
||||
m_Td0311Bid.SetInputValue(0, "2");
|
||||
m_Td0311Bid.SetInputValue(1, m_astrAccounts[0]);
|
||||
m_Td0311Bid.SetInputValue(3, strCode);
|
||||
m_Td0311Bid.SetInputValue(4, iCnt); // 수량
|
||||
m_Td0311Bid.SetInputValue(5, iUnitPrice); // 단가
|
||||
m_Td0311Bid.SetInputValue(7, "0");
|
||||
m_Td0311Bid.SetInputValue(8, "03");
|
||||
|
||||
m_Td0311Bid.BlockRequest();
|
||||
m_Td0311Bid.BlockRequest();
|
||||
}
|
||||
}
|
||||
|
||||
public void Sell(string strCode, int iUnitPrice, int iCnt)
|
||||
{
|
||||
//long iCnt = (long)Math.Floor(fAskAmount/fCurPrice);
|
||||
//iCnt=1;
|
||||
lock (lockSell)
|
||||
{
|
||||
//long iCnt = (long)Math.Floor(fAskAmount/fCurPrice);
|
||||
//iCnt=1;
|
||||
|
||||
m_Td0311Ask.SetInputValue(0, "1");
|
||||
m_Td0311Ask.SetInputValue(1, m_astrAccounts[0]);
|
||||
m_Td0311Ask.SetInputValue(3, strCode);
|
||||
m_Td0311Ask.SetInputValue(4, iCnt); // 수량
|
||||
m_Td0311Ask.SetInputValue(5, iUnitPrice); // 단가
|
||||
m_Td0311Ask.SetInputValue(7, "0");
|
||||
m_Td0311Ask.SetInputValue(8, "03");
|
||||
m_Td0311Ask.SetInputValue(0, "1");
|
||||
m_Td0311Ask.SetInputValue(1, m_astrAccounts[0]);
|
||||
m_Td0311Ask.SetInputValue(3, strCode);
|
||||
m_Td0311Ask.SetInputValue(4, iCnt); // 수량
|
||||
m_Td0311Ask.SetInputValue(5, iUnitPrice); // 단가
|
||||
m_Td0311Ask.SetInputValue(7, "0");
|
||||
m_Td0311Ask.SetInputValue(8, "03");
|
||||
|
||||
m_Td0311Ask.BlockRequest();
|
||||
m_Td0311Ask.BlockRequest();
|
||||
}
|
||||
}
|
||||
|
||||
public void SellCurPrice(string strCode, int iCnt)
|
||||
{
|
||||
//long iCnt = (long)Math.Floor(fAskAmount/fCurPrice);
|
||||
//iCnt=1;
|
||||
lock (lockSell)
|
||||
{
|
||||
//long iCnt = (long)Math.Floor(fAskAmount/fCurPrice);
|
||||
//iCnt=1;
|
||||
|
||||
m_Td0311Ask.SetInputValue(0, "1");
|
||||
m_Td0311Ask.SetInputValue(1, m_astrAccounts[0]);
|
||||
m_Td0311Ask.SetInputValue(3, strCode);
|
||||
m_Td0311Ask.SetInputValue(4, iCnt); // 수량
|
||||
m_Td0311Ask.SetInputValue(5, 0); // 단가
|
||||
m_Td0311Ask.SetInputValue(7, "0");
|
||||
m_Td0311Ask.SetInputValue(8, "03");
|
||||
m_Td0311Ask.SetInputValue(0, "1");
|
||||
m_Td0311Ask.SetInputValue(1, m_astrAccounts[0]);
|
||||
m_Td0311Ask.SetInputValue(3, strCode);
|
||||
m_Td0311Ask.SetInputValue(4, iCnt); // 수량
|
||||
m_Td0311Ask.SetInputValue(5, 0); // 단가
|
||||
m_Td0311Ask.SetInputValue(7, "0");
|
||||
m_Td0311Ask.SetInputValue(8, "03");
|
||||
|
||||
m_Td0311Ask.BlockRequest();
|
||||
m_Td0311Ask.BlockRequest();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user