forked from aabiryukov/CryptoMarketApi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alexander Biryukov
committed
Nov 6, 2017
1 parent
233af37
commit 82efcb1
Showing
149 changed files
with
8,738 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,13 @@ | ||
# CryptoMarketApi | ||
.Net API for most popular Crypto exchanges | ||
.Net API for most popular Crypto Exchanges | ||
|
||
# Implemented Exchanges | ||
- Bitfinex | ||
- Bitstamp | ||
- BTCChina | ||
- BTC-E | ||
- Huobi | ||
- OKCoin | ||
|
||
# Usage examples | ||
See project src\ApiTest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform> | ||
<ProductVersion>8.0.30703</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{948B9B9B-8CED-4A3D-AF73-A8147AF93B26}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>ApiTest</RootNamespace> | ||
<AssemblyName>ApiTest</AssemblyName> | ||
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion> | ||
<TargetFrameworkProfile> | ||
</TargetFrameworkProfile> | ||
<FileAlignment>512</FileAlignment> | ||
<SccProjectName>SAK</SccProjectName> | ||
<SccLocalPath>SAK</SccLocalPath> | ||
<SccAuxPath>SAK</SccAuxPath> | ||
<SccProvider>SAK</SccProvider> | ||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> | ||
<RestorePackages>true</RestorePackages> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'"> | ||
<DebugSymbols>true</DebugSymbols> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<DebugType>full</DebugType> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<ErrorReport>prompt</ErrorReport> | ||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'"> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<Optimize>true</Optimize> | ||
<DebugType>pdbonly</DebugType> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<ErrorReport>prompt</ErrorReport> | ||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> | ||
<RunCodeAnalysis>false</RunCodeAnalysis> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="BitfinexTest.cs" /> | ||
<Compile Include="BitstampTest.cs" /> | ||
<Compile Include="BtcChinaTest.cs" /> | ||
<Compile Include="BtceTest.cs" /> | ||
<Compile Include="HuobiTest.cs" /> | ||
<Compile Include="OKCoinTest.cs" /> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="app.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\BitfinexApi\BitfinexApi.csproj"> | ||
<Project>{19fa129a-4457-43b3-9ba6-78a8ce8e329c}</Project> | ||
<Name>BitfinexApi</Name> | ||
</ProjectReference> | ||
<ProjectReference Include="..\BtcChinaApi\BtcChinaApi.csproj"> | ||
<Project>{32f257c3-e814-43aa-adfd-ec05fd351cd9}</Project> | ||
<Name>BtcChinaApi</Name> | ||
</ProjectReference> | ||
<ProjectReference Include="..\BtceApi\BtceApi.csproj"> | ||
<Project>{5c94acd3-1172-4fad-bcae-bb7b201d7521}</Project> | ||
<Name>BtceApi</Name> | ||
</ProjectReference> | ||
<ProjectReference Include="..\BitstampApi\BitstampApi.csproj"> | ||
<Project>{E36ECD12-0B89-415A-BD60-7F698AA79152}</Project> | ||
<Name>BitstampApi</Name> | ||
</ProjectReference> | ||
<ProjectReference Include="..\HuobiApi\HuobiAPI.csproj"> | ||
<Project>{9e2333e7-0c1b-4379-ba2b-398d423e465c}</Project> | ||
<Name>HuobiAPI</Name> | ||
</ProjectReference> | ||
<ProjectReference Include="..\OKCoinApi\OKCoinAPI.csproj"> | ||
<Project>{d76daa8b-0266-4649-a005-1aea4141628f}</Project> | ||
<Name>OKCoinAPI</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Bitfinex; | ||
using Bitfinex.Json; | ||
|
||
namespace ApiTest | ||
{ | ||
class BitfinexTest | ||
{ | ||
private const string ApiKey = "PUT-HERE-API-KEY"; | ||
private const string ApiSecret = "PUT-HERE-API-SECRET"; | ||
|
||
|
||
public static void Test() | ||
{ | ||
/* | ||
var ticker = BitfinexApi.GetPublicTicker(BtcInfo.PairTypeEnum.btcusd, BtcInfo.BitfinexUnauthenicatedCallsEnum.pubticker); | ||
Console.WriteLine(ticker.LastPrice); | ||
var trades = BitfinexApi.GetPairTrades(BtcInfo.PairTypeEnum.btcusd, BtcInfo.BitfinexUnauthenicatedCallsEnum.trades); | ||
Console.WriteLine("trades.Count=" + trades.Count); | ||
var orderBook = BitfinexApi.GetOrderBook(BtcInfo.PairTypeEnum.btcusd); | ||
Console.WriteLine("orderBook.Asks.Length={0}, orderBook.Bids.Length={1}", orderBook.Asks.Length, orderBook.Bids.Length); | ||
*/ | ||
var api = new BitfinexApi(ApiKey, ApiSecret); | ||
|
||
var balances = api.GetBalances(); | ||
var usd = balances.FirstOrDefault(x => x.Type == "exchange" && x.Currency == "usd"); | ||
var btc = balances.FirstOrDefault(x => x.Type == "exchange" && x.Currency == "btc"); | ||
Console.WriteLine("usd: " + usd); | ||
Console.WriteLine("btc: " + btc); | ||
|
||
foreach (var balance in balances) | ||
{ | ||
Console.WriteLine("balance: " + balance); | ||
} | ||
|
||
var info = api.GetAccountInformation(); | ||
Console.WriteLine("Account info: {0}", info); | ||
|
||
var openOrders = api.GetActiveOrders(); | ||
Console.WriteLine("Open orders: {0}", openOrders.Count()); | ||
/* | ||
var cancelResult = api.CancelOrder(12345); | ||
Console.WriteLine("CancelOrder: {0}", cancelResult); | ||
var sellAnswer = api.Sell(12456.3M, 2); | ||
Console.WriteLine("Sell: {0}", sellAnswer); | ||
var buyAnswer = api.Buy(12.3M, 1); | ||
Console.WriteLine("Buy: {0}", buyAnswer); | ||
*/ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using System.Linq; | ||
using Bitstamp; | ||
|
||
namespace ApiTest | ||
{ | ||
static class BitstampTest | ||
{ | ||
private const string ApiKey = "PUT-HERE-API-KEY"; | ||
private const string ApiSecret = "PUT-HERE-API-SECRET"; | ||
private const string ClientId = "PUT-HERE-CLIENT-ID"; | ||
|
||
public static void Test() | ||
{ | ||
var ticker = BitstampApi.GetTicker(); | ||
Console.WriteLine(ticker.Last); | ||
|
||
var trans = BitstampApi.GetTransactions(); | ||
Console.WriteLine("trans.Count=" + trans.Count); | ||
var orderBook = BitstampApi.GetOrderBook(); | ||
Console.WriteLine("orderBook.Asks.Count=" + orderBook.Asks.Count); | ||
|
||
var api = new BitstampApi(ApiKey, ApiSecret, ClientId); | ||
|
||
var balance = api.GetBalance(); | ||
Console.WriteLine(balance); | ||
|
||
var openOrders = api.GetOpenOrders(); | ||
Console.WriteLine("Open orders: {0}", openOrders.Count()); | ||
|
||
var cancelResult = api.CancelOrder(12345); | ||
Console.WriteLine("CancelOrder: {0}", cancelResult); | ||
|
||
var sellAnswer = api.Sell(12456.3M, 2); | ||
Console.WriteLine("Sell: {0}", sellAnswer); | ||
|
||
var buyAnswer = api.Buy(12.3M, 1); | ||
Console.WriteLine("Buy: {0}", buyAnswer); | ||
|
||
/* | ||
Console.WriteLine(info); | ||
var transHistory = btceApi.GetTransHistory(); | ||
Console.WriteLine(transHistory); | ||
var tradeHistory = btceApi.GetTradeHistory(count: 20); | ||
Console.WriteLine(tradeHistory); | ||
var orderList = btceApi.ActiveOrders(); | ||
Console.WriteLine(orderList); | ||
// var tradeAnswer = btceApi.Trade(BtcePair.btc_usd, TradeType.Sell, 20, 0.1m); | ||
// var cancelAnswer = btceApi.CancelOrder(tradeAnswer.OrderId); | ||
*/ | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using System.Threading; | ||
using BTCChina; | ||
using BTCChina.WebSockets; | ||
|
||
namespace ApiTest | ||
{ | ||
static class BtcChinaTest | ||
{ | ||
private const string ApiKey = "PUT-HERE-API-KEY"; | ||
private const string ApiSecret = "PUT-HERE-API-SECRET"; | ||
|
||
public static void Test() | ||
{ | ||
/* | ||
// Sell | ||
{ | ||
Console.WriteLine("SALE Testing..."); | ||
var priceUsd = 245 * 99999; | ||
var CIY2USD = 0.1611; | ||
var client1 = new BTCChinaAPI(ApiKey, ApiSecret); | ||
var responce = client1.PlaceOrder((double)(priceUsd / CIY2USD), -(double)2.5, | ||
BTCChinaAPI.MarketType.BTCCNY); | ||
Console.WriteLine(responce); | ||
} | ||
*/ | ||
|
||
/* | ||
using (var wsApi = new BtcChinaWebSocketApi()) | ||
{ | ||
Console.WriteLine("Btcc: Socket starting..."); | ||
wsApi.Start(); | ||
Console.ReadLine(); | ||
wsApi.Stop(); | ||
} | ||
*/ | ||
|
||
var ticker = BTCChinaAPI.GetTicker(); | ||
Console.WriteLine("ticker.Last: " + ticker.Last); | ||
|
||
var orderBook = BTCChinaAPI.GetOrderBook(); | ||
Console.WriteLine("orderBook.Asks.Count=" + orderBook.Asks.Count); | ||
|
||
var client = new BTCChinaAPI(ApiKey, ApiSecret); | ||
var info = client.getAccountInfo(); | ||
Console.WriteLine("UserName= " + info.Profile.UserName); | ||
|
||
var orderId = client.PlaceOrder(1, 1, BTCChinaAPI.MarketType.BTCCNY); | ||
Console.WriteLine("orderId: " + orderId); | ||
|
||
var cancelResult = client.cancelOrder(orderId); | ||
Console.WriteLine("cancelResult: " + cancelResult); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System; | ||
using BtcE; | ||
|
||
namespace ApiTest | ||
{ | ||
static class BtceTest | ||
{ | ||
private const string ApiKey = "PUT-HERE-API-KEY"; | ||
private const string ApiSecret = "PUT-HERE-API-SECRET"; | ||
|
||
public static void Test() | ||
{ | ||
/* | ||
{ | ||
var btceApi = new BtceApi(ApiKey, ApiSecret); | ||
var info = btceApi.GetInfo(); | ||
Console.WriteLine("Info: BTC={0}, USD={1}", info.Funds.Btc, info.Funds.Usd); | ||
var order = btceApi.Trade(BtcePair.btc_usd, TradeType.Sell, 1245.8M, 3M); | ||
// 4.801251M | ||
Console.WriteLine("Order: {0}", order); | ||
} | ||
*/ | ||
|
||
/* | ||
{ | ||
var api = new BtceApi(ApiKey, ApiSecret); | ||
while (true) | ||
{ | ||
var time = DateTime.Now; | ||
var userInfo = api.GetInfo(); | ||
var ping = Math.Round((DateTime.Now - time).TotalSeconds, 2); | ||
Console.WriteLine("Ping [{1}]: {0}", ping, userInfo.Funds.Btc); | ||
Thread.Sleep(1000); | ||
} | ||
} | ||
*/ | ||
{ | ||
var ticker = BtceApi.GetTicker(BtcePair.btc_usd); | ||
Console.WriteLine(ticker); | ||
|
||
var depth3 = BtceApiV3.GetDepth(new BtcePair[] {BtcePair.btc_usd}); | ||
Console.WriteLine(depth3); | ||
|
||
var ticker3 = BtceApiV3.GetTicker(new BtcePair[] {BtcePair.btc_usd}); | ||
var trades3 = BtceApiV3.GetTrades(new BtcePair[] {BtcePair.btc_usd}); | ||
var trades = BtceApi.GetTrades(BtcePair.btc_usd); | ||
var btcusdDepth = BtceApi.GetDepth(BtcePair.usd_rur); | ||
var fee = BtceApi.GetFee(BtcePair.usd_rur); | ||
|
||
var btceApi = new BtceApi(ApiKey, ApiSecret); | ||
var info = btceApi.GetInfo(); | ||
Console.WriteLine("Info: BTC={0}, USD={1}", info.Funds.Btc, info.Funds.Usd); | ||
var transHistory = btceApi.GetTransHistory(since: DateTime.Now.AddMonths(-6)); | ||
Console.WriteLine("transHistory count={0}", transHistory.Count); | ||
var tradeHistory = btceApi.GetTradeHistory(count: 20); | ||
Console.WriteLine(tradeHistory); | ||
var orderList = btceApi.ActiveOrders(); | ||
Console.WriteLine("OrderList:"); | ||
foreach (var or in orderList) | ||
{ | ||
Console.WriteLine("{0}: {1}", or.Key, or.Value); | ||
} | ||
// var tradeAnswer = btceApi.Trade(BtcePair.btc_usd, TradeType.Sell, 20, 0.1m); | ||
// var cancelAnswer = btceApi.CancelOrder(tradeAnswer.OrderId); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.