하아찡

[C#/WPF/수정] Upbit 프로젝트 Chart 매수 매도 선 추가 본문

C#/코인프로그램 - 코드

[C#/WPF/수정] Upbit 프로젝트 Chart 매수 매도 선 추가

하아찡 2023. 12. 8. 20:09

 

 

프로그램 내부에서 주문했을때

프로그램 내부에서 주문했을때

 

 

외부 기기에서 주문했을때

 

 

 

추가 및 변경 코드

private void GetOrderList() { GetOrderList(true); }
private void GetOrderList(bool b)
{
    if(Market != "")
    {
        Order Orderfnc = new Order();
        List<OrderList> list = Task.Run(() => Orderfnc.OrderListAsync(Market, "wait")).Result;
        int cnt = PrintChartYAxis.Count;
        if (cnt >= 5)
        {
            for (int i = 5; i < cnt; i++)
            {
                PrintChartYAxis.RemoveAt(5);
            }
        }
        foreach(var item in list)
        {
            ChartSideCursor i = new ChartSideCursor();
            i.X = 0;
            i.Type = item.side;
            i.CursorValue = item.price;
            i.BackColor = item.side == "bid" ?  MyColors.ColorChartOrderBid : MyColors.ColorChartOrderAsk;
            i.Color = item.side == "bid" ? MyColors.ColorChartOrderBidText : MyColors.ColorChartOrderAskText;

            double value = Convert.ToDouble(i.CursorValue);
            if (value >= 0)
            {
                double yvalue = (GridHeight * ((MaxPrice - value) / (MaxPrice - MinPrice))) + GapYAxis;

                //차트 범위 초과했을경우 안보이게 수정
                if (GridHeight <= yvalue || 0 >= yvalue)
                    yvalue = -100;

                i.Y = yvalue;
            }
            else
            {
                i.Y = -100;
            }

            PrintChartYAxis.Add(i);
        }
    }
    
}
/// <summary>
/// 해당 코인이 보유중일경우 차트에 출력.
/// 23.12.08
/// </summary>
private void GetCoinPrice()
{
    if (Market == "")
        return;

    if (PrintChartYAxis[(int)YAxis.Avg].Y <= 0)
    {
        UpbitFunctions.Accounts FAccount = new UpbitFunctions.Accounts();
        double price = FAccount.GetAccountCoinPrice(Market);
        PrintChartYAxis[(int)YAxis.Avg].CursorValue = price.ToString();
    }
    
    for(int i = (int)YAxis.Avg; i < PrintChartYAxis.Count; i++)
    {
        if (PrintChartYAxis[i].Type == "bid" || PrintChartYAxis[i].Type == "ask" || PrintChartYAxis[i].Type == "AvgPrice")
        {

            double value = Convert.ToDouble(PrintChartYAxis[i].CursorValue);
            if (value >= 0)
            {
                double yvalue = (GridHeight * ((MaxPrice - value) / (MaxPrice - MinPrice))) + GapYAxis;

                //차트 범위 초과했을경우 안보이게 수정
                if (GridHeight <= yvalue || 0 >= yvalue)
                    yvalue = -100;

                PrintChartYAxis[i].Y = yvalue;
            }
            else
            {
                PrintChartYAxis[i].Y = -100;
            }

        }
    }
}
반응형