irb(main):001:0> User.first.tradier.balances
User Load (0.3ms) SELECT `users`.* FROM `users` LIMIT 1
(0.2ms) SELECT COUNT(*) FROM `agreements` WHERE `agreements`.`user_id` = 1
Oauth::AccessToken Load (0.2ms) SELECT `access_tokens`.* FROM `access_tokens` WHERE `access_tokens`.`uuid` = 'test-ebenes' AND `access_tokens`.`app_id` = 'd3caaf2a-d098-4a28-8bde-387f407c92d0' LIMIT 1
=> [#<Tradier::BalanceCollection:0x007f91b9b09738 @attrs={:balances=>{:account_number=>10026165, :account_type=>1, :cash=>3293903.03913, :close_pl=>0.0, :dividend_balance=>0.0, :equity=>3298548.99913, :long_liquid_value=>0.0, :long_market_value=>20761.42, :market_value=>41522.82, :net_value=>-235000.0, :open_pl=>172.7, :option_long_value=>11.0, :option_requirement=>0.0, :option_short_value=>0.0, :pending_cash=>119.5, :pending_orders_count=>3, :short_liquid_value=>0.0, :short_market_value=>0.0, :stock_long_value=>4628.03, :stock_short_value=>0.0, :sweep=>0.0, :cash_available=>20761.42, :prev_day_cash_available=>0.0}, :account_number=>10026165}>, #<Tradier::BalanceCollection:0x007f91b9b09710 @attrs={:balances=>{:account_number=>15970260, :account_type=>2, :cash=>0.0, :close_pl=>0.0, :dividend_balance=>0.0, :equity=>10048225.16, :long_liquid_value=>67484.98, :long_market_value=>67484.98, :market_value=>0.0, :net_value=>0.0, :open_pl=>-1818.37, :option_long_value=>831.0, :option_requirement=>0.0, :option_short_value=>0.0, :pending_cash=>0.0, :pending_orders_count=>0, :short_liquid_value=>0.0, :short_market_value=>0.0, :stock_long_value=>48034.03, :stock_short_value=>0.0, :sweep=>0.0, :day_trade_buying_power=>20000000.0, :excess=>10000000.0, :fed_call=>0.0, :maintenance_call=>0.0, :maintenance_call_previous=>0, :option_buying_power=>20000000.0, :sma=>-35307.0, :sma_change=>0.0, :sma_or_call_previous=>0, :stock_buying_power=>20000000.0}, :account_number=>15970260}>, #<Tradier::BalanceCollection:0x007f91b9b096c0 @attrs={:balances=>{:account_number=>10060892, :account_type=>2, :cash=>0.0, :close_pl=>0.0, :dividend_balance=>0.0, :equity=>0.0, :long_liquid_value=>260.88, :long_market_value=>260.88, :market_value=>0.0, :net_value=>0.0, :open_pl=>0.0, :option_long_value=>0.0, :option_requirement=>0.0, :option_short_value=>0.0, :pending_cash=>0.0, :pending_orders_count=>0, :short_liquid_value=>0.0, :short_market_value=>0.0, :stock_long_value=>0.0, :stock_short_value=>0.0, :sweep=>0.0, :fed_call=>0.0, :maintenance_call=>0.0, :option_buying_power=>0.0, :sma=>-130.0, :sma_change=>0.0, :sma_or_call_previous=>0, :stock_buying_power=>0.0}, :account_number=>10060892}>]
irb(main):002:0> User.first.tradier.balances.to_xml
User Load (0.4ms) SELECT `users`.* FROM `users` LIMIT 1
(0.3ms) SELECT COUNT(*) FROM `agreements` WHERE `agreements`.`user_id` = 1
Oauth::AccessToken Load (0.3ms) SELECT `access_tokens`.* FROM `access_tokens` WHERE `access_tokens`.`uuid` = 'test-ebenes' AND `access_tokens`.`app_id` = 'd3caaf2a-d098-4a28-8bde-387f407c92d0' LIMIT 1
=> "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<tradier-balance-collections type=\"array\">\n <tradier-balance-collection type=\"Tradier::BalanceCollection\">#<Tradier::BalanceCollection:0x007f91b9a89ec0></tradier-balance-collection>\n <tradier-balance-collection type=\"Tradier::BalanceCollection\">#<Tradier::BalanceCollection:0x007f91b9a89d58></tradier-balance-collection>\n <tradier-balance-collection type=\"Tradier::BalanceCollection\">#<Tradier::BalanceCollection:0x007f91b9a89d30></tradier-balance-collection>\n</tradier-balance-collections>\n"
irb(main):003:0> User.first.tradier.balances.to_json
User Load (0.4ms) SELECT `users`.* FROM `users` LIMIT 1
(0.3ms) SELECT COUNT(*) FROM `agreements` WHERE `agreements`.`user_id` = 1
Oauth::AccessToken Load (0.3ms) SELECT `access_tokens`.* FROM `access_tokens` WHERE `access_tokens`.`uuid` = 'test-ebenes' AND `access_tokens`.`app_id` = 'd3caaf2a-d098-4a28-8bde-387f407c92d0' LIMIT 1
NoMethodError: undefined method `map' for nil:NilClass
from /Users/jbarry/Projects/brokerage.tradier.com/.bundle/bundler/gems/tradier.rb-571c278384cc/lib/tradier/balance_collection.rb:15:in `balances'
from /Users/jbarry/Projects/brokerage.tradier.com/.bundle/bundler/gems/tradier.rb-571c278384cc/lib/tradier/balance_collection.rb:9:in `each'
from /Users/jbarry/Projects/brokerage.tradier.com/.bundle/gems/activesupport-3.2.13/lib/active_support/json/encoding.rb:201:in `to_a'
from /Users/jbarry/Projects/brokerage.tradier.com/.bundle/gems/activesupport-3.2.13/lib/active_support/json/encoding.rb:201:in `as_json'
from /Users/jbarry/Projects/brokerage.tradier.com/.bundle/gems/activesupport-3.2.13/lib/active_support/json/encoding.rb:55:in `block in as_json'
from /Users/jbarry/Projects/brokerage.tradier.com/.bundle/gems/activesupport-3.2.13/lib/active_support/json/encoding.rb:77:in `check_for_circular_references'
from /Users/jbarry/Projects/brokerage.tradier.com/.bundle/gems/activesupport-3.2.13/lib/active_support/json/encoding.rb:54:in `as_json'
from /Users/jbarry/Projects/brokerage.tradier.com/.bundle/gems/activesupport-3.2.13/lib/active_support/json/encoding.rb:209:in `block in as_json'
from /Users/jbarry/Projects/brokerage.tradier.com/.bundle/gems/activesupport-3.2.13/lib/active_support/json/encoding.rb:209:in `map'
from /Users/jbarry/Projects/brokerage.tradier.com/.bundle/gems/activesupport-3.2.13/lib/active_support/json/encoding.rb:209:in `as_json'
from /Users/jbarry/Projects/brokerage.tradier.com/.bundle/gems/activesupport-3.2.13/lib/active_support/json/encoding.rb:47:in `block in encode'
from /Users/jbarry/Projects/brokerage.tradier.com/.bundle/gems/activesupport-3.2.13/lib/active_support/json/encoding.rb:77:in `check_for_circular_references'
from /Users/jbarry/Projects/brokerage.tradier.com/.bundle/gems/activesupport-3.2.13/lib/active_support/json/encoding.rb:46:in `encode'
from /Users/jbarry/Projects/brokerage.tradier.com/.bundle/gems/activesupport-3.2.13/lib/active_support/json/encoding.rb:31:in `encode'
from /Users/jbarry/Projects/brokerage.tradier.com/.bundle/gems/activesupport-3.2.13/lib/active_support/core_ext/object/to_json.rb:16:in `to_json'
from (irb):3
from /Users/jbarry/Projects/brokerage.tradier.com/.bundle/gems/railties-3.2.13/lib/rails/commands/console.rb:47:in `start'
from /Users/jbarry/Projects/brokerage.tradier.com/.bundle/gems/railties-3.2.13/lib/rails/commands/console.rb:8:in `start'
from /Users/jbarry/Projects/brokerage.tradier.com/.bundle/gems/railties-3.2.13/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'irb(main):004:0>