├── .gitattributes ├── .gitignore ├── IntTrader.API.Blockchain ├── IntTrader.API.Blockchain.csproj ├── Model │ ├── MultiAddressEntryModel.cs │ ├── MultiAddressModel.cs │ └── SingleAddressModel.cs ├── NLog.config ├── Properties │ └── AssemblyInfo.cs ├── Request │ ├── BlockchainRequestBase.cs │ ├── MultiAddressRequest.cs │ └── SingleAddressRequest.cs ├── Response │ ├── BlockchainResponse.cs │ ├── MultiAddressResponse.cs │ └── SingleAddressResponse.cs └── packages.config ├── IntTrader.API ├── Base │ ├── Attributes │ │ └── Request.cs │ ├── Exchange │ │ ├── Base │ │ │ ├── ExchangeBase.cs │ │ │ ├── ExchangeType.cs │ │ │ └── TypeBase.cs │ │ ├── ExchangeManager.cs │ │ └── Orders │ │ │ ├── OrderSide.cs │ │ │ └── OrderType.cs │ ├── Model │ │ ├── BalanceEntryModel.cs │ │ ├── BalanceModel.cs │ │ ├── CancelOrderModel.cs │ │ ├── CreateOrderModel.cs │ │ ├── OpenOrderEntryModel.cs │ │ ├── OpenOrdersModel.cs │ │ ├── OrderBookEntryModel.cs │ │ ├── OrderBookModel.cs │ │ ├── ResponseModelBase.cs │ │ ├── TickerModel.cs │ │ ├── TradesEntryModel.cs │ │ └── TradesModel.cs │ ├── Request │ │ ├── CancelOrderRequest.cs │ │ ├── CreateOrderRequest.cs │ │ ├── RequestBase.cs │ │ └── RequestMonitor.cs │ ├── Response │ │ ├── ResponseBase.cs │ │ └── ResponseData.cs │ ├── Settings │ │ ├── ExchangeAPI.cs │ │ └── SettingsBase.cs │ └── Transform │ │ ├── IBalance.cs │ │ ├── IBalanceEntry.cs │ │ ├── ICancelOrder.cs │ │ ├── ICreateOrder.cs │ │ ├── IOrder.cs │ │ ├── IOrderBook.cs │ │ ├── IOrderBookEntry.cs │ │ ├── IOrders.cs │ │ ├── ITicker.cs │ │ └── ITrades.cs ├── Converter │ ├── DateTimeConverter.cs │ ├── DecimalConverter.cs │ └── DecimalRounding.cs ├── Currency │ ├── CurrencyBase.cs │ ├── PairBase.cs │ └── PairManager.cs ├── Event │ ├── CreateOrderEventArgs.cs │ └── RequestEventArgs.cs ├── Exceptions │ ├── CurrencyNotSupported.cs │ └── PairNotSupportedException.cs ├── IntTrader.API.csproj ├── NLog.config ├── Properties │ └── AssemblyInfo.cs ├── Threading │ ├── LockFreeQueue.cs │ └── RequestHandler.cs ├── Web │ ├── GetRequest.cs │ └── WebClientExtended.cs └── packages.config ├── IntTrader.Exchange.Bitfinex ├── Bitfinex │ ├── BitfinexExchange.cs │ ├── Request │ │ ├── Authenticated │ │ │ ├── AuthenticatedRequest.cs │ │ │ ├── Balance.cs │ │ │ ├── CreateOrderRequest.cs │ │ │ └── OrderCancel.cs │ │ ├── BitfinexRequestBase.cs │ │ ├── OrderBook.cs │ │ ├── OrderStatus.cs │ │ ├── Orders.cs │ │ ├── Ticker.cs │ │ ├── Today.cs │ │ └── TradesRequest.cs │ └── Response │ │ ├── BalanceEntry.cs │ │ ├── BalanceResponse.cs │ │ ├── BitfinexResponse.cs │ │ ├── CancelOrderResponse.cs │ │ ├── CreateOrderResponse.cs │ │ ├── OrderBookEntry.cs │ │ ├── OrderBookResponse.cs │ │ ├── OrderResponse.cs │ │ ├── OrderResponseBase.cs │ │ ├── OrderStatusResponse.cs │ │ ├── OrdersResponse.cs │ │ ├── TickerResponse.cs │ │ ├── TodayResponse.cs │ │ └── TradesResponse.cs ├── IntTrader.API.Bitfinex.Exchange.csproj ├── NLog.config ├── Properties │ └── AssemblyInfo.cs └── packages.config ├── IntTrader.Exchange.Kraken ├── IntTrader.API.Kraken.Exchange.csproj ├── Kraken │ ├── Authentication.cs │ ├── KrakenExchange.cs │ ├── Request │ │ ├── Authenticated │ │ │ ├── AuthenticatedRequest.cs │ │ │ ├── BalanceRequest.cs │ │ │ ├── CancelOrderRequest.cs │ │ │ ├── CreateOrderRequest.cs │ │ │ └── OpenOrdersRequest.cs │ │ ├── KrakenRequestBase.cs │ │ ├── OrderBook.cs │ │ ├── Ticker.cs │ │ └── TradesRequest.cs │ └── Response │ │ ├── BalanceResponse.cs │ │ ├── CancelOrderResponse.cs │ │ ├── CreateOrderResponse.cs │ │ ├── KrakenResponse.cs │ │ ├── OpenOrdersResponse.cs │ │ ├── OrderBookEntry.cs │ │ ├── OrderBookResponse.cs │ │ ├── TickerResponse.cs │ │ └── TradesResponse.cs ├── NLog.config ├── Properties │ └── AssemblyInfo.cs └── packages.config ├── IntTrader.ExchangeLoader ├── ExchangeLoader.cs ├── IntTrader.API.ExchangeLoader.csproj ├── NLog.config ├── Properties │ └── AssemblyInfo.cs └── packages.config ├── IntTrader.sln ├── IntTrader ├── App.xaml ├── App.xaml.cs ├── Controls │ ├── Balance │ │ ├── Balance.xaml │ │ ├── Balance.xaml.cs │ │ ├── BalanceEntryViewModel.cs │ │ └── BalanceViewModel.cs │ ├── Blockchain │ │ └── Address │ │ │ ├── AddressItemViewModel.cs │ │ │ ├── AddressView.xaml │ │ │ ├── AddressView.xaml.cs │ │ │ └── AddressViewModel.cs │ ├── CommandToolBar │ │ ├── CommandToolBarView.xaml │ │ ├── CommandToolBarView.xaml.cs │ │ └── CommandToolBarViewModel.cs │ ├── Dashboard │ │ ├── DashboardEntryViewModel.cs │ │ ├── DashboardView.xaml │ │ ├── DashboardView.xaml.cs │ │ └── DashboardViewModel.cs │ ├── Exchange │ │ ├── ExchangeView.xaml │ │ ├── ExchangeView.xaml.cs │ │ └── ExchangeViewModel.cs │ ├── ExchangeSettings │ │ ├── ExchangeSettingsEntryViewModel.cs │ │ ├── ExchangeSettingsView.xaml │ │ ├── ExchangeSettingsView.xaml.cs │ │ └── ExchangeSettingsViewModel.cs │ ├── NewOrder │ │ ├── NewBuyOrderView.xaml │ │ ├── NewBuyOrderView.xaml.cs │ │ ├── NewOrderViewModel.cs │ │ ├── NewSellOrderView.xaml │ │ └── NewSellOrderView.xaml.cs │ ├── OrderBook │ │ ├── LastTrade.xaml │ │ ├── LastTrade.xaml.cs │ │ ├── OrderBook.xaml │ │ ├── OrderBook.xaml.cs │ │ ├── OrderBookEntry.cs │ │ ├── OrderBookViewModel.cs │ │ ├── OrderListAsks.xaml │ │ ├── OrderListAsks.xaml.cs │ │ ├── OrderListBids.xaml │ │ └── OrderListBids.xaml.cs │ ├── OrderNotifications │ │ ├── OrderNotificationEntryViewModel.cs │ │ ├── OrderNotificationView.xaml │ │ ├── OrderNotificationView.xaml.cs │ │ └── OrderNotificationViewModel.cs │ ├── Request │ │ ├── RequestEntryViewModel.cs │ │ ├── RequestView.xaml │ │ ├── RequestView.xaml.cs │ │ └── RequestViewModel.cs │ ├── Sentiment │ │ ├── SentimentView.xaml │ │ ├── SentimentView.xaml.cs │ │ └── SentimentViewModel.cs │ ├── Ticker │ │ ├── Ticker.xaml │ │ ├── Ticker.xaml.cs │ │ └── TickerViewModel.cs │ ├── Trades │ │ ├── TradesEntryViewModel.cs │ │ ├── TradesView.xaml │ │ ├── TradesView.xaml.cs │ │ └── TradesViewModel.cs │ └── UserOrders │ │ ├── OrderViewModel.cs │ │ ├── UserOrderView.xaml │ │ ├── UserOrderView.xaml.cs │ │ └── UserOrdersViewModel.cs ├── Dialogs │ ├── OrderNotifications │ │ ├── OrderNotificationWindow.xaml │ │ ├── OrderNotificationWindow.xaml.cs │ │ └── OrderNotificationWindowViewModel.cs │ └── Password │ │ ├── CreatePassword.xaml │ │ ├── CreatePassword.xaml.cs │ │ ├── CreatePasswordViewModel.cs │ │ ├── Login.xaml │ │ ├── Login.xaml.cs │ │ └── LoginViewModel.cs ├── IntTrader.csproj ├── NLog.config ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── Resources │ ├── BalanceResources.xaml │ ├── BasicResources.xaml │ ├── OrderBookResources.xaml │ ├── ScrollViewer.xaml │ ├── SentimentResources.xaml │ ├── bitcoin.ico │ └── bitcoin.png ├── Service │ ├── ApplicationSettingsService.cs │ ├── ExchangeSettingsService.cs │ ├── UpdateController.cs │ └── UpdateEntry.cs ├── Settings │ ├── AppSettings.cs │ ├── AppSettingsBase.cs │ └── Data │ │ └── AddressEntry.cs ├── Themes │ └── ExpressionDark.xaml ├── View │ ├── MainWindow.xaml │ └── MainWindow.xaml.cs ├── ViewModel │ ├── ExchangeManagerViewModel.cs │ ├── ExchangeViewModelBase.cs │ ├── MainViewModel.cs │ ├── PairManageViewModel.cs │ ├── PairViewModel.cs │ ├── PrefixSuffixEntry.cs │ └── ViewModelBase.cs ├── app.config ├── bitcoin.ico └── packages.config ├── README.md ├── Resources └── Icons │ ├── BitcoinResources.svg │ ├── bitcoin.ico │ └── bitcoin.png ├── Zicore.Security ├── Cryptography │ ├── Hash.cs │ └── RijndaelSimple.cs ├── Properties │ └── AssemblyInfo.cs └── Zicore.Security.csproj ├── Zicore.Settings.Json ├── JsonSettings.cs ├── JsonSettingsEncrypted.cs ├── Properties │ └── AssemblyInfo.cs ├── Zicore.Settings.Json.csproj └── packages.config ├── Zicore.WPF.Base ├── AdornerServices │ ├── WatermarkAdorner.cs │ └── WatermarkService.cs ├── Behaviour │ ├── BindableSelectedItemBehavior.cs │ ├── GridViewColumnResize.cs │ └── IgnoreMouseWheelBehavior.cs ├── Commands │ └── RelayCommand.cs ├── Common │ └── BindableBase.cs ├── Controls │ └── DataBoundRadioButton.cs ├── Converter │ └── IsNegativeValueConverter.cs ├── Event │ └── EventArgs.cs ├── Properties │ └── AssemblyInfo.cs ├── Win32 │ └── User32.cs └── Zicore.WPF.Base.csproj └── built └── dev └── R1 └── IntTrader.zip /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /IntTrader.API.Blockchain/Model/MultiAddressEntryModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace IntTrader.API.Blockchain.Model 7 | { 8 | public class MultiAddressEntryModel 9 | { 10 | private String _hash160; 11 | private String _address; 12 | private long _numberTransactions; 13 | private long _numberUnredeemed; 14 | private decimal _totalReceived; 15 | private decimal _totalSent; 16 | private decimal _finalBalance; 17 | 18 | public string Hash160 19 | { 20 | get { return _hash160; } 21 | set { _hash160 = value; } 22 | } 23 | 24 | public string Address 25 | { 26 | get { return _address; } 27 | set { _address = value; } 28 | } 29 | 30 | public long NumberTransactions 31 | { 32 | get { return _numberTransactions; } 33 | set { _numberTransactions = value; } 34 | } 35 | 36 | public long NumberUnredeemed 37 | { 38 | get { return _numberUnredeemed; } 39 | set { _numberUnredeemed = value; } 40 | } 41 | 42 | public decimal TotalReceived 43 | { 44 | get { return _totalReceived; } 45 | set { _totalReceived = value; } 46 | } 47 | 48 | public decimal TotalSent 49 | { 50 | get { return _totalSent; } 51 | set { _totalSent = value; } 52 | } 53 | 54 | public decimal FinalBalance 55 | { 56 | get { return _finalBalance; } 57 | set { _finalBalance = value; } 58 | } 59 | 60 | public override string ToString() 61 | { 62 | return string.Format( 63 | "Hash160: {0}, Address: {1}, NumberTransactions: {2}, NumberUnredeemed: {3}, TotalReceived: {4}, TotalSent: {5}, FinalBalance: {6}", 64 | Hash160, Address, NumberTransactions, NumberUnredeemed, TotalReceived, TotalSent, FinalBalance); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /IntTrader.API.Blockchain/Model/MultiAddressModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace IntTrader.API.Blockchain.Model 7 | { 8 | public class MultiAddressModel 9 | { 10 | List _items = new List(); 11 | 12 | public List Items 13 | { 14 | get { return _items; } 15 | set { _items = value; } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /IntTrader.API.Blockchain/Model/SingleAddressModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace IntTrader.API.Blockchain.Model 7 | { 8 | public class SingleAddressModel 9 | { 10 | private String _hash160; 11 | private String _address; 12 | private long _numberTransactions; 13 | private long _numberUnredeemed; 14 | private decimal _totalReceived; 15 | private decimal _totalSent; 16 | private decimal _finalBalance; 17 | 18 | public string Hash160 19 | { 20 | get { return _hash160; } 21 | set { _hash160 = value; } 22 | } 23 | 24 | public string Address 25 | { 26 | get { return _address; } 27 | set { _address = value; } 28 | } 29 | 30 | public long NumberTransactions 31 | { 32 | get { return _numberTransactions; } 33 | set { _numberTransactions = value; } 34 | } 35 | 36 | public long NumberUnredeemed 37 | { 38 | get { return _numberUnredeemed; } 39 | set { _numberUnredeemed = value; } 40 | } 41 | 42 | public decimal TotalReceived 43 | { 44 | get { return _totalReceived; } 45 | set { _totalReceived = value; } 46 | } 47 | 48 | public decimal TotalSent 49 | { 50 | get { return _totalSent; } 51 | set { _totalSent = value; } 52 | } 53 | 54 | public decimal FinalBalance 55 | { 56 | get { return _finalBalance; } 57 | set { _finalBalance = value; } 58 | } 59 | 60 | public override string ToString() 61 | { 62 | return string.Format( 63 | "Hash160: {0}, Address: {1}, NumberTransactions: {2}, NumberUnredeemed: {3}, TotalReceived: {4}, TotalSent: {5}, FinalBalance: {6}", 64 | Hash160, Address, NumberTransactions, NumberUnredeemed, TotalReceived, TotalSent, FinalBalance); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /IntTrader.API.Blockchain/NLog.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 14 | 15 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /IntTrader.API.Blockchain/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Allgemeine Informationen über eine Assembly werden über die folgenden 6 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, 7 | // die mit einer Assembly verknüpft sind. 8 | [assembly: AssemblyTitle("IntTrader.API.Blockchain")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("IntTrader.API.Blockchain")] 13 | [assembly: AssemblyCopyright("Copyright © 2014 by Zicore")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar 18 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von 19 | // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. 20 | [assembly: ComVisible(false)] 21 | 22 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird 23 | [assembly: Guid("e5ae9342-24a4-488c-b5fe-96eaf52ad0f7")] 24 | 25 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: 26 | // 27 | // Hauptversion 28 | // Nebenversion 29 | // Buildnummer 30 | // Revision 31 | // 32 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern 33 | // übernehmen, indem Sie "*" eingeben: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /IntTrader.API.Blockchain/Request/BlockchainRequestBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Text; 4 | using IntTrader.API.Base.Request; 5 | using IntTrader.API.Base.Response; 6 | using IntTrader.API.Web; 7 | using NLog; 8 | using Newtonsoft.Json; 9 | using Newtonsoft.Json.Linq; 10 | 11 | namespace IntTrader.API.Blockchain.Request 12 | { 13 | public class BlockchainRequestBase : RequestBase 14 | { 15 | public static String ApiUri = "https://blockchain.info"; 16 | private String _language = "de"; 17 | 18 | public string Language 19 | { 20 | get { return _language; } 21 | set { _language = value; } 22 | } 23 | 24 | private readonly static Logger Log = LogManager.GetCurrentClassLogger(); 25 | private String _requestUri; 26 | 27 | [JsonProperty("request")] 28 | protected string RequestUri 29 | { 30 | get { return _requestUri; } 31 | set { _requestUri = value; } 32 | } 33 | 34 | [JsonIgnore] 35 | protected string Uri 36 | { 37 | get { return String.Format("{0}/{1}/{2}", ApiUri, Language, RequestUri); } 38 | } 39 | 40 | 41 | 42 | public String ToJsonBase64String() 43 | { 44 | return Convert.ToBase64String(Encoding.UTF8.GetBytes(ToJsonString())); 45 | } 46 | 47 | public virtual String ToJsonString() 48 | { 49 | return JsonConvert.SerializeObject(this); 50 | } 51 | 52 | public override ResponseData Request() 53 | { 54 | using (var client = WebClientExtended.GetDefault()) 55 | { 56 | client.Headers["Host"] = "blockchain.info"; 57 | 58 | try 59 | { 60 | Log.Info(RequestUri); 61 | AddGetParameters(this, client); 62 | var postResult = client.DownloadString(Uri); 63 | return new ResponseData(this, postResult); 64 | } 65 | catch (WebException ex) 66 | { 67 | return new ResponseData(this, ex); 68 | } 69 | } 70 | } 71 | 72 | private void AddGetParameters(Object obj, WebClientExtended client) 73 | { 74 | String result = JsonConvert.SerializeObject(obj); 75 | JObject jObject = JObject.Parse(result); 76 | 77 | foreach (var token in jObject) 78 | { 79 | if (token.Key != "request") 80 | { 81 | client.QueryString.Add(token.Key, token.Value.ToString()); 82 | } 83 | } 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /IntTrader.API.Blockchain/Request/MultiAddressRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace IntTrader.API.Blockchain.Request 6 | { 7 | public class MultiAddressRequest : BlockchainRequestBase 8 | { 9 | public MultiAddressRequest(List addresses) 10 | { 11 | RequestUri = "multiaddr?active=" + PrepareAddresses(addresses); 12 | } 13 | 14 | private String PrepareAddresses(IList addresses) 15 | { 16 | var sb = new StringBuilder(); 17 | for (int i = 0; i < addresses.Count; i++) 18 | { 19 | sb.Append(addresses[i]); 20 | if (i < addresses.Count - 1) 21 | { 22 | sb.Append("|"); 23 | } 24 | } 25 | return sb.ToString(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /IntTrader.API.Blockchain/Request/SingleAddressRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | 4 | namespace IntTrader.API.Blockchain.Request 5 | { 6 | public class SingleAddressRequest : BlockchainRequestBase 7 | { 8 | public SingleAddressRequest(String address) 9 | { 10 | this.Address = address; 11 | RequestUri = "address/" + Address + "?format=json"; 12 | } 13 | 14 | private String _address = ""; 15 | 16 | [JsonIgnore] 17 | public string Address 18 | { 19 | get { return _address; } 20 | set { _address = value; } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /IntTrader.API.Blockchain/Response/BlockchainResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using IntTrader.API.Base.Response; 6 | 7 | namespace IntTrader.API.Blockchain.Response 8 | { 9 | public class BlockchainResponse : ResponseBase 10 | { 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /IntTrader.API.Blockchain/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Attributes/Request.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace IntTrader.API.Base.Attributes 7 | { 8 | [AttributeUsage(AttributeTargets.All)] 9 | public class RequestCommand : Attribute 10 | { 11 | public RequestCommand(String command, bool isPublic) 12 | { 13 | Command = command; 14 | IsPublic = isPublic; 15 | } 16 | 17 | public string Command { get; set; } 18 | public bool IsPublic { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Exchange/Base/ExchangeType.cs: -------------------------------------------------------------------------------- 1 | namespace IntTrader.API.Base.Exchange.Base 2 | { 3 | public class ExchangeType : TypeBase 4 | { 5 | public ExchangeType(string value, string name) 6 | : base(value, name) 7 | { 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Exchange/Base/TypeBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace IntTrader.API.Base.Exchange.Base 4 | { 5 | public class TypeBase 6 | { 7 | public TypeBase(String value, String name) 8 | { 9 | this.Value = value; 10 | this.Name = name; 11 | } 12 | 13 | private String _value; 14 | private String _name; 15 | private String _description; 16 | 17 | public string Value 18 | { 19 | get { return _value; } 20 | protected set { _value = value; } 21 | } 22 | 23 | public string Name 24 | { 25 | get { return _name; } 26 | set { _name = value; } 27 | } 28 | 29 | public string Description 30 | { 31 | get { return _description; } 32 | set { _description = value; } 33 | } 34 | 35 | public override string ToString() 36 | { 37 | return String.Format("{0}", Name); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Exchange/Orders/OrderSide.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Base.Exchange.Base; 2 | 3 | namespace IntTrader.API.Base.Exchange.Orders 4 | { 5 | public class OrderSide : TypeBase 6 | { 7 | public static readonly OrderSide Buy = new OrderSide("buy", "Buy"); 8 | public static readonly OrderSide Sell = new OrderSide("sell", "Sell"); 9 | 10 | public OrderSide(string value, string name) 11 | : base(value, name) 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Exchange/Orders/OrderType.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Base.Exchange.Base; 2 | 3 | namespace IntTrader.API.Base.Exchange.Orders 4 | { 5 | public class OrderType : TypeBase 6 | { 7 | /// 8 | /// Creates an for the communication with the API's 9 | /// 10 | /// The value for the API 11 | /// The name for the presentation layer 12 | public OrderType(string value, string name) 13 | : base(value, name) 14 | { 15 | } 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Model/BalanceEntryModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace IntTrader.API.Base.Model 4 | { 5 | public class BalanceEntryModel 6 | { 7 | private String _currencyKey; 8 | private String _walletType; 9 | private decimal _amount; 10 | private decimal _available; 11 | 12 | public string CurrencyKey 13 | { 14 | get { return _currencyKey; } 15 | set { _currencyKey = value; } 16 | } 17 | 18 | public string WalletType 19 | { 20 | get { return _walletType; } 21 | set { _walletType = value; } 22 | } 23 | 24 | public decimal Amount 25 | { 26 | get { return _amount; } 27 | set { _amount = value; } 28 | } 29 | 30 | public decimal Available 31 | { 32 | get { return _available; } 33 | set { _available = value; } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Model/BalanceModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace IntTrader.API.Base.Model 4 | { 5 | public class BalanceModel : ResponseModelBase 6 | { 7 | private List _items = new List(); 8 | 9 | public List Items 10 | { 11 | get { return _items; } 12 | set { _items = value; } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Model/CancelOrderModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace IntTrader.API.Base.Model 4 | { 5 | public class CancelOrderModel : ResponseModelBase 6 | { 7 | private String _orderId = ""; 8 | 9 | private int _ordersCanceled = 0; 10 | private int _ordersPending = 0; 11 | 12 | public int OrdersCanceled 13 | { 14 | get { return _ordersCanceled; } 15 | set { _ordersCanceled = value; } 16 | } 17 | 18 | public int OrdersPending 19 | { 20 | get { return _ordersPending; } 21 | set { _ordersPending = value; } 22 | } 23 | 24 | public string OrderId 25 | { 26 | get { return _orderId; } 27 | set { _orderId = value; } 28 | } 29 | 30 | OpenOrderEntryModel _openOrder = new OpenOrderEntryModel(); 31 | 32 | public OpenOrderEntryModel OpenOrder 33 | { 34 | get { return _openOrder; } 35 | set { _openOrder = value; } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Model/CreateOrderModel.cs: -------------------------------------------------------------------------------- 1 | namespace IntTrader.API.Base.Model 2 | { 3 | public class CreateOrderModel : OpenOrderEntryModel 4 | { 5 | public CreateOrderModel() 6 | { 7 | 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Model/OpenOrdersModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace IntTrader.API.Base.Model 5 | { 6 | public class OpenOrdersModel : ResponseModelBase 7 | { 8 | private List _orders = new List(); 9 | 10 | [JsonProperty("Orders")] 11 | public List Orders 12 | { 13 | get { return _orders; } 14 | set { _orders = value; } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Model/OrderBookEntryModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | 4 | namespace IntTrader.API.Base.Model 5 | { 6 | public class OrderBookEntryModel : ResponseModelBase 7 | { 8 | // "price": "0.0278", 9 | // "amount": "20.0", 10 | // "timestamp": "1395065891.0" 11 | 12 | private decimal _price; 13 | private decimal _amount; 14 | private int _groupedVolume; 15 | private int _groupedPrice; 16 | 17 | private DateTime _dateTime; 18 | 19 | public decimal Price 20 | { 21 | get { return _price; } 22 | set { _price = value; } 23 | } 24 | 25 | public decimal Amount 26 | { 27 | get { return _amount; } 28 | set { _amount = value; } 29 | } 30 | 31 | public DateTime DateTime 32 | { 33 | get { return _dateTime; } 34 | set { _dateTime = value; } 35 | } 36 | 37 | public int GroupedVolume 38 | { 39 | get { return _groupedVolume; } 40 | set { _groupedVolume = value; } 41 | } 42 | 43 | public int GroupedPrice 44 | { 45 | get { return _groupedPrice; } 46 | set { _groupedPrice = value; } 47 | } 48 | 49 | public override string ToString() 50 | { 51 | return String.Format(CultureInfo.InvariantCulture, "{0:HH:mm:ss} {1:000.000000} {2:000000.000000}", DateTime, Price, Amount); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Model/OrderBookModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace IntTrader.API.Base.Model 4 | { 5 | public class OrderBookModel : ResponseModelBase 6 | { 7 | public OrderBookModel() 8 | { 9 | 10 | } 11 | 12 | public override void Update() 13 | { 14 | base.Update(); 15 | } 16 | 17 | private List _bids = new List(); 18 | private List _asks = new List(); 19 | 20 | public List Bids 21 | { 22 | get { return _bids; } 23 | set { _bids = value; } 24 | } 25 | 26 | public List Asks 27 | { 28 | get { return _asks; } 29 | set { _asks = value; } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Model/ResponseModelBase.cs: -------------------------------------------------------------------------------- 1 | namespace IntTrader.API.Base.Model 2 | { 3 | public enum ResponseState 4 | { 5 | Success, 6 | Error, 7 | Exception, 8 | NotImplemented 9 | } 10 | 11 | public class ResponseModelBase 12 | { 13 | public virtual void Update() 14 | { 15 | 16 | } 17 | 18 | ResponseState _responseState = ResponseState.Success; 19 | 20 | public ResponseState ResponseState 21 | { 22 | get { return _responseState; } 23 | set { _responseState = value; } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Model/TradesEntryModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IntTrader.API.Base.Exchange.Orders; 3 | 4 | namespace IntTrader.API.Base.Model 5 | { 6 | public class TradesEntryModel 7 | { 8 | private DateTime _timestamp; 9 | private String _orderId; 10 | private decimal _price; 11 | private decimal _amount; 12 | private OrderSide _side; 13 | private String _type; 14 | private String _info; 15 | 16 | public DateTime Timestamp 17 | { 18 | get { return _timestamp; } 19 | set { _timestamp = value; } 20 | } 21 | 22 | public string OrderId 23 | { 24 | get { return _orderId; } 25 | set { _orderId = value; } 26 | } 27 | 28 | public decimal Price 29 | { 30 | get { return _price; } 31 | set { _price = value; } 32 | } 33 | 34 | public decimal Amount 35 | { 36 | get { return _amount; } 37 | set { _amount = value; } 38 | } 39 | 40 | public OrderSide Side 41 | { 42 | get { return _side; } 43 | set { _side = value; } 44 | } 45 | 46 | public string Type 47 | { 48 | get { return _type; } 49 | set { _type = value; } 50 | } 51 | 52 | public string Info 53 | { 54 | get { return _info; } 55 | set { _info = value; } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Model/TradesModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace IntTrader.API.Base.Model 4 | { 5 | public class TradesModel : ResponseModelBase 6 | { 7 | List _items = new List(); 8 | 9 | public List Items 10 | { 11 | get { return _items; } 12 | set { _items = value; } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Request/CancelOrderRequest.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | 4 | namespace IntTrader.API.Base.Request 5 | { 6 | public class CancelOrderRequestBase 7 | { 8 | private String _orderId; 9 | public String OrderId 10 | { 11 | get { return _orderId; } 12 | set { _orderId = value; } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Request/CreateOrderRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IntTrader.API.Base.Exchange.Base; 3 | using IntTrader.API.Base.Exchange.Orders; 4 | 5 | namespace IntTrader.API.Base.Request 6 | { 7 | public class CreateOrderRequestBase 8 | { 9 | private String _pair; 10 | private decimal _amount; 11 | private decimal _price; 12 | private ExchangeType _exchangeType; 13 | private OrderSide _side; 14 | private OrderType _ordertype; 15 | private bool _isHidden = false; 16 | private bool _validate = false; 17 | 18 | public string Pair 19 | { 20 | get { return _pair; } 21 | set { _pair = value; } 22 | } 23 | 24 | public decimal Amount 25 | { 26 | get { return _amount; } 27 | set { _amount = value; } 28 | } 29 | 30 | public decimal Price 31 | { 32 | get { return _price; } 33 | set { _price = value; } 34 | } 35 | 36 | public ExchangeType ExchangeType 37 | { 38 | get { return _exchangeType; } 39 | set { _exchangeType = value; } 40 | } 41 | 42 | public OrderSide Side 43 | { 44 | get { return _side; } 45 | set { _side = value; } 46 | } 47 | 48 | public OrderType OrderType 49 | { 50 | get { return _ordertype; } 51 | set { _ordertype = value; } 52 | } 53 | 54 | public bool IsHidden 55 | { 56 | get { return _isHidden; } 57 | set { _isHidden = value; } 58 | } 59 | 60 | public bool Validate 61 | { 62 | get { return _validate; } 63 | set { _validate = value; } 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /IntTrader.API/Base/Request/RequestBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IntTrader.API.Base.Model; 3 | using IntTrader.API.Base.Response; 4 | using IntTrader.API.Event; 5 | using Newtonsoft.Json; 6 | 7 | namespace IntTrader.API.Base.Request 8 | { 9 | public abstract class RequestBase 10 | { 11 | 12 | public virtual T Request() where T : class 13 | { 14 | var rs = Request(); 15 | rs.Request = this; 16 | return Deserialize(rs); 17 | } 18 | 19 | public T Deserialize(ResponseData responseData) where T : class 20 | { 21 | T result = null; 22 | 23 | if (!String.IsNullOrEmpty(responseData.Value)) 24 | { 25 | result = JsonConvert.DeserializeObject(responseData.Value); 26 | } 27 | 28 | var response = result as ResponseBase; 29 | if (response != null) 30 | { 31 | response.ResponseData = responseData; 32 | response.VerifyResponse(); 33 | RequestMonitor.OnRequestEvent(this, response); 34 | } 35 | 36 | return result; 37 | } 38 | 39 | public T DeserializeList(ResponseData responseData) 40 | { 41 | return JsonConvert.DeserializeObject(responseData.Value); 42 | } 43 | 44 | public abstract ResponseData Request(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Request/RequestMonitor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using IntTrader.API.Base.Response; 6 | using IntTrader.API.Event; 7 | 8 | namespace IntTrader.API.Base.Request 9 | { 10 | public class RequestMonitor 11 | { 12 | public static event EventHandler RequestEvent; 13 | 14 | public static void OnRequestEvent(object sender, ResponseBase response) 15 | { 16 | EventHandler handler = RequestEvent; 17 | if (handler != null) handler(sender, new RequestEventArgs(response)); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Response/ResponseBase.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Base.Exchange.Base; 2 | using IntTrader.API.Base.Model; 3 | using IntTrader.API.Currency; 4 | 5 | namespace IntTrader.API.Base.Response 6 | { 7 | public class ResponseBase 8 | { 9 | public ResponseData ResponseData { get; set; } 10 | public ExchangeBase Exchange { get; set; } 11 | public PairManager PairManager { get; set; } 12 | 13 | public virtual void VerifyResponse() 14 | { 15 | if (!ResponseData.HasResult) 16 | { 17 | ResponseData.ResponseState = ResponseState.Exception; 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Response/ResponseData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Net; 6 | using System.Text; 7 | using IntTrader.API.Base.Model; 8 | using IntTrader.API.Base.Request; 9 | 10 | namespace IntTrader.API.Base.Response 11 | { 12 | public class ResponseData 13 | { 14 | private Exception _exception; 15 | 16 | public Exception Exception 17 | { 18 | get { return _exception; } 19 | protected set { _exception = value; } 20 | } 21 | 22 | ResponseState _responseState = ResponseState.Success; 23 | private RequestBase _request; 24 | private String _value; 25 | private bool _hasResult = false; 26 | 27 | public ResponseState ResponseState 28 | { 29 | get { return _responseState; } 30 | set { _responseState = value; } 31 | } 32 | 33 | public string Value 34 | { 35 | get { return _value; } 36 | set { _value = value; } 37 | } 38 | 39 | public bool HasResult 40 | { 41 | get { return _hasResult; } 42 | set { _hasResult = value; } 43 | } 44 | 45 | public RequestBase Request 46 | { 47 | get { return _request; } 48 | set { _request = value; } 49 | } 50 | 51 | public ResponseData(RequestBase request, String message) 52 | { 53 | HasResult = true; 54 | this.Request = request; 55 | this.Value = message; 56 | } 57 | 58 | public ResponseData(RequestBase request, WebException exception) 59 | { 60 | this.Request = request; 61 | HasResult = false; 62 | ReadExceptionResponse(exception); 63 | } 64 | 65 | private void ReadExceptionResponse(WebException exception) 66 | { 67 | if (exception == null) 68 | { 69 | return; 70 | } 71 | 72 | Exception = exception; 73 | 74 | if (exception.Response == null) 75 | { 76 | Value = exception.Message; 77 | } 78 | else 79 | { 80 | var stream = exception.Response.GetResponseStream(); 81 | if (stream != null) 82 | { 83 | using (var sr = new StreamReader(stream)) 84 | { 85 | Value = sr.ReadToEnd(); 86 | } 87 | } 88 | } 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Settings/ExchangeAPI.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | 4 | namespace IntTrader.API.Base.Settings 5 | { 6 | public class ExchangeAPI 7 | { 8 | private String _name; 9 | private String _apiKey; 10 | private String _apiSecret; 11 | 12 | public string Name 13 | { 14 | get { return _name; } 15 | set { _name = value; } 16 | } 17 | 18 | public string APIKey 19 | { 20 | get { return _apiKey; } 21 | set { _apiKey = value; } 22 | } 23 | 24 | public string APISecret 25 | { 26 | get { return _apiSecret; } 27 | set { _apiSecret = value; } 28 | } 29 | 30 | [JsonIgnore] 31 | public bool IsValid 32 | { 33 | get { return !String.IsNullOrEmpty(APIKey) && !String.IsNullOrEmpty(APISecret); } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Settings/SettingsBase.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using IntTrader.API.Base.Exchange.Base; 3 | using Zicore.Settings.Json; 4 | 5 | namespace IntTrader.API.Base.Settings 6 | { 7 | public class SettingsBase : JsonSettingsEncrypted 8 | { 9 | List _exchanges = new List { }; 10 | 11 | public List Exchanges 12 | { 13 | get { return _exchanges; } 14 | set 15 | { 16 | foreach (var exchangeBase in value) 17 | { 18 | foreach (var exchange in Exchanges) 19 | { 20 | if (exchange.Name == exchangeBase.Name) 21 | { 22 | exchange.ExchangeAPI = exchangeBase.ExchangeAPI; 23 | } 24 | } 25 | } 26 | } 27 | } 28 | 29 | public static string ApplicationName = "IntTrader"; 30 | public static string FileName = "ExchangeSettings.aes.json"; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Transform/IBalance.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Base.Model; 2 | 3 | namespace IntTrader.API.Base.Transform 4 | { 5 | public interface IBalance 6 | { 7 | BalanceModel Transform(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Transform/IBalanceEntry.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Base.Model; 2 | 3 | namespace IntTrader.API.Base.Transform 4 | { 5 | public interface IBalanceEntry 6 | { 7 | BalanceEntryModel Transform(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Transform/ICancelOrder.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Base.Model; 2 | 3 | namespace IntTrader.API.Base.Transform 4 | { 5 | public interface ICancelOrder 6 | { 7 | CancelOrderModel Transform(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Transform/ICreateOrder.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Base.Model; 2 | 3 | namespace IntTrader.API.Base.Transform 4 | { 5 | public interface ICreateOrder 6 | { 7 | CreateOrderModel Transform(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Transform/IOrder.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Base.Model; 2 | 3 | namespace IntTrader.API.Base.Transform 4 | { 5 | public interface IOrder 6 | { 7 | OpenOrderEntryModel Transform(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Transform/IOrderBook.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Base.Model; 2 | 3 | namespace IntTrader.API.Base.Transform 4 | { 5 | public interface IOrderBook 6 | { 7 | OrderBookModel Transform(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Transform/IOrderBookEntry.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Base.Model; 2 | 3 | namespace IntTrader.API.Base.Transform 4 | { 5 | public interface IOrderBookEntry 6 | { 7 | OrderBookEntryModel Transform(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Transform/IOrders.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Base.Model; 2 | 3 | namespace IntTrader.API.Base.Transform 4 | { 5 | public interface IOrders 6 | { 7 | OpenOrdersModel Transform(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Transform/ITicker.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Base.Model; 2 | 3 | namespace IntTrader.API.Base.Transform 4 | { 5 | public interface ITicker 6 | { 7 | TickerModel Transform(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /IntTrader.API/Base/Transform/ITrades.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Base.Model; 2 | 3 | namespace IntTrader.API.Base.Transform 4 | { 5 | public interface ITrades 6 | { 7 | TradesModel Transform(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /IntTrader.API/Converter/DateTimeConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | 4 | namespace IntTrader.API.Converter 5 | { 6 | public class DateTimeConverter 7 | { 8 | 9 | /// 10 | /// Converts a Unix timestamp into a System.DateTime 11 | /// 12 | /// The Unix timestamp in milliseconds to convert, as a double 13 | /// DateTime obtained through conversion 14 | public static DateTime ConvertTimestamp(double timestamp) 15 | { 16 | var origin = new DateTime(1970, 1, 1, 0, 0, 0, 0); 17 | return origin.AddSeconds(timestamp); // convert from milliseconds to seconds 18 | } 19 | 20 | public static DateTime ConvertTimestamp(String timestamp) 21 | { 22 | if (String.IsNullOrEmpty(timestamp)) 23 | { 24 | return DateTime.MinValue; 25 | } 26 | //double result = 0; 27 | //double.TryParse(timestamp, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out result); 28 | return ConvertTimestamp(double.Parse(timestamp, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture)); 29 | } 30 | 31 | public static double ConvertDateTime(DateTime dateTime) 32 | { 33 | var origin = new DateTime(1970, 1, 1, 0, 0, 0, 0); 34 | return (dateTime - origin).TotalSeconds; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /IntTrader.API/Converter/DecimalConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | 4 | namespace IntTrader.API.Converter 5 | { 6 | public class DecimalConverter 7 | { 8 | public static String Convert(Decimal value) 9 | { 10 | return value.ToString(CultureInfo.InvariantCulture); 11 | } 12 | 13 | public static decimal ConvertToPrecision(decimal value, long precision) 14 | { 15 | return value / precision; 16 | } 17 | 18 | public static decimal Normalize(decimal value) 19 | { 20 | return value / 1.000000000000000000000000000000000m; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /IntTrader.API/Converter/DecimalRounding.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace IntTrader.API.Converter 7 | { 8 | public static class DecimalRounding 9 | { 10 | public static decimal RoundUp(decimal number, int places) 11 | { 12 | decimal factor = RoundFactor(places); 13 | number *= factor; 14 | number = Math.Ceiling(number); 15 | number /= factor; 16 | return number; 17 | } 18 | 19 | public static decimal RoundDown(decimal number, int places) 20 | { 21 | decimal factor = RoundFactor(places); 22 | number *= factor; 23 | number = Math.Floor(number); 24 | number /= factor; 25 | return number; 26 | } 27 | 28 | internal static decimal RoundFactor(int places) 29 | { 30 | decimal factor = 1m; 31 | 32 | if (places < 0) 33 | { 34 | places = -places; 35 | for (int i = 0; i < places; i++) 36 | factor /= 10m; 37 | } 38 | 39 | else 40 | { 41 | for (int i = 0; i < places; i++) 42 | factor *= 10m; 43 | } 44 | 45 | return factor; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /IntTrader.API/Currency/PairBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace IntTrader.API.Currency 4 | { 5 | public class PairBase 6 | { 7 | public static readonly String BTCXRP = "XRPBTC"; 8 | 9 | public static readonly String LTCEUR = "LTCEUR"; 10 | public static readonly String LTCUSD = "LTCUSD"; 11 | 12 | public static readonly String BTCEUR = "BTCEUR"; 13 | public static readonly String BTCUSD = "BTCUSD"; 14 | 15 | public static readonly String DRKUSD = "DRKUSD"; 16 | public static readonly String DRKEUR = "DRKEUR"; 17 | 18 | public static readonly String DRKBTC = "DRKBTC"; 19 | public static readonly String LTCBTC = "LTCBTC"; 20 | 21 | public static readonly String BTCLTC = "BTCLTC"; 22 | 23 | 24 | public PairBase() 25 | { 26 | 27 | } 28 | 29 | private String _name; 30 | private String _description; 31 | private String _key; 32 | 33 | private CurrencyBase _leftCurrency; 34 | private CurrencyBase _rightCurrency; 35 | 36 | 37 | public string Description 38 | { 39 | get { return _description; } 40 | set { _description = value; } 41 | } 42 | 43 | public string Name 44 | { 45 | get { return _name; } 46 | set { _name = value; } 47 | } 48 | 49 | public string Key 50 | { 51 | get { return _key; } 52 | set { _key = value; } 53 | } 54 | 55 | public CurrencyBase LeftCurrency 56 | { 57 | get { return _leftCurrency; } 58 | set { _leftCurrency = value; } 59 | } 60 | 61 | public CurrencyBase RightCurrency 62 | { 63 | get { return _rightCurrency; } 64 | set { _rightCurrency = value; } 65 | } 66 | 67 | public String NamePair 68 | { 69 | get { return String.Format("{0}/{1}", LeftCurrency.Name, RightCurrency.Name); } 70 | } 71 | 72 | public String SymbolPair 73 | { 74 | get { return String.Format("{0}/{1}", LeftCurrency.Symbol, RightCurrency.Symbol); } 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /IntTrader.API/Event/CreateOrderEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using IntTrader.API.Base.Exchange.Base; 6 | using IntTrader.API.Base.Model; 7 | 8 | namespace IntTrader.API.Event 9 | { 10 | public class CreateOrderEventArgs : EventArgs 11 | { 12 | private ExchangeBase _exchange; 13 | private CreateOrderModel _model; 14 | 15 | public CreateOrderEventArgs(ExchangeBase exchange, CreateOrderModel model) 16 | { 17 | _exchange = exchange; 18 | _model = model; 19 | } 20 | 21 | public ExchangeBase Exchange 22 | { 23 | get { return _exchange; } 24 | set { _exchange = value; } 25 | } 26 | 27 | 28 | public CreateOrderModel Model 29 | { 30 | get { return _model; } 31 | set { _model = value; } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /IntTrader.API/Event/RequestEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using IntTrader.API.Base.Response; 6 | 7 | namespace IntTrader.API.Event 8 | { 9 | public class RequestEventArgs : EventArgs 10 | { 11 | public RequestEventArgs(ResponseBase response) 12 | { 13 | this.Response = response; 14 | } 15 | 16 | private ResponseBase _response; 17 | 18 | public ResponseBase Response 19 | { 20 | get { return _response; } 21 | set { _response = value; } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /IntTrader.API/Exceptions/CurrencyNotSupported.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace IntTrader.API.Exceptions 4 | { 5 | public class CurrencyNotSupportedException : Exception 6 | { 7 | private String _currencyKey; 8 | 9 | public string CurrencyKey 10 | { 11 | get { return _currencyKey; } 12 | set { _currencyKey = value; } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /IntTrader.API/Exceptions/PairNotSupportedException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace IntTrader.API.Exceptions 4 | { 5 | public class PairNotSupportedException : Exception 6 | { 7 | private String _pairKey; 8 | 9 | public string PairKey 10 | { 11 | get { return _pairKey; } 12 | set { _pairKey = value; } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /IntTrader.API/NLog.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /IntTrader.API/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Allgemeine Informationen über eine Assembly werden über die folgenden 6 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, 7 | // die mit einer Assembly verknüpft sind. 8 | [assembly: AssemblyTitle("IntTrader.API")] 9 | [assembly: AssemblyDescription("IntTrader.API")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("IntTrader.API")] 13 | [assembly: AssemblyCopyright("Copyright © 2014 by Zicore")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar 18 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von 19 | // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. 20 | [assembly: ComVisible(false)] 21 | 22 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird 23 | [assembly: Guid("5808c2ba-964c-4df7-b968-8c0a772da071")] 24 | 25 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: 26 | // 27 | // Hauptversion 28 | // Nebenversion 29 | // Buildnummer 30 | // Revision 31 | // 32 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern 33 | // übernehmen, indem Sie "*" eingeben: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /IntTrader.API/Threading/LockFreeQueue.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | 3 | namespace IntTrader.API.Threading 4 | { 5 | public class LockFreeQueue 6 | { 7 | public LockFreeQueue() 8 | { 9 | first = new Node(); 10 | last = first; 11 | } 12 | 13 | int count = 0; 14 | 15 | public int Count 16 | { 17 | get { return count; } 18 | set { count = value; } 19 | } 20 | 21 | Node first; 22 | Node last; 23 | 24 | public void Enqueue(T item) 25 | { 26 | Node newNode = new Node(); 27 | newNode.item = item; 28 | Node old = Interlocked.Exchange(ref first, newNode); 29 | old.next = newNode; 30 | count++; 31 | } 32 | 33 | public bool Dequeue(out T item) 34 | { 35 | Node current; 36 | do 37 | { 38 | current = last; 39 | if (current.next == null) 40 | { 41 | item = default(T); 42 | return false; 43 | } 44 | } 45 | while (current != Interlocked.CompareExchange(ref last, current.next, current)); 46 | item = current.next.item; 47 | current.next.item = default(T); 48 | count--; 49 | return true; 50 | } 51 | 52 | class Node 53 | { 54 | public T item; 55 | public Node next; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /IntTrader.API/Threading/RequestHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | 5 | namespace IntTrader.API.Threading 6 | { 7 | /// 8 | /// This is required to make all requests in proper order, in the order the nonce is incrementing. 9 | /// 10 | public class RequestHandler 11 | { 12 | readonly private LockFreeQueue _queue = new LockFreeQueue(); 13 | readonly Task _task; 14 | private volatile bool _isEnabled = false; 15 | 16 | public bool IsEnabled 17 | { 18 | get { return _isEnabled; } 19 | set { _isEnabled = value; } 20 | } 21 | 22 | public LockFreeQueue Queue 23 | { 24 | get { return _queue; } 25 | } 26 | 27 | public RequestHandler() 28 | { 29 | 30 | _isEnabled = true; 31 | _task = new Task(Execute); 32 | _task.Start(); 33 | } 34 | 35 | private void Execute() 36 | { 37 | while (_isEnabled) 38 | { 39 | Action action; 40 | while (_queue.Dequeue(out action)) 41 | { 42 | try 43 | { 44 | action.Invoke(); 45 | } 46 | catch 47 | { 48 | 49 | } 50 | } 51 | Thread.Sleep(1); 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /IntTrader.API/Web/GetRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Net; 2 | 3 | namespace IntTrader.API.Web 4 | { 5 | public class GetRequest 6 | { 7 | private Cookie _cookie; 8 | private string _host; 9 | private string _referer; 10 | private string _uri; 11 | private string _userAgent; 12 | 13 | public Cookie Cookie 14 | { 15 | get { return _cookie; } 16 | set { _cookie = value; } 17 | } 18 | 19 | public string Host 20 | { 21 | get { return _host; } 22 | set { _host = value; } 23 | } 24 | 25 | public string Referer 26 | { 27 | get { return _referer; } 28 | set { _referer = value; } 29 | } 30 | 31 | public string Uri 32 | { 33 | get { return _uri; } 34 | set { _uri = value; } 35 | } 36 | 37 | public string UserAgent 38 | { 39 | get { return _userAgent; } 40 | set { _userAgent = value; } 41 | } 42 | 43 | public string Request() 44 | { 45 | return WebClientExtended.Get(this); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /IntTrader.API/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Bitfinex/Bitfinex/Request/Authenticated/Balance.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using IntTrader.API.Base.Exchange.Base; 3 | using IntTrader.API.Exchange.Bitfinex.Response; 4 | 5 | namespace IntTrader.API.Exchange.Bitfinex.Request.Authenticated 6 | { 7 | public class Balance : AuthenticatedRequest 8 | { 9 | public Balance(ExchangeBase exchange) 10 | : base(exchange) 11 | { 12 | RequestUri = "/v1/balances"; 13 | } 14 | 15 | //public BalanceResponse RequestSolid() 16 | //{ 17 | // var rs = Request(); 18 | // return new BalanceResponse { Items = Deserialize>(rs) }; 19 | //} 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Bitfinex/Bitfinex/Request/Authenticated/OrderCancel.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Base.Exchange.Base; 2 | using IntTrader.API.Base.Response; 3 | using IntTrader.API.Exchange.Bitfinex.Response; 4 | using Newtonsoft.Json; 5 | 6 | namespace IntTrader.API.Exchange.Bitfinex.Request.Authenticated 7 | { 8 | public class OrderCancel : AuthenticatedRequest 9 | { 10 | public OrderCancel(ExchangeBase exchange) 11 | : base(exchange) 12 | { 13 | RequestUri = "/v1/order/cancel"; 14 | } 15 | 16 | private long _orderId; 17 | 18 | [JsonProperty("order_id")] 19 | public long OrderId 20 | { 21 | get { return _orderId; } 22 | set { _orderId = value; } 23 | } 24 | 25 | public OrderStatusResponse Deserialize(ResponseData responseData) 26 | { 27 | return Deserialize(responseData); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Bitfinex/Bitfinex/Request/BitfinexRequestBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Text; 4 | using IntTrader.API.Base.Request; 5 | using IntTrader.API.Base.Response; 6 | using IntTrader.API.Web; 7 | using NLog; 8 | using Newtonsoft.Json; 9 | using Newtonsoft.Json.Linq; 10 | 11 | namespace IntTrader.API.Exchange.Bitfinex.Request 12 | { 13 | public class BitfinexRequestBase : RequestBase 14 | { 15 | public static String ApiUri = "https://api.bitfinex.com"; 16 | private readonly static Logger Log = LogManager.GetCurrentClassLogger(); 17 | private String _requestUri; 18 | 19 | [JsonProperty("request")] 20 | protected string RequestUri 21 | { 22 | get { return _requestUri; } 23 | set { _requestUri = value; } 24 | } 25 | 26 | [JsonIgnore] 27 | protected string Uri 28 | { 29 | get { return String.Format("{0}{1}", ApiUri, RequestUri); } 30 | } 31 | 32 | public String ToJsonBase64String() 33 | { 34 | return Convert.ToBase64String(Encoding.UTF8.GetBytes(ToJsonString())); 35 | } 36 | 37 | public virtual String ToJsonString() 38 | { 39 | return JsonConvert.SerializeObject(this); 40 | } 41 | 42 | public override ResponseData Request() 43 | { 44 | using (var client = WebClientExtended.GetDefault()) 45 | { 46 | client.Headers["Host"] = "api.bitfinex.com"; 47 | 48 | try 49 | { 50 | Log.Info(RequestUri); 51 | AddGetParameters(this, client); 52 | var postResult = client.DownloadString(Uri); 53 | return new ResponseData(this, postResult); 54 | } 55 | catch (WebException ex) 56 | { 57 | return new ResponseData(this, ex); 58 | } 59 | } 60 | } 61 | 62 | private void AddGetParameters(Object obj, WebClientExtended client) 63 | { 64 | String result = JsonConvert.SerializeObject(obj); 65 | JObject jObject = JObject.Parse(result); 66 | 67 | foreach (var token in jObject) 68 | { 69 | if (token.Key != "request") 70 | { 71 | client.QueryString.Add(token.Key, token.Value.ToString()); 72 | } 73 | } 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Bitfinex/Bitfinex/Request/OrderBook.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Currency; 2 | using Newtonsoft.Json; 3 | 4 | namespace IntTrader.API.Exchange.Bitfinex.Request 5 | { 6 | public class OrderBook : BitfinexRequestBase 7 | { 8 | public OrderBook(PairBase symbol) 9 | { 10 | RequestUri = "/v1/book/" + symbol.Name; 11 | } 12 | 13 | private int _limitBids = 500; 14 | private int _limitAsks = 500; 15 | 16 | [JsonProperty("limit_bids")] 17 | public int LimitBids 18 | { 19 | get { return _limitBids; } 20 | set { _limitBids = value; } 21 | } 22 | 23 | [JsonProperty("limit_asks")] 24 | public int LimitAsks 25 | { 26 | get { return _limitAsks; } 27 | set { _limitAsks = value; } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Bitfinex/Bitfinex/Request/OrderStatus.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Base.Exchange.Base; 2 | using IntTrader.API.Base.Response; 3 | using IntTrader.API.Exchange.Bitfinex.Request.Authenticated; 4 | using IntTrader.API.Exchange.Bitfinex.Response; 5 | using Newtonsoft.Json; 6 | 7 | namespace IntTrader.API.Exchange.Bitfinex.Request 8 | { 9 | public class OrderStatus : AuthenticatedRequest 10 | { 11 | public OrderStatus(ExchangeBase exchange) 12 | : base(exchange) 13 | { 14 | RequestUri = "/v1/order/status"; 15 | } 16 | 17 | private int _orderId; 18 | 19 | [JsonProperty("order_id")] 20 | public int OrderId 21 | { 22 | get { return _orderId; } 23 | set { _orderId = value; } 24 | } 25 | 26 | public OrderStatusResponse Deserialize(ResponseData responseData) 27 | { 28 | return Deserialize(responseData); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Bitfinex/Bitfinex/Request/Orders.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using IntTrader.API.Base.Exchange.Base; 3 | using IntTrader.API.Exchange.Bitfinex.Request.Authenticated; 4 | using IntTrader.API.Exchange.Bitfinex.Response; 5 | 6 | namespace IntTrader.API.Exchange.Bitfinex.Request 7 | { 8 | public class Orders : AuthenticatedRequest 9 | { 10 | public Orders(ExchangeBase exchange) 11 | : base(exchange) 12 | { 13 | RequestUri = "/v1/orders"; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Bitfinex/Bitfinex/Request/Ticker.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Currency; 2 | 3 | namespace IntTrader.API.Exchange.Bitfinex.Request 4 | { 5 | public class Ticker : BitfinexRequestBase 6 | { 7 | public Ticker(PairBase symbol) 8 | { 9 | RequestUri = "/v1/ticker/" + symbol.Name; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Bitfinex/Bitfinex/Request/Today.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Currency; 2 | 3 | namespace IntTrader.API.Exchange.Bitfinex.Request 4 | { 5 | public class Today : BitfinexRequestBase 6 | { 7 | public Today(PairBase symbol) 8 | { 9 | RequestUri = "/v1/today/" + symbol.Name; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Bitfinex/Bitfinex/Request/TradesRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IntTrader.API.Currency; 3 | using Newtonsoft.Json; 4 | 5 | namespace IntTrader.API.Exchange.Bitfinex.Request 6 | { 7 | public class TradesRequest : BitfinexRequestBase 8 | { 9 | public TradesRequest(PairBase pair) 10 | { 11 | RequestUri = "/v1/trades/" + pair.Name; 12 | } 13 | 14 | private int _limit = 50; 15 | private String _timestamp; 16 | 17 | [JsonProperty("limit_trades")] 18 | public int Limit 19 | { 20 | get { return _limit; } 21 | set { _limit = value; } 22 | } 23 | 24 | [JsonProperty("timestamp")] 25 | public string Timestamp 26 | { 27 | get { return _timestamp; } 28 | set { _timestamp = value; } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Bitfinex/Bitfinex/Response/BalanceEntry.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IntTrader.API.Base.Model; 3 | using IntTrader.API.Base.Transform; 4 | using Newtonsoft.Json; 5 | 6 | namespace IntTrader.API.Exchange.Bitfinex.Response 7 | { 8 | public class BalanceEntry : IBalanceEntry 9 | { 10 | //A list of wallet balances: 11 | //type (string): "trading", "deposit" or "exchange". 12 | //currency (string): Currency 13 | //amount (decimal): How much balance of this currency in this wallet 14 | //available (decimal): How much X there is in this wallet that is available to trade. 15 | 16 | private String _walletType; 17 | private String _currency; 18 | private decimal _amount; 19 | private decimal _available; 20 | 21 | [JsonProperty("type")] 22 | public string WalletType 23 | { 24 | get { return _walletType; } 25 | set { _walletType = value; } 26 | } 27 | 28 | [JsonProperty("currency")] 29 | public string Currency 30 | { 31 | get { return _currency; } 32 | set { _currency = value; } 33 | } 34 | 35 | [JsonProperty("amount")] 36 | public decimal Amount 37 | { 38 | get { return _amount; } 39 | set { _amount = value; } 40 | } 41 | 42 | [JsonProperty("available")] 43 | public decimal Available 44 | { 45 | get { return _available; } 46 | set { _available = value; } 47 | } 48 | 49 | public BalanceEntryModel Transform() 50 | { 51 | return new BalanceEntryModel 52 | { 53 | Amount = Amount, 54 | CurrencyKey = Currency, 55 | Available = Available, 56 | WalletType = WalletType 57 | }; 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Bitfinex/Bitfinex/Response/BalanceResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using IntTrader.API.Base.Model; 4 | using IntTrader.API.Base.Transform; 5 | using Newtonsoft.Json; 6 | using Newtonsoft.Json.Linq; 7 | 8 | namespace IntTrader.API.Exchange.Bitfinex.Response 9 | { 10 | [JsonConverter(typeof(BalanceConverter))] 11 | public class BalanceResponse : BitfinexResponse, IBalance 12 | { 13 | private List _items = new List(); 14 | 15 | public List Items 16 | { 17 | get { return _items; } 18 | set { _items = value; } 19 | } 20 | 21 | public BalanceModel Transform() 22 | { 23 | var list = new List(); 24 | 25 | Items.ForEach(x => list.Add(x.Transform())); 26 | return new BalanceModel 27 | { 28 | Items = list 29 | }; 30 | } 31 | } 32 | 33 | public class BalanceConverter : JsonConverter 34 | { 35 | public override bool CanConvert(Type objectType) 36 | { 37 | return (objectType == typeof(BalanceResponse)); 38 | } 39 | 40 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) 41 | { 42 | throw new NotImplementedException(); 43 | } 44 | 45 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) 46 | { 47 | var json = JToken.Load(reader); 48 | BalanceResponse response = new BalanceResponse(); 49 | response.Items = json.ToObject>(); 50 | return response; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Bitfinex/Bitfinex/Response/BitfinexResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IntTrader.API.Base.Model; 3 | using IntTrader.API.Base.Response; 4 | using Newtonsoft.Json; 5 | 6 | namespace IntTrader.API.Exchange.Bitfinex.Response 7 | { 8 | public class BitfinexResponse : ResponseBase 9 | { 10 | public BitfinexResponse() 11 | { 12 | 13 | } 14 | 15 | public static T Deserialize(ResponseData responseData) where T : BitfinexResponse 16 | { 17 | return JsonConvert.DeserializeObject(responseData.Value); 18 | } 19 | 20 | private String _message; 21 | 22 | [JsonProperty("message")] 23 | public string Message 24 | { 25 | get { return _message; } 26 | set { _message = value; } 27 | } 28 | 29 | public override void VerifyResponse() 30 | { 31 | if (!String.IsNullOrEmpty(Message)) 32 | { 33 | ResponseData.ResponseState = ResponseState.Error; 34 | } 35 | base.VerifyResponse(); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Bitfinex/Bitfinex/Response/CancelOrderResponse.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Base.Model; 2 | using IntTrader.API.Base.Transform; 3 | 4 | namespace IntTrader.API.Exchange.Bitfinex.Response 5 | { 6 | public class CancelOrderResponse : OrderResponseBase, ICancelOrder 7 | { 8 | 9 | 10 | public CancelOrderModel Transform() 11 | { 12 | var m = new CancelOrderModel(); 13 | m.OrdersCanceled = 1; 14 | m.OrderId = this.Id; 15 | return m; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Bitfinex/Bitfinex/Response/CreateOrderResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IntTrader.API.Base.Exchange.Base; 3 | using IntTrader.API.Base.Model; 4 | using IntTrader.API.Base.Transform; 5 | using IntTrader.API.Converter; 6 | using Newtonsoft.Json; 7 | 8 | namespace IntTrader.API.Exchange.Bitfinex.Response 9 | { 10 | public class CreateOrderResponse : OrderStatusResponse, ICreateOrder 11 | { 12 | private String _orderId; 13 | 14 | [JsonProperty("order_id")] 15 | public String OrderId 16 | { 17 | get { return _orderId; } 18 | set { _orderId = value; } 19 | } 20 | 21 | public CreateOrderModel Transform() 22 | { 23 | return new CreateOrderModel 24 | { 25 | OrderId = OrderId, 26 | AverageExecutionPrice = AverageExecutionPrice, 27 | DateTime = DateTimeConverter.ConvertTimestamp(Timestamp), 28 | ExchangeString = ExchangeString, 29 | ExecutedAmount = ExecutedAmount, 30 | IsCancelled = IsCancelled, 31 | IsLive = IsLive, 32 | OriginalAmount = OriginalAmount, 33 | Price = Price, 34 | RemainingAmount = RemainingAmount, 35 | Symbol = Symbol, 36 | Type = Type, 37 | WasForced = WasForced, 38 | OrderStatus = ConvertStatus(this), 39 | WasSuccessful = true 40 | }; 41 | } 42 | 43 | // To support the real status, who knows if "Live and Canceled" is even possible 44 | private String ConvertStatus(OrderStatusResponse order) 45 | { 46 | String status = ""; 47 | if (order.IsLive && !order.IsCancelled) 48 | status = "Live"; 49 | 50 | if (order.IsLive && order.IsCancelled) 51 | status = "Live | Canceled"; 52 | 53 | if (!order.IsLive && order.IsCancelled) 54 | status = "Canceled"; 55 | 56 | if (order.WasForced) 57 | status += " | Forced"; 58 | return status; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Bitfinex/Bitfinex/Response/OrderBookEntry.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IntTrader.API.Base.Model; 3 | using IntTrader.API.Base.Transform; 4 | using IntTrader.API.Converter; 5 | using Newtonsoft.Json; 6 | 7 | namespace IntTrader.API.Exchange.Bitfinex.Response 8 | { 9 | public class OrderBookEntry : IOrderBookEntry 10 | { 11 | // "price": "0.0278", 12 | // "amount": "20.0", 13 | // "timestamp": "1395065891.0" 14 | 15 | private decimal _price; 16 | private decimal _amount; 17 | private String _timestamp; 18 | 19 | [JsonProperty("price")] 20 | public decimal Price 21 | { 22 | get { return _price; } 23 | set { _price = value; } 24 | } 25 | 26 | [JsonProperty("amount")] 27 | public decimal Amount 28 | { 29 | get { return _amount; } 30 | set { _amount = value; } 31 | } 32 | 33 | [JsonProperty("timestamp")] 34 | public string Timestamp 35 | { 36 | get { return _timestamp; } 37 | set { _timestamp = value; } 38 | } 39 | 40 | public OrderBookEntryModel Transform() 41 | { 42 | return new OrderBookEntryModel { Amount = Amount, Price = Price, DateTime = DateTimeConverter.ConvertTimestamp(Timestamp) }; 43 | } 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Bitfinex/Bitfinex/Response/OrderBookResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using IntTrader.API.Base.Model; 3 | using IntTrader.API.Base.Transform; 4 | using Newtonsoft.Json; 5 | 6 | namespace IntTrader.API.Exchange.Bitfinex.Response 7 | { 8 | public class OrderBookResponse : BitfinexResponse, IOrderBook 9 | { 10 | public OrderBookResponse() 11 | { 12 | 13 | } 14 | 15 | private List _bids; 16 | private List _asks; 17 | 18 | [JsonProperty("bids")] 19 | public List Bids 20 | { 21 | get { return _bids; } 22 | set { _bids = value; } 23 | } 24 | 25 | [JsonProperty("asks")] 26 | public List Asks 27 | { 28 | get { return _asks; } 29 | set { _asks = value; } 30 | } 31 | 32 | public OrderBookModel Transform() 33 | { 34 | var asks = new List(); 35 | var bids = new List(); 36 | 37 | Asks.ForEach(x => asks.Add(x.Transform())); 38 | Bids.ForEach(x => bids.Add(x.Transform())); 39 | 40 | return new OrderBookModel 41 | { 42 | Asks = new List(asks), 43 | Bids = new List(bids) 44 | }; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Bitfinex/Bitfinex/Response/OrderResponse.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Base.Exchange.Base; 2 | using IntTrader.API.Base.Model; 3 | using IntTrader.API.Base.Transform; 4 | using IntTrader.API.Converter; 5 | 6 | namespace IntTrader.API.Exchange.Bitfinex.Response 7 | { 8 | public class OrderResponse : OrderResponseBase, IOrder 9 | { 10 | //id (int) 11 | //symbol (string): The symbol name the order belongs to. 12 | //exchange (string): "bitfinex", "bitstamp". 13 | //price (decimal): The price the order was issued at (can be null for market orders). 14 | //avg_execution_price (decimal): The average price at which this order as been executed so far. 0 if the order has not been executed at all. side (string): Either "buy" or "sell". 15 | //type (string): Either "market" / "limit" / "stop" / "trailing-stop". 16 | //timestamp (time): The timestamp the order was submitted. 17 | //is_live (bool): Could the order still be filled? 18 | //is_cancelled (bool): Has the order been cancelled? 19 | //was_forced (bool): For margin only: true if it was forced by the system. 20 | //executed_amount (decimal): How much of the order has been executed so far in its history? 21 | //remaining_amount (decimal): How much is still remaining to be submitted? 22 | //original_amount (decimal): What was the order originally submitted for? 23 | //Active Orders 24 | 25 | public OpenOrderEntryModel Transform() 26 | { 27 | return new OpenOrderEntryModel 28 | { 29 | AverageExecutionPrice = AvgerageExecutionPrice, 30 | ExchangeString = ExchangeString, 31 | ExecutedAmount = ExecutedAmount, 32 | IsCancelled = IsCancelled, 33 | IsLive = IsLive, 34 | OrderId = Id, 35 | OriginalAmount = OriginalAmount, 36 | Price = Price, 37 | RemainingAmount = RemainingAmount, 38 | Symbol = Symbol, 39 | DateTime = DateTimeConverter.ConvertTimestamp(Timestamp), 40 | Type = Type, 41 | WasForced = WasForced 42 | }; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Bitfinex/Bitfinex/Response/OrdersResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using IntTrader.API.Base.Model; 4 | using IntTrader.API.Base.Transform; 5 | using Newtonsoft.Json; 6 | using Newtonsoft.Json.Linq; 7 | 8 | namespace IntTrader.API.Exchange.Bitfinex.Response 9 | { 10 | [JsonConverter(typeof(OrdersConverter))] 11 | public class OrdersResponse : BitfinexResponse, IOrders 12 | { 13 | public OrdersResponse() 14 | { 15 | 16 | } 17 | 18 | List _orders = new List(); 19 | 20 | public List Orders 21 | { 22 | get { return _orders; } 23 | set { _orders = value; } 24 | } 25 | 26 | public OpenOrdersModel Transform() 27 | { 28 | var ordersModel = new OpenOrdersModel(); 29 | 30 | Orders.ForEach(x => ordersModel.Orders.Add(x.Transform())); 31 | 32 | return ordersModel; 33 | } 34 | } 35 | 36 | public class OrdersConverter : JsonConverter 37 | { 38 | public override bool CanConvert(Type objectType) 39 | { 40 | return (objectType == typeof(OrdersResponse)); 41 | } 42 | 43 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) 44 | { 45 | throw new NotImplementedException(); 46 | } 47 | 48 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) 49 | { 50 | var json = JToken.Load(reader); 51 | OrdersResponse response = new OrdersResponse(); 52 | response.Orders = json.ToObject>(); 53 | return response; 54 | } 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Bitfinex/Bitfinex/Response/TickerResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IntTrader.API.Base.Model; 3 | using IntTrader.API.Base.Transform; 4 | using IntTrader.API.Converter; 5 | using Newtonsoft.Json; 6 | 7 | namespace IntTrader.API.Exchange.Bitfinex.Response 8 | { 9 | public class TickerResponse : BitfinexResponse, ITicker 10 | { 11 | public TickerResponse() 12 | { 13 | 14 | } 15 | //mid (price): (bid + ask) / 2 16 | //bid (price): Innermost bid. 17 | //ask (price): Innermost ask. 18 | //last_price (price) The price at which the last order executed. 19 | //timestamp (time) The timestamp at which this information was valid. 20 | 21 | private decimal _mid; 22 | private decimal _bid; 23 | private decimal _ask; 24 | private decimal _lastPrice; 25 | private String _timestamp; 26 | 27 | [JsonProperty("mid")] 28 | public decimal Mid 29 | { 30 | get { return _mid; } 31 | set { _mid = value; } 32 | } 33 | 34 | [JsonProperty("bid")] 35 | public decimal Bid 36 | { 37 | get { return _bid; } 38 | set { _bid = value; } 39 | } 40 | 41 | [JsonProperty("ask")] 42 | public decimal Ask 43 | { 44 | get { return _ask; } 45 | set { _ask = value; } 46 | } 47 | 48 | [JsonProperty("last_price")] 49 | public decimal LastPrice 50 | { 51 | get { return _lastPrice; } 52 | set { _lastPrice = value; } 53 | } 54 | 55 | [JsonProperty("timestamp")] 56 | public string Timestamp 57 | { 58 | get { return _timestamp; } 59 | set { _timestamp = value; } 60 | } 61 | 62 | public TickerModel Transform() 63 | { 64 | return new TickerModel 65 | { 66 | Ask = Ask, 67 | Bid = Bid, 68 | DateTime = DateTimeConverter.ConvertTimestamp(Timestamp), 69 | LastPrice = LastPrice, 70 | Mid = Mid 71 | }; 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Bitfinex/Bitfinex/Response/TodayResponse.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace IntTrader.API.Exchange.Bitfinex.Response 4 | { 5 | public class TodayResponse : BitfinexResponse 6 | { 7 | public TodayResponse() 8 | { 9 | 10 | } 11 | 12 | //low (price) 13 | //high (price) 14 | //volume (price) 15 | 16 | private decimal _low; 17 | private decimal _high; 18 | private decimal _volume; 19 | 20 | [JsonProperty("low")] 21 | public decimal Low 22 | { 23 | get { return _low; } 24 | set { _low = value; } 25 | } 26 | 27 | [JsonProperty("high")] 28 | public decimal High 29 | { 30 | get { return _high; } 31 | set { _high = value; } 32 | } 33 | 34 | [JsonProperty("volume")] 35 | public decimal Volume 36 | { 37 | get { return _volume; } 38 | set { _volume = value; } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Bitfinex/NLog.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 14 | 15 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Bitfinex/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Allgemeine Informationen über eine Assembly werden über die folgenden 6 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, 7 | // die mit einer Assembly verknüpft sind. 8 | [assembly: AssemblyTitle("IntTrader.Bitfinex.Exchange")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("IntTrader.Bitfinex.Exchange")] 13 | [assembly: AssemblyCopyright("Copyright © 2014 by Zicore")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar 18 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von 19 | // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. 20 | [assembly: ComVisible(false)] 21 | 22 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird 23 | [assembly: Guid("f999a260-cd5f-42f2-bfd8-4b2658c86b81")] 24 | 25 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: 26 | // 27 | // Hauptversion 28 | // Nebenversion 29 | // Buildnummer 30 | // Revision 31 | // 32 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern 33 | // übernehmen, indem Sie "*" eingeben: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Bitfinex/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Kraken/Kraken/Authentication.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Security.Cryptography; 3 | using System.Text; 4 | 5 | namespace IntTrader.API.Exchange.Kraken 6 | { 7 | public class Authentication 8 | { 9 | public Authentication() 10 | { 11 | 12 | } 13 | 14 | //byte[] base64DecodedSecred = Convert.FromBase64String(_secret); 15 | 16 | // var np = nonce + Convert.ToChar(0) + props; 17 | 18 | // var pathBytes = Encoding.UTF8.GetBytes(path); 19 | // var hash256Bytes = sha256_hash(np); 20 | // var z = new byte[pathBytes.Count() + hash256Bytes.Count()]; 21 | // pathBytes.CopyTo(z, 0); 22 | // hash256Bytes.CopyTo(z, pathBytes.Count()); 23 | 24 | // var signature = getHash(base64DecodedSecred, z); 25 | 26 | //Message signature using HMAC-SHA512 of (URI path + SHA256(nonce + POST data)) and base64 decoded secret API key 27 | 28 | public String CreateSignature(String uri, String nonce, String postData, String apiSecret) 29 | { 30 | var decodedKey = Convert.FromBase64String(apiSecret); 31 | using (var hmac = new HMACSHA512(decodedKey)) 32 | { 33 | using (var sha256 = new SHA256Managed()) 34 | { 35 | 36 | var nonceBytes = Encoding.UTF8.GetBytes(nonce); 37 | var postDataBytes = Encoding.UTF8.GetBytes(postData); 38 | var uriBytes = Encoding.UTF8.GetBytes(uri); 39 | 40 | 41 | var sha256Bytes = new byte[nonceBytes.Length + postDataBytes.Length]; 42 | nonceBytes.CopyTo(sha256Bytes, 0); 43 | postDataBytes.CopyTo(sha256Bytes, nonceBytes.Length); 44 | sha256Bytes = sha256.ComputeHash(sha256Bytes); 45 | 46 | 47 | 48 | var complementMessage = new byte[uriBytes.Length + sha256Bytes.Length]; 49 | uriBytes.CopyTo(complementMessage, 0); 50 | sha256Bytes.CopyTo(complementMessage, uriBytes.Length); 51 | 52 | 53 | var signature = hmac.ComputeHash(complementMessage); 54 | return Convert.ToBase64String(signature); 55 | } 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Kraken/Kraken/Request/Authenticated/BalanceRequest.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Base.Exchange.Base; 2 | 3 | namespace IntTrader.API.Exchange.Kraken.Request.Authenticated 4 | { 5 | public class BalanceRequest : AuthenticatedRequest 6 | { 7 | public BalanceRequest(ExchangeBase exchange) 8 | : base(exchange) 9 | { 10 | RequestUri = "/0/private/Balance"; 11 | } 12 | 13 | //public BalanceResponse RequestSolid() 14 | //{ 15 | // var rs = Request(); 16 | // return new BalanceResponse { Items = Deserialize>(rs) }; 17 | //} 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Kraken/Kraken/Request/Authenticated/CancelOrderRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IntTrader.API.Base.Exchange.Base; 3 | using IntTrader.API.Base.Response; 4 | using IntTrader.API.Exchange.Kraken.Response; 5 | using Newtonsoft.Json; 6 | 7 | namespace IntTrader.API.Exchange.Kraken.Request.Authenticated 8 | { 9 | public class CancelOrderRequest : AuthenticatedRequest 10 | { 11 | public CancelOrderRequest(ExchangeBase exchange) 12 | : base(exchange) 13 | { 14 | RequestUri = "/0/private/CancelOrder"; 15 | } 16 | 17 | private String _txid; 18 | 19 | [JsonProperty("txid")] 20 | public String Txid 21 | { 22 | get { return _txid; } 23 | set { _txid = value; } 24 | } 25 | 26 | public CancelOrderResponse Deserialize(ResponseData responseData) 27 | { 28 | return Deserialize(responseData); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Kraken/Kraken/Request/Authenticated/OpenOrdersRequest.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Base.Exchange.Base; 2 | 3 | namespace IntTrader.API.Exchange.Kraken.Request.Authenticated 4 | { 5 | public class OpenOrdersRequest : AuthenticatedRequest 6 | { 7 | public OpenOrdersRequest(ExchangeBase exchange) 8 | : base(exchange) 9 | { 10 | RequestUri = "/0/private/OpenOrders"; 11 | } 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Kraken/Kraken/Request/KrakenRequestBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Text; 4 | using IntTrader.API.Base.Request; 5 | using IntTrader.API.Base.Response; 6 | using IntTrader.API.Web; 7 | using NLog; 8 | using Newtonsoft.Json; 9 | using Newtonsoft.Json.Linq; 10 | 11 | namespace IntTrader.API.Exchange.Kraken.Request 12 | { 13 | public class KrakenRequestBase : RequestBase 14 | { 15 | public static String ApiUri = "https://api.kraken.com"; 16 | private readonly static Logger Log = LogManager.GetCurrentClassLogger(); 17 | 18 | 19 | private String _requestUri; 20 | 21 | [JsonProperty("request")] 22 | protected string RequestUri 23 | { 24 | get { return _requestUri; } 25 | set { _requestUri = value; } 26 | } 27 | 28 | [JsonIgnore] 29 | protected string Uri 30 | { 31 | get { return String.Format("{0}{1}", ApiUri, RequestUri); } 32 | } 33 | 34 | public String ToJsonBase64String() 35 | { 36 | return Convert.ToBase64String(Encoding.UTF8.GetBytes(ToJsonString())); 37 | } 38 | 39 | public virtual String ToJsonString() 40 | { 41 | return JsonConvert.SerializeObject(this); 42 | } 43 | 44 | 45 | public override ResponseData Request() 46 | { 47 | using (var client = WebClientExtended.GetDefault()) 48 | { 49 | client.Headers["Host"] = "api.kraken.com"; 50 | 51 | try 52 | { 53 | AddGetParameters(this, client); 54 | 55 | Log.Info(RequestUri); 56 | var postResult = client.DownloadString(Uri); 57 | return new ResponseData(this, postResult); 58 | } 59 | catch (WebException ex) 60 | { 61 | return new ResponseData(this, ex); 62 | } 63 | } 64 | } 65 | 66 | private void AddGetParameters(Object obj, WebClientExtended client) 67 | { 68 | String result = JsonConvert.SerializeObject(obj); 69 | JObject jObject = JObject.Parse(result); 70 | 71 | foreach (var token in jObject) 72 | { 73 | if (token.Key != "request") 74 | { 75 | client.QueryString.Add(token.Key, token.Value.ToString()); 76 | } 77 | } 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Kraken/Kraken/Request/OrderBook.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Currency; 2 | using Newtonsoft.Json; 3 | 4 | namespace IntTrader.API.Exchange.Kraken.Request 5 | { 6 | public class OrderBook : KrakenRequestBase 7 | { 8 | public OrderBook(PairBase symbol) 9 | { 10 | RequestUri = "/0/public/Depth?pair=" + symbol.Name + "&count=" + Limit; 11 | } 12 | 13 | private int _limit = 500; 14 | 15 | [JsonProperty("count")] 16 | public int Limit 17 | { 18 | get { return _limit; } 19 | set { _limit = value; } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Kraken/Kraken/Request/Ticker.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Currency; 2 | 3 | namespace IntTrader.API.Exchange.Kraken.Request 4 | { 5 | public class Ticker : KrakenRequestBase 6 | { 7 | public Ticker(PairBase symbol) 8 | { 9 | RequestUri = "/0/public/Ticker?pair=" + symbol.Name; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Kraken/Kraken/Request/TradesRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IntTrader.API.Currency; 3 | using Newtonsoft.Json; 4 | 5 | namespace IntTrader.API.Exchange.Kraken.Request 6 | { 7 | public class TradesRequest : KrakenRequestBase 8 | { 9 | public TradesRequest(PairBase pair) 10 | { 11 | Pair = pair.Name; 12 | RequestUri = "/0/public/Trades"; 13 | } 14 | 15 | //pair = asset pair to get trade data for 16 | //since = return trade data since given id (optional. exclusive) 17 | 18 | private String _sinceOrderId; 19 | 20 | [JsonProperty("since")] 21 | public string SinceOrderId 22 | { 23 | get { return _sinceOrderId; } 24 | set { _sinceOrderId = value; } 25 | } 26 | 27 | private String _pair; 28 | 29 | [JsonProperty("pair")] 30 | public string Pair 31 | { 32 | get { return _pair; } 33 | set { _pair = value; } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Kraken/Kraken/Response/CancelOrderResponse.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Base.Model; 2 | using IntTrader.API.Base.Transform; 3 | using Newtonsoft.Json; 4 | 5 | namespace IntTrader.API.Exchange.Kraken.Response 6 | { 7 | public class CancelOrderResponse : KrakenResponse, ICancelOrder 8 | { 9 | CancelOrderInfo _cancelOrderInfo = new CancelOrderInfo(); 10 | 11 | [JsonProperty("result")] 12 | public CancelOrderInfo CancelOrderInfo 13 | { 14 | get { return _cancelOrderInfo; } 15 | set { _cancelOrderInfo = value; } 16 | } 17 | 18 | public CancelOrderModel Transform() 19 | { 20 | var m = new CancelOrderModel(); 21 | m.OrdersCanceled = CancelOrderInfo.Count; 22 | m.OrdersPending = CancelOrderInfo.Pending; 23 | return m; 24 | } 25 | } 26 | 27 | public class CancelOrderInfo 28 | { 29 | private int _count; 30 | private int _pending; 31 | 32 | public int Count 33 | { 34 | get { return _count; } 35 | set { _count = value; } 36 | } 37 | 38 | public int Pending 39 | { 40 | get { return _pending; } 41 | set { _pending = value; } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Kraken/Kraken/Response/CreateOrderResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using IntTrader.API.Base.Model; 5 | using IntTrader.API.Base.Transform; 6 | using Newtonsoft.Json; 7 | 8 | namespace IntTrader.API.Exchange.Kraken.Response 9 | { 10 | public class CreateOrderResponse : KrakenResponse, ICreateOrder 11 | { 12 | public CreateOrderModel Transform() 13 | { 14 | var m = new CreateOrderModel(); 15 | 16 | if (Result != null && Result.Txid.Count > 0) 17 | { 18 | var firstId = this.Result.Txid.FirstOrDefault(); 19 | m.OrderId = firstId; 20 | m.OrderDescription = Result.OrderDescriptionInfo.Order; 21 | m.CloseDescription = Result.OrderDescriptionInfo.Close; 22 | } 23 | 24 | return m; 25 | } 26 | 27 | OrderInfo _result = new OrderInfo(); 28 | 29 | [JsonProperty("result")] 30 | public OrderInfo Result 31 | { 32 | get { return _result; } 33 | set { _result = value; } 34 | } 35 | } 36 | 37 | public class OrderInfo 38 | { 39 | private List _txid; 40 | 41 | [JsonProperty("txid")] 42 | public List Txid 43 | { 44 | get { return _txid; } 45 | set { _txid = value; } 46 | } 47 | 48 | OrderDescriptionInfo _orderDescriptionInfo = new OrderDescriptionInfo(); 49 | 50 | [JsonProperty("descr")] 51 | public OrderDescriptionInfo OrderDescriptionInfo 52 | { 53 | get { return _orderDescriptionInfo; } 54 | set { _orderDescriptionInfo = value; } 55 | } 56 | } 57 | 58 | public class OrderDescriptionInfo 59 | { 60 | private String _order; 61 | private String _close; 62 | 63 | 64 | public string Order 65 | { 66 | get { return _order; } 67 | set { _order = value; } 68 | } 69 | 70 | public string Close 71 | { 72 | get { return _close; } 73 | set { _close = value; } 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Kraken/Kraken/Response/KrakenResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using IntTrader.API.Base.Model; 4 | using IntTrader.API.Base.Response; 5 | using Newtonsoft.Json; 6 | 7 | namespace IntTrader.API.Exchange.Kraken.Response 8 | { 9 | public class KrakenResponse : ResponseBase 10 | { 11 | List _error = new List(); 12 | 13 | [JsonProperty("error")] 14 | public List Error 15 | { 16 | get { return _error; } 17 | set { _error = value; } 18 | } 19 | 20 | public override void VerifyResponse() 21 | { 22 | if (Error.Count > 0) 23 | { 24 | ResponseData.ResponseState = ResponseState.Error; 25 | } 26 | 27 | base.VerifyResponse(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Kraken/Kraken/Response/OrderBookEntry.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IntTrader.API.Base.Model; 3 | using IntTrader.API.Base.Transform; 4 | using IntTrader.API.Converter; 5 | using Newtonsoft.Json; 6 | using Newtonsoft.Json.Linq; 7 | 8 | namespace IntTrader.API.Exchange.Kraken.Response 9 | { 10 | [JsonConverter(typeof(OrderBookEntryConverter))] 11 | public class OrderBookEntry : IOrderBookEntry 12 | { 13 | // "price": "0.0278", 14 | // "amount": "20.0", 15 | // "timestamp": "1395065891.0" 16 | 17 | private decimal _price; 18 | private decimal _amount; 19 | private String _timestamp; 20 | 21 | [JsonProperty("price")] 22 | public decimal Price 23 | { 24 | get { return _price; } 25 | set { _price = value; } 26 | } 27 | 28 | [JsonProperty("amount")] 29 | public decimal Amount 30 | { 31 | get { return _amount; } 32 | set { _amount = value; } 33 | } 34 | 35 | [JsonProperty("timestamp")] 36 | public string Timestamp 37 | { 38 | get { return _timestamp; } 39 | set { _timestamp = value; } 40 | } 41 | 42 | public OrderBookEntryModel Transform() 43 | { 44 | return new OrderBookEntryModel { Amount = Amount, Price = Price, DateTime = DateTimeConverter.ConvertTimestamp(Timestamp) }; 45 | } 46 | 47 | } 48 | 49 | public class OrderBookEntryConverter : JsonConverter 50 | { 51 | public override bool CanConvert(Type objectType) 52 | { 53 | return (objectType == typeof(OrderBookEntry)); 54 | } 55 | 56 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) 57 | { 58 | throw new NotImplementedException(); 59 | } 60 | 61 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) 62 | { 63 | JToken token = JToken.Load(reader); 64 | 65 | var entry = new OrderBookEntry(); 66 | 67 | entry.Price = token[0].ToObject(); 68 | entry.Amount = token[1].ToObject(); 69 | entry.Timestamp = token[2].ToObject(); 70 | 71 | return entry; 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Kraken/Kraken/Response/OrderBookResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using IntTrader.API.Base.Model; 4 | using IntTrader.API.Base.Transform; 5 | using Newtonsoft.Json; 6 | 7 | namespace IntTrader.API.Exchange.Kraken.Response 8 | { 9 | public class OrderBookResponse : KrakenResponse, IOrderBook 10 | { 11 | Dictionary _orderBookResponseResult = new Dictionary(); 12 | 13 | [JsonProperty("result")] 14 | public Dictionary OrderBooks 15 | { 16 | get { return _orderBookResponseResult; } 17 | set { _orderBookResponseResult = value; } 18 | } 19 | 20 | public OrderBookModel Transform() 21 | { 22 | var firstOrderBook = OrderBooks.Values.First(); 23 | var asks = new List(); 24 | var bids = new List(); 25 | 26 | firstOrderBook.Asks.ForEach(x => asks.Add(x.Transform())); 27 | firstOrderBook.Bids.ForEach(x => bids.Add(x.Transform())); 28 | 29 | var result = new OrderBookModel 30 | { 31 | Asks = new List(asks), 32 | Bids = new List(bids) 33 | }; 34 | return result; 35 | } 36 | 37 | public class OrderBookResponseResult 38 | { 39 | private List _bids; 40 | private List _asks; 41 | 42 | [JsonProperty("bids")] 43 | public List Bids 44 | { 45 | get { return _bids; } 46 | set { _bids = value; } 47 | } 48 | 49 | [JsonProperty("asks")] 50 | public List Asks 51 | { 52 | get { return _asks; } 53 | set { _asks = value; } 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Kraken/NLog.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 14 | 15 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Kraken/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Allgemeine Informationen über eine Assembly werden über die folgenden 6 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, 7 | // die mit einer Assembly verknüpft sind. 8 | [assembly: AssemblyTitle("IntTrader.API.Kraken.Exchange")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("IntTrader.API.Kraken.Exchange")] 13 | [assembly: AssemblyCopyright("Copyright © 2014 by Zicore")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar 18 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von 19 | // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. 20 | [assembly: ComVisible(false)] 21 | 22 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird 23 | [assembly: Guid("2f9fcfa5-088b-4697-a257-ae66e31fe089")] 24 | 25 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: 26 | // 27 | // Hauptversion 28 | // Nebenversion 29 | // Buildnummer 30 | // Revision 31 | // 32 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern 33 | // übernehmen, indem Sie "*" eingeben: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /IntTrader.Exchange.Kraken/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /IntTrader.ExchangeLoader/NLog.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /IntTrader.ExchangeLoader/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Allgemeine Informationen über eine Assembly werden über die folgenden 6 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, 7 | // die mit einer Assembly verknüpft sind. 8 | [assembly: AssemblyTitle("IntTrader.API.ExchangeLoader")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("IntTrader.API.ExchangeLoader")] 13 | [assembly: AssemblyCopyright("Copyright © 2014 by Zicore")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar 18 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von 19 | // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. 20 | [assembly: ComVisible(false)] 21 | 22 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird 23 | [assembly: Guid("fb8d27fc-f1de-408b-a30b-da9b1e4f4ff4")] 24 | 25 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: 26 | // 27 | // Hauptversion 28 | // Nebenversion 29 | // Buildnummer 30 | // Revision 31 | // 32 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern 33 | // übernehmen, indem Sie "*" eingeben: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /IntTrader.ExchangeLoader/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /IntTrader/App.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /IntTrader/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using IntTrader.Settings; 3 | 4 | namespace IntTrader 5 | { 6 | /// 7 | /// Interaktionslogik für "App.xaml" 8 | /// 9 | public partial class App : Application 10 | { 11 | 12 | public static AppSettings Settings = new AppSettings(); 13 | public App() 14 | { 15 | Settings.Load(); 16 | } 17 | 18 | protected override void OnExit(ExitEventArgs e) 19 | { 20 | Settings.Save(); 21 | base.OnExit(e); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /IntTrader/Controls/Balance/Balance.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace IntTrader.Controls.Balance 4 | { 5 | /// 6 | /// Interaktionslogik für Balance.xaml 7 | /// 8 | public partial class Balance : UserControl 9 | { 10 | public Balance() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /IntTrader/Controls/Balance/BalanceEntryViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IntTrader.API.Currency; 3 | using IntTrader.ViewModel; 4 | 5 | namespace IntTrader.Controls.Balance 6 | { 7 | public class BalanceEntryViewModel : ViewModelBase 8 | { 9 | private String _walletType; 10 | private CurrencyBase _currency; 11 | private decimal _amount; 12 | private decimal _available; 13 | 14 | public string Type 15 | { 16 | get { return _walletType; } 17 | set 18 | { 19 | _walletType = value; 20 | OnPropertyChanged("Type"); 21 | } 22 | } 23 | 24 | public CurrencyBase Currency 25 | { 26 | get { return _currency; } 27 | set { _currency = value; } 28 | } 29 | 30 | public decimal Amount 31 | { 32 | get { return _amount; } 33 | set 34 | { 35 | _amount = value; 36 | OnPropertyChanged("Amount"); 37 | } 38 | } 39 | 40 | public decimal Available 41 | { 42 | get { return _available; } 43 | set 44 | { 45 | _available = value; 46 | OnPropertyChanged("Available"); 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /IntTrader/Controls/Blockchain/Address/AddressView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Windows.Data; 8 | using System.Windows.Documents; 9 | using System.Windows.Input; 10 | using System.Windows.Media; 11 | using System.Windows.Media.Imaging; 12 | using System.Windows.Navigation; 13 | using System.Windows.Shapes; 14 | 15 | namespace IntTrader.Controls.Blockchain.Address 16 | { 17 | /// 18 | /// Interaktionslogik für AddressView.xaml 19 | /// 20 | public partial class AddressView : UserControl 21 | { 22 | public AddressView() 23 | { 24 | InitializeComponent(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /IntTrader/Controls/CommandToolBar/CommandToolBarView.xaml: -------------------------------------------------------------------------------- 1 |  8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /IntTrader/Controls/CommandToolBar/CommandToolBarView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace IntTrader.Controls.CommandToolBar 4 | { 5 | /// 6 | /// Interaktionslogik für CommandToolBarView.xaml 7 | /// 8 | public partial class CommandToolBarView : UserControl 9 | { 10 | public CommandToolBarView() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /IntTrader/Controls/CommandToolBar/CommandToolBarViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IntTrader.API.Base.Exchange; 3 | using IntTrader.Controls.ExchangeSettings; 4 | using IntTrader.ViewModel; 5 | using Zicore.WPF.Base.Commands; 6 | 7 | namespace IntTrader.Controls.CommandToolBar 8 | { 9 | public class CommandToolBarViewModel : ExchangeManagerViewModel 10 | { 11 | public CommandToolBarViewModel(MainViewModel mainViewModel, ExchangeManager exchangeManager, ExchangeSettingsViewModel settings) 12 | : base(exchangeManager) 13 | { 14 | MainViewModel = mainViewModel; 15 | this.Settings = settings; 16 | Settings.SettingsService.SettingsLoaded += SettingsServiceOnSettingsLoaded; 17 | Settings.SettingsService.SettingsUnloaded += SettingsServiceOnSettingsUnloaded; 18 | } 19 | 20 | private RelayCommand _showNotificationsCommand; 21 | 22 | public RelayCommand ShowNotificationsCommand 23 | { 24 | get 25 | { 26 | if (_showNotificationsCommand == null) 27 | { 28 | _showNotificationsCommand = new RelayCommand(x => MainViewModel.ShowNotifications()); 29 | } 30 | return _showNotificationsCommand; 31 | } 32 | } 33 | 34 | private void SettingsServiceOnSettingsUnloaded(object sender, EventArgs eventArgs) 35 | { 36 | OnPropertyChanged("SettingsUnlocked"); 37 | } 38 | 39 | private void SettingsServiceOnSettingsLoaded(object sender, EventArgs eventArgs) 40 | { 41 | OnPropertyChanged("SettingsUnlocked"); 42 | } 43 | 44 | public MainViewModel MainViewModel { get; set; } 45 | public ExchangeSettingsViewModel Settings { get; set; } 46 | 47 | public bool SettingsUnlocked 48 | { 49 | get { return ExchangeManager.SettingsUnlocked(); } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /IntTrader/Controls/Dashboard/DashboardEntryViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IntTrader.API.Currency; 3 | using IntTrader.Controls.Exchange; 4 | using IntTrader.Controls.Ticker; 5 | using IntTrader.Service; 6 | using IntTrader.ViewModel; 7 | 8 | namespace IntTrader.Controls.Dashboard 9 | { 10 | public class DashboardEntryViewModel : ExchangeViewModelBase 11 | { 12 | UpdateController _updateController = new UpdateController(); 13 | public MainViewModel MainViewModel { get; set; } 14 | public DashboardViewModel DashboardViewModel { get; set; } 15 | 16 | public DashboardEntryViewModel(ExchangeViewModel exchangeViewModel, DashboardViewModel dashboardViewModel, MainViewModel mainViewModel) 17 | : base(exchangeViewModel.Exchange) 18 | { 19 | this.ExchangeViewModel = exchangeViewModel; 20 | this.MainViewModel = mainViewModel; 21 | this.DashboardViewModel = dashboardViewModel; 22 | this.Ticker = new TickerViewModel(Exchange); 23 | this.Header = exchangeViewModel.Header; 24 | _updateController.Register(String.Format("{0}DashboardTicker", Exchange.Name), Ticker.Update, 10, true, true); 25 | MainViewModel.TimerSeconds.Tick += TimerSecondsOnTick; 26 | } 27 | 28 | private void TimerSecondsOnTick(object sender, EventArgs eventArgs) 29 | { 30 | bool isActive = DashboardViewModel.IsActive; 31 | _updateController.Update(ref isActive); 32 | } 33 | 34 | public ExchangeViewModel ExchangeViewModel { get; set; } 35 | public TickerViewModel Ticker { get; set; } 36 | 37 | public override void UpdatePair(PairBase pair) 38 | { 39 | Ticker.UpdatePair(pair); 40 | base.UpdatePair(pair); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /IntTrader/Controls/Dashboard/DashboardView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace IntTrader.Controls.Dashboard 4 | { 5 | /// 6 | /// Interaktionslogik für DashboardView.xaml 7 | /// 8 | public partial class DashboardView : UserControl 9 | { 10 | public DashboardView() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /IntTrader/Controls/Dashboard/DashboardViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.ObjectModel; 2 | using System.Windows.Media; 3 | using IntTrader.API.Base.Exchange; 4 | using IntTrader.Service; 5 | using IntTrader.ViewModel; 6 | 7 | namespace IntTrader.Controls.Dashboard 8 | { 9 | public class DashboardViewModel : ExchangeManagerViewModel 10 | { 11 | public MainViewModel MainViewModel { get; set; } 12 | public UpdateController UpdateController { get; private set; } 13 | public ObservableCollection DashboardItems { get; set; } 14 | 15 | public DashboardViewModel(ExchangeManager exchangeManager, MainViewModel mainViewModel) 16 | : base(exchangeManager) 17 | { 18 | //Foreground = Brushes.OrangeRed; 19 | MainViewModel = mainViewModel; 20 | Header = "Dashboard"; 21 | LoadDashboardItems(); 22 | } 23 | 24 | public override bool IsActive 25 | { 26 | get { return MainViewModel.SelectedTab == this; } 27 | } 28 | 29 | private void LoadDashboardItems() 30 | { 31 | DashboardItems = new ObservableCollection(); 32 | foreach (var exchange in MainViewModel.Exchanges) 33 | { 34 | foreach (var pair in exchange.Exchange.PairManager.SupportedPairs) 35 | { 36 | var entry = new DashboardEntryViewModel(exchange, this, MainViewModel); 37 | entry.UpdatePair(pair.Value); 38 | DashboardItems.Add(entry); 39 | } 40 | } 41 | } 42 | 43 | public DashboardEntryViewModel SelectedDashboardItem 44 | { 45 | get { return null; } 46 | set 47 | { 48 | if (value != null) 49 | { 50 | MainViewModel.SelectedTab = value.ExchangeViewModel; 51 | value.ExchangeViewModel.Pairs.Select(value.Ticker.Pair); 52 | } 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /IntTrader/Controls/Exchange/ExchangeView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace IntTrader.Controls.Exchange 4 | { 5 | /// 6 | /// Interaktionslogik für ExchangeView.xaml 7 | /// 8 | public partial class ExchangeView : UserControl 9 | { 10 | public ExchangeView() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /IntTrader/Controls/ExchangeSettings/ExchangeSettingsEntryViewModel.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Base.Settings; 2 | using IntTrader.ViewModel; 3 | 4 | namespace IntTrader.Controls.ExchangeSettings 5 | { 6 | public class ExchangeSettingsEntryViewModel : ViewModelBase 7 | { 8 | private ExchangeAPI _exchangeAPI; 9 | public ExchangeAPI ExchangeAPI 10 | { 11 | get { return _exchangeAPI; } 12 | set { _exchangeAPI = value; } 13 | } 14 | 15 | public string Name 16 | { 17 | get { return _exchangeAPI.Name; } 18 | set 19 | { 20 | _exchangeAPI.Name = value; 21 | OnPropertyChanged("Name"); 22 | } 23 | } 24 | 25 | public string APIKey 26 | { 27 | get { return _exchangeAPI.APIKey; } 28 | set 29 | { 30 | _exchangeAPI.APIKey = value; 31 | OnPropertyChanged("APIKey"); 32 | } 33 | } 34 | 35 | public string APISecret 36 | { 37 | get { return "*****"; } 38 | set 39 | { 40 | _exchangeAPI.APISecret = value; 41 | OnPropertyChanged("APISecret"); 42 | } 43 | } 44 | 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /IntTrader/Controls/ExchangeSettings/ExchangeSettingsView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace IntTrader.Controls.ExchangeSettings 4 | { 5 | /// 6 | /// Interaktionslogik für SettingsView.xaml 7 | /// 8 | public partial class ExchangeSettingsView : UserControl 9 | { 10 | public ExchangeSettingsView() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /IntTrader/Controls/NewOrder/NewBuyOrderView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace IntTrader.Controls.NewOrder 4 | { 5 | /// 6 | /// Interaktionslogik für NewBuyOrderView.xaml 7 | /// 8 | public partial class NewBuyOrderView : UserControl 9 | { 10 | public NewBuyOrderView() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /IntTrader/Controls/NewOrder/NewSellOrderView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace IntTrader.Controls.NewOrder 4 | { 5 | /// 6 | /// Interaktionslogik für NewOrderView.xaml 7 | /// 8 | public partial class NewSellOrderView : UserControl 9 | { 10 | public NewSellOrderView() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /IntTrader/Controls/OrderBook/LastTrade.xaml: -------------------------------------------------------------------------------- 1 |  8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 28 | 29 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /IntTrader/Controls/OrderBook/LastTrade.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace IntTrader.Controls.OrderBook 4 | { 5 | /// 6 | /// Interaktionslogik für LastTrade.xaml 7 | /// 8 | public partial class LastTrade : UserControl 9 | { 10 | public LastTrade() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /IntTrader/Controls/OrderBook/OrderBook.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace IntTrader.Controls.OrderBook 4 | { 5 | /// 6 | /// Interaktionslogik für OrderBook.xaml 7 | /// 8 | public partial class OrderBook : UserControl 9 | { 10 | public OrderBook() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /IntTrader/Controls/OrderBook/OrderBookEntry.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IntTrader.ViewModel; 3 | 4 | namespace IntTrader.Controls.OrderBook 5 | { 6 | public class OrderBookEntry : ViewModelBase 7 | { 8 | public OrderBookEntry() 9 | { 10 | 11 | } 12 | 13 | private PrefixSuffixEntry _priceEntry; 14 | private PrefixSuffixEntry _amountEntry; 15 | 16 | private decimal _price; 17 | private decimal _amount; 18 | private int _groupedPrice; 19 | 20 | public int GroupedPrice 21 | { 22 | get { return _groupedPrice; } 23 | set 24 | { 25 | _groupedPrice = value; 26 | OnPropertyChanged("GroupedPrice"); 27 | } 28 | } 29 | 30 | public int GroupedVolume 31 | { 32 | get { return _groupedVolume; } 33 | set 34 | { 35 | _groupedVolume = value; 36 | OnPropertyChanged("GroupedVolume"); 37 | } 38 | } 39 | 40 | private int _groupedVolume; 41 | 42 | private DateTime _dateTime; 43 | 44 | public PrefixSuffixEntry PriceEntry 45 | { 46 | get { return _priceEntry; } 47 | set 48 | { 49 | _priceEntry = value; 50 | OnPropertyChanged("PriceEntry"); 51 | } 52 | } 53 | 54 | public PrefixSuffixEntry AmountEntry 55 | { 56 | get { return _amountEntry; } 57 | set 58 | { 59 | _amountEntry = value; 60 | OnPropertyChanged("AmountEntry"); 61 | } 62 | } 63 | 64 | public decimal Price 65 | { 66 | get { return _price; } 67 | set 68 | { 69 | _price = value; 70 | _priceEntry = PrefixSuffixEntry.CalculatePrice(Price); 71 | OnPropertyChanged("Price"); 72 | } 73 | } 74 | 75 | public decimal Amount 76 | { 77 | get { return _amount; } 78 | set 79 | { 80 | _amount = value; 81 | _amountEntry = PrefixSuffixEntry.CalculateAmount(Amount); 82 | OnPropertyChanged("Amount"); 83 | } 84 | } 85 | 86 | public DateTime DateTime 87 | { 88 | get { return _dateTime; } 89 | set 90 | { 91 | _dateTime = value; 92 | OnPropertyChanged("DateTime"); 93 | } 94 | } 95 | 96 | 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /IntTrader/Controls/OrderBook/OrderListAsks.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /IntTrader/Controls/OrderBook/OrderListAsks.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace IntTrader.Controls.OrderBook 4 | { 5 | /// 6 | /// Interaktionslogik für OrderListAsks.xaml 7 | /// 8 | public partial class OrderListAsks : UserControl 9 | { 10 | public OrderListAsks() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /IntTrader/Controls/OrderBook/OrderListBids.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /IntTrader/Controls/OrderBook/OrderListBids.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace IntTrader.Controls.OrderBook 4 | { 5 | /// 6 | /// Interaktionslogik für OrderListBids.xaml 7 | /// 8 | public partial class OrderListBids : UserControl 9 | { 10 | public OrderListBids() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /IntTrader/Controls/OrderNotifications/OrderNotificationEntryViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using IntTrader.API.Base.Exchange; 6 | using IntTrader.API.Base.Model; 7 | using IntTrader.ViewModel; 8 | using Zicore.WPF.Base.Event; 9 | 10 | namespace IntTrader.Controls.OrderNotifications 11 | { 12 | public class OrderNotificationEntryViewModel : ExchangeManagerViewModel 13 | { 14 | public MainViewModel MainViewModel { get; set; } 15 | 16 | public OrderNotificationEntryViewModel(MainViewModel mainViewModel, ExchangeManager exchangeManager) 17 | : base(exchangeManager) 18 | { 19 | MainViewModel = mainViewModel; 20 | } 21 | 22 | private String _id; 23 | private decimal _price; 24 | private decimal _volume; 25 | private bool _successful; 26 | private String _message; 27 | private String _symbolText; 28 | private String _dateTime; 29 | 30 | public string Id 31 | { 32 | get { return _id; } 33 | set { _id = value; } 34 | } 35 | 36 | public decimal Price 37 | { 38 | get { return _price; } 39 | set { _price = value; } 40 | } 41 | 42 | public decimal Volume 43 | { 44 | get { return _volume; } 45 | set { _volume = value; } 46 | } 47 | 48 | public bool Successful 49 | { 50 | get { return _successful; } 51 | set { _successful = value; } 52 | } 53 | 54 | public string Message 55 | { 56 | get { return _message; } 57 | set { _message = value; } 58 | } 59 | 60 | public string SymbolText 61 | { 62 | get { return _symbolText; } 63 | set { _symbolText = value; } 64 | } 65 | 66 | public string DateTime 67 | { 68 | get { return _dateTime; } 69 | set { _dateTime = value; } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /IntTrader/Controls/OrderNotifications/OrderNotificationView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Windows.Data; 8 | using System.Windows.Documents; 9 | using System.Windows.Input; 10 | using System.Windows.Media; 11 | using System.Windows.Media.Imaging; 12 | using System.Windows.Navigation; 13 | using System.Windows.Shapes; 14 | 15 | namespace IntTrader.Controls.OrderNotifications 16 | { 17 | /// 18 | /// Interaktionslogik für OrderNotificationView.xaml 19 | /// 20 | public partial class OrderNotificationView : UserControl 21 | { 22 | public OrderNotificationView() 23 | { 24 | InitializeComponent(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /IntTrader/Controls/OrderNotifications/OrderNotificationViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.ObjectModel; 4 | using System.Linq; 5 | using System.Text; 6 | using IntTrader.API.Base.Exchange; 7 | using IntTrader.API.Base.Model; 8 | using IntTrader.API.Converter; 9 | using IntTrader.API.Event; 10 | using IntTrader.ViewModel; 11 | using Zicore.WPF.Base.Event; 12 | 13 | namespace IntTrader.Controls.OrderNotifications 14 | { 15 | public class OrderNotificationViewModel : ExchangeManagerViewModel 16 | { 17 | public MainViewModel MainViewModel { get; set; } 18 | 19 | public OrderNotificationViewModel(MainViewModel mainViewModel, ExchangeManager exchangeManager) 20 | : base(exchangeManager) 21 | { 22 | MainViewModel = mainViewModel; 23 | ExchangeManager.CreateOrderEvent += ExchangeManagerOnCreateOrderEvent; 24 | } 25 | 26 | private void ExchangeManagerOnCreateOrderEvent(object sender, CreateOrderEventArgs e) 27 | { 28 | var item = new OrderNotificationEntryViewModel(MainViewModel, ExchangeManager) 29 | { 30 | Id = e.Model.OrderId, 31 | Price = e.Model.Price, 32 | Volume = e.Model.ExecutedAmount, 33 | Successful = e.Model.WasSuccessful, 34 | DateTime = e.Model.DateTime.ToShortDateString() 35 | }; 36 | 37 | if (!String.IsNullOrEmpty(e.Model.Symbol) && e.Exchange.PairManager.SupportedPairs.ContainsKey(e.Model.Symbol)) 38 | { 39 | var currency = e.Exchange.PairManager.GetPair(e.Model.Symbol); 40 | item.SymbolText = currency.SymbolPair; 41 | } 42 | 43 | Dispatch(() => Items.Add(item)); 44 | } 45 | 46 | 47 | 48 | ObservableCollection _items = new ObservableCollection(); 49 | 50 | public ObservableCollection Items 51 | { 52 | get { return _items; } 53 | set { _items = value; } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /IntTrader/Controls/Request/RequestEntryViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using IntTrader.API.Base.Model; 6 | using IntTrader.API.Base.Response; 7 | using IntTrader.ViewModel; 8 | 9 | namespace IntTrader.Controls.Request 10 | { 11 | public class RequestEntryViewModel : ViewModelBase 12 | { 13 | public RequestEntryViewModel(ResponseData responseBase) 14 | { 15 | this.ResponseData = responseBase; 16 | this.Name = ResponseData.Request.GetType().FullName; 17 | if (responseBase.ResponseState == ResponseState.Error || 18 | responseBase.ResponseState == ResponseState.Exception) 19 | { 20 | if (!String.IsNullOrEmpty(responseBase.Value) && responseBase.Value.Length <= 240) 21 | { 22 | this.Description = responseBase.Value; 23 | } 24 | this.State = ResponseData.ResponseState.ToString(); 25 | } 26 | } 27 | 28 | private DateTime _timestamp = DateTime.Now; 29 | private String _name; 30 | private String _state; 31 | private ResponseData _responseData; 32 | private String _description; 33 | 34 | public DateTime Timestamp 35 | { 36 | get { return _timestamp; } 37 | set { _timestamp = value; } 38 | } 39 | 40 | public String TimestampFormat 41 | { 42 | get { return String.Format("{0:yyyy-MM-dd HH:mm:ss}", Timestamp); } 43 | } 44 | 45 | public string Name 46 | { 47 | get { return _name; } 48 | set { _name = value; } 49 | } 50 | 51 | public string State 52 | { 53 | get { return _state; } 54 | set { _state = value; } 55 | } 56 | 57 | public string Description 58 | { 59 | get { return _description; } 60 | set { _description = value; } 61 | } 62 | 63 | public ResponseData ResponseData 64 | { 65 | get { return _responseData; } 66 | set { _responseData = value; } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /IntTrader/Controls/Request/RequestView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Windows.Data; 8 | using System.Windows.Documents; 9 | using System.Windows.Input; 10 | using System.Windows.Media; 11 | using System.Windows.Media.Imaging; 12 | using System.Windows.Navigation; 13 | using System.Windows.Shapes; 14 | 15 | namespace IntTrader.Controls.Request 16 | { 17 | /// 18 | /// Interaktionslogik für RequestView.xaml 19 | /// 20 | public partial class RequestView : UserControl 21 | { 22 | public RequestView() 23 | { 24 | InitializeComponent(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /IntTrader/Controls/Request/RequestViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.ObjectModel; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Windows.Input; 7 | using IntTrader.API.Base.Exchange; 8 | using IntTrader.API.Base.Model; 9 | using IntTrader.API.Base.Request; 10 | using IntTrader.API.Event; 11 | using IntTrader.ViewModel; 12 | using Zicore.WPF.Base.Commands; 13 | 14 | namespace IntTrader.Controls.Request 15 | { 16 | public class RequestViewModel : ExchangeManagerViewModel 17 | { 18 | public MainViewModel MainViewModel { get; set; } 19 | 20 | public RequestViewModel(MainViewModel mainViewModel, ExchangeManager exchangeManager) 21 | : base(exchangeManager) 22 | { 23 | MainViewModel = mainViewModel; 24 | this.Header = "Requests"; 25 | RequestMonitor.RequestEvent += RequestMonitorOnRequestEvent; 26 | } 27 | 28 | private ObservableCollection _items = new ObservableCollection(); 29 | 30 | public ObservableCollection Items 31 | { 32 | get { return _items; } 33 | protected set { _items = value; } 34 | } 35 | 36 | private bool _isErrorsOnly = true; 37 | 38 | public bool IsErrorsOnly 39 | { 40 | get { return _isErrorsOnly; } 41 | set 42 | { 43 | _isErrorsOnly = value; 44 | OnPropertyChanged("IsErrorsOnly"); 45 | } 46 | } 47 | 48 | private RelayCommand _clearCommand; 49 | 50 | public ICommand ClearCommand 51 | { 52 | get { return _clearCommand ?? (_clearCommand = new RelayCommand(x => Clear())); } 53 | } 54 | 55 | private void Clear() 56 | { 57 | Items.Clear(); 58 | } 59 | 60 | private void RequestMonitorOnRequestEvent(object sender, RequestEventArgs e) 61 | { 62 | Dispatch(() => Dispatch(e)); 63 | } 64 | 65 | private void Dispatch(RequestEventArgs e) 66 | { 67 | if (e.Response != null) 68 | { 69 | bool addEntry = true; 70 | 71 | if (IsErrorsOnly) 72 | { 73 | addEntry = (e.Response.ResponseData.ResponseState == ResponseState.Error || 74 | e.Response.ResponseData.ResponseState == ResponseState.Exception); 75 | } 76 | 77 | if (addEntry) 78 | { 79 | var vm = new RequestEntryViewModel(e.Response.ResponseData); 80 | Items.Insert(0, vm); 81 | } 82 | } 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /IntTrader/Controls/Sentiment/SentimentView.xaml: -------------------------------------------------------------------------------- 1 |  8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /IntTrader/Controls/Sentiment/SentimentView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Windows.Data; 8 | using System.Windows.Documents; 9 | using System.Windows.Input; 10 | using System.Windows.Media; 11 | using System.Windows.Media.Imaging; 12 | using System.Windows.Navigation; 13 | using System.Windows.Shapes; 14 | 15 | namespace IntTrader.Controls.Sentiment 16 | { 17 | /// 18 | /// Interaktionslogik für SentimentView.xaml 19 | /// 20 | public partial class SentimentView : UserControl 21 | { 22 | public SentimentView() 23 | { 24 | InitializeComponent(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /IntTrader/Controls/Ticker/Ticker.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /IntTrader/Controls/Ticker/Ticker.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace IntTrader.Controls.Ticker 4 | { 5 | /// 6 | /// Interaktionslogik für Ticker.xaml 7 | /// 8 | public partial class Ticker : UserControl 9 | { 10 | public Ticker() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /IntTrader/Controls/Trades/TradesView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Windows.Data; 8 | using System.Windows.Documents; 9 | using System.Windows.Input; 10 | using System.Windows.Media; 11 | using System.Windows.Media.Imaging; 12 | using System.Windows.Navigation; 13 | using System.Windows.Shapes; 14 | 15 | namespace IntTrader.Controls.Trades 16 | { 17 | /// 18 | /// Interaktionslogik für TradesView.xaml 19 | /// 20 | public partial class TradesView : UserControl 21 | { 22 | public TradesView() 23 | { 24 | InitializeComponent(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /IntTrader/Controls/Trades/TradesViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.ObjectModel; 4 | using System.Linq; 5 | using System.Text; 6 | using IntTrader.API.Base.Exchange.Base; 7 | using IntTrader.API.Base.Model; 8 | using IntTrader.Controls.Exchange; 9 | using IntTrader.Controls.Sentiment; 10 | using IntTrader.Service; 11 | using IntTrader.ViewModel; 12 | 13 | namespace IntTrader.Controls.Trades 14 | { 15 | public class TradesViewModel : ExchangeViewModelBase 16 | { 17 | public MainViewModel MainViewModel { get; set; } 18 | public ExchangeViewModelBase Parent { get; set; } 19 | 20 | public SentimentViewModel SentimentViewModel { get; set; } 21 | 22 | public TradesViewModel(MainViewModel mainViewModel, ExchangeViewModelBase parent, ExchangeBase exchangeBase) 23 | : base(exchangeBase) 24 | { 25 | MainViewModel = mainViewModel; 26 | SentimentViewModel = new SentimentViewModel(exchangeBase, this); 27 | Parent = parent; 28 | MainViewModel.TimerSeconds.Tick += TimerSecondsOnTick; 29 | _updateController.Register("Trades", Update, 12, false, true); 30 | Update(); 31 | } 32 | 33 | private void TimerSecondsOnTick(object sender, EventArgs eventArgs) 34 | { 35 | bool condition = Parent.IsActive; 36 | _updateController.Update(ref condition); 37 | } 38 | 39 | UpdateController _updateController = new UpdateController(); 40 | 41 | ObservableCollection _items = new ObservableCollection(); 42 | 43 | TradesModel _tradesModel = new TradesModel(); 44 | 45 | public TradesModel TradesModel 46 | { 47 | get { return _tradesModel; } 48 | set { _tradesModel = value; } 49 | } 50 | 51 | public ObservableCollection Items 52 | { 53 | get { return _items; } 54 | set { _items = value; } 55 | } 56 | public override void OnUpdate() 57 | { 58 | if (Exchange.IsAvailable(APIFunction.RequestTrades)) 59 | { 60 | var model = Exchange.RequestTrades(Pair); 61 | Dispatch(() => Dispatch(model)); 62 | } 63 | base.OnUpdate(); 64 | } 65 | 66 | private void Dispatch(TradesModel model) 67 | { 68 | this.TradesModel = model; 69 | Items.Clear(); 70 | foreach (var trade in model.Items.Take(500)) 71 | { 72 | var vm = TradesEntryViewModel.FromModel(Exchange, trade); 73 | Items.Add(vm); 74 | } 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /IntTrader/Controls/UserOrders/UserOrderView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace IntTrader.Controls.UserOrders 4 | { 5 | /// 6 | /// Interaktionslogik für OrdersView.xaml 7 | /// 8 | public partial class UserOrderView : UserControl 9 | { 10 | public UserOrderView() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /IntTrader/Controls/UserOrders/UserOrdersViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.ObjectModel; 3 | using IntTrader.API.Base.Exchange.Base; 4 | using IntTrader.API.Base.Model; 5 | using IntTrader.ViewModel; 6 | using Zicore.WPF.Base.Event; 7 | 8 | namespace IntTrader.Controls.UserOrders 9 | { 10 | public class UserOrdersViewModel : ExchangeViewModelBase 11 | { 12 | public UserOrdersViewModel(ExchangeBase exchangeBase) 13 | : base(exchangeBase) 14 | { 15 | } 16 | 17 | public event EventHandler> OrderCanceled; 18 | protected virtual void OnOrderCanceled(object sender, EventArgs args) 19 | { 20 | EventHandler> handler = OrderCanceled; 21 | if (handler != null) handler(sender, args); 22 | } 23 | 24 | public override void OnUpdate() 25 | { 26 | if (Exchange.IsAvailable(APIFunction.RequestOpenOrders)) 27 | { 28 | var model = Exchange.RequestOpenOrders(); 29 | Dispatch(() => Dispatch(model)); 30 | } 31 | } 32 | 33 | private void Dispatch(OpenOrdersModel model) 34 | { 35 | Orders.Clear(); 36 | foreach (var order in model.Orders) 37 | { 38 | var orderViewModel = OrderViewModel.Create(Exchange, order); 39 | orderViewModel.OrderCanceled += OrderViewModelOnOrderCanceled; 40 | Orders.Add(orderViewModel); 41 | } 42 | } 43 | 44 | private void OrderViewModelOnOrderCanceled(object sender, EventArgs eventArgs) 45 | { 46 | OnOrderCanceled(sender, eventArgs); 47 | OnUpdate(); 48 | } 49 | 50 | readonly ObservableCollection _orders = new ObservableCollection(); 51 | 52 | public ObservableCollection Orders 53 | { 54 | get { return _orders; } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /IntTrader/Dialogs/OrderNotifications/OrderNotificationWindow.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /IntTrader/Dialogs/OrderNotifications/OrderNotificationWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Shapes; 14 | 15 | namespace IntTrader.Dialogs.OrderNotifications 16 | { 17 | /// 18 | /// Interaktionslogik für OrderNotificationView.xaml 19 | /// 20 | public partial class OrderNotificationWindow : Window 21 | { 22 | public OrderNotificationWindow() 23 | { 24 | InitializeComponent(); 25 | } 26 | 27 | private void OrderNotificationWindow_OnClosing(object sender, CancelEventArgs e) 28 | { 29 | e.Cancel = true; 30 | Visibility = Visibility.Collapsed; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /IntTrader/Dialogs/OrderNotifications/OrderNotificationWindowViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using IntTrader.API.Base.Exchange; 6 | using IntTrader.Controls.OrderNotifications; 7 | using IntTrader.ViewModel; 8 | 9 | namespace IntTrader.Dialogs.OrderNotifications 10 | { 11 | public class OrderNotificationWindowViewModel : ExchangeManagerViewModel 12 | { 13 | public MainViewModel MainViewModel { get; set; } 14 | 15 | public OrderNotificationWindowViewModel(MainViewModel mainViewModel, ExchangeManager exchangeManager) 16 | : base(exchangeManager) 17 | { 18 | MainViewModel = mainViewModel; 19 | OrderNotificationViewModel = new OrderNotificationViewModel(MainViewModel, ExchangeManager); 20 | } 21 | 22 | public OrderNotificationViewModel OrderNotificationViewModel { get; set; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /IntTrader/Dialogs/Password/CreatePassword.xaml: -------------------------------------------------------------------------------- 1 |  8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /IntTrader/Dialogs/Password/CreatePassword.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Security.Cryptography; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | using Zicore.Security.Cryptography; 5 | 6 | namespace IntTrader.Dialogs.Password 7 | { 8 | /// 9 | /// Interaktionslogik für CreatePassword.xaml 10 | /// 11 | public partial class CreatePassword : Window 12 | { 13 | public CreatePassword() 14 | { 15 | InitializeComponent(); 16 | var vm = DataContext as CreatePasswordViewModel; 17 | if (vm != null) 18 | { 19 | vm.RequestCloseEvent += (sender, args) => Close(); 20 | } 21 | } 22 | 23 | readonly SHA256Managed _sha256 = new SHA256Managed(); 24 | 25 | private void ButtonBase_OnClick(object sender, RoutedEventArgs e) 26 | { 27 | Close(); 28 | } 29 | 30 | private void Password_OnPasswordChanged(object sender, RoutedEventArgs e) 31 | { 32 | var pBox = sender as PasswordBox; 33 | if (pBox != null) 34 | { 35 | var vm = DataContext as CreatePasswordViewModel; 36 | if (vm != null) 37 | { 38 | vm.Password = Hash.TextToHexStringHash(pBox.Password, _sha256, 256); 39 | } 40 | } 41 | } 42 | 43 | private void PasswordRepeat_OnPasswordChanged(object sender, RoutedEventArgs e) 44 | { 45 | var pBox = sender as PasswordBox; 46 | if (pBox != null) 47 | { 48 | var vm = DataContext as CreatePasswordViewModel; 49 | if (vm != null) 50 | { 51 | vm.PasswordRepeat = Hash.TextToHexStringHash(pBox.Password, _sha256, 256); 52 | } 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /IntTrader/Dialogs/Password/CreatePasswordViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IntTrader.ViewModel; 3 | using Zicore.WPF.Base.Commands; 4 | 5 | namespace IntTrader.Dialogs.Password 6 | { 7 | public class CreatePasswordViewModel : ViewModelBase 8 | { 9 | private String _password; 10 | 11 | public String Password 12 | { 13 | get { return _password; } 14 | set 15 | { 16 | _password = value; 17 | OnPropertyChanged("Password"); 18 | } 19 | } 20 | 21 | private String _passwordRepeat; 22 | 23 | public String PasswordRepeat 24 | { 25 | get { return _passwordRepeat; } 26 | set 27 | { 28 | _passwordRepeat = value; 29 | OnPropertyChanged("PasswordRepeat"); 30 | } 31 | } 32 | 33 | private RelayCommand _applyCommand; 34 | 35 | public event EventHandler Close; 36 | 37 | protected virtual void OnClose() 38 | { 39 | EventHandler handler = Close; 40 | if (handler != null) handler(this, EventArgs.Empty); 41 | 42 | } 43 | 44 | public RelayCommand ApplyCommand 45 | { 46 | get 47 | { 48 | if (_applyCommand == null) 49 | { 50 | _applyCommand = new RelayCommand(x => Apply(), x => CanExecute()); 51 | } 52 | return _applyCommand; 53 | } 54 | } 55 | 56 | public void Apply() 57 | { 58 | OnClose(); 59 | OnRequestClose(); 60 | } 61 | 62 | public bool CanExecute() 63 | { 64 | return !string.IsNullOrEmpty(Password) && Password == PasswordRepeat; 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /IntTrader/Dialogs/Password/Login.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Security.Cryptography; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | using Zicore.Security.Cryptography; 5 | 6 | namespace IntTrader.Dialogs.Password 7 | { 8 | /// 9 | /// Interaktionslogik für Login.xaml 10 | /// 11 | public partial class Login : Window 12 | { 13 | public Login() 14 | { 15 | InitializeComponent(); 16 | var vm = DataContext as LoginViewModel; 17 | if (vm != null) 18 | { 19 | vm.RequestCloseEvent += (sender, args) => Close(); 20 | } 21 | } 22 | 23 | readonly SHA256Managed _sha256 = new SHA256Managed(); 24 | 25 | private void Password_OnPasswordChanged(object sender, RoutedEventArgs e) 26 | { 27 | var pBox = sender as PasswordBox; 28 | if (pBox != null) 29 | { 30 | var vm = DataContext as LoginViewModel; 31 | if (vm != null) 32 | { 33 | vm.Password = Hash.TextToHexStringHash(pBox.Password, _sha256, 256); 34 | } 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /IntTrader/NLog.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /IntTrader/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // Allgemeine Informationen über eine Assembly werden über die folgenden 8 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, 9 | // die mit einer Assembly verknüpft sind. 10 | [assembly: AssemblyTitle("IntTrader")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("IntTrader")] 15 | [assembly: AssemblyCopyright("Copyright © 2014 by Zicore")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar 20 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von 21 | // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. 22 | [assembly: ComVisible(false)] 23 | 24 | //Um mit dem Erstellen lokalisierbarer Anwendungen zu beginnen, legen Sie 25 | //ImCodeVerwendeteKultur in der .csproj-Datei 26 | //in einer fest. Wenn Sie in den Quelldateien beispielsweise Deutsch 27 | //(Deutschland) verwenden, legen Sie auf \"de-DE\" fest. Heben Sie dann die Auskommentierung 28 | //des nachstehenden NeutralResourceLanguage-Attributs auf. Aktualisieren Sie "en-US" in der nachstehenden Zeile, 29 | //sodass es mit der UICulture-Einstellung in der Projektdatei übereinstimmt. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //Speicherort der designspezifischen Ressourcenwörterbücher 36 | //(wird verwendet, wenn eine Ressource auf der Seite 37 | // oder in den Anwendungsressourcen-Wörterbüchern nicht gefunden werden kann.) 38 | ResourceDictionaryLocation.SourceAssembly //Speicherort des generischen Ressourcenwörterbuchs 39 | //(wird verwendet, wenn eine Ressource auf der Seite, in der Anwendung oder einem 40 | // designspezifischen Ressourcenwörterbuch nicht gefunden werden kann.) 41 | )] 42 | 43 | 44 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: 45 | // 46 | // Hauptversion 47 | // Nebenversion 48 | // Buildnummer 49 | // Revision 50 | // 51 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern 52 | // übernehmen, indem Sie "*" eingeben: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /IntTrader/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Dieser Code wurde von einem Tool generiert. 4 | // Laufzeitversion:4.0.30319.34014 5 | // 6 | // Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn 7 | // der Code erneut generiert wird. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace IntTrader.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /IntTrader/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /IntTrader/Resources/BalanceResources.xaml: -------------------------------------------------------------------------------- 1 |  3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /IntTrader/Resources/BasicResources.xaml: -------------------------------------------------------------------------------- 1 |  3 | 4 | 5 | 6 | 7 | m 565.43258 308.62112 c -59.508 -59.237 -155.414 -59.724 -214.213 -0.699 -39.633 39.47099 -52.246 95.73699 -38.264 146.43599 l -214.669997 214.664 0.332 73.64 c 0.066 13.305 4.948997 17.854 18.130997 18.14 l 89.311 -0.016 0.01 -52.327 52.322 -0.013 0.01 -51.614 50.25 0.007 -0.015 -52.35 h 68.4 l 43.179 -43.178 c 50.638 13.862 106.764 1.249 146.269 -38.127 58.818 -58.997 58.331 -154.916 -1.052 -214.56299 z m -31.743 88.29499 c -15.64 15.336 -41.116 15.178 -56.891 -0.359 -15.76 -15.997 -15.912 -41.473 -0.342 -56.875 15.68 -15.826 41.14 -15.68 56.87 0.354 15.803 15.507 15.96 40.99 0.363 56.88 z 8 | M 107.786 104.991 C 109.219 95.409 101.923 90.26 91.948 86.824 l 3.235 -12.978 -7.899 -1.969 -3.151 12.636 c -2.079 -0.518 -4.21 -1.006 -6.331 -1.489 l 3.171 -12.72 -7.894 -1.969 -3.239 12.976 c -1.719 -0.392 -3.406 -0.778 -5.045 -1.186 l 0.008 -0.04 -10.894 -2.72 -2.102 8.437 c 0 0 5.861 1.343 5.737 1.427 3.2 0.799 3.777 2.916 3.681 4.594 l -3.685 14.785 c 0.22 0.057 0.505 0.136 0.821 0.264 -0.264 -0.066 -0.545 -0.137 -0.834 -0.207 l -5.166 20.71 c -0.392 0.972 -1.385 2.431 -3.621 1.877 0.079 0.114 -5.745 -1.433 -5.745 -1.433 l -3.92 9.041 10.28 2.563 c 1.911 0.479 3.788 0.979 5.632 1.453 l -3.267 13.127 7.891 1.969 3.237 -12.987 c 2.158 0.584 4.25 1.125 6.298 1.634 l -3.226 12.926 7.9 1.969 3.27 -13.102 c 13.473 2.548 23.604 1.52 27.866 -10.663 3.437 -9.81 -0.17 -15.469 -7.258 -19.16 5.161 -1.19 9.051 -4.586 10.088 -11.598 z m -18.049 25.311 c -2.444 9.811 -18.96 4.507 -24.318 3.176 l 4.338 -17.389 c 5.355 1.335 22.53 3.981 19.98 14.213 z m 2.44 -25.452 c -2.226 8.924 -15.975 4.389 -20.435 3.277 l 3.932 -15.772 c 4.459 1.112 18.824 3.187 16.503 12.495 z 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /IntTrader/Resources/bitcoin.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zicore/IntTrader/d80cc14cc1505991cf417c0364a8c84542f15fd2/IntTrader/Resources/bitcoin.ico -------------------------------------------------------------------------------- /IntTrader/Resources/bitcoin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zicore/IntTrader/d80cc14cc1505991cf417c0364a8c84542f15fd2/IntTrader/Resources/bitcoin.png -------------------------------------------------------------------------------- /IntTrader/Service/ApplicationSettingsService.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Base.Exchange; 2 | using IntTrader.ViewModel; 3 | 4 | namespace IntTrader.Service 5 | { 6 | public class ApplicationSettingsService : ExchangeManagerViewModel 7 | { 8 | public ApplicationSettingsService(ExchangeManager exchangeManager) 9 | : base(exchangeManager) 10 | { 11 | } 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /IntTrader/Service/UpdateController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace IntTrader.Service 5 | { 6 | public class UpdateController 7 | { 8 | private readonly Dictionary _updateEntries = new Dictionary(); 9 | 10 | /// 11 | /// Should be called in an intervall, like every second 12 | /// 13 | public void Update(ref bool condition) 14 | { 15 | foreach (var u in _updateEntries) 16 | { 17 | u.Value.Iterate(ref condition); 18 | } 19 | } 20 | 21 | public UpdateEntry Register(String key, Action action, int intervall, bool immediateAction, bool requireCondition) 22 | { 23 | var updateEntry = new UpdateEntry { Key = key, Action = action, CounterMax = intervall, ImmediateAction = immediateAction, RequireCondition = requireCondition }; 24 | _updateEntries[key] = updateEntry; 25 | return updateEntry; 26 | } 27 | 28 | public void Remove(String key) 29 | { 30 | _updateEntries.Remove(key); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /IntTrader/Service/UpdateEntry.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NLog; 3 | 4 | namespace IntTrader.Service 5 | { 6 | public class UpdateEntry 7 | { 8 | public UpdateEntry() 9 | { 10 | RequireCondition = true; 11 | } 12 | 13 | private String _key; 14 | private int _counter = 0; 15 | private int _counterMax = 0; 16 | 17 | public int Counter 18 | { 19 | get { return _counter; } 20 | private set { _counter = value; } 21 | } 22 | 23 | public int CounterMax 24 | { 25 | get { return _counterMax; } 26 | set { _counterMax = value; } 27 | } 28 | 29 | public string Key 30 | { 31 | get { return _key; } 32 | set { _key = value; } 33 | } 34 | 35 | public UpdateEntry SetRequireCondition() 36 | { 37 | RequireCondition = true; 38 | return this; 39 | } 40 | 41 | public bool RequireCondition { get; set; } 42 | public bool ImmediateAction { get; set; } 43 | public Action Action { get; set; } 44 | 45 | private static readonly Logger Log = LogManager.GetCurrentClassLogger(); 46 | 47 | public void Iterate(ref bool condition) 48 | { 49 | if (Counter++ >= CounterMax || ImmediateAction) 50 | { 51 | 52 | if (condition || !RequireCondition) 53 | { 54 | Log.Info("Action:{0} Condition:{1}", Key, condition); 55 | Action(); 56 | OnActionRaised(); 57 | } 58 | Counter = 0; 59 | ImmediateAction = false; 60 | } 61 | } 62 | 63 | public event EventHandler ActionRaised; 64 | 65 | protected virtual void OnActionRaised() 66 | { 67 | EventHandler handler = ActionRaised; 68 | if (handler != null) handler(this, EventArgs.Empty); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /IntTrader/Settings/AppSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using IntTrader.Settings.Data; 6 | 7 | namespace IntTrader.Settings 8 | { 9 | public class AppSettings : AppSettingsBase 10 | { 11 | 12 | List _addresses = new List(); 13 | public List Addresses 14 | { 15 | get { return _addresses; } 16 | set { _addresses = value; } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /IntTrader/Settings/AppSettingsBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Text; 7 | using NLog; 8 | using Zicore.Settings.Json; 9 | 10 | namespace IntTrader.Settings 11 | { 12 | public class AppSettingsBase : JsonSettings 13 | { 14 | protected AppSettingsBase() 15 | { 16 | 17 | } 18 | 19 | private static readonly Logger Log = LogManager.GetCurrentClassLogger(); 20 | 21 | public static string ApplicationName = "IntTrader"; 22 | public static string FileName = "AppSettings.json"; 23 | 24 | public void Load() 25 | { 26 | try 27 | { 28 | Load(ApplicationName, FileName); 29 | } 30 | catch (FileNotFoundException) 31 | { 32 | Save(); 33 | } 34 | catch (Exception ex) 35 | { 36 | Log.Debug(ex); 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /IntTrader/Settings/Data/AddressEntry.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace IntTrader.Settings.Data 7 | { 8 | public class AddressEntry 9 | { 10 | private int _sort = 0; 11 | 12 | private String _address; 13 | private String _name; 14 | private String _description; 15 | 16 | public int Sort 17 | { 18 | get { return _sort; } 19 | set { _sort = value; } 20 | } 21 | 22 | public string Name 23 | { 24 | get { return _name; } 25 | set { _name = value; } 26 | } 27 | 28 | public string Description 29 | { 30 | get { return _description; } 31 | set { _description = value; } 32 | } 33 | 34 | public string Address 35 | { 36 | get { return _address; } 37 | set { _address = value; } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /IntTrader/View/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Windows; 3 | using IntTrader.ViewModel; 4 | 5 | namespace IntTrader.View 6 | { 7 | /// 8 | /// Interaktionslogik für MainWindow.xaml 9 | /// 10 | public partial class MainWindow : Window 11 | { 12 | public MainWindow() 13 | { 14 | InitializeComponent(); 15 | } 16 | 17 | private void MainWindow_OnClosing(object sender, CancelEventArgs e) 18 | { 19 | var m = this.DataContext as MainViewModel; 20 | if (m != null) 21 | { 22 | m.RequestClose(); 23 | } 24 | } 25 | 26 | private void MainWindow_OnLoaded(object sender, RoutedEventArgs e) 27 | { 28 | var m = this.DataContext as MainViewModel; 29 | if (m != null) 30 | { 31 | m.OnLoaded(); 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /IntTrader/ViewModel/ExchangeManagerViewModel.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Base.Exchange; 2 | 3 | namespace IntTrader.ViewModel 4 | { 5 | /// 6 | /// When it is not specific to one exchange, it should implement 7 | /// 8 | public class ExchangeManagerViewModel : ViewModelBase 9 | { 10 | public ExchangeManagerViewModel(ExchangeManager exchangeManager) 11 | { 12 | this.ExchangeManager = exchangeManager; 13 | } 14 | 15 | public ExchangeManager ExchangeManager { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /IntTrader/ViewModel/ExchangeViewModelBase.cs: -------------------------------------------------------------------------------- 1 | using IntTrader.API.Base.Exchange.Base; 2 | using IntTrader.Service; 3 | 4 | namespace IntTrader.ViewModel 5 | { 6 | 7 | /// 8 | /// Every View model which is Exchange specific should inherit this 9 | /// 10 | public class ExchangeViewModelBase : ViewModelBase 11 | { 12 | public ExchangeViewModelBase(ExchangeBase exchangeBase) 13 | { 14 | this.Exchange = exchangeBase; 15 | UpdateController = new UpdateController(); 16 | } 17 | 18 | public ExchangeBase Exchange { get; set; } 19 | 20 | public UpdateController UpdateController { get; private set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /IntTrader/ViewModel/PairManageViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.ObjectModel; 3 | using System.Linq; 4 | using IntTrader.API.Base.Exchange.Base; 5 | using IntTrader.API.Currency; 6 | 7 | namespace IntTrader.ViewModel 8 | { 9 | public class PairManageViewModel : ExchangeViewModelBase 10 | { 11 | private readonly ObservableCollection _pairs = new ObservableCollection(); 12 | public ObservableCollection Pairs 13 | { 14 | get { return _pairs; } 15 | } 16 | 17 | public event EventHandler PairChanged; 18 | 19 | protected virtual void OnPairChanged() 20 | { 21 | EventHandler handler = PairChanged; 22 | if (handler != null) handler(this, EventArgs.Empty); 23 | } 24 | 25 | public PairManageViewModel(ExchangeBase exchangeBase) 26 | : base(exchangeBase) 27 | { 28 | foreach (var supportedPair in Exchange.PairManager.SupportedPairs.Values) 29 | { 30 | Pairs.Add(PairViewModel.FromPair(supportedPair)); 31 | } 32 | 33 | SelectedPair = Pairs.FirstOrDefault(); 34 | } 35 | 36 | private PairViewModel _selectedPair; 37 | public PairViewModel SelectedPair 38 | { 39 | get { return _selectedPair; } 40 | set 41 | { 42 | _selectedPair = value; 43 | OnPairChanged(); 44 | } 45 | } 46 | 47 | public void Select(PairBase pair) 48 | { 49 | foreach (var pairViewModel in Pairs) 50 | { 51 | if (pairViewModel.Pair.Key == pair.Key) 52 | { 53 | this.SelectedPair = pairViewModel; 54 | break; 55 | } 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /IntTrader/ViewModel/PairViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IntTrader.API.Currency; 3 | 4 | namespace IntTrader.ViewModel 5 | { 6 | public class PairViewModel : ViewModelBase 7 | { 8 | public PairViewModel() 9 | { 10 | 11 | } 12 | 13 | public static PairViewModel FromPair(PairBase pair) 14 | { 15 | return new PairViewModel 16 | { 17 | Name = pair.Name, 18 | Description = pair.Description, 19 | Pair = pair 20 | }; 21 | } 22 | 23 | private string _name; 24 | private string _description; 25 | 26 | public string Name 27 | { 28 | get { return _name; } 29 | set 30 | { 31 | _name = value; 32 | OnPropertyChanged("Name"); 33 | } 34 | } 35 | 36 | public string Description 37 | { 38 | get { return _description; } 39 | set 40 | { 41 | _description = value; 42 | OnPropertyChanged("Description"); 43 | } 44 | } 45 | 46 | public override string ToString() 47 | { 48 | return String.Format("{0} ({1})", Pair.NamePair, Pair.SymbolPair); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /IntTrader/ViewModel/PrefixSuffixEntry.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | 4 | namespace IntTrader.ViewModel 5 | { 6 | public class PrefixSuffixEntry 7 | { 8 | public PrefixSuffixEntry() 9 | { 10 | 11 | } 12 | private string _prefix; 13 | private string _suffix; 14 | 15 | public string Prefix 16 | { 17 | get { return _prefix; } 18 | set { _prefix = value; } 19 | } 20 | 21 | public string Suffix 22 | { 23 | get { return _suffix; } 24 | set { _suffix = value; } 25 | } 26 | 27 | public static PrefixSuffixEntry CalculatePrice(decimal price) 28 | { 29 | var entry = new PrefixSuffixEntry(); 30 | String strPrice = String.Format(CultureInfo.InvariantCulture, "{0:0.000000}", price); 31 | String strSuffix = ""; 32 | while (strPrice.EndsWith("0")) 33 | { 34 | strPrice = strPrice.Remove(strPrice.Length - 1); 35 | strSuffix += "0"; 36 | } 37 | entry.Suffix = strSuffix; 38 | entry.Prefix = strPrice; 39 | return entry; 40 | } 41 | 42 | public static PrefixSuffixEntry CalculateAmount(decimal amount) 43 | { 44 | var entry = new PrefixSuffixEntry(); 45 | decimal fraction = amount - Math.Floor(amount); 46 | 47 | entry.Prefix = String.Format(CultureInfo.InvariantCulture, "{0:F0}", amount); 48 | int fractions = 5 - entry.Prefix.Length; 49 | if (fractions > 0) 50 | { 51 | fraction = Math.Round(fraction, fractions); 52 | var format = String.Format(CultureInfo.InvariantCulture, "{{0:F{0}}}", fractions); 53 | var result = String.Format(CultureInfo.InvariantCulture, format, fraction); 54 | entry.Suffix = result.Remove(0, 1); 55 | } 56 | return entry; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /IntTrader/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /IntTrader/bitcoin.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zicore/IntTrader/d80cc14cc1505991cf417c0364a8c84542f15fd2/IntTrader/bitcoin.ico -------------------------------------------------------------------------------- /IntTrader/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Resources/Icons/bitcoin.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zicore/IntTrader/d80cc14cc1505991cf417c0364a8c84542f15fd2/Resources/Icons/bitcoin.ico -------------------------------------------------------------------------------- /Resources/Icons/bitcoin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zicore/IntTrader/d80cc14cc1505991cf417c0364a8c84542f15fd2/Resources/Icons/bitcoin.png -------------------------------------------------------------------------------- /Zicore.Security/Cryptography/Hash.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Security.Cryptography; 3 | using System.Text; 4 | 5 | namespace Zicore.Security.Cryptography 6 | { 7 | public class Hash 8 | { 9 | /// 10 | /// Returns hash of string as hexadecimal string (lower case) 11 | /// 12 | /// string to hash 13 | /// Crypto algorithm 14 | /// Amount of iterations 15 | /// the lowercase hashed hexadecimal string. 16 | public static string TextToHexStringHash(string textToHash, HashAlgorithm crypto, int iterations) 17 | { 18 | if (string.IsNullOrEmpty(textToHash)) 19 | { 20 | throw new ArgumentException("Hash is null or empty", "textToHash"); 21 | } 22 | 23 | if (crypto == null) 24 | throw new ArgumentNullException("crypto"); 25 | 26 | byte[] textToHashBytes = Encoding.Default.GetBytes(textToHash); 27 | 28 | byte[] result = textToHashBytes; 29 | for (int i = 0; i < iterations; i++) 30 | { 31 | result = crypto.ComputeHash(result); 32 | } 33 | return ToHexString(result); 34 | } 35 | 36 | public static Byte[] GetHashBytes(String t, HashAlgorithm crypto) 37 | { 38 | return crypto.ComputeHash(Encoding.UTF8.GetBytes(t)); 39 | } 40 | 41 | public static Byte[] GetHashBytes(char[] t, HashAlgorithm crypto, int position) 42 | { 43 | return crypto.ComputeHash(Encoding.Default.GetBytes(t, 0, position)); 44 | } 45 | 46 | public static Byte[] GetHashBytes(byte[] t, HashAlgorithm crypto) 47 | { 48 | return crypto.ComputeHash(t); 49 | } 50 | 51 | public static String ToHexString(byte[] bytes) 52 | { 53 | return BitConverter.ToString(bytes).Replace("-", string.Empty).ToLower(); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Zicore.Security/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Allgemeine Informationen über eine Assembly werden über die folgenden 6 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, 7 | // die mit einer Assembly verknüpft sind. 8 | [assembly: AssemblyTitle("Zicore.Security")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Zicore.Security")] 13 | [assembly: AssemblyCopyright("Copyright © 2014 by Zicore")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar 18 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von 19 | // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. 20 | [assembly: ComVisible(false)] 21 | 22 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird 23 | [assembly: Guid("027d5bbe-8360-4779-a153-22a86444b0bb")] 24 | 25 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: 26 | // 27 | // Hauptversion 28 | // Nebenversion 29 | // Buildnummer 30 | // Revision 31 | // 32 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern 33 | // übernehmen, indem Sie "*" eingeben: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Zicore.Security/Zicore.Security.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {48C98F71-2210-4806-8ED3-6AEED2729801} 8 | Library 9 | Properties 10 | Zicore.Security 11 | Zicore.Security 12 | v4.0 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 54 | -------------------------------------------------------------------------------- /Zicore.Settings.Json/JsonSettingsEncrypted.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Security.Cryptography; 3 | using System.Text; 4 | using Zicore.Security.Cryptography; 5 | 6 | namespace Zicore.Settings.Json 7 | { 8 | public class JsonSettingsEncrypted : JsonSettings 9 | { 10 | public JsonSettingsEncrypted(String key) 11 | { 12 | SetKey(key); 13 | } 14 | 15 | public JsonSettingsEncrypted() 16 | { 17 | 18 | } 19 | 20 | private readonly SHA256 _sha256 = new SHA256Managed(); 21 | private byte[] _key; 22 | 23 | public void SetKey(String stringKey) 24 | { 25 | if (String.IsNullOrWhiteSpace(stringKey)) 26 | throw new ArgumentException("Argument must be not null and not whitespace", "stringKey"); 27 | stringKey = stringKey.Trim(); 28 | 29 | _key = Hash(256, _sha256, Encoding.UTF8.GetBytes(stringKey)); 30 | } 31 | 32 | private static byte[] Hash(int iterations, HashAlgorithm hash, byte[] input) 33 | { 34 | byte[] buffer = input; 35 | for (int i = 0; i < iterations; i++) 36 | { 37 | buffer = hash.ComputeHash(buffer); 38 | } 39 | return buffer; 40 | } 41 | 42 | protected override byte[] LoadFilter(byte[] data) 43 | { 44 | if (_key == null || _key.Length == 0) 45 | throw new CryptographicException("Key not set"); 46 | 47 | var aes = new RijndaelSimple(_key); 48 | data = aes.Decrypt(data, 256); 49 | return base.LoadFilter(data); 50 | } 51 | 52 | protected override byte[] SaveFilter(byte[] data) 53 | { 54 | if (_key == null || _key.Length == 0) 55 | throw new CryptographicException("Key not set"); 56 | 57 | var aes = new RijndaelSimple(_key); 58 | data = aes.Encrypt(data, 256); 59 | return base.SaveFilter(data); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Zicore.Settings.Json/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Allgemeine Informationen über eine Assembly werden über die folgenden 6 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, 7 | // die mit einer Assembly verknüpft sind. 8 | [assembly: AssemblyTitle("Zicore.Settings.Json")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Zicore.Settings.Json")] 13 | [assembly: AssemblyCopyright("Copyright © 2014 by Zicore")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar 18 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von 19 | // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. 20 | [assembly: ComVisible(false)] 21 | 22 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird 23 | [assembly: Guid("f2be08b8-a637-45c2-970d-b2700f644324")] 24 | 25 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: 26 | // 27 | // Hauptversion 28 | // Nebenversion 29 | // Buildnummer 30 | // Revision 31 | // 32 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern 33 | // übernehmen, indem Sie "*" eingeben: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Zicore.Settings.Json/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Zicore.WPF.Base/Behaviour/BindableSelectedItemBehavior.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | using System.Windows.Interactivity; 4 | 5 | namespace Zicore.WPF.Base.Behaviour 6 | { 7 | public sealed class BindableSelectedItemBehavior : Behavior 8 | { 9 | #region SelectedItem Property 10 | 11 | public object SelectedItem 12 | { 13 | get { return (object)GetValue(SelectedItemProperty); } 14 | set { SetValue(SelectedItemProperty, value); } 15 | } 16 | 17 | public static readonly DependencyProperty SelectedItemProperty = 18 | DependencyProperty.Register("SelectedItem", typeof(object), typeof(BindableSelectedItemBehavior), new UIPropertyMetadata(null, OnSelectedItemChanged)); 19 | 20 | private static void OnSelectedItemChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) 21 | { 22 | var item = e.NewValue as TreeViewItem; 23 | if (item != null) 24 | { 25 | item.SetValue(TreeViewItem.IsSelectedProperty, true); 26 | } 27 | } 28 | 29 | #endregion 30 | 31 | protected override void OnAttached() 32 | { 33 | base.OnAttached(); 34 | 35 | this.AssociatedObject.SelectedItemChanged += OnTreeViewSelectedItemChanged; 36 | } 37 | 38 | protected override void OnDetaching() 39 | { 40 | base.OnDetaching(); 41 | 42 | if (this.AssociatedObject != null) 43 | { 44 | this.AssociatedObject.SelectedItemChanged -= OnTreeViewSelectedItemChanged; 45 | } 46 | } 47 | 48 | private void OnTreeViewSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs e) 49 | { 50 | this.SelectedItem = e.NewValue; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Zicore.WPF.Base/Behaviour/IgnoreMouseWheelBehavior.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Input; 3 | using System.Windows.Interactivity; 4 | 5 | namespace Zicore.WPF.Base.Behaviour 6 | { 7 | /// 8 | /// Captures and eats MouseWheel events so that a nested ListBox does not 9 | /// prevent an outer scrollable control from scrolling. 10 | /// 11 | public sealed class IgnoreMouseWheelBehavior : Behavior 12 | { 13 | 14 | protected override void OnAttached() 15 | { 16 | base.OnAttached(); 17 | AssociatedObject.PreviewMouseWheel += AssociatedObject_PreviewMouseWheel; 18 | } 19 | 20 | protected override void OnDetaching() 21 | { 22 | AssociatedObject.PreviewMouseWheel -= AssociatedObject_PreviewMouseWheel; 23 | base.OnDetaching(); 24 | } 25 | 26 | void AssociatedObject_PreviewMouseWheel(object sender, MouseWheelEventArgs e) 27 | { 28 | e.Handled = true; 29 | var e2 = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta); 30 | e2.RoutedEvent = UIElement.MouseWheelEvent; 31 | AssociatedObject.RaiseEvent(e2); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Zicore.WPF.Base/Commands/RelayCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Windows.Input; 4 | 5 | namespace Zicore.WPF.Base.Commands 6 | { 7 | /// 8 | /// A command whose sole purpose is to 9 | /// relay its functionality to other 10 | /// objects by invoking delegates. The 11 | /// default return value for the CanExecute 12 | /// method is 'true'. 13 | /// 14 | public class RelayCommand : ICommand 15 | { 16 | readonly Action _execute; 17 | readonly Predicate _canExecute; 18 | 19 | /// 20 | /// Creates a new command that can always execute. 21 | /// 22 | /// The execution logic. 23 | public RelayCommand(Action execute) 24 | : this(execute, null) 25 | { 26 | } 27 | 28 | /// 29 | /// Creates a new command. 30 | /// 31 | /// The execution logic. 32 | /// The execution status logic. 33 | public RelayCommand(Action execute, Predicate canExecute) 34 | { 35 | if (execute == null) 36 | throw new ArgumentNullException("execute"); 37 | 38 | _execute = execute; 39 | _canExecute = canExecute; 40 | } 41 | 42 | [DebuggerStepThrough] 43 | public bool CanExecute(object parameter) 44 | { 45 | return _canExecute == null || _canExecute(parameter); 46 | } 47 | 48 | public event EventHandler CanExecuteChanged 49 | { 50 | add { CommandManager.RequerySuggested += value; } 51 | remove { CommandManager.RequerySuggested -= value; } 52 | } 53 | 54 | public void Execute(object parameter) 55 | { 56 | _execute(parameter); 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /Zicore.WPF.Base/Controls/DataBoundRadioButton.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | 4 | namespace Zicore.WPF.Base.Controls 5 | { 6 | public class DataBoundRadioButton : RadioButton 7 | { 8 | protected override void OnChecked(RoutedEventArgs e) 9 | { 10 | // Do nothing. This will prevent IsChecked from being manually set and overwriting the binding. 11 | } 12 | 13 | protected override void OnToggle() 14 | { 15 | // Do nothing. This will prevent IsChecked from being manually set and overwriting the binding. 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Zicore.WPF.Base/Converter/IsNegativeValueConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Data; 3 | 4 | namespace Zicore.WPF.Base.Converter 5 | { 6 | public class IsNegativeValueConverter : IValueConverter 7 | { 8 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 9 | { 10 | Double doubleValue = 0.0; 11 | if (value != null) 12 | { 13 | try 14 | { 15 | Double.TryParse(value.ToString(), out doubleValue); 16 | } 17 | catch { } 18 | } 19 | 20 | return doubleValue < 0; 21 | } 22 | 23 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 24 | { 25 | throw new NotImplementedException(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Zicore.WPF.Base/Event/EventArgs.cs: -------------------------------------------------------------------------------- 1 | namespace Zicore.WPF.Base.Event 2 | { 3 | /// 4 | /// Type Save Generic Eventargs 5 | /// 6 | /// Type of the Argument Value 7 | /// This generic inherited version of the default eventargs can be used to avoid many dummy eventarg classes. 8 | public class EventArgs : System.EventArgs 9 | { 10 | //[ContractInvariantMethod] 11 | //void ObjectInvariant() 12 | //{ 13 | // Contract.Invariant(this.Value != null); 14 | //} 15 | 16 | private T m_Value; 17 | 18 | /// 19 | /// Gets or sets the value of the EventArgs. 20 | /// 21 | /// The value. 22 | public T Value 23 | { 24 | get 25 | { 26 | return m_Value; 27 | } 28 | private set 29 | { 30 | 31 | m_Value = value; 32 | } 33 | } 34 | /// 35 | /// Initializes a new instance of the class. 36 | /// 37 | public EventArgs() 38 | : base() 39 | { 40 | } 41 | 42 | /// 43 | /// Initializes a new instance of the class. 44 | /// 45 | public EventArgs(T value) 46 | : this() 47 | { 48 | //Contract.Requires(value != null); 49 | //Contract.Ensures(this.Value != null); 50 | this.Value = value; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Zicore.WPF.Base/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Allgemeine Informationen über eine Assembly werden über die folgenden 6 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, 7 | // die mit einer Assembly verknüpft sind. 8 | [assembly: AssemblyTitle("Zicore.WPF.Base")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("http://zicore.de/")] 12 | [assembly: AssemblyProduct("Zicore.WPF.Base")] 13 | [assembly: AssemblyCopyright("Copyright © 2012-2014 by Zicore")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar 18 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von 19 | // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. 20 | [assembly: ComVisible(false)] 21 | 22 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird 23 | [assembly: Guid("f8a22294-8fbc-4bf5-a331-f296e47fd9d6")] 24 | 25 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: 26 | // 27 | // Hauptversion 28 | // Nebenversion 29 | // Buildnummer 30 | // Revision 31 | // 32 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern 33 | // übernehmen, indem Sie "*" eingeben: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Zicore.WPF.Base/Win32/User32.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using System.Windows; 4 | using System.Windows.Interop; 5 | 6 | namespace Zicore.WPF.Base.Win32 7 | { 8 | 9 | public static class User32 10 | { 11 | [DllImport("user32.dll")] 12 | static extern bool SetWindowPos( 13 | IntPtr hWnd, 14 | IntPtr hWndInsertAfter, 15 | int X, 16 | int Y, 17 | int cx, 18 | int cy, 19 | uint uFlags); 20 | 21 | const UInt32 SWP_NOSIZE = 0x0001; 22 | const UInt32 SWP_NOMOVE = 0x0002; 23 | 24 | static readonly IntPtr HWND_BOTTOM = new IntPtr(1); 25 | 26 | public static void SendWpfWindowBack(Window window) 27 | { 28 | var hWnd = new WindowInteropHelper(window).Handle; 29 | SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /built/dev/R1/IntTrader.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zicore/IntTrader/d80cc14cc1505991cf417c0364a8c84542f15fd2/built/dev/R1/IntTrader.zip --------------------------------------------------------------------------------