コード例 #1
0
 public CryptsyMarket(CryptsyMarketId setMarketId, string baseCurrencyCode, string baseCurrencyName,
                      string quoteCurrencyCode, string quoteCurrencyName, string label,
                      MarketStatistics statistics, DateTime created)
     : base(setMarketId, baseCurrencyCode, quoteCurrencyCode, label, statistics)
 {
     this.Created           = created;
     this.BaseCurrencyName  = baseCurrencyName;
     this.QuoteCurrencyName = quoteCurrencyName;
 }
コード例 #2
0
        public static MyOrder ParseMyOrder(JObject myOrderJson, TimeZoneInfo timeZone)
        {
            DateTime        created   = DateTime.Parse(myOrderJson.Value <string>("created"));
            CryptsyMarketId marketId  = CryptsyMarketId.Parse(myOrderJson["marketid"]);
            CryptsyOrderId  orderId   = CryptsyOrderId.Parse(myOrderJson["orderid"]);
            OrderType       orderType = (OrderType)Enum.Parse(typeof(OrderType), myOrderJson.Value <string>("ordertype"));

            created = TimeZoneInfo.ConvertTimeToUtc(created, timeZone);

            return(new MyOrder(orderId,
                               orderType, created,
                               myOrderJson.Value <decimal>("price"),
                               myOrderJson.Value <decimal>("quantity"), myOrderJson.Value <decimal>("orig_quantity"),
                               marketId
                               ));
        }
コード例 #3
0
        public void TestParseCryptsyMarketTrades()
        {
            JObject jsonObj = LoadTestData("getmarkettrades.json");
            CryptsyMarketId marketId = new CryptsyMarketId("1");
            JArray marketTradesJson = jsonObj.Value<JArray>("return");
            TimeZoneInfo defaultTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
            List<CryptsyMarketTrade> marketTrades = marketTradesJson.Select(
                marketTrade => CryptsyMarketTrade.Parse(marketTrade as JObject, marketId, defaultTimeZone)
            ).ToList();

            CryptsyMarketTrade mostRecentTrade = marketTrades[0];

            Assert.AreEqual("10958207", mostRecentTrade.TradeId.ToString());
            Assert.AreEqual((decimal)16433.01498728, mostRecentTrade.Quantity);
            Assert.AreEqual(OrderType.Sell, mostRecentTrade.TradeType);
        }
コード例 #4
0
        public static CryptsyMarketTrade Parse(JObject jsonTrade, MarketId defaultMarketId, TimeZoneInfo timeZone)
        {
            DateTime tradeDateTime = DateTime.Parse(jsonTrade.Value <string>("datetime"));
            JToken   marketIdToken = jsonTrade["marketid"];
            MarketId marketId      = null == marketIdToken
                ? defaultMarketId
                : CryptsyMarketId.Parse(marketIdToken);
            CryptsyTradeId tradeId   = CryptsyTradeId.Parse(jsonTrade["tradeid"]);
            OrderType      orderType = (OrderType)Enum.Parse(typeof(OrderType), jsonTrade.Value <string>("initiate_ordertype"));

            tradeDateTime = TimeZoneInfo.ConvertTimeToUtc(tradeDateTime, timeZone);

            return(new CryptsyMarketTrade(tradeId,
                                          orderType, tradeDateTime,
                                          jsonTrade.Value <decimal>("tradeprice"),
                                          jsonTrade.Value <decimal>("quantity"), jsonTrade.Value <decimal>("fee"),
                                          marketId
                                          ));
        }
コード例 #5
0
        public void TestParseCryptsyMyTrades()
        {
            JObject jsonObj = LoadTestData("getmytrades.json");
            CryptsyMarketId marketId = new CryptsyMarketId("132");
            TimeZoneInfo defaultTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
            List<MyTrade> trades = jsonObj.Value<JArray>("return").Select(
                marketTrade => CryptsyParsers.ParseMyTrade(marketTrade as JObject, marketId, defaultTimeZone)
            ).ToList();

            Assert.AreEqual(2, trades.Count);
            Assert.AreEqual("9373209", trades[0].TradeId.ToString());
            Assert.AreEqual((decimal)0.00000059, trades[0].Price);
            Assert.AreEqual((decimal)1500.00000000, trades[0].Quantity);
            Assert.AreEqual((decimal)0.000000069, trades[0].Fee);

            Assert.AreEqual("9164163", trades[1].TradeId.ToString());
        }