Lean  $LEAN_TAG$
Organization.cs
1 /*
2  * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
3  * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14 */
15 
16 using System;
17 using System.Collections.Generic;
18 using Newtonsoft.Json;
20 
21 // Collection of response objects for QuantConnect Organization/ endpoints
22 namespace QuantConnect.Api
23 {
24  /// <summary>
25  /// Response wrapper for Organizations/List
26  /// TODO: The response objects in the array do not contain all Organization Properties; do we need another wrapper object?
27  /// </summary>
29  {
30  /// <summary>
31  /// List of organizations in the response
32  /// </summary>
33  [JsonProperty(PropertyName = "organizations")]
34  public List<Organization> List { get; set; }
35  }
36 
37  /// <summary>
38  /// Response wrapper for Organizations/Read
39  /// </summary>
41  {
42  /// <summary>
43  /// Organization read from the response
44  /// </summary>
45  [JsonProperty(PropertyName = "organization")]
46  public Organization Organization { get; set; }
47  }
48 
49  /// <summary>
50  /// Object representation of Organization from QuantConnect Api
51  /// </summary>
52  public class Organization
53  {
54  /// <summary>
55  /// Organization ID; Used for API Calls
56  /// </summary>
57  [JsonProperty(PropertyName = "id")]
58  public string Id { get; set; }
59 
60  /// <summary>
61  /// Seats in Organization
62  /// </summary>
63  [JsonProperty(PropertyName = "seats")]
64  public int Seats { get; set; }
65 
66  /// <summary>
67  /// Data Agreement information
68  /// </summary>
69  [JsonProperty(PropertyName = "data")]
70  public DataAgreement DataAgreement { get; set; }
71 
72  /// <summary>
73  /// Organization Product Subscriptions
74  /// </summary>
75  [JsonProperty(PropertyName = "products")]
76  public List<Product> Products { get; set; }
77 
78  /// <summary>
79  /// Organization Credit Balance and Transactions
80  /// </summary>
81  [JsonProperty(PropertyName = "credit")]
82  public Credit Credit { get; set; }
83  }
84 
85  /// <summary>
86  /// Organization Data Agreement
87  /// </summary>
88  public class DataAgreement
89  {
90  /// <summary>
91  /// Epoch time the Data Agreement was Signed
92  /// </summary>
93  [JsonProperty(PropertyName = "signedTime")]
94  public long? EpochSignedTime { get; set; }
95 
96  /// <summary>
97  /// DateTime the agreement was signed.
98  /// Uses EpochSignedTime converted to a standard datetime.
99  /// </summary>
100  public DateTime? SignedTime => EpochSignedTime.HasValue ? DateTimeOffset.FromUnixTimeSeconds(EpochSignedTime.Value).DateTime : null;
101 
102  /// <summary>
103  /// True/False if it is currently signed
104  /// </summary>
105  [JsonProperty(PropertyName = "current")]
106  public bool Signed { get; set; }
107  }
108 
109  /// <summary>
110  /// Organization Credit Object
111  /// </summary>
112  public class Credit
113  {
114  /// <summary>
115  /// Represents a change in organization credit
116  /// </summary>
117  public class Movement
118  {
119  /// <summary>
120  /// Date of the change in credit
121  /// </summary>
122  [JsonProperty(PropertyName = "date")]
123  public DateTime Date { get; set; }
124 
125  /// <summary>
126  /// Credit description
127  /// </summary>
128  [JsonProperty(PropertyName = "description")]
129  public string Description { get; set; }
130 
131  /// <summary>
132  /// Amount of change
133  /// </summary>
134  [JsonProperty(PropertyName = "amount")]
135  public decimal Amount { get; set; }
136 
137  /// <summary>
138  /// Ending Balance in QCC after Movement
139  /// </summary>
140  [JsonProperty(PropertyName = "balance")]
141  public decimal Balance { get; set; }
142  }
143 
144  /// <summary>
145  /// QCC Current Balance
146  /// </summary>
147  [JsonProperty(PropertyName = "balance")]
148  public decimal Balance { get; set; }
149 
150  /// <summary>
151  /// List of changes to Credit
152  /// </summary>
153  [JsonProperty(PropertyName = "movements")]
154  public List<Movement> Movements { get; set; }
155  }
156 
157  /// <summary>
158  /// QuantConnect Products
159  /// </summary>
160  [JsonConverter(typeof(ProductJsonConverter))]
161  public class Product
162  {
163  /// <summary>
164  /// Product Type
165  /// </summary>
166  public ProductType Type { get; set; }
167 
168  /// <summary>
169  /// Collection of item subscriptions
170  /// Nodes/Data/Seats/etc
171  /// </summary>
172  public List<ProductItem> Items { get; set; }
173  }
174 
175  /// <summary>
176  /// QuantConnect ProductItem
177  /// </summary>
178  public class ProductItem
179  {
180  /// <summary>
181  /// Product Type
182  /// </summary>
183  [JsonProperty(PropertyName = "name")]
184  public string Name { get; set; }
185 
186  /// <summary>
187  /// Collection of item subscriptions
188  /// Nodes/Data/Seats/etc
189  /// </summary>
190  [JsonProperty(PropertyName = "quantity")]
191  public int Quantity { get; set; }
192 
193  /// <summary>
194  /// USD Unit price for this item
195  /// </summary>
196  [JsonProperty(PropertyName = "unitPrice")]
197  public int UnitPrice { get; set; }
198 
199  /// <summary>
200  /// USD Total price for this product
201  /// </summary>
202  [JsonProperty(PropertyName = "total")]
203  public int TotalPrice { get; set; }
204 
205  /// <summary>
206  /// ID for this product
207  /// </summary>
208  [JsonProperty(PropertyName = "productId")]
209  public int Id { get; set; }
210  }
211 
212  /// <summary>
213  /// Product types offered by QuantConnect
214  /// Used by Product class
215  /// </summary>
216  public enum ProductType
217  {
218  /// <summary>
219  /// Professional Seats Subscriptions
220  /// </summary>
222 
223  /// <summary>
224  /// Backtest Nodes Subscriptions
225  /// </summary>
226  BacktestNode,
227 
228  /// <summary>
229  /// Research Nodes Subscriptions
230  /// </summary>
231  ResearchNode,
232 
233  /// <summary>
234  /// Live Trading Nodes Subscriptions
235  /// </summary>
236  LiveNode,
237 
238  /// <summary>
239  /// Support Subscriptions
240  /// </summary>
241  Support,
242 
243  /// <summary>
244  /// Data Subscriptions
245  /// </summary>
246  Data,
247 
248  /// <summary>
249  /// Modules Subscriptions
250  /// </summary>
251  Modules
252  }
253 }