-
Notifications
You must be signed in to change notification settings - Fork 497
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exchange clients now use a common ExchangeApi.cs for api queries.
Started implementing poloniex api.
- Loading branch information
bonesoul
committed
Oct 22, 2014
1 parent
cb22fa4
commit 449d64f
Showing
16 changed files
with
355 additions
and
154 deletions.
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
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
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
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -27,6 +27,7 @@ public enum Exchange | |
{ | ||
Unknown, | ||
Cryptsy, | ||
Bittrex | ||
Bittrex, | ||
Poloniex | ||
} | ||
} |
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,84 @@ | ||
#region License | ||
// | ||
// CoiniumServ - Crypto Currency Mining Pool Server Software | ||
// Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org | ||
// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ | ||
// | ||
// This software is dual-licensed: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// For the terms of this license, see licenses/gpl_v3.txt. | ||
// | ||
// Alternatively, you can license this software under a commercial | ||
// license or white-label it as set out in licenses/commercial.txt. | ||
// | ||
#endregion | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Serilog; | ||
|
||
namespace CoiniumServ.Markets.Exchanges | ||
{ | ||
public class BittrexClient: ExchangeApi, IBittrexClient | ||
{ | ||
private const string ApiBase = "https://bittrex.com/api/v1.1/"; | ||
|
||
private readonly ILogger _logger; | ||
|
||
public BittrexClient() | ||
{ | ||
_logger = Log.ForContext<BittrexClient>(); | ||
} | ||
|
||
public async Task<IList<IMarketData>> GetMarkets() | ||
{ | ||
var list = new List<IMarketData>(); | ||
var data = await Request(ApiBase, "public/getmarketsummaries"); | ||
|
||
try | ||
{ | ||
foreach (var market in data.@result) | ||
{ | ||
try | ||
{ | ||
string name = market.MarketName; | ||
var temp = name.Split('-'); | ||
|
||
var entry = new MarketData | ||
{ | ||
Exchange = Exchange.Bittrex, | ||
MarketCurrency = temp.Last(), | ||
BaseCurrency = temp.First(), | ||
Ask = market.Ask, | ||
Bid = market.Bid, | ||
VolumeInMarketCurrency = market.Volume, | ||
VolumeInBaseCurrency = market.BaseVolume | ||
}; | ||
|
||
list.Add(entry); | ||
} | ||
catch (Exception e) | ||
{ | ||
_logger.Error(e.Message); | ||
} | ||
} | ||
} | ||
catch (Exception e) | ||
{ | ||
_logger.Error(e.Message); | ||
} | ||
|
||
return list; | ||
} | ||
} | ||
} |
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,94 @@ | ||
#region License | ||
// | ||
// CoiniumServ - Crypto Currency Mining Pool Server Software | ||
// Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org | ||
// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ | ||
// | ||
// This software is dual-licensed: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// For the terms of this license, see licenses/gpl_v3.txt. | ||
// | ||
// Alternatively, you can license this software under a commercial | ||
// license or white-label it as set out in licenses/commercial.txt. | ||
// | ||
#endregion | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Newtonsoft.Json.Converters; | ||
using Serilog; | ||
|
||
namespace CoiniumServ.Markets.Exchanges | ||
{ | ||
public class CryptsyClient : ExchangeApi, ICryptsyClient | ||
{ | ||
private const string PublicApiBase = "http://pubapi.cryptsy.com/"; | ||
private const string PublicApiEndpoint = "api.php"; | ||
private const string PrivateApiBase = " https://api.cryptsy.com/"; | ||
private const string PrivateApiEndpoint = "api"; | ||
|
||
private readonly ExpandoObjectConverter _converter = new ExpandoObjectConverter(); | ||
private readonly ILogger _logger; | ||
|
||
public CryptsyClient() | ||
{ | ||
_logger = Log.ForContext<BittrexClient>(); | ||
} | ||
|
||
public async Task<IList<IMarketData>> GetMarkets() | ||
{ | ||
var list = new List<IMarketData>(); | ||
|
||
var @params = new Dictionary<string, string> | ||
{ | ||
{"method", "marketdatav2"} | ||
}; | ||
|
||
var data = await Request(PublicApiBase, PublicApiEndpoint, @params); | ||
|
||
try | ||
{ | ||
foreach (var kvp in data.@return.markets) | ||
{ | ||
try | ||
{ | ||
var buyOrders = (IList<dynamic>) kvp.Value.buyorders; | ||
var sellOrders = (IList<dynamic>) kvp.Value.sellorders; | ||
|
||
var entry = new MarketData | ||
{ | ||
Exchange = Exchange.Cryptsy, | ||
MarketCurrency = kvp.Value.primarycode, | ||
BaseCurrency = kvp.Value.secondarycode, | ||
Ask = double.Parse(sellOrders.First().price, CultureInfo.InvariantCulture), | ||
Bid = double.Parse(buyOrders.First().price, CultureInfo.InvariantCulture), | ||
VolumeInMarketCurrency = double.Parse(kvp.Value.volume, CultureInfo.InvariantCulture), | ||
}; | ||
list.Add(entry); | ||
} | ||
catch (Exception e) | ||
{ | ||
_logger.Error(e.Message); | ||
} | ||
} | ||
} | ||
catch (Exception e) | ||
{ | ||
_logger.Error(e.Message); | ||
} | ||
|
||
return list; | ||
} | ||
} | ||
} |
Oops, something went wrong.