public MtGoxWithdrawalLimit(double value, Int64 value_int, string display, MtGoxCurrencySymbol currency) { this.value = value; this.value_int = value_int; this.display = display; this.currency = currency; }
public MtGoxWalletBalance(double value, Int64 value_int, string display, MtGoxCurrencySymbol currency) { this.value = value; this.value_int = value_int; this.display = display; this.currency = currency; }
/// <summary> /// Helper method to build wallet objects /// </summary> private static MtGoxWallet BuildWallet(string walletName, dynamic obj) { if (obj == null) { throw new Exception("No wallet for this currency"); } MtGoxCurrencySymbol name = (MtGoxCurrencySymbol)Enum.Parse(typeof(MtGoxCurrencySymbol), walletName, true); MtGoxWalletBalance bal = new MtGoxWalletBalance(double.Parse(obj.Balance.value), Int64.Parse(obj.Balance.value_int), obj.Balance.display, (MtGoxCurrencySymbol)Enum.Parse(typeof(MtGoxCurrencySymbol), obj.Balance.currency, true)); int ops = obj.Operations; MtGoxWithdrawalLimit dwd = null; if (obj.Daily_Withdraw_Limit != null) { dwd = new MtGoxWithdrawalLimit(double.Parse(obj.Daily_Withdraw_Limit.value), Int64.Parse(obj.Daily_Withdraw_Limit.value_int), obj.Daily_Withdraw_Limit.display, (MtGoxCurrencySymbol)Enum.Parse(typeof(MtGoxCurrencySymbol), obj.Daily_Withdraw_Limit.currency, true)); } MtGoxWithdrawalLimit mwd = null; if (obj.Monthly_Withdraw_Limit != null) { mwd = new MtGoxWithdrawalLimit(double.Parse(obj.Monthly_Withdraw_Limit.value), Int64.Parse(obj.Monthly_Withdraw_Limit.value_int), obj.Monthly_Withdraw_Limit.display, (MtGoxCurrencySymbol)Enum.Parse(typeof(MtGoxCurrencySymbol), obj.Monthly_Withdraw_Limit.currency, true)); } MtGoxWithdrawalLimit maxwd = null; if (obj.Max_Withdraw != null) { maxwd = new MtGoxWithdrawalLimit(double.Parse(obj.Max_Withdraw.value), Int64.Parse(obj.Max_Withdraw.value_int), obj.Max_Withdraw.display, (MtGoxCurrencySymbol)Enum.Parse(typeof(MtGoxCurrencySymbol), obj.Max_Withdraw.currency, true)); } MtGoxWallet wal = new MtGoxWallet(name, bal, ops, dwd, mwd, maxwd); return(wal); }
public MtGoxWallet(MtGoxCurrencySymbol name, MtGoxWalletBalance balance, int Operations, MtGoxWithdrawalLimit Daily_Withdraw_Limit, MtGoxWithdrawalLimit Monthly_Withdraw_Limit, MtGoxWithdrawalLimit Max_Withdraw) { this.name = name; this.balance = balance; this.Operations = Operations; this.Daily_Withdraw_Limit = Daily_Withdraw_Limit; this.Monthly_Withdraw_Limit = Monthly_Withdraw_Limit; this.Max_Withdraw = Max_Withdraw; }
/// <summary> /// 0/history_[CUR].csv /// </summary> public string history_CUR(MtGoxCurrencySymbol currency) { try { string url = (this.baseURL) + "0/history_" + currency.ToString() + ".csv"; string postData = ""; string responseStr = (new MtGoxNetTools()).DoAuthenticatedAPIPost(url, apiKey, apiSecret, postData); return(responseStr); } catch (Exception ex) { return(null); } }
/// <summary> /// 0/data/getDepth.php /// </summary> public MtGoxDepthInfo getDepth(MtGoxCurrencySymbol currency) { try { string url = (this.baseURL) + "0/data/getDepth.php?currency=" + currency.ToString(); string postData = ""; string responseStr = (new MtGoxNetTools()).DoAuthenticatedAPIPost(url, apiKey, apiSecret, postData); MtGoxDepthInfo returnValue = MtGoxDepthInfo.getObjects(responseStr); return(returnValue); } catch (Exception ex) { return(null); } }
/// <summary> /// 0/buyBTC.php /// </summary> public List<MtGoxOrder> buyBTC(double amount, MtGoxCurrencySymbol currency, double price = 0.0) { try { string url = (this.baseURL) + "0/buyBTC.php"; string postData; if (price == 0.0) postData = "amount=" + amount + "¤cy=" + currency.ToString(); else postData = "amount=" + amount + "&price=" + price + "¤cy=" + currency.ToString(); string responseStr = (new MtGoxNetTools()).DoAuthenticatedAPIPost(url, apiKey, apiSecret, postData); return MtGoxOrder.getObjects(responseStr); } catch (Exception ex) { return null; } }
/// <summary> /// 0/buyBTC.php /// </summary> public List <MtGoxOrder> buyBTC(double amount, MtGoxCurrencySymbol currency, double price = 0.0) { try { string url = (this.baseURL) + "0/buyBTC.php"; string postData; if (price == 0.0) { postData = "amount=" + amount + "¤cy=" + currency.ToString(); } else { postData = "amount=" + amount + "&price=" + price + "¤cy=" + currency.ToString(); } string responseStr = (new MtGoxNetTools()).DoAuthenticatedAPIPost(url, apiKey, apiSecret, postData); return(MtGoxOrder.getObjects(responseStr)); } catch (Exception ex) { return(null); } }
public bool Init() { bool bReturn = true; try { mtgoxV0.apiKey = MtGoxConfig.Key; mtgoxV0.apiSecret = MtGoxConfig.Secret; Currency = MtGoxConfig.Currency; userInfo = new UserInfo(); userInfo.Currency = Currency; historyFund = new HistoryInfo(); historyBtc = new HistoryInfo(); currentHistory = mtgoxV0.info(); if (currentHistory == null) { bReturn = false; return bReturn; } this.LoadHistory(); this.loadUserInfo(); this.loadOrders(); tickerTimer = new System.Threading.Timer(GetRealtimeTrade, null, Consts.DefaultRefreshTime * 1000, Consts.DefaultRefreshTime * 1000); formTimer = new System.Threading.Timer(BindRealtimeTrade, null, Consts.DefaultRefreshTime * 1000 + System.DateTime.Now.Month * 100 + System.DateTime.Now.Year, Consts.DefaultRefreshTime * 1000); this.GetRealtimeTrade(null); this.BindUserInfo(); } catch (Exception ex) { bReturn = false; Trace.WriteLine(string.Format("{0} \r\n stack:{1}", Utils.GetDetailedException(ex), Utils.GetStackTrace(ex))); } return bReturn; }
/// <summary> /// 0/history_[CUR].csv /// </summary> public string history_CUR(MtGoxCurrencySymbol currency) { try { string url = (this.baseURL) + "0/history_" + currency.ToString() + ".csv"; string postData = ""; string responseStr = (new MtGoxNetTools()).DoAuthenticatedAPIPost(url, apiKey, apiSecret, postData); return responseStr; } catch (Exception ex) { return null; } }
/// <summary> /// 0/data/getDepth.php /// </summary> public MtGoxDepthInfo getDepth(MtGoxCurrencySymbol currency) { try { string url = (this.baseURL) + "0/data/getDepth.php?currency=" + currency.ToString(); string postData = ""; string responseStr = (new MtGoxNetTools()).DoAuthenticatedAPIPost(url, apiKey, apiSecret, postData); MtGoxDepthInfo returnValue = MtGoxDepthInfo.getObjects(responseStr); return returnValue; } catch (Exception ex) { return null; } }