Exemple #1
0
        private TickerFormatter GetTickerFormatter(FormatterTypeEnum type)
        {
            /* ALL
             *  {"open":0.008545,"close":0.008656,"low":0.008088,"high":0.009388,"amount":88056.1860,
             *  "count":16077,"vol":771.7975953754,"symbol":"ltcbtc"}
             */

            /*single
             *{"id":1499225271,"ts":1499225271000,"close":1885.0000,"open":1960.0000,"high":1985.0000,"low":1856.0000,
             * "amount":81486.2926,"count":42122,"vol":157052744.85708200,"ask":[1885.0000,21.8804],"bid":[1884.0000,1.6702]}
             */

            /*websocket
             *"amount":12224.2922,"open":9790.52,"close":10195.00,"high":10300.00,"ts":1494496390000,
             * "id":1494496390,"count":15195,"low":9657.00,"vol":121906001.754751
             */

            var result = new TickerFormatter
            {
                LastKey         = "close",
                VolumeFormatter = new VolumeFormatter
                {
                    BaseVolumeKey  = "amount",
                    QuoteVolumeKey = "vol"
                }
            };

            if (type != FormatterTypeEnum.All)
            {
                result.TimestampFormatter = new TimestampFormatter
                {
                    TimestampKey  = "ts",
                    TimestampType = CurrentTimestampType
                };

                result.IdKey = "id";

                if (type == FormatterTypeEnum.Signle)
                {
                    result.AskBidFormatter = new AskBidFormatter
                    {
                        AskKey = "ask",
                        BidKey = "bid"
                    };
                }
            }

            return(result);
        }
Exemple #2
0
        private TradeFormatter GetTradeFormatter(FormatterTypeEnum type)
        {
            return(new TradeFormatter
            {
                AmountKey = "amount",
                PriceKey = "price",
                DirectionKey = "direction",
                TimestampFormatter = new TimestampFormatter
                {
                    TimestampKey = "ts",
                    TimestampType = CurrentTimestampType
                },
                IdKey = "id",
                DirectionIsBuyValue = "buy"
            });

            /* websocket
             *      {"id":"id1","status":"ok","subbed":"market.btcusdt.trade.detail","ts":1527574853489}
             *      {{
             *        "ch": "market.btcusdt.trade.detail",
             *        "ts": 1527574905759,
             *        "tick": {
             *          "id": 8232977476,
             *          "ts": 1527574905623,
             *          "data": [
             *            {
             *              "amount": 0.3066,
             *              "ts": 1527574905623,
             *              "id": 82329774765058180723,
             *              "price": 7101.81,
             *              "direction": "buy"
             *            }
             *          ]
             *        }
             *      }}
             */

            /*
             * {"status":"ok","ch":"market.ethusdt.trade.detail","ts":1542104543483,
             * "tick":{"id":27952707649,"ts":1542104541926,
             *  "data":[{"amount":0.100000000000000000,"ts":1542104541926,"id":2795270764916609236638,"price":210.900000000000000000,"direction":"buy"},{"amount":0.327700000000000000,"ts":1542104541926,"id":2795270764916609248055,"price":210.900000000000000000,"direction":"buy"}]}}
             */
        }
Exemple #3
0
        private CandleFormatter GetCandleFormatter(FormatterTypeEnum type)
        {
            /*websocket
             * "ch":"market.btcusdt.kline.1min","ts":1489474082831,
             * "tick":{"id":1489464480,"amount":0.0,"count":0,"open":7962.62,"close":7962.62,"low":7962.62,"high":7962.62,"vol":0.0}
             */

            /* single
             * {
             * "status": "ok",
             * "ch": "market.btcusdt.kline.1day",
             * "ts": 1499223904680,
             * “data”: [
             * {
             *  "id": 1499184000,
             *  "amount": 37593.0266,
             *  "count": 0,
             *  "open": 1935.2000,
             *  "close": 1879.0000,
             *  "low": 1856.0000,
             *  "high": 1940.0000,
             *  "vol": 71031537.97866500
             * },
             */
            return(new CandleFormatter
            {
                OpenKey = "open",
                HighKey = "high",
                LowKey = "low",
                CloseKey = "close",
                TimestampFormatter = new TimestampFormatter
                {
                    TimestampType = TimestampType.UnixSeconds, // K线的时间戳是到秒的
                    TimestampKey = "id",
                },
                VolumeFormatter = new VolumeFormatter
                {
                    BaseVolumeKey = null,
                    QuoteVolumeKey = "vol"
                }
            });
        }