Skip to content
This repository has been archived by the owner on Oct 16, 2019. It is now read-only.

Commit

Permalink
Add constants for ticker symbols
Browse files Browse the repository at this point in the history
Closes #28
  • Loading branch information
andreashuber69 committed Oct 6, 2017
1 parent d30f137 commit 051d9f5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
16 changes: 13 additions & 3 deletions Bitstamp/BitstampClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,21 @@ namespace Bitstamp
/// <summary>Represents a client for the Bitstamp API.</summary>
public sealed partial class BitstampClient : IDisposable
{
/// <summary>Gets the BTC/EUR ticker symbol.</summary>
public static string BtcEurSymbol => "BTC/EUR";

/// <summary>Gets the ticker symbol for BTC/EUR.</summary>
public static IReadOnlyList<string> TickerSymbols { get; } = new[] { BtcEurSymbol };

/// <summary>Initializes a new instance of the <see cref="BitstampClient"/> class.</summary>
/// <remarks>An instance initialized with this constructor can be used to access the public API only.</remarks>
public BitstampClient()
{
this.BtcEur = new BtcEurExchange(this);
this.Exchanges =
new Dictionary<string, ICurrencyExchange>()
{
{ BtcEurSymbol, new BtcEurExchange(this) }
};
}

/// <summary>Initializes a new instance of the <see cref="BitstampClient"/> class.</summary>
Expand Down Expand Up @@ -57,8 +67,8 @@ public BitstampClient(int customerId, string apiKey, string apiSecret)
this.sha256 = new HMACSHA256(Encoding.ASCII.GetBytes(apiSecret));
}

/// <summary>Gets the exchange for BTCEUR.</summary>
public ICurrencyExchange BtcEur { get; }
/// <summary>Gets the supported currency exchanges.</summary>
public IReadOnlyDictionary<string, ICurrencyExchange> Exchanges { get; }

/// <summary>Releases all resources used by the <see cref="BitstampClient"/>.</summary>
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Dispose must never throw.")]
Expand Down
2 changes: 1 addition & 1 deletion Bitstamp/BtcEurExchange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public sealed partial class BitstampClient
private sealed class BtcEurExchange : CurrencyExchange
{
internal BtcEurExchange(BitstampClient client)
: base(client, "BTC/EUR")
: base(client, BtcEurSymbol)
{
}

Expand Down
4 changes: 3 additions & 1 deletion SmartTrade/BtcEurTradeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
namespace SmartTrade
{
using Android.App;
using Bitstamp;

[Service]
internal sealed class BtcEurTradeService : TradeService
{
public BtcEurTradeService()
: base(new ExchangeClient(new Settings("BTC/EUR"), c => c.BtcEur))
: base(new ExchangeClient(
new Settings(BitstampClient.BtcEurSymbol), c => c.Exchanges[BitstampClient.BtcEurSymbol]))
{
}
}
Expand Down
7 changes: 5 additions & 2 deletions SmartTrade/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@

namespace SmartTrade
{
using System.Linq;

using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.OS;
using Android.Views;
using Android.Widget;
using Bitstamp;

[Activity(Label = "@string/AppName", MainLauncher = true, Icon = "@mipmap/icon", ScreenOrientation = ScreenOrientation.Portrait)]
internal sealed class MainActivity : ActivityBase, AdapterView.IOnItemClickListener
Expand All @@ -30,8 +33,8 @@ protected sealed override void OnCreate(Bundle savedInstanceState)
this.SetContentView(Resource.Layout.Main);

this.tickersListView = this.FindViewById<ListView>(Resource.Id.TickersListView);
this.tickersListView.Adapter =
new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, new[] { "BTC/EUR" });
this.tickersListView.Adapter = new ArrayAdapter<string>(
this, Android.Resource.Layout.SimpleListItem1, BitstampClient.TickerSymbols.ToArray());
this.tickersListView.OnItemClickListener = this;
}

Expand Down

0 comments on commit 051d9f5

Please sign in to comment.