GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Post merge fixes · nuswgg/Lean@6bfea3d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Algorithm.CSharp
    • FractionalQuantityRegressionAlgorithm.cs
    • FuzzyInferenceAlgorithm.cs
  • Brokerages/InteractiveBrokers
    • InteractiveBrokersBrokerage.cs
  • Common
    • Orders
      • OptionExerciseOrder.cs
    • Securities/Option
      • Option.cs
  • Tests
    • RegressionTests.cs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Algorithm.CSharp/FractionalQuantityRegressionAlgorithm.cs‎

Copy file name to clipboardExpand all lines: Algorithm.CSharp/FractionalQuantityRegressionAlgorithm.cs
+4-10Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@
1313
* limitations under the License.
1414
*/
1515

16-
using QuantConnect.Data;
1716
using QuantConnect.Data.Consolidators;
1817
using QuantConnect.Data.Market;
1918
using System;
20-
using System.Linq;
2119

2220
namespace QuantConnect.Algorithm.CSharp
2321
{
@@ -39,15 +37,14 @@ public override void Initialize()
3937

4038
SetTimeZone(NodaTime.DateTimeZone.Utc);
4139
var security = AddSecurity(SecurityType.Forex, "BTCUSD", Resolution.Daily, Market.Bitfinex, false, 3.3m, true);
42-
TradeBarConsolidator con = new TradeBarConsolidator(1);
40+
var con = new QuoteBarConsolidator(1);
4341
SubscriptionManager.AddConsolidator("BTCUSD", con);
4442
con.DataConsolidated += con_DataConsolidated;
4543
SetBenchmark(security.Symbol);
4644
}
4745

48-
void con_DataConsolidated(object sender, TradeBar e)
46+
void con_DataConsolidated(object sender, QuoteBar e)
4947
{
50-
5148
var quantity = Math.Truncate(Portfolio.Cash / Math.Abs(e.Value + 1));
5249
if (!Portfolio.Invested)
5350
{
@@ -67,16 +64,13 @@ void con_DataConsolidated(object sender, TradeBar e)
6764
}
6865
else if (Portfolio["BTCUSD"].Quantity == quantity + 0.09m)
6966
{
70-
7167
//should fail
72-
var ticket = Order("BTCUSD", 0.001);
68+
Order("BTCUSD", 0.001);
7369

7470
SetHoldings("BTCUSD", -2.0m);
7571
SetHoldings("BTCUSD", 2.0m);
76-
this.Quit();
72+
Quit();
7773
}
78-
79-
8074
}
8175
}
8276
}
Collapse file

‎Algorithm.CSharp/FuzzyInferenceAlgorithm.cs‎

Copy file name to clipboardExpand all lines: Algorithm.CSharp/FuzzyInferenceAlgorithm.cs
+18-3Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
using System;
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;
217
using QuantConnect.Data.Market;
318
using QuantConnect.Indicators;
419
using Accord.Fuzzy;
@@ -49,7 +64,7 @@ public void OnData(TradeBars data)
4964
{
5065
if (signal > 30)
5166
{
52-
int quantity = Decimal.ToInt32(Portfolio.MarginRemaining / data[symbol].Price);
67+
var quantity = decimal.ToInt32(Portfolio.MarginRemaining / data[symbol].Price);
5368
Buy(symbol, quantity);
5469
Debug("Purchased Stock: " + quantity + " shares");
5570
}
@@ -58,7 +73,7 @@ public void OnData(TradeBars data)
5873
{
5974
if (signal < -10)
6075
{
61-
int quantity = Portfolio[symbol].Quantity;
76+
var quantity = decimal.ToInt32(Portfolio[symbol].Quantity);
6277
Sell(symbol, quantity);
6378
Debug("Sold Stock: " + quantity + " shares");
6479
}
Collapse file

‎Brokerages/InteractiveBrokers/InteractiveBrokersBrokerage.cs‎

Copy file name to clipboardExpand all lines: Brokerages/InteractiveBrokers/InteractiveBrokersBrokerage.cs
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ private void IBPlaceOrder(Order order, bool needsNewId, string exchange = null)
644644

645645
if (order.Type == OrderType.OptionExercise)
646646
{
647-
_client.ClientSocket.exerciseOptions(ibOrderId, contract, 1, order.Quantity, _account, 0);
647+
_client.ClientSocket.exerciseOptions(ibOrderId, contract, 1, decimal.ToInt32(order.Quantity), _account, 0);
648648
}
649649
else
650650
{
Collapse file

‎Common/Orders/OptionExerciseOrder.cs‎

Copy file name to clipboardExpand all lines: Common/Orders/OptionExerciseOrder.cs
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public OptionExerciseOrder()
3939
/// <param name="quantity">Quantity of the option we're seeking to exercise. Must be a positive value.</param>
4040
/// <param name="time">Time the order was placed</param>
4141
/// <param name="tag">User defined data tag for this order</param>
42-
public OptionExerciseOrder(Symbol symbol, int quantity, DateTime time, string tag = "")
42+
public OptionExerciseOrder(Symbol symbol, decimal quantity, DateTime time, string tag = "")
4343
: base(symbol, quantity, time, tag)
4444
{
4545
Price = Symbol.ID.StrikePrice;
@@ -64,7 +64,6 @@ protected override decimal GetValueImpl(Security security)
6464
return option.GetExerciseQuantity(Quantity) * Price / option.SymbolProperties.ContractMultiplier;
6565
}
6666

67-
6867
/// <summary>
6968
/// Creates a deep-copy clone of this order
7069
/// </summary>
Collapse file

‎Common/Securities/Option/Option.cs‎

Copy file name to clipboardExpand all lines: Common/Securities/Option/Option.cs
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@
1515

1616
using System;
1717
using QuantConnect.Data;
18-
using QuantConnect.Data.Market;
1918
using QuantConnect.Orders.Fees;
2019
using QuantConnect.Orders.Fills;
2120
using QuantConnect.Orders.Slippage;
2221
using QuantConnect.Orders.OptionExercise;
23-
using System.Collections.Generic;
2422

2523
namespace QuantConnect.Securities.Option
2624
{
@@ -185,9 +183,9 @@ public decimal GetAggregateExerciseAmount()
185183
/// we may have 1 option contract with multiplier of 100 with right to buy/sell only 50 shares of underlying stock.
186184
/// </summary>
187185
/// <returns></returns>
188-
public int GetExerciseQuantity(int quantity)
186+
public decimal GetExerciseQuantity(decimal quantity)
189187
{
190-
return (int)(quantity * ContractUnitOfTrade / ContractMultiplier);
188+
return quantity * ContractUnitOfTrade / ContractMultiplier;
191189
}
192190

193191
/// <summary>
Collapse file

‎Tests/RegressionTests.cs‎

Copy file name to clipboardExpand all lines: Tests/RegressionTests.cs
+18-18Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ private static TestCaseData[] GetRegressionTestParameters()
499499
{"Treynor Ratio", "0.391"},
500500
{"Total Fees", "$23.05"},
501501
};
502-
var optionExerciseAssignRegressionAlgorithmStatistics = new Dictionary<string, string>
502+
var optionExerciseAssignRegressionAlgorithmStatistics = new Dictionary<string, string>
503503
{
504504
{"Total Trades", "4"},
505505
{"Average Win", "0.30%"},
@@ -590,28 +590,28 @@ private static TestCaseData[] GetRegressionTestParameters()
590590
{"Treynor Ratio", "0"},
591591
{"Total Fees", "$1.00"}
592592
};
593-
593+
594594
var fractionalQuantityRegressionStatistics = new Dictionary<string, string>
595595
{
596596
{"Total Trades", "6"},
597-
{"Average Win", "2.57%"},
598-
{"Average Loss", "-0.01%"},
599-
{"Compounding Annual Return", "900.493%"},
597+
{"Average Win", "1.29%"},
598+
{"Average Loss", "0.0%"},
599+
{"Compounding Annual Return", "920.568%"},
600600
{"Drawdown", "3.300%"},
601-
{"Expectancy", "86.582"},
602-
{"Net Profit", "2.556%"},
603-
{"Sharpe Ratio", "3.003"},
604-
{"Loss Rate", "67%"},
605-
{"Win Rate", "33%"},
606-
{"Profit-Loss Ratio", "261.75"},
607-
{"Alpha", "-0.014"},
608-
{"Beta", "0.996"},
609-
{"Annual Standard Deviation", "0.452"},
610-
{"Annual Variance", "0.204"},
611-
{"Information Ratio", "-10.05"},
601+
{"Expectancy", "-0.333"},
602+
{"Net Profit", "2.578%"},
603+
{"Sharpe Ratio", "3.031"},
604+
{"Loss Rate", "33%"},
605+
{"Win Rate", "67%"},
606+
{"Profit-Loss Ratio", "0"},
607+
{"Alpha", "-0.001"},
608+
{"Beta", "0.995"},
609+
{"Annual Standard Deviation", "0.451"},
610+
{"Annual Variance", "0.203"},
611+
{"Information Ratio", "-3.42"},
612612
{"Tracking Error", "0.002"},
613-
{"Treynor Ratio", "1.361"},
614-
{"Total Fees", "$22.33"},
613+
{"Treynor Ratio", "1.374"},
614+
{"Total Fees", "$0.00"}
615615
};
616616

617617
return new List<AlgorithmStatisticsTestParameters>

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.