public PublicTransactionData(string transaction_date, string type, string units_traded, string price, string total) { if (CUnixTime.IsDateTimeFormat(transaction_date) == true) { var _tdate = CUnixTime.ConvertToUtcTime(transaction_date + "+09:00"); this.transaction_date = CUnixTime.ConvertToUnixTimeMilli(_tdate); } else { this.transaction_date = Convert.ToInt64(transaction_date); } this.type = type; this.units_traded = Convert.ToDecimal(units_traded); this.price = decimal.Parse(price, NumberStyles.Float); this.total = decimal.Parse(total, NumberStyles.Float); }
/// <summary> /// Funding History for the specified wallet. /// </summary> /// <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 ValueTask <Transfers> FetchAllTransfers(string timeframe = "1d", long since = 0, int limits = 20, Dictionary <string, object> args = null) { var _result = new Transfers(); var _markets = await publicApi.LoadMarkets(); if (_markets.success == true) { privateClient.ExchangeInfo.ApiCallWait(TradeType.Private); var _params = new Dictionary <string, object>(); { _params.Add("offset", 0); _params.Add("limit", limits); _params.Add("sort", "desc"); privateClient.MergeParamsAndArgs(_params, args); } var _json_value = await privateClient.CallApiPost1Async("/v2/user_transactions/", _params); #if RAWJSON _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 <JObject> >(_json_value.Content); foreach (var _t in _json_data) { var _type = _t["type"].Value <int>(); if (_type != 0 && _type != 1) { continue; } var _currency = ""; var _amount = 0.0m; foreach (var _c in _markets.CurrencyNames) { var _token = _t.SelectToken(_c.Key); if (_token == null) { continue; } _amount = _token.Value <decimal>(); if (_amount != 0.0m) { _currency = _c.Value; break; } } if (String.IsNullOrEmpty(_currency) == true) { continue; } var _transaction_id = _t["id"].Value <string>(); var _transfer_id = _t["order_id"].Value <string>(); var _transaction_type = (_type == 0) ? TransactionType.Deposit : TransactionType.Withdraw; var _to_address = ""; var _from_address = ""; if (_type == 0) { _transaction_type = TransactionType.Deposit; _from_address = "undefined"; } else { _transaction_type = TransactionType.Withdraw; _to_address = "undefined"; } var _fee = _t["fee"].Value <decimal>(); var _timestamp = CUnixTime.ConvertToUnixTimeMilli(_t["datetime"].Value <string>()); _result.result.Add(new BTransferItem { transactionId = _transaction_id, transferId = _transfer_id, transactionType = _transaction_type, transferType = TransferType.Done, fromAddress = _from_address, toAddress = _to_address, currency = _currency, amount = _amount, fee = _fee, timestamp = _timestamp, isCompleted = true }); } } _result.SetResult(_json_result); } else { _result.SetResult(_markets); } return(_result); }