sharp-trading/bittrex/BittrexOrderbook.cs

39 lines
811 B
C#

using System;
using sharp.json;
using System.Collections.Generic;
using System.IO;
namespace sharp.trading.bittrex
{
public class BittrexOrderbook : OrderBook
{
BittrexMarket bmarket;
public BittrexOrderbook(BittrexMarket market)
:base(market)
{
bmarket = market;
}
public override void Refresh()
{
JSON reply = JSONWebRequest.Call(String.Format("https://bittrex.com/api/v1.1/public/getorderbook?market={0}&type=both",bmarket.MarketName));
if (!reply["success"].Boolean){
throw new IOException("Orderbook Refresh failed: " + reply["message"].String);
}
VolumeRate[] bids = reply["result"]["buy"].To<VolumeRate[]>();
VolumeRate[] asks = reply["result"]["sell"].To<VolumeRate[]>();
Array.Sort(bids);
Array.Sort(asks);
Bids = bids;
Asks = asks;
}
}
}