tradier 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.yardopts +8 -0
 - data/LICENSE.md +20 -0
 - data/README.md +114 -0
 - data/Rakefile +19 -0
 - data/lib/tradier.rb +31 -0
 - data/lib/tradier/account.rb +30 -0
 - data/lib/tradier/api/accounts.rb +122 -0
 - data/lib/tradier/api/markets.rb +113 -0
 - data/lib/tradier/api/orders.rb +84 -0
 - data/lib/tradier/api/utils.rb +47 -0
 - data/lib/tradier/api/utils/account.rb +15 -0
 - data/lib/tradier/api/utils/balance.rb +15 -0
 - data/lib/tradier/api/utils/base.rb +46 -0
 - data/lib/tradier/api/utils/event.rb +15 -0
 - data/lib/tradier/api/utils/expiration.rb +19 -0
 - data/lib/tradier/api/utils/gainloss.rb +15 -0
 - data/lib/tradier/api/utils/history.rb +15 -0
 - data/lib/tradier/api/utils/option_quote.rb +15 -0
 - data/lib/tradier/api/utils/order.rb +15 -0
 - data/lib/tradier/api/utils/position.rb +15 -0
 - data/lib/tradier/api/utils/quote.rb +15 -0
 - data/lib/tradier/api/utils/strike.rb +15 -0
 - data/lib/tradier/api/utils/timesales.rb +15 -0
 - data/lib/tradier/api/utils/watchlist.rb +15 -0
 - data/lib/tradier/api/watchlists.rb +139 -0
 - data/lib/tradier/balance.rb +17 -0
 - data/lib/tradier/base.rb +76 -0
 - data/lib/tradier/calendar.rb +23 -0
 - data/lib/tradier/client.rb +89 -0
 - data/lib/tradier/clock.rb +21 -0
 - data/lib/tradier/configurable.rb +76 -0
 - data/lib/tradier/core_ext/enumerable.rb +9 -0
 - data/lib/tradier/default.rb +75 -0
 - data/lib/tradier/error.rb +34 -0
 - data/lib/tradier/error/bad_gateway.rb +11 -0
 - data/lib/tradier/error/bad_request.rb +10 -0
 - data/lib/tradier/error/client_error.rb +28 -0
 - data/lib/tradier/error/configuration_error.rb +6 -0
 - data/lib/tradier/error/decode_error.rb +9 -0
 - data/lib/tradier/error/forbidden.rb +10 -0
 - data/lib/tradier/error/gateway_timeout.rb +11 -0
 - data/lib/tradier/error/internal_server_error.rb +11 -0
 - data/lib/tradier/error/not_acceptable.rb +10 -0
 - data/lib/tradier/error/not_found.rb +10 -0
 - data/lib/tradier/error/raise_error.rb +31 -0
 - data/lib/tradier/error/server_error.rb +28 -0
 - data/lib/tradier/error/service_unavailable.rb +11 -0
 - data/lib/tradier/error/too_many_requests.rb +12 -0
 - data/lib/tradier/error/unauthorized.rb +10 -0
 - data/lib/tradier/error/unprocessable_entity.rb +10 -0
 - data/lib/tradier/event.rb +8 -0
 - data/lib/tradier/history.rb +20 -0
 - data/lib/tradier/option_quote.rb +37 -0
 - data/lib/tradier/order.rb +14 -0
 - data/lib/tradier/position.rb +7 -0
 - data/lib/tradier/profile.rb +14 -0
 - data/lib/tradier/quote.rb +12 -0
 - data/lib/tradier/response/parse_json.rb +25 -0
 - data/lib/tradier/response/raise_error.rb +31 -0
 - data/lib/tradier/symbol.rb +147 -0
 - data/lib/tradier/timesales.rb +11 -0
 - data/lib/tradier/version.rb +3 -0
 - data/lib/tradier/watchlist.rb +16 -0
 - data/lib/tradier/watchlist_item.rb +17 -0
 - data/spec/fixtures/account_balances.json +28 -0
 - data/spec/fixtures/account_gainloss.json +18 -0
 - data/spec/fixtures/account_history.json +96 -0
 - data/spec/fixtures/account_orders.json +833 -0
 - data/spec/fixtures/account_positions.json +22 -0
 - data/spec/fixtures/calendar.json +400 -0
 - data/spec/fixtures/chain.json +2972 -0
 - data/spec/fixtures/clock.json +10 -0
 - data/spec/fixtures/expirations.json +18 -0
 - data/spec/fixtures/history.json +2086 -0
 - data/spec/fixtures/option_quote.json +14 -0
 - data/spec/fixtures/option_quotes.json +26 -0
 - data/spec/fixtures/order.json +1 -0
 - data/spec/fixtures/order_with_warnings.json +17 -0
 - data/spec/fixtures/placed_order.json +6 -0
 - data/spec/fixtures/quote.json +45 -0
 - data/spec/fixtures/quotes.json +88 -0
 - data/spec/fixtures/session.json +6 -0
 - data/spec/fixtures/strikes.json +173 -0
 - data/spec/fixtures/timesales.json +2956 -0
 - data/spec/fixtures/user_balances.json +118 -0
 - data/spec/fixtures/user_gainloss.json +6775 -0
 - data/spec/fixtures/user_history.json +101 -0
 - data/spec/fixtures/user_orders.json +57 -0
 - data/spec/fixtures/user_positions.json +50 -0
 - data/spec/fixtures/user_profile.json +103 -0
 - data/spec/fixtures/watchlist.json +30 -0
 - data/spec/fixtures/watchlist_item.json +6 -0
 - data/spec/fixtures/watchlists.json +18 -0
 - data/spec/spec_helper.rb +64 -0
 - data/spec/tradier/account_spec.rb +76 -0
 - data/spec/tradier/api/accounts_spec.rb +195 -0
 - data/spec/tradier/api/markets_spec.rb +219 -0
 - data/spec/tradier/api/orders_spec.rb +94 -0
 - data/spec/tradier/api/utils/expiration_spec.rb +8 -0
 - data/spec/tradier/api/watchlists_spec.rb +164 -0
 - data/spec/tradier/balance_spec.rb +4 -0
 - data/spec/tradier/base_spec.rb +11 -0
 - data/spec/tradier/calendar_spec.rb +27 -0
 - data/spec/tradier/client_spec.rb +125 -0
 - data/spec/tradier/clock_spec.rb +73 -0
 - data/spec/tradier/error/client_error_spec.rb +22 -0
 - data/spec/tradier/error/server_error_spec.rb +22 -0
 - data/spec/tradier/error_spec.rb +26 -0
 - data/spec/tradier/option_quote_spec.rb +61 -0
 - data/spec/tradier/order_spec.rb +43 -0
 - data/spec/tradier/position_spec.rb +4 -0
 - data/spec/tradier/profile_spec.rb +28 -0
 - data/spec/tradier/quote_spec.rb +29 -0
 - data/spec/tradier/symbol_spec.rb +54 -0
 - data/spec/tradier/watchlist_item_spec.rb +48 -0
 - data/spec/tradier/watchlist_spec.rb +35 -0
 - data/spec/tradier_spec.rb +105 -0
 - data/tradier.gemspec +30 -0
 - metadata +302 -0
 
| 
         @@ -0,0 +1,101 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            {
         
     | 
| 
      
 2 
     | 
    
         
            +
                "accounts": {
         
     | 
| 
      
 3 
     | 
    
         
            +
                    "account": {
         
     | 
| 
      
 4 
     | 
    
         
            +
                        "history": {
         
     | 
| 
      
 5 
     | 
    
         
            +
                            "event": [
         
     | 
| 
      
 6 
     | 
    
         
            +
                                {
         
     | 
| 
      
 7 
     | 
    
         
            +
                                    "acct_no": 0,
         
     | 
| 
      
 8 
     | 
    
         
            +
                                    "amount": 0,
         
     | 
| 
      
 9 
     | 
    
         
            +
                                    "date": "2013-06-13T06:20:06.110Z",
         
     | 
| 
      
 10 
     | 
    
         
            +
                                    "description": "null",
         
     | 
| 
      
 11 
     | 
    
         
            +
                                    "event_type": "null",
         
     | 
| 
      
 12 
     | 
    
         
            +
                                    "meta": "null",
         
     | 
| 
      
 13 
     | 
    
         
            +
                                    "symbol": "null"
         
     | 
| 
      
 14 
     | 
    
         
            +
                                },
         
     | 
| 
      
 15 
     | 
    
         
            +
                                {
         
     | 
| 
      
 16 
     | 
    
         
            +
                                    "acct_no": 0,
         
     | 
| 
      
 17 
     | 
    
         
            +
                                    "amount": 0,
         
     | 
| 
      
 18 
     | 
    
         
            +
                                    "date": "2013-06-14T06:20:05.133Z",
         
     | 
| 
      
 19 
     | 
    
         
            +
                                    "description": "null",
         
     | 
| 
      
 20 
     | 
    
         
            +
                                    "event_type": "null",
         
     | 
| 
      
 21 
     | 
    
         
            +
                                    "meta": "null",
         
     | 
| 
      
 22 
     | 
    
         
            +
                                    "symbol": "null"
         
     | 
| 
      
 23 
     | 
    
         
            +
                                },
         
     | 
| 
      
 24 
     | 
    
         
            +
                                {
         
     | 
| 
      
 25 
     | 
    
         
            +
                                    "acct_no": 0,
         
     | 
| 
      
 26 
     | 
    
         
            +
                                    "amount": 0,
         
     | 
| 
      
 27 
     | 
    
         
            +
                                    "date": "2013-06-14T06:20:05.727Z",
         
     | 
| 
      
 28 
     | 
    
         
            +
                                    "description": "null",
         
     | 
| 
      
 29 
     | 
    
         
            +
                                    "event_type": "null",
         
     | 
| 
      
 30 
     | 
    
         
            +
                                    "meta": "null",
         
     | 
| 
      
 31 
     | 
    
         
            +
                                    "symbol": "null"
         
     | 
| 
      
 32 
     | 
    
         
            +
                                },
         
     | 
| 
      
 33 
     | 
    
         
            +
                                {
         
     | 
| 
      
 34 
     | 
    
         
            +
                                    "acct_no": 0,
         
     | 
| 
      
 35 
     | 
    
         
            +
                                    "amount": 0,
         
     | 
| 
      
 36 
     | 
    
         
            +
                                    "date": "2013-06-14T06:20:06.147Z",
         
     | 
| 
      
 37 
     | 
    
         
            +
                                    "description": "null",
         
     | 
| 
      
 38 
     | 
    
         
            +
                                    "event_type": "null",
         
     | 
| 
      
 39 
     | 
    
         
            +
                                    "meta": "null",
         
     | 
| 
      
 40 
     | 
    
         
            +
                                    "symbol": "null"
         
     | 
| 
      
 41 
     | 
    
         
            +
                                },
         
     | 
| 
      
 42 
     | 
    
         
            +
                                {
         
     | 
| 
      
 43 
     | 
    
         
            +
                                    "acct_no": 0,
         
     | 
| 
      
 44 
     | 
    
         
            +
                                    "amount": 0,
         
     | 
| 
      
 45 
     | 
    
         
            +
                                    "date": "2013-06-14T06:20:06.320Z",
         
     | 
| 
      
 46 
     | 
    
         
            +
                                    "description": "null",
         
     | 
| 
      
 47 
     | 
    
         
            +
                                    "event_type": "null",
         
     | 
| 
      
 48 
     | 
    
         
            +
                                    "meta": "null",
         
     | 
| 
      
 49 
     | 
    
         
            +
                                    "symbol": "null"
         
     | 
| 
      
 50 
     | 
    
         
            +
                                },
         
     | 
| 
      
 51 
     | 
    
         
            +
                                {
         
     | 
| 
      
 52 
     | 
    
         
            +
                                    "acct_no": 0,
         
     | 
| 
      
 53 
     | 
    
         
            +
                                    "amount": 0,
         
     | 
| 
      
 54 
     | 
    
         
            +
                                    "date": "2013-06-15T06:20:03.843Z",
         
     | 
| 
      
 55 
     | 
    
         
            +
                                    "description": "null",
         
     | 
| 
      
 56 
     | 
    
         
            +
                                    "event_type": "null",
         
     | 
| 
      
 57 
     | 
    
         
            +
                                    "meta": "null",
         
     | 
| 
      
 58 
     | 
    
         
            +
                                    "symbol": "null"
         
     | 
| 
      
 59 
     | 
    
         
            +
                                },
         
     | 
| 
      
 60 
     | 
    
         
            +
                                {
         
     | 
| 
      
 61 
     | 
    
         
            +
                                    "acct_no": 0,
         
     | 
| 
      
 62 
     | 
    
         
            +
                                    "amount": 0,
         
     | 
| 
      
 63 
     | 
    
         
            +
                                    "date": "2013-06-15T06:20:04.593Z",
         
     | 
| 
      
 64 
     | 
    
         
            +
                                    "description": "null",
         
     | 
| 
      
 65 
     | 
    
         
            +
                                    "event_type": "null",
         
     | 
| 
      
 66 
     | 
    
         
            +
                                    "meta": "null",
         
     | 
| 
      
 67 
     | 
    
         
            +
                                    "symbol": "null"
         
     | 
| 
      
 68 
     | 
    
         
            +
                                },
         
     | 
| 
      
 69 
     | 
    
         
            +
                                {
         
     | 
| 
      
 70 
     | 
    
         
            +
                                    "acct_no": 0,
         
     | 
| 
      
 71 
     | 
    
         
            +
                                    "amount": 0,
         
     | 
| 
      
 72 
     | 
    
         
            +
                                    "date": "2013-06-15T06:20:05.310Z",
         
     | 
| 
      
 73 
     | 
    
         
            +
                                    "description": "null",
         
     | 
| 
      
 74 
     | 
    
         
            +
                                    "event_type": "null",
         
     | 
| 
      
 75 
     | 
    
         
            +
                                    "meta": "null",
         
     | 
| 
      
 76 
     | 
    
         
            +
                                    "symbol": "null"
         
     | 
| 
      
 77 
     | 
    
         
            +
                                },
         
     | 
| 
      
 78 
     | 
    
         
            +
                                {
         
     | 
| 
      
 79 
     | 
    
         
            +
                                    "acct_no": 0,
         
     | 
| 
      
 80 
     | 
    
         
            +
                                    "amount": 0,
         
     | 
| 
      
 81 
     | 
    
         
            +
                                    "date": "2013-06-15T06:20:05.590Z",
         
     | 
| 
      
 82 
     | 
    
         
            +
                                    "description": "null",
         
     | 
| 
      
 83 
     | 
    
         
            +
                                    "event_type": "null",
         
     | 
| 
      
 84 
     | 
    
         
            +
                                    "meta": "null",
         
     | 
| 
      
 85 
     | 
    
         
            +
                                    "symbol": "null"
         
     | 
| 
      
 86 
     | 
    
         
            +
                                },
         
     | 
| 
      
 87 
     | 
    
         
            +
                                {
         
     | 
| 
      
 88 
     | 
    
         
            +
                                    "acct_no": 0,
         
     | 
| 
      
 89 
     | 
    
         
            +
                                    "amount": 0,
         
     | 
| 
      
 90 
     | 
    
         
            +
                                    "date": "2013-06-16T06:20:04.967Z",
         
     | 
| 
      
 91 
     | 
    
         
            +
                                    "description": "null",
         
     | 
| 
      
 92 
     | 
    
         
            +
                                    "event_type": "null",
         
     | 
| 
      
 93 
     | 
    
         
            +
                                    "meta": "null",
         
     | 
| 
      
 94 
     | 
    
         
            +
                                    "symbol": "null"
         
     | 
| 
      
 95 
     | 
    
         
            +
                                }
         
     | 
| 
      
 96 
     | 
    
         
            +
                            ]
         
     | 
| 
      
 97 
     | 
    
         
            +
                        },
         
     | 
| 
      
 98 
     | 
    
         
            +
                        "account_number": 15970260
         
     | 
| 
      
 99 
     | 
    
         
            +
                    }
         
     | 
| 
      
 100 
     | 
    
         
            +
                }
         
     | 
| 
      
 101 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -0,0 +1,57 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            {
         
     | 
| 
      
 2 
     | 
    
         
            +
              "accounts": {
         
     | 
| 
      
 3 
     | 
    
         
            +
                "account": {
         
     | 
| 
      
 4 
     | 
    
         
            +
                  "account_number": 10026165,
         
     | 
| 
      
 5 
     | 
    
         
            +
                  "orders": {
         
     | 
| 
      
 6 
     | 
    
         
            +
                    "order": [
         
     | 
| 
      
 7 
     | 
    
         
            +
                      {
         
     | 
| 
      
 8 
     | 
    
         
            +
                          "account_id": 0,
         
     | 
| 
      
 9 
     | 
    
         
            +
                          "exec_inst": 0,
         
     | 
| 
      
 10 
     | 
    
         
            +
                          "exec_status": "Filled",
         
     | 
| 
      
 11 
     | 
    
         
            +
                          "extended_hours": false,
         
     | 
| 
      
 12 
     | 
    
         
            +
                          "id": 0,
         
     | 
| 
      
 13 
     | 
    
         
            +
                          "num_legs": 0,
         
     | 
| 
      
 14 
     | 
    
         
            +
                          "option_type": "Undefined",
         
     | 
| 
      
 15 
     | 
    
         
            +
                          "order_id": 952,
         
     | 
| 
      
 16 
     | 
    
         
            +
                          "parent_id": 0,
         
     | 
| 
      
 17 
     | 
    
         
            +
                          "price": 0.0,
         
     | 
| 
      
 18 
     | 
    
         
            +
                          "quantity": 2.0,
         
     | 
| 
      
 19 
     | 
    
         
            +
                          "request_date": "2013-06-06T15:24:50.333Z",
         
     | 
| 
      
 20 
     | 
    
         
            +
                          "response_date": "2013-06-06T15:24:50.410Z",
         
     | 
| 
      
 21 
     | 
    
         
            +
                          "side": "Buy",
         
     | 
| 
      
 22 
     | 
    
         
            +
                          "status": "Filled",
         
     | 
| 
      
 23 
     | 
    
         
            +
                          "symbol": "AAPL",
         
     | 
| 
      
 24 
     | 
    
         
            +
                          "time_in_force": "Day",
         
     | 
| 
      
 25 
     | 
    
         
            +
                          "trailing_limit_type": 0,
         
     | 
| 
      
 26 
     | 
    
         
            +
                          "trailing_stop_type": 0,
         
     | 
| 
      
 27 
     | 
    
         
            +
                          "type": "Market",
         
     | 
| 
      
 28 
     | 
    
         
            +
                          "userId": 1005
         
     | 
| 
      
 29 
     | 
    
         
            +
                      },
         
     | 
| 
      
 30 
     | 
    
         
            +
                      {
         
     | 
| 
      
 31 
     | 
    
         
            +
                          "account_id": 0,
         
     | 
| 
      
 32 
     | 
    
         
            +
                          "exec_inst": 0,
         
     | 
| 
      
 33 
     | 
    
         
            +
                          "exec_status": "Filled",
         
     | 
| 
      
 34 
     | 
    
         
            +
                          "extended_hours": false,
         
     | 
| 
      
 35 
     | 
    
         
            +
                          "id": 0,
         
     | 
| 
      
 36 
     | 
    
         
            +
                          "num_legs": 0,
         
     | 
| 
      
 37 
     | 
    
         
            +
                          "option_type": "Undefined",
         
     | 
| 
      
 38 
     | 
    
         
            +
                          "order_id": 953,
         
     | 
| 
      
 39 
     | 
    
         
            +
                          "parent_id": 0,
         
     | 
| 
      
 40 
     | 
    
         
            +
                          "price": 0.0,
         
     | 
| 
      
 41 
     | 
    
         
            +
                          "quantity": 2.0,
         
     | 
| 
      
 42 
     | 
    
         
            +
                          "request_date": "2013-06-06T15:29:27.973Z",
         
     | 
| 
      
 43 
     | 
    
         
            +
                          "response_date": "2013-06-06T15:29:28.003Z",
         
     | 
| 
      
 44 
     | 
    
         
            +
                          "side": "Buy",
         
     | 
| 
      
 45 
     | 
    
         
            +
                          "status": "Filled",
         
     | 
| 
      
 46 
     | 
    
         
            +
                          "symbol": "AAPL",
         
     | 
| 
      
 47 
     | 
    
         
            +
                          "time_in_force": "Day",
         
     | 
| 
      
 48 
     | 
    
         
            +
                          "trailing_limit_type": 0,
         
     | 
| 
      
 49 
     | 
    
         
            +
                          "trailing_stop_type": 0,
         
     | 
| 
      
 50 
     | 
    
         
            +
                          "type": "Market",
         
     | 
| 
      
 51 
     | 
    
         
            +
                          "userId": 1005
         
     | 
| 
      
 52 
     | 
    
         
            +
                      }
         
     | 
| 
      
 53 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 54 
     | 
    
         
            +
                  }
         
     | 
| 
      
 55 
     | 
    
         
            +
                }
         
     | 
| 
      
 56 
     | 
    
         
            +
              }
         
     | 
| 
      
 57 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -0,0 +1,50 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            {
         
     | 
| 
      
 2 
     | 
    
         
            +
                "accounts": {
         
     | 
| 
      
 3 
     | 
    
         
            +
                    "account": [
         
     | 
| 
      
 4 
     | 
    
         
            +
                        {
         
     | 
| 
      
 5 
     | 
    
         
            +
                            "account_number": 64394603,
         
     | 
| 
      
 6 
     | 
    
         
            +
                            "positions": "null"
         
     | 
| 
      
 7 
     | 
    
         
            +
                        },
         
     | 
| 
      
 8 
     | 
    
         
            +
                        {
         
     | 
| 
      
 9 
     | 
    
         
            +
                            "account_number": 64394610,
         
     | 
| 
      
 10 
     | 
    
         
            +
                            "positions": {
         
     | 
| 
      
 11 
     | 
    
         
            +
                                "position": [
         
     | 
| 
      
 12 
     | 
    
         
            +
                                    {
         
     | 
| 
      
 13 
     | 
    
         
            +
                                        "cost_basis": 9847.3500000000004,
         
     | 
| 
      
 14 
     | 
    
         
            +
                                        "date_acquired": "2013-08-12T20:09:01.437Z",
         
     | 
| 
      
 15 
     | 
    
         
            +
                                        "description": "null",
         
     | 
| 
      
 16 
     | 
    
         
            +
                                        "id": 507,
         
     | 
| 
      
 17 
     | 
    
         
            +
                                        "quantity": 21.0,
         
     | 
| 
      
 18 
     | 
    
         
            +
                                        "symbol": "AAPL"
         
     | 
| 
      
 19 
     | 
    
         
            +
                                    },
         
     | 
| 
      
 20 
     | 
    
         
            +
                                    {
         
     | 
| 
      
 21 
     | 
    
         
            +
                                        "cost_basis": -2.0,
         
     | 
| 
      
 22 
     | 
    
         
            +
                                        "date_acquired": "2013-08-13T18:37:49.927Z",
         
     | 
| 
      
 23 
     | 
    
         
            +
                                        "description": "null",
         
     | 
| 
      
 24 
     | 
    
         
            +
                                        "id": 513,
         
     | 
| 
      
 25 
     | 
    
         
            +
                                        "quantity": -1.0,
         
     | 
| 
      
 26 
     | 
    
         
            +
                                        "symbol": "DELL140118C00015000"
         
     | 
| 
      
 27 
     | 
    
         
            +
                                    }
         
     | 
| 
      
 28 
     | 
    
         
            +
                                ]
         
     | 
| 
      
 29 
     | 
    
         
            +
                            }
         
     | 
| 
      
 30 
     | 
    
         
            +
                        },
         
     | 
| 
      
 31 
     | 
    
         
            +
                        {
         
     | 
| 
      
 32 
     | 
    
         
            +
                            "account_number": 64394613,
         
     | 
| 
      
 33 
     | 
    
         
            +
                            "positions": {
         
     | 
| 
      
 34 
     | 
    
         
            +
                                "position": {
         
     | 
| 
      
 35 
     | 
    
         
            +
                                    "cost_basis": 49700.0,
         
     | 
| 
      
 36 
     | 
    
         
            +
                                    "date_acquired": "2013-07-29T16:21:56.167Z",
         
     | 
| 
      
 37 
     | 
    
         
            +
                                    "description": "null",
         
     | 
| 
      
 38 
     | 
    
         
            +
                                    "id": 477,
         
     | 
| 
      
 39 
     | 
    
         
            +
                                    "quantity": 10.0,
         
     | 
| 
      
 40 
     | 
    
         
            +
                                    "symbol": "AAPL131019C00400000"
         
     | 
| 
      
 41 
     | 
    
         
            +
                                }
         
     | 
| 
      
 42 
     | 
    
         
            +
                            }
         
     | 
| 
      
 43 
     | 
    
         
            +
                        },
         
     | 
| 
      
 44 
     | 
    
         
            +
                        {
         
     | 
| 
      
 45 
     | 
    
         
            +
                            "account_number": 37733449,
         
     | 
| 
      
 46 
     | 
    
         
            +
                            "positions": "null"
         
     | 
| 
      
 47 
     | 
    
         
            +
                        }
         
     | 
| 
      
 48 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 49 
     | 
    
         
            +
                }
         
     | 
| 
      
 50 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -0,0 +1,103 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            {
         
     | 
| 
      
 2 
     | 
    
         
            +
                "profile": {
         
     | 
| 
      
 3 
     | 
    
         
            +
                    "account": [
         
     | 
| 
      
 4 
     | 
    
         
            +
                        {
         
     | 
| 
      
 5 
     | 
    
         
            +
                            "account_number": 10026165,
         
     | 
| 
      
 6 
     | 
    
         
            +
                            "id": 8,
         
     | 
| 
      
 7 
     | 
    
         
            +
                            "status": 0,
         
     | 
| 
      
 8 
     | 
    
         
            +
                            "type": "Margin"
         
     | 
| 
      
 9 
     | 
    
         
            +
                        },
         
     | 
| 
      
 10 
     | 
    
         
            +
                        {
         
     | 
| 
      
 11 
     | 
    
         
            +
                            "account_number": 15970260,
         
     | 
| 
      
 12 
     | 
    
         
            +
                            "id": 10,
         
     | 
| 
      
 13 
     | 
    
         
            +
                            "status": 0,
         
     | 
| 
      
 14 
     | 
    
         
            +
                            "type": "Margin"
         
     | 
| 
      
 15 
     | 
    
         
            +
                        },
         
     | 
| 
      
 16 
     | 
    
         
            +
                        {
         
     | 
| 
      
 17 
     | 
    
         
            +
                            "account_number": 10060892,
         
     | 
| 
      
 18 
     | 
    
         
            +
                            "id": 12,
         
     | 
| 
      
 19 
     | 
    
         
            +
                            "status": 0,
         
     | 
| 
      
 20 
     | 
    
         
            +
                            "type": "Margin"
         
     | 
| 
      
 21 
     | 
    
         
            +
                        },
         
     | 
| 
      
 22 
     | 
    
         
            +
                        {
         
     | 
| 
      
 23 
     | 
    
         
            +
                            "account_number": 64394601,
         
     | 
| 
      
 24 
     | 
    
         
            +
                            "id": 22,
         
     | 
| 
      
 25 
     | 
    
         
            +
                            "status": 0,
         
     | 
| 
      
 26 
     | 
    
         
            +
                            "type": "Margin"
         
     | 
| 
      
 27 
     | 
    
         
            +
                        },
         
     | 
| 
      
 28 
     | 
    
         
            +
                        {
         
     | 
| 
      
 29 
     | 
    
         
            +
                            "account_number": 64394602,
         
     | 
| 
      
 30 
     | 
    
         
            +
                            "id": 24,
         
     | 
| 
      
 31 
     | 
    
         
            +
                            "status": 0,
         
     | 
| 
      
 32 
     | 
    
         
            +
                            "type": "Margin"
         
     | 
| 
      
 33 
     | 
    
         
            +
                        },
         
     | 
| 
      
 34 
     | 
    
         
            +
                        {
         
     | 
| 
      
 35 
     | 
    
         
            +
                            "account_number": 64394603,
         
     | 
| 
      
 36 
     | 
    
         
            +
                            "id": 26,
         
     | 
| 
      
 37 
     | 
    
         
            +
                            "status": 0,
         
     | 
| 
      
 38 
     | 
    
         
            +
                            "type": "Margin"
         
     | 
| 
      
 39 
     | 
    
         
            +
                        },
         
     | 
| 
      
 40 
     | 
    
         
            +
                        {
         
     | 
| 
      
 41 
     | 
    
         
            +
                            "account_number": 64394604,
         
     | 
| 
      
 42 
     | 
    
         
            +
                            "id": 28,
         
     | 
| 
      
 43 
     | 
    
         
            +
                            "status": 0,
         
     | 
| 
      
 44 
     | 
    
         
            +
                            "type": "Margin"
         
     | 
| 
      
 45 
     | 
    
         
            +
                        },
         
     | 
| 
      
 46 
     | 
    
         
            +
                        {
         
     | 
| 
      
 47 
     | 
    
         
            +
                            "account_number": 64394605,
         
     | 
| 
      
 48 
     | 
    
         
            +
                            "id": 30,
         
     | 
| 
      
 49 
     | 
    
         
            +
                            "status": 0,
         
     | 
| 
      
 50 
     | 
    
         
            +
                            "type": "Margin"
         
     | 
| 
      
 51 
     | 
    
         
            +
                        },
         
     | 
| 
      
 52 
     | 
    
         
            +
                        {
         
     | 
| 
      
 53 
     | 
    
         
            +
                            "account_number": 64394606,
         
     | 
| 
      
 54 
     | 
    
         
            +
                            "id": 32,
         
     | 
| 
      
 55 
     | 
    
         
            +
                            "status": 0,
         
     | 
| 
      
 56 
     | 
    
         
            +
                            "type": "Margin"
         
     | 
| 
      
 57 
     | 
    
         
            +
                        },
         
     | 
| 
      
 58 
     | 
    
         
            +
                        {
         
     | 
| 
      
 59 
     | 
    
         
            +
                            "account_number": 64394607,
         
     | 
| 
      
 60 
     | 
    
         
            +
                            "id": 34,
         
     | 
| 
      
 61 
     | 
    
         
            +
                            "status": 0,
         
     | 
| 
      
 62 
     | 
    
         
            +
                            "type": "Margin"
         
     | 
| 
      
 63 
     | 
    
         
            +
                        },
         
     | 
| 
      
 64 
     | 
    
         
            +
                        {
         
     | 
| 
      
 65 
     | 
    
         
            +
                            "account_number": 64394608,
         
     | 
| 
      
 66 
     | 
    
         
            +
                            "id": 36,
         
     | 
| 
      
 67 
     | 
    
         
            +
                            "status": 0,
         
     | 
| 
      
 68 
     | 
    
         
            +
                            "type": "Margin"
         
     | 
| 
      
 69 
     | 
    
         
            +
                        },
         
     | 
| 
      
 70 
     | 
    
         
            +
                        {
         
     | 
| 
      
 71 
     | 
    
         
            +
                            "account_number": 64394609,
         
     | 
| 
      
 72 
     | 
    
         
            +
                            "id": 38,
         
     | 
| 
      
 73 
     | 
    
         
            +
                            "status": 0,
         
     | 
| 
      
 74 
     | 
    
         
            +
                            "type": "Margin"
         
     | 
| 
      
 75 
     | 
    
         
            +
                        },
         
     | 
| 
      
 76 
     | 
    
         
            +
                        {
         
     | 
| 
      
 77 
     | 
    
         
            +
                            "account_number": 64394610,
         
     | 
| 
      
 78 
     | 
    
         
            +
                            "id": 40,
         
     | 
| 
      
 79 
     | 
    
         
            +
                            "status": 0,
         
     | 
| 
      
 80 
     | 
    
         
            +
                            "type": "Margin"
         
     | 
| 
      
 81 
     | 
    
         
            +
                        },
         
     | 
| 
      
 82 
     | 
    
         
            +
                        {
         
     | 
| 
      
 83 
     | 
    
         
            +
                            "account_number": 64394611,
         
     | 
| 
      
 84 
     | 
    
         
            +
                            "id": 42,
         
     | 
| 
      
 85 
     | 
    
         
            +
                            "status": 0,
         
     | 
| 
      
 86 
     | 
    
         
            +
                            "type": "Margin"
         
     | 
| 
      
 87 
     | 
    
         
            +
                        },
         
     | 
| 
      
 88 
     | 
    
         
            +
                        {
         
     | 
| 
      
 89 
     | 
    
         
            +
                            "account_number": 64394612,
         
     | 
| 
      
 90 
     | 
    
         
            +
                            "id": 44,
         
     | 
| 
      
 91 
     | 
    
         
            +
                            "status": 0,
         
     | 
| 
      
 92 
     | 
    
         
            +
                            "type": "Margin"
         
     | 
| 
      
 93 
     | 
    
         
            +
                        },
         
     | 
| 
      
 94 
     | 
    
         
            +
                        {
         
     | 
| 
      
 95 
     | 
    
         
            +
                            "account_number": 64394613,
         
     | 
| 
      
 96 
     | 
    
         
            +
                            "id": 46,
         
     | 
| 
      
 97 
     | 
    
         
            +
                            "status": 0,
         
     | 
| 
      
 98 
     | 
    
         
            +
                            "type": "Margin"
         
     | 
| 
      
 99 
     | 
    
         
            +
                        }
         
     | 
| 
      
 100 
     | 
    
         
            +
                    ],
         
     | 
| 
      
 101 
     | 
    
         
            +
                    "name": "test-ebenes"
         
     | 
| 
      
 102 
     | 
    
         
            +
                }
         
     | 
| 
      
 103 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            {
         
     | 
| 
      
 2 
     | 
    
         
            +
                "watchlist": {
         
     | 
| 
      
 3 
     | 
    
         
            +
                    "id": "default",
         
     | 
| 
      
 4 
     | 
    
         
            +
                    "items": {
         
     | 
| 
      
 5 
     | 
    
         
            +
                        "item": [
         
     | 
| 
      
 6 
     | 
    
         
            +
                            {
         
     | 
| 
      
 7 
     | 
    
         
            +
                                "purchase-price": 0.0,
         
     | 
| 
      
 8 
     | 
    
         
            +
                                "symbol": "aapl"
         
     | 
| 
      
 9 
     | 
    
         
            +
                            },
         
     | 
| 
      
 10 
     | 
    
         
            +
                            {
         
     | 
| 
      
 11 
     | 
    
         
            +
                                "purchase-price": 0.0,
         
     | 
| 
      
 12 
     | 
    
         
            +
                                "symbol": "msft"
         
     | 
| 
      
 13 
     | 
    
         
            +
                            },
         
     | 
| 
      
 14 
     | 
    
         
            +
                            {
         
     | 
| 
      
 15 
     | 
    
         
            +
                                "purchase-price": 0.0,
         
     | 
| 
      
 16 
     | 
    
         
            +
                                "symbol": "goog"
         
     | 
| 
      
 17 
     | 
    
         
            +
                            },
         
     | 
| 
      
 18 
     | 
    
         
            +
                            {
         
     | 
| 
      
 19 
     | 
    
         
            +
                                "purchase-price": 0.0,
         
     | 
| 
      
 20 
     | 
    
         
            +
                                "symbol": "skul"
         
     | 
| 
      
 21 
     | 
    
         
            +
                            },
         
     | 
| 
      
 22 
     | 
    
         
            +
                            {
         
     | 
| 
      
 23 
     | 
    
         
            +
                                "purchase-price": 0.0,
         
     | 
| 
      
 24 
     | 
    
         
            +
                                "symbol": "nflx"
         
     | 
| 
      
 25 
     | 
    
         
            +
                            }
         
     | 
| 
      
 26 
     | 
    
         
            +
                        ]
         
     | 
| 
      
 27 
     | 
    
         
            +
                    },
         
     | 
| 
      
 28 
     | 
    
         
            +
                    "name": "Default"
         
     | 
| 
      
 29 
     | 
    
         
            +
                }
         
     | 
| 
      
 30 
     | 
    
         
            +
            }
         
     | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | 
         @@ -0,0 +1,64 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # encoding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'simplecov'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'coveralls'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
         
     | 
| 
      
 7 
     | 
    
         
            +
              SimpleCov::Formatter::HTMLFormatter,
         
     | 
| 
      
 8 
     | 
    
         
            +
              Coveralls::SimpleCov::Formatter
         
     | 
| 
      
 9 
     | 
    
         
            +
            ]
         
     | 
| 
      
 10 
     | 
    
         
            +
            SimpleCov.start do
         
     | 
| 
      
 11 
     | 
    
         
            +
              add_group 'Tradier', 'lib/tradier'
         
     | 
| 
      
 12 
     | 
    
         
            +
              add_group 'Specs', 'spec'
         
     | 
| 
      
 13 
     | 
    
         
            +
              add_filter '.bundle'
         
     | 
| 
      
 14 
     | 
    
         
            +
            end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            require 'tradier'
         
     | 
| 
      
 17 
     | 
    
         
            +
            require 'rspec'
         
     | 
| 
      
 18 
     | 
    
         
            +
            require 'webmock/rspec'
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            RSpec.configure do |config|
         
     | 
| 
      
 21 
     | 
    
         
            +
              config.expect_with :rspec do |c|
         
     | 
| 
      
 22 
     | 
    
         
            +
                c.syntax = :expect
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
            end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            def a_delete(path)
         
     | 
| 
      
 27 
     | 
    
         
            +
              a_request(:delete, Tradier::Default::ENDPOINT + path)
         
     | 
| 
      
 28 
     | 
    
         
            +
            end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            def a_get(path)
         
     | 
| 
      
 31 
     | 
    
         
            +
              a_request(:get, Tradier::Default::ENDPOINT + path)
         
     | 
| 
      
 32 
     | 
    
         
            +
            end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            def a_post(path)
         
     | 
| 
      
 35 
     | 
    
         
            +
              a_request(:post, Tradier::Default::ENDPOINT + path)
         
     | 
| 
      
 36 
     | 
    
         
            +
            end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            def a_put(path)
         
     | 
| 
      
 39 
     | 
    
         
            +
              a_request(:put, Tradier::Default::ENDPOINT + path)
         
     | 
| 
      
 40 
     | 
    
         
            +
            end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
            def stub_delete(path)
         
     | 
| 
      
 43 
     | 
    
         
            +
              stub_request(:delete, Tradier::Default::ENDPOINT + path)
         
     | 
| 
      
 44 
     | 
    
         
            +
            end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
            def stub_get(path)
         
     | 
| 
      
 47 
     | 
    
         
            +
              stub_request(:get, Tradier::Default::ENDPOINT + path)
         
     | 
| 
      
 48 
     | 
    
         
            +
            end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
            def stub_post(path)
         
     | 
| 
      
 51 
     | 
    
         
            +
              stub_request(:post, Tradier::Default::ENDPOINT + path)
         
     | 
| 
      
 52 
     | 
    
         
            +
            end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
            def stub_put(path)
         
     | 
| 
      
 55 
     | 
    
         
            +
              stub_request(:put, Tradier::Default::ENDPOINT + path)
         
     | 
| 
      
 56 
     | 
    
         
            +
            end
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
            def fixture_path
         
     | 
| 
      
 59 
     | 
    
         
            +
              File.expand_path("../fixtures", __FILE__)
         
     | 
| 
      
 60 
     | 
    
         
            +
            end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
            def fixture(file)
         
     | 
| 
      
 63 
     | 
    
         
            +
              File.read(File.join(fixture_path,file))
         
     | 
| 
      
 64 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,76 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Tradier::Account do
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              describe "#account_number" do
         
     | 
| 
      
 6 
     | 
    
         
            +
                it "returns the account_number when set" do
         
     | 
| 
      
 7 
     | 
    
         
            +
                  account = Tradier::Account.new(:account_number => '20130704')
         
     | 
| 
      
 8 
     | 
    
         
            +
                  expect(account.account_number).to eq('20130704')
         
     | 
| 
      
 9 
     | 
    
         
            +
                end
         
     | 
| 
      
 10 
     | 
    
         
            +
                it "returns nil when account_number is not set" do
         
     | 
| 
      
 11 
     | 
    
         
            +
                  account = Tradier::Account.new({})
         
     | 
| 
      
 12 
     | 
    
         
            +
                  expect(account.account_number).to be_nil
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              describe "#type" do
         
     | 
| 
      
 17 
     | 
    
         
            +
                it "returns the type when set" do
         
     | 
| 
      
 18 
     | 
    
         
            +
                  account = Tradier::Account.new(:type => 'Margin')
         
     | 
| 
      
 19 
     | 
    
         
            +
                  expect(account.type).to eq('Margin')
         
     | 
| 
      
 20 
     | 
    
         
            +
                end
         
     | 
| 
      
 21 
     | 
    
         
            +
                it "returns nil when type is not set" do
         
     | 
| 
      
 22 
     | 
    
         
            +
                  account = Tradier::Account.new({})
         
     | 
| 
      
 23 
     | 
    
         
            +
                  expect(account.type).to be_nil
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              describe '#margin?' do
         
     | 
| 
      
 28 
     | 
    
         
            +
                it 'returns true when account type is margin' do
         
     | 
| 
      
 29 
     | 
    
         
            +
                  account = Tradier::Account.new(:type => 'Margin')
         
     | 
| 
      
 30 
     | 
    
         
            +
                  expect(account.margin?).to be_true
         
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
      
 32 
     | 
    
         
            +
              end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
              describe '#cash?' do
         
     | 
| 
      
 35 
     | 
    
         
            +
                it 'returns true when account type is cash' do
         
     | 
| 
      
 36 
     | 
    
         
            +
                  account = Tradier::Account.new(:type => 'Cash')
         
     | 
| 
      
 37 
     | 
    
         
            +
                  expect(account.cash?).to be_true
         
     | 
| 
      
 38 
     | 
    
         
            +
                end
         
     | 
| 
      
 39 
     | 
    
         
            +
              end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
              describe '#positions' do
         
     | 
| 
      
 42 
     | 
    
         
            +
                it 'returns an array' do
         
     | 
| 
      
 43 
     | 
    
         
            +
                  account = Tradier::Account.new(:positions => { :position => [{ :symbol => 'foo' }]})
         
     | 
| 
      
 44 
     | 
    
         
            +
                  expect(account.positions).to be_an Array
         
     | 
| 
      
 45 
     | 
    
         
            +
                end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                it 'returns an a collection of Tradier::Position' do
         
     | 
| 
      
 48 
     | 
    
         
            +
                  account = Tradier::Account.new(:positions => { :position => [{ :symbol => 'foo' }]})
         
     | 
| 
      
 49 
     | 
    
         
            +
                  expect(account.positions.first).to be_a Tradier::Position
         
     | 
| 
      
 50 
     | 
    
         
            +
                end
         
     | 
| 
      
 51 
     | 
    
         
            +
              end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
              describe '#orders' do
         
     | 
| 
      
 54 
     | 
    
         
            +
                it 'returns an array of orders' do
         
     | 
| 
      
 55 
     | 
    
         
            +
                  account = Tradier::Account.new(:orders => { :order => [{ :id => '123' }]})
         
     | 
| 
      
 56 
     | 
    
         
            +
                  expect(account.orders).to be_an Array
         
     | 
| 
      
 57 
     | 
    
         
            +
                end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                it 'returns a collection of Tradier::Order' do
         
     | 
| 
      
 60 
     | 
    
         
            +
                  account = Tradier::Account.new(:orders => { :order => [{ :id => '123' }]})
         
     | 
| 
      
 61 
     | 
    
         
            +
                  expect(account.orders.first).to be_a Tradier::Order
         
     | 
| 
      
 62 
     | 
    
         
            +
                end
         
     | 
| 
      
 63 
     | 
    
         
            +
              end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
              describe '#gainloss' do
         
     | 
| 
      
 66 
     | 
    
         
            +
                it 'returns an array of closed positions' do
         
     | 
| 
      
 67 
     | 
    
         
            +
                  pending
         
     | 
| 
      
 68 
     | 
    
         
            +
                end
         
     | 
| 
      
 69 
     | 
    
         
            +
              end
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
              describe '#history' do
         
     | 
| 
      
 72 
     | 
    
         
            +
                it 'returns an array of history' do
         
     | 
| 
      
 73 
     | 
    
         
            +
                  pending
         
     | 
| 
      
 74 
     | 
    
         
            +
                end
         
     | 
| 
      
 75 
     | 
    
         
            +
              end
         
     | 
| 
      
 76 
     | 
    
         
            +
            end
         
     |