76 lines
1.9 KiB
C#
76 lines
1.9 KiB
C#
using System;
|
|
using sharp.json;
|
|
using System.Collections.Generic;
|
|
using System.Runtime.Remoting.Messaging;
|
|
namespace sharp.trading.bittrex
|
|
{
|
|
public class BittrexMarket : Market
|
|
{
|
|
BittrexConnector connector;
|
|
JSONMarket market;
|
|
|
|
OrderBook orderBook;
|
|
|
|
public BittrexMarket(BittrexConnector connector, JSONMarket market)
|
|
: base(connector, market.MarketCurrency, market.BaseCurrency)
|
|
{
|
|
this.market = market;
|
|
this.connector = connector;
|
|
|
|
MinimumTradeVolume = market.MinTradeSize;
|
|
|
|
orderBook = new BittrexOrderbook(this);
|
|
}
|
|
|
|
public override void Close()
|
|
{
|
|
/** TODO: Nothing to free just now **/
|
|
}
|
|
|
|
public override OrderBook getOrderBook()
|
|
{
|
|
orderBook.Refresh();
|
|
return this.orderBook;
|
|
}
|
|
|
|
public override Order[] getOrders()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public string MarketName { get { return market.MarketName; } }
|
|
public string MarketCurrency { get { return market.MarketCurrency; } }
|
|
public string BaseCurrency { get { return market.BaseCurrency; } }
|
|
|
|
|
|
public override string ToString()
|
|
{
|
|
return string.Format("[BittrexMarket: MarketName={0}, MarketCurrency={1}, BaseCurrency={2}]", MarketName, MarketCurrency, BaseCurrency);
|
|
}
|
|
|
|
public override HistoricTrade[] getHistoricTrades()
|
|
{
|
|
KeyValuePair<string, string>[] parms = new KeyValuePair<string, string>[]{
|
|
new KeyValuePair<string, string>("market",MarketName)
|
|
};
|
|
JSON result = connector.publicCall("https://bittrex.com/api/v1.1/public/getmarkethistory", parms);
|
|
return result.To<BittrexHistoricTrade[]>();
|
|
}
|
|
|
|
public override Tick[] getTicks()
|
|
{
|
|
KeyValuePair<string, string>[] parms = new KeyValuePair<string, string>[]{
|
|
new KeyValuePair<string, string>("marketName",MarketName),
|
|
new KeyValuePair<string, string>("tickInterval","day")
|
|
};
|
|
JSON jticks = connector.publicCall("https://bittrex.com/Api/v2.0/pub/market/GetTicks",parms);
|
|
return jticks.To<BittrexTick[]>();
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|