示例#1
0
        /// <summary>
        /// Get a history of all of your wallet transactions (deposits, withdrawals, PNL).
        /// </summary>
        /// <param name="currency"></param>
        /// <param name="count">Number of results to fetch.</param>
        /// <param name="start">Starting point for results.</param>
        /// <returns></returns>
        public async ValueTask <Transfers> GetWalletHistory(string currency, long count, long start = 0)
        {
            var _result = new Transfers();

            var _params = new Dictionary <string, object>();
            {
                _params.Add("currency", currency);
                if (count > 0)
                {
                    _params.Add("count", count);
                }
                _params.Add("start", start);
            }

            var _response = await privateClient.CallApiGet2Async("/api/v1/user/walletHistory", _params);

            if (_response != null)
            {
#if RAWJSON
                _result.rawJson = _response.Content;
#endif
                if (_response.IsSuccessful == true)
                {
                    var _transfers = privateClient.DeserializeObject <List <BTransferItem> >(_response.Content);
                    if (_transfers != null)
                    {
                        foreach (var _t in _transfers)
                        {
                            _t.toAddress = String.IsNullOrEmpty(_t.toAddress) == false ? _t.toAddress : "undefined";

                            if (_t.transactionType == TransactionType.Deposit)
                            {
                                _t.fromAddress = _t.toAddress ?? "";
                                _t.fromTag     = _t.toTag;

                                _t.toAddress = "";
                                _t.toTag     = "";
                            }

                            _t.transferType = TransferTypeConverter.FromString(_t.transactStatus);
                            _t.isCompleted  = (_t.transferType == TransferType.Done);

                            _t.transactionId = (_t.timestamp * 1000).ToString();
                        }

                        _result.result = _transfers.ToList <ITransferItem>();
                        _result.SetSuccess();
                    }
                }
                else
                {
                    var _message = privateClient.GetResponseMessage(_response);
                    _result.SetFailure(_message.message);
                }
            }

            return(_result);
        }
示例#2
0
        /// <summary>
        /// Get a history of all of your wallet transactions (deposits, withdrawals, PNL).
        /// </summary>
        /// <param name="currency_name">base coin or quote coin name</param>
        /// <param name="timeframe">time frame interval (optional): default "1d"</param>
        /// <param name="since">return committed data since given time (milli-seconds) (optional): default 0</param>
        /// <param name="limits">You can set the maximum number of transactions you want to get with this parameter</param>
        /// <param name="args">Add additional attributes for each exchange</param>
        /// <returns></returns>
        public override async Task <Transfers> FetchTransfers(string currency_name, string timeframe = "1d", long since = 0, int limits = 20, Dictionary <string, object> args = null)
        {
            var _result = new Transfers();

            var _currency_id = await publicApi.LoadCurrencyId(currency_name);

            if (_currency_id.success == true)
            {
                privateClient.ExchangeInfo.ApiCallWait(TradeType.Private);

                var _timestamp = privateClient.ExchangeInfo.GetTimestamp(timeframe);
                var _timeframe = privateClient.ExchangeInfo.GetTimeframe(timeframe);

                var _params = new Dictionary <string, object>();
                {
                    _params.Add("currency", _currency_id.result);

                    privateClient.MergeParamsAndArgs(_params, args);
                }

                var _json_value = await privateClient.CallApiGet1Async("/api/v1/user/walletHistory", _params);

#if DEBUG
                _result.rawJson = _json_value.Content;
#endif
                var _json_result = privateClient.GetResponseMessage(_json_value.Response);
                if (_json_result.success == true)
                {
                    var _json_data = privateClient.DeserializeObject <List <BTransferItem> >(_json_value.Content);
                    {
                        var _transfers = _json_data
                                         .Where(t => t.timestamp >= since)
                                         .OrderByDescending(t => t.timestamp)
                                         .Take(limits);

                        foreach (var _t in _transfers)
                        {
                            _t.toAddress = String.IsNullOrEmpty(_t.toAddress) == false ? _t.toAddress : "undefined";

                            if (_t.transactionType == TransactionType.Deposit)
                            {
                                _t.fromAddress = _t.toAddress;
                                _t.fromTag     = _t.toTag;

                                _t.toAddress = "";
                                _t.toTag     = "";
                            }

                            _t.transferType = TransferTypeConverter.FromString(_t.transactStatus);
                            _t.isCompleted  = (_t.transferType == TransferType.Done);

                            _t.walletBalance = (_t.walletBalance ?? 0m) * 0.00000001m;
                            _t.marginBalance = (_t.marginBalance ?? 0m) * 0.00000001m;
                            _t.amount        = _t.amount * 0.00000001m;
                            _t.fee           = _t.fee * 0.00000001m;

                            if (_t.timestamp == 0)
                            {
                                _t.timestamp = CUnixTime.NowMilli;
                            }

                            //_t.transferId = _t.timestamp.ToString();              // transferId 있음
                            _t.transactionId = (_t.timestamp * 1000).ToString();    // transactionId 없음

                            _result.result.Add(_t);
                        }
                    }
                }

                _result.SetResult(_json_result);
            }
            else
            {
                _result.SetResult(_currency_id);
            }

            return(_result);
        }