본문 바로가기

취미/코인

c# 기반 업비트 API를 활용한 자동매매 - 개발 환경 설치하기

1. Web에서 .NET 5.0 SDK를 설치하다.

https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/sdk-5.0.405-windows-x64-installer

 

Download .NET 5.0 SDK (v5.0.405) - Windows x64 Installer

 

dotnet.microsoft.com

 

2. Visual Studio Installer로 ".NET 플랫폼 간 개발"도구를 설치한다.

 

3.  Visual Studio 2019로 "콘솔 애플리케이션"을 생성한다.

2022.02.09 - [개발도구/Visual Studio] - Visual Stuido 2019 Community 설치하기

 

Visual Stuido 2019 Community 설치하기

1. 다운로드 링크 Visual Studio Community 2019 : 무료 Visual Studio Professional  2019 : 유료(개인) Visual Studio Enterprise  2019 : 유료(기업) https://docs.microsoft.com/ko-kr/visualstudio/relea..

gororoman.tistory.com

 

 

대상 프레임워크는 ".NET 5.0"으로 설정한다.

 

4. NuGet 패키지 관리자를 이용하여 RestSharp 106.15.0을 설치한다. 

 반드시, 버전은 106.15.0으로 설정한다.

RestSharp의 릴리즈 노트에 따르면 107.0.0 버전부터 IRestResponse가 RestResponse로 변경되었다.

https://github.com/restsharp/RestSharp/releases

 

Releases · restsharp/RestSharp

Simple REST and HTTP API Client for .NET. Contribute to restsharp/RestSharp development by creating an account on GitHub.

github.com

 

5. NuGet 패키지 관리자를 이용하여 Json 13.0.1을 설치한다. 

 

6. 업비트에서 제공하는 샘플 코드를 삽입한다.

https://docs.upbit.com/reference/%EB%A7%88%EC%BC%93-%EC%BD%94%EB%93%9C-%EC%A1%B0%ED%9A%8C

 

업비트 개발자 센터

업비트 Open API 사용을 위한 개발 문서를 제공 합니다.업비트 Open API 사용하여 다양한 앱과 프로그램을 제작해보세요.

docs.upbit.com

using System;

using RestSharp;
using Newtonsoft.Json.Linq;


namespace UpbitDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = new RestClient("https://api.upbit.com/v1/market/all?isDetails=false");
            var request = new RestRequest(Method.GET);
            request.AddHeader("Accept", "application/json");
            IRestResponse response = client.Execute(request);

            JArray jArray = JArray.Parse(response.Content);
            Console.WriteLine(jArray.ToString());
        }
    }
}

 

7. 프로젝트 파일을 실행한다.

 

끝.