Skip to content

Commit

Permalink
Camel case results
Browse files Browse the repository at this point in the history
- Camel case lean results and streamed packets
  • Loading branch information
Martin-Molinero committed Apr 26, 2024
1 parent b527a3d commit cec0bfc
Show file tree
Hide file tree
Showing 11 changed files with 149 additions and 69 deletions.
22 changes: 11 additions & 11 deletions Common/AlgorithmConfiguration.cs
Expand Up @@ -32,71 +32,71 @@ public class AlgorithmConfiguration
/// <summary>
/// The algorithm's name
/// </summary>
[JsonProperty(PropertyName = "Name")]
[JsonProperty(PropertyName = "name")]
public string Name;

/// <summary>
/// List of tags associated with the algorithm
/// </summary>
[JsonProperty(PropertyName = "Tags")]
[JsonProperty(PropertyName = "tags")]
public ISet<string> Tags;

/// <summary>
/// The algorithm's account currency
/// </summary>
[JsonProperty(PropertyName = "AccountCurrency", NullValueHandling = NullValueHandling.Ignore)]
[JsonProperty(PropertyName = "accountCurrency", NullValueHandling = NullValueHandling.Ignore)]
public string AccountCurrency;

/// <summary>
/// The algorithm's brokerage model
/// </summary>
/// <remarks> Required to set the correct brokerage model on report generation.</remarks>
[JsonProperty(PropertyName = "Brokerage")]
[JsonProperty(PropertyName = "brokerage")]
public BrokerageName BrokerageName;

/// <summary>
/// The algorithm's account type
/// </summary>
/// <remarks> Required to set the correct brokerage model on report generation.</remarks>
[JsonProperty(PropertyName = "AccountType")]
[JsonProperty(PropertyName = "accountType")]
public AccountType AccountType;

/// <summary>
/// The parameters used by the algorithm
/// </summary>
[JsonProperty(PropertyName = "Parameters")]
[JsonProperty(PropertyName = "parameters")]
public IReadOnlyDictionary<string, string> Parameters;

/// <summary>
/// Backtest maximum end date
/// </summary>
[JsonProperty(PropertyName = "OutOfSampleMaxEndDate")]
[JsonProperty(PropertyName = "outOfSampleMaxEndDate")]
public DateTime? OutOfSampleMaxEndDate;

/// <summary>
/// The backtest out of sample day count
/// </summary>
[JsonProperty(PropertyName = "OutOfSampleDays")]
[JsonProperty(PropertyName = "outOfSampleDays")]
public int OutOfSampleDays;

/// <summary>
/// The backtest start date
/// </summary>
[JsonProperty(PropertyName = "StartDate")]
[JsonProperty(PropertyName = "startDate")]
[JsonConverter(typeof(DateTimeJsonConverter), DateFormat.UI)]
public DateTime StartDate;

/// <summary>
/// The backtest end date
/// </summary>
[JsonProperty(PropertyName = "EndDate")]
[JsonProperty(PropertyName = "endDate")]
[JsonConverter(typeof(DateTimeJsonConverter), DateFormat.UI)]
public DateTime EndDate;

/// <summary>
/// Number of trading days per year for Algorithm's portfolio statistics.
/// </summary>
[JsonProperty(PropertyName = "TradingDaysPerYear")]
[JsonProperty(PropertyName = "tradingDaysPerYear")]
public int TradingDaysPerYear;

/// <summary>
Expand Down
13 changes: 9 additions & 4 deletions Common/Chart.cs
Expand Up @@ -18,8 +18,8 @@
using System.Data;
using System.Drawing;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using QuantConnect.Logging;
using QuantConnect.Util;

namespace QuantConnect
{
Expand All @@ -28,27 +28,32 @@ namespace QuantConnect
/// </summary>
public class Chart
{
/// Name of the Chart:
/// <summary>
/// Name of the Chart
/// </summary>
[JsonProperty("name")]
public string Name = "";

/// Type of the Chart, Overlayed or Stacked.
[Obsolete("ChartType is now obsolete. Please use Series indexes instead by setting index in the series constructor.")]
[JsonProperty("chartType")]
public ChartType ChartType = ChartType.Overlay;

/// List of Series Objects for this Chart:
[JsonConverter(typeof(ChartSeriesJsonConverter))]
[JsonProperty("series")]
public Dictionary<string, BaseSeries> Series = new Dictionary<string, BaseSeries>();

/// <summary>
/// Associated symbol if any, making this an asset plot
/// </summary>
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
[JsonProperty("symbol", DefaultValueHandling = DefaultValueHandling.Ignore)]
public Symbol Symbol { get; set; }

/// <summary>
/// True to hide this series legend from the chart
/// </summary>
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
[JsonProperty("legendDisabled", DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool LegendDisabled { get; set; }

/// <summary>
Expand Down
16 changes: 9 additions & 7 deletions Common/Global.cs
Expand Up @@ -65,41 +65,43 @@ public static class DateFormat
public class Holding
{
/// Symbol of the Holding:
[JsonProperty("symbol")]
public Symbol Symbol = Symbol.Empty;

/// Type of the security
[JsonIgnore]
public SecurityType Type => Symbol.SecurityType;

/// The currency symbol of the holding, such as $
[JsonProperty("currencySymbol")]
public string CurrencySymbol;

/// Average Price of our Holding in the currency the symbol is traded in
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
[JsonProperty("averagePrice", DefaultValueHandling = DefaultValueHandling.Ignore)]
public decimal AveragePrice;

/// Quantity of Symbol We Hold.
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
[JsonProperty("quantity", DefaultValueHandling = DefaultValueHandling.Ignore)]
public decimal Quantity;

/// Current Market Price of the Asset in the currency the symbol is traded in
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
[JsonProperty("marketPrice", DefaultValueHandling = DefaultValueHandling.Ignore)]
public decimal MarketPrice;

/// Current market conversion rate into the account currency
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
[JsonProperty("conversionRate", DefaultValueHandling = DefaultValueHandling.Ignore)]
public decimal? ConversionRate;

/// Current market value of the holding
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
[JsonProperty("marketValue", DefaultValueHandling = DefaultValueHandling.Ignore)]
public decimal MarketValue;

/// Current unrealized P/L of the holding
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
[JsonProperty("unrealizedPnL", DefaultValueHandling = DefaultValueHandling.Ignore)]
public decimal UnrealizedPnL;

/// Current unrealized P/L % of the holding
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
[JsonProperty("unrealizedPnLPercent", DefaultValueHandling = DefaultValueHandling.Ignore)]
public decimal UnrealizedPnLPercent;

/// Create a new default holding:
Expand Down
2 changes: 2 additions & 0 deletions Common/Packets/BacktestResultPacket.cs
Expand Up @@ -221,11 +221,13 @@ public class BacktestResult : Result
/// <summary>
/// Rolling window detailed statistics.
/// </summary>
[JsonProperty(PropertyName = "rollingWindow")]
public Dictionary<string, AlgorithmPerformance> RollingWindow = new Dictionary<string, AlgorithmPerformance>();

/// <summary>
/// Rolling window detailed statistics.
/// </summary>
[JsonProperty(PropertyName = "totalPerformance")]
public AlgorithmPerformance TotalPerformance = null;

/// <summary>
Expand Down
8 changes: 4 additions & 4 deletions Common/Packets/LiveResultPacket.cs
Expand Up @@ -153,7 +153,7 @@ public class LiveResult : Result
/// <summary>
/// Holdings dictionary of algorithm holdings information
/// </summary>
[JsonProperty(PropertyName = "Holdings", NullValueHandling = NullValueHandling.Ignore)]
[JsonProperty(PropertyName = "holdings", NullValueHandling = NullValueHandling.Ignore)]
public IDictionary<string, Holding> Holdings;

/// <summary>
Expand All @@ -179,19 +179,19 @@ public CashBook CashBook
/// <summary>
/// Cash for the algorithm's live results.
/// </summary>
[JsonProperty(PropertyName = "Cash", NullValueHandling = NullValueHandling.Ignore)]
[JsonProperty(PropertyName = "cash", NullValueHandling = NullValueHandling.Ignore)]
public Dictionary<string, Cash> Cash;

/// <summary>
/// The algorithm's account currency
/// </summary>
[JsonProperty(PropertyName = "AccountCurrency", NullValueHandling = NullValueHandling.Ignore)]
[JsonProperty(PropertyName = "accountCurrency", NullValueHandling = NullValueHandling.Ignore)]
public string AccountCurrency;

/// <summary>
/// The algorithm's account currency
/// </summary>
[JsonProperty(PropertyName = "AccountCurrencySymbol", NullValueHandling = NullValueHandling.Ignore)]
[JsonProperty(PropertyName = "accountCurrencySymbol", NullValueHandling = NullValueHandling.Ignore)]
public string AccountCurrencySymbol;

/// <summary>
Expand Down
18 changes: 9 additions & 9 deletions Common/Result.cs
Expand Up @@ -31,56 +31,56 @@ public class Result
/// <summary>
/// Charts updates for the live algorithm since the last result packet
/// </summary>
[JsonProperty(PropertyName = "Charts", NullValueHandling = NullValueHandling.Ignore)]
[JsonProperty(PropertyName = "charts", NullValueHandling = NullValueHandling.Ignore)]
public IDictionary<string, Chart> Charts;

/// <summary>
/// Order updates since the last result packet
/// </summary>
[JsonProperty(PropertyName = "Orders", NullValueHandling = NullValueHandling.Ignore)]
[JsonProperty(PropertyName = "orders", NullValueHandling = NullValueHandling.Ignore)]
public IDictionary<int, Order> Orders;

/// <summary>
/// OrderEvent updates since the last result packet
/// </summary>
[JsonProperty(PropertyName = "OrderEvents", NullValueHandling = NullValueHandling.Ignore)]
[JsonProperty(PropertyName = "orderEvents", NullValueHandling = NullValueHandling.Ignore)]
public List<OrderEvent> OrderEvents;

/// <summary>
/// Trade profit and loss information since the last algorithm result packet
/// </summary>
[JsonProperty(PropertyName = "ProfitLoss", NullValueHandling = NullValueHandling.Ignore)]
[JsonProperty(PropertyName = "profitLoss", NullValueHandling = NullValueHandling.Ignore)]
public IDictionary<DateTime, decimal> ProfitLoss;

/// <summary>
/// Statistics information sent during the algorithm operations.
/// </summary>
/// <remarks>Intended for update mode -- send updates to the existing statistics in the result GUI. If statistic key does not exist in GUI, create it</remarks>
[JsonProperty(PropertyName = "Statistics", NullValueHandling = NullValueHandling.Ignore)]
[JsonProperty(PropertyName = "statistics", NullValueHandling = NullValueHandling.Ignore)]
public IDictionary<string, string> Statistics;

/// <summary>
/// Runtime banner/updating statistics in the title banner of the live algorithm GUI.
/// </summary>
[JsonProperty(PropertyName = "RuntimeStatistics", NullValueHandling = NullValueHandling.Ignore)]
[JsonProperty(PropertyName = "runtimeStatistics", NullValueHandling = NullValueHandling.Ignore)]
public IDictionary<string, string> RuntimeStatistics;

/// <summary>
/// State of the result packet.
/// </summary>
[JsonProperty(PropertyName = "State", NullValueHandling = NullValueHandling.Ignore)]
[JsonProperty(PropertyName = "state", NullValueHandling = NullValueHandling.Ignore)]
public IDictionary<string, string> State;

/// <summary>
/// Server status information, including CPU/RAM usage, ect...
/// </summary>
[JsonProperty(PropertyName = "ServerStatistics", NullValueHandling = NullValueHandling.Ignore)]
[JsonProperty(PropertyName = "serverStatistics", NullValueHandling = NullValueHandling.Ignore)]
public IDictionary<string, string> ServerStatistics;

/// <summary>
/// The algorithm's configuration required for report generation
/// </summary>
[JsonProperty(PropertyName = "AlgorithmConfiguration", NullValueHandling = NullValueHandling.Ignore)]
[JsonProperty(PropertyName = "algorithmConfiguration", NullValueHandling = NullValueHandling.Ignore)]
public AlgorithmConfiguration AlgorithmConfiguration;

/// <summary>
Expand Down
5 changes: 5 additions & 0 deletions Common/Securities/Cash.cs
Expand Up @@ -100,18 +100,21 @@ private void OnConversionRateUpdated(object sender, decimal e)
/// Gets the symbol used to represent this cash
/// </summary>
[ProtoMember(1)]
[JsonProperty("symbol")]
public string Symbol { get; }

/// <summary>
/// Gets or sets the amount of cash held
/// </summary>
[ProtoMember(2)]
[JsonProperty("amount")]
public decimal Amount { get; private set; }

/// <summary>
/// Gets the conversion rate into account currency
/// </summary>
[ProtoMember(3)]
[JsonProperty("conversionRate")]
public decimal ConversionRate
{
get
Expand All @@ -133,11 +136,13 @@ internal set
/// The symbol of the currency, such as $
/// </summary>
[ProtoMember(4)]
[JsonProperty("currencySymbol")]
public string CurrencySymbol { get; }

/// <summary>
/// Gets the value of this cash in the account currency
/// </summary>
[JsonProperty("valueInAccountCurrency")]
public decimal ValueInAccountCurrency => Amount * ConversionRate;

/// <summary>
Expand Down

0 comments on commit cec0bfc

Please sign in to comment.