internal Account(Newtonsoft.Json.Linq.JToken json) : this() { IsDeactivated = (bool)json["deactivated"]; IsWithdrawalHalted = (bool)json["withdrawal_halted"]; IsSweepEnabled = (bool)json["sweep_enabled"]; OnlyPositionClosingTrades = (bool)json["only_position_closing_trades"]; UpdatedAt = (DateTime)json["updated_at"]; AccountUrl = new Url <Account>((string)json["url"]); PortfolioUrl = new Url <AccountPortfolio>((string)json["portfolio"]); UserUrl = new Url <User>((string)json["user"]); PositionsUrl = new Url <AccountPositions>((string)json["positions"]); AccountNumber = (string)json["account_number"]; AccountType = (string)json["type"]; Sma = json["sma"]; SmaHeldForOrders = json["sma_held_for_orders"]; if (json["margin_balances"] != null) { MarginBalances = new MarginBalance(json["margin_balances"]); } MaxAchEarlyAccessAmount = (decimal)json["max_ach_early_access_amount"]; //Robinhood Instant accounts are MarginBalance based - use this instead of CashBalance if (MarginBalances != null) { CashBalance = MarginBalances; } else { CashBalance = new Balance(json["cash_balances"]); } }
internal Account(Newtonsoft.Json.Linq.JToken json) : this() { IsDeactivated = (bool)json["deactivated"]; IsWithdrawalHalted = (bool)json["withdrawal_halted"]; IsSweepEnabled = (bool)json["sweep_enabled"]; DepositHalted = (bool)json["deposit_halted"]; OnlyPositionClosingTrades = (bool)json["only_position_closing_trades"]; UpdatedAt = (DateTime)json["updated_at"]; AccountUrl = new Url <Account>((string)json["url"]); PortfolioUrl = new Url <AccountPortfolio>((string)json["portfolio"]); UserUrl = new Url <User>((string)json["user"]); PositionsUrl = new Url <AccountPositions>((string)json["positions"]); AccountNumber = (string)json["account_number"]; AccountType = (string)json["type"]; Sma = (decimal?)json["sma"]; SmaHeldForOrders = (decimal?)json["sma_held_for_orders"]; BuyingPower = (decimal)json["buying_power"]; Cash = (decimal)json["cash"]; CashHeldForOrders = (decimal)json["cash_held_for_orders"]; UnclearedDeposits = (decimal)json["uncleared_deposits"]; UnsettledFunds = (decimal)json["unsettled_funds"]; // mark MarginBalance, CashBalance null if they do not exist try { CashBalances = new CashBalance(json["cash_balances"]); } catch { CashBalances = null; } try { MarginBalances = new MarginBalance(json["margin_balances"]); } catch { MarginBalances = null; } MaxAchEarlyAccessAmount = (decimal)json["max_ach_early_access_amount"]; }