Skip to content

Commit a80464f

Browse files
committed
CoinBene API CSharp Demos,first commit
0 parents  commit a80464f

35 files changed

+667
-0
lines changed

API CShart Demo.sln

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.24720.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "API", "API\API.csproj", "{A90588E3-5041-4320-9AFB-32B89A8D33C4}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{8E7D27D7-B0C2-47EC-A60C-DB85DAAD77D2}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{A90588E3-5041-4320-9AFB-32B89A8D33C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{A90588E3-5041-4320-9AFB-32B89A8D33C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{A90588E3-5041-4320-9AFB-32B89A8D33C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{A90588E3-5041-4320-9AFB-32B89A8D33C4}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{8E7D27D7-B0C2-47EC-A60C-DB85DAAD77D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{8E7D27D7-B0C2-47EC-A60C-DB85DAAD77D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{8E7D27D7-B0C2-47EC-A60C-DB85DAAD77D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{8E7D27D7-B0C2-47EC-A60C-DB85DAAD77D2}.Release|Any CPU.Build.0 = Release|Any CPU
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
EndGlobal

API/API.csproj

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{A90588E3-5041-4320-9AFB-32B89A8D33C4}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>API</RootNamespace>
11+
<AssemblyName>API</AssemblyName>
12+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<DebugSymbols>true</DebugSymbols>
17+
<DebugType>full</DebugType>
18+
<Optimize>false</Optimize>
19+
<OutputPath>bin\Debug\</OutputPath>
20+
<DefineConstants>DEBUG;TRACE</DefineConstants>
21+
<ErrorReport>prompt</ErrorReport>
22+
<WarningLevel>4</WarningLevel>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25+
<DebugType>pdbonly</DebugType>
26+
<Optimize>true</Optimize>
27+
<OutputPath>bin\Release\</OutputPath>
28+
<DefineConstants>TRACE</DefineConstants>
29+
<ErrorReport>prompt</ErrorReport>
30+
<WarningLevel>4</WarningLevel>
31+
</PropertyGroup>
32+
<ItemGroup>
33+
<Reference Include="System" />
34+
<Reference Include="System.Core" />
35+
<Reference Include="System.Xml.Linq" />
36+
<Reference Include="System.Data.DataSetExtensions" />
37+
<Reference Include="Microsoft.CSharp" />
38+
<Reference Include="System.Data" />
39+
<Reference Include="System.Net.Http" />
40+
<Reference Include="System.Xml" />
41+
</ItemGroup>
42+
<ItemGroup>
43+
<Compile Include="Properties\AssemblyInfo.cs" />
44+
<Compile Include="Service.cs" />
45+
<Compile Include="utils.cs" />
46+
</ItemGroup>
47+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
48+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
49+
Other similar extension points exist, see Microsoft.Common.targets.
50+
<Target Name="BeforeBuild">
51+
</Target>
52+
<Target Name="AfterBuild">
53+
</Target>
54+
-->
55+
</Project>

API/Properties/AssemblyInfo.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// 有关程序集的一般信息由以下
6+
// 控制。更改这些特性值可修改
7+
// 与程序集关联的信息。
8+
[assembly: AssemblyTitle("API")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("API")]
13+
[assembly: AssemblyCopyright("Copyright © 2018")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
//将 ComVisible 设置为 false 将使此程序集中的类型
18+
//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19+
//请将此类型的 ComVisible 特性设置为 true。
20+
[assembly: ComVisible(false)]
21+
22+
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23+
[assembly: Guid("a90588e3-5041-4320-9afb-32b89a8d33c4")]
24+
25+
// 程序集的版本信息由下列四个值组成:
26+
//
27+
// 主版本
28+
// 次版本
29+
// 生成号
30+
// 修订号
31+
//
32+
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33+
// 方法是按如下所示使用“*”: :
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

API/Service.cs

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Net.Http;
7+
using System.Security.Cryptography;
8+
9+
namespace API
10+
{
11+
public class Service
12+
{
13+
private static readonly HttpClient client = new HttpClient();
14+
private static string market_url = "http://api.coinbene.com/v1/market/";
15+
private static string trade_url = "http://api.coinbene.com/v1/trade/";
16+
17+
18+
//获取最新价
19+
public static Task<string> get_ticker(string symbol)
20+
{
21+
var url = market_url + "ticker?symbol=" + symbol;
22+
return utils.http_get_nosign(url);
23+
}
24+
25+
//获取挂单
26+
public static Task<string> get_orderbook(string symbol, int depth = 200)
27+
{
28+
var url = market_url + "orderbook?symbol=" + symbol + "&depth=" + depth;
29+
return utils.http_get_nosign(url);
30+
}
31+
32+
//获取成交记录
33+
public static Task<string> get_trade(string symbol, int size = 300)
34+
{
35+
/*
36+
size:获取记录数量,按照时间倒序传输。默认300
37+
*/
38+
var url = market_url + "trades?symbol=" + symbol + "&size=" + size;
39+
return utils.http_get_nosign(url);
40+
}
41+
42+
43+
44+
//查询账户余额
45+
public static Task<string> post_balance(Dictionary<string, string> dic)
46+
{
47+
/*
48+
以字典形式传参
49+
apiid:可在coinbene申请,
50+
secret: 个人密钥(请勿透露给他人),
51+
timestamp: 时间戳,
52+
account: 默认为exchange,
53+
*/
54+
var url = trade_url + "balance";
55+
return utils.http_post_sign(url, dic);
56+
}
57+
58+
59+
//下单
60+
public static Task<string> post_order_place(Dictionary<string, string> dic)
61+
{
62+
/*
63+
以字典形式传参
64+
apiid, symbol, timestamp
65+
type: 可选 buy-limit / sell - limit
66+
price: 购买单价
67+
quantity:购买数量
68+
*/
69+
var url = trade_url + "order/place";
70+
return utils.http_post_sign(url, dic);
71+
}
72+
73+
74+
// 查询委托
75+
public static Task<string> post_info(Dictionary<string, string> dic)
76+
{
77+
/*
78+
以字典形式传参
79+
apiid, timestamp, secret, orderid
80+
*/
81+
var url = trade_url + "order/info";
82+
return utils.http_post_sign(url, dic);
83+
}
84+
85+
86+
87+
//查询当前委托
88+
public static Task<string> post_open_orders(Dictionary<string, string> dic) {
89+
/*
90+
以字典形式传参
91+
apiid, timestamp, secret, symbol
92+
*/
93+
var url = trade_url + "order/open-orders";
94+
return utils.http_post_sign(url, dic);
95+
}
96+
97+
//撤单
98+
public static Task<string> post_cancel(Dictionary<string, string> dic) {
99+
/*
100+
以字典形式传参
101+
apiid, timestamp, secret, orderid
102+
*/
103+
var url = trade_url + "order/cancel";
104+
return utils.http_post_sign(url, dic);
105+
}
106+
107+
108+
}
109+
}

API/bin/Debug/API.dll

10 KB
Binary file not shown.

API/bin/Debug/API.pdb

19.5 KB
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
c:\users\wangd\documents\visual studio 2015\Projects\BlockChainTrade\API CShart Demo\API\bin\Debug\API.dll
2+
c:\users\wangd\documents\visual studio 2015\Projects\BlockChainTrade\API CShart Demo\API\bin\Debug\API.pdb
3+
c:\users\wangd\documents\visual studio 2015\Projects\BlockChainTrade\API CShart Demo\API\obj\Debug\API.csprojResolveAssemblyReference.cache
4+
c:\users\wangd\documents\visual studio 2015\Projects\BlockChainTrade\API CShart Demo\API\obj\Debug\API.dll
5+
c:\users\wangd\documents\visual studio 2015\Projects\BlockChainTrade\API CShart Demo\API\obj\Debug\API.pdb
Binary file not shown.

API/obj/Debug/API.dll

10 KB
Binary file not shown.

API/obj/Debug/API.pdb

19.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)