Commit Graph

96 Commits

Author SHA1 Message Date
AlexCatarino 4c982f37f9 Fixes CalculateOrderQuantity
Since we were not rounding off feeToPriceRatio, we were reducing order quantity more than needed in limit cases.
Fixes RegressionTests that were wrongly modified.
2017-12-04 14:04:27 +00:00
AlexCatarino 122ff90e23 Fixes CalculateOrderQuantity to handle decimal quantities
In quantity calculation, we didn't reduce the order quantity by decimal numbers, leading to a big step when dealing with crypto-currencies. For example, from 2.3456 it would drop to 1.3456 where values in between should've been tested.
2017-12-04 14:03:03 +00:00
Stefano Raggi a24164ecec Refactor OrderProperties class to IOrderProperties interface
This change will make it easier to add other planned brokerage features:
for Interactive Brokers, besides Financial Advisor support, we will be adding IB algorithmic orders soon (PR #1203).
2017-10-26 18:22:11 +02:00
Stefano Raggi ddb3c7d33b Add DefaultOrderProperties to QCAlgorithm
The properties in the default instance can be modified by users duing Initialize.
These properties are always copied into all new orders submitted with any method available (Order, SetHoldings, etc.)
2017-10-26 18:15:08 +02:00
jameschch@outlook.com 578efe843f Further changes for crypto type 2017-08-29 12:19:15 +01:00
12112 921ec8f983 merge from upstream 2017-08-22 16:56:35 +01:00
Stefano Raggi 9b3909b6e8 Fix a couple of bugs in BasicTemplateOptionsAlgorithm
The algorithm had two issues:
1. the LINQ query for contract selection was not including the option right (Put or Call)
2. the algorithm was submitting two extra orders at the end of the day (when market closed)

A helper method was also added in QCAlgorithm to determine if the market is open for a given symbol at the current time.
2017-07-22 21:26:03 +02:00
12112 83fdf9c386 crypto wip 2017-07-14 16:53:42 +01:00
Stefano Raggi 9139ca7c40 Merge master into issue-330/decimal-quantity 2017-06-19 23:50:26 +02:00
oswaldozapata 255823390a Updated to use liquidated string as default value of argument so this can be consistent with other methods that accept a tag. 2017-04-24 21:07:59 -04:00
oswaldozapata e3ae31258b Now when Liquidating, the tag field on the trade list will show as "Liquidated" to indicate that this was due to a Liquidate() call. 2017-04-24 00:41:39 -04:00
AlexCatarino b51464361b Fixes current holdings value computation in CalculateOrderQuantity
The variable currentHoldingsValue didn't take into account the quote currency conversion rate.
2017-04-21 17:03:50 +01:00
Stefano Raggi 5d10fcaa9e Do not submit orders during warmup 2017-01-17 23:41:25 +01:00
quant1729 5a57b4d25b Merge branch 'futures' 2016-12-29 22:12:58 +01:00
Stefano Raggi 8cbb8051c1 Add check for zero unitprice in SetHoldings
Prevents possible DivideByZeroException with non-USD Forex pairs at Tick resolution
2016-12-20 17:42:02 +01:00
quant1729 b3590647b5 Support for option strategies in API, QL option pricing models:
- Added OptionStrategies class with 10 popular option strats
- Defined OptionStrategy class
- Added support for trading of option strategies in QCAlgorithm.Trading.cs
- Added several estimator interfaces to introduce QL pricing models extention points: IDividendYieldEstimator, IRiskFreeRateEstimator, IUnderlyingVolatilityEstimator provided default implementation (flat term structure)
- Added QLOptionPriceModel class that contains meat of the calculations
- Added OptionPriceModels class that exposes 12 popular option pricing models to the user: those include Black Scholes, Barone-Adesi Whaley, Bjerksund Stensland, Crank Nicolson FD, Binomial Trees and more.
- Modified Greeks class to support lazy evaluation and introduce IV
- Partially tested on live data and trading (IQFeed/IB) and backtests. Need more data for tests.
2016-09-20 17:14:25 +02:00
quant1729 5b2b4753d4 Added support for basic option strategies 2016-09-18 21:26:38 +02:00
quant1729 2dce74e26d - Extended Option security and Option holding classes
- Updated IB fee model to support option exercise
- Added support for splits for options. Not tested on real data yet.
- Added option exercise functionality for long positions. Unit Tests. Not tested on real data yet.
- Added option assignment functionality for short positions. Assignment event. Unit Tests.
- Added basic option assignment simulator for backtesting brokerage. Simulates assignments for deep ITM short positions close to expiration. Unit Tests.
2016-08-31 18:00:00 +02:00
jameschch@outlook.com befbfc20ca merge latest upstream 2016-07-26 20:03:03 +01:00
jaredbroad 1642aed05a Refactor PreOrderChecksImpl() and add lot size check for 0-quantity orders 2016-07-13 16:00:37 -04:00
jameschch@outlook.com 464e2a1a15 Remove obsolete comment 2016-07-03 18:57:57 +01:00
jameschch@outlook.com 0e8755dc48 Changes related to #330 order quantity decimalized 2016-06-24 11:53:29 +01:00
jameschch@outlook.com 7763efdc83 Changes related to #330 order quantity decimalized 2016-06-24 11:28:21 +01:00
devalkeralia 5387f9403d Added logic for Rounding off Order Quantity for SetHolding method 2016-06-15 18:17:44 -04:00
Michael Handschuh a95b4c722a Remove remaining single sub assumptions from Algorithm projects 2016-04-12 19:06:46 -04:00
Michael Handschuh ae8c68f99c Adds Security.IsTradable flag
By default, all internal feeds are considered non-tradable, but this value can be overriden via public get/set
2016-04-06 19:15:50 -04:00
Stefano Raggi 46a82a8a91 QCAlgorithm.Liquidate now liquidates holdings in symbol order 2016-04-01 01:00:42 +02:00
Michael Handschuh a221f35743 Revert "Fixes CalculateOrderQuantity regression bug from 5301d81"
This reverts commit 08181aa8c8.

This commit broke several regression tests relating to the SetHoldings function and should be reviewed further.
2016-03-29 09:50:59 -04:00
Michael Handschuh 08181aa8c8 Fixes CalculateOrderQuantity regression bug from 5301d81 2016-03-28 23:49:24 -04:00
Michael 0d720cedef Merge pull request #327 from StefanoRaggi/set-holdings-review
SetHoldings/CalculateOrderQuantity bug fixes + new tests
2016-03-28 13:41:42 -04:00
Stefano Raggi bf80c482e6 Reduces number of iterations in CalculateOrderQuantity when fees high relative to price 2016-03-23 11:00:22 +01:00
Stefano Raggi 12f1a16c2c Changed time buffer for MarketOnClose order submit from 11 to 16 minutes 2016-03-18 18:49:38 +01:00
Stefano Raggi 5301d81149 Fixes bug in QCAlgorithm.CalculateOrderQuantity 2016-03-16 00:36:32 +01:00
Stefano Raggi 2e8cb0c4aa Fixes CalculateOrderQuantity to use remaining/required margins
This change should fix insufficient margin errors in many situations, especially when reversing trade direction and/or when using various order fee structures
2016-03-15 00:52:54 +01:00
Michael Handschuh dbcc672540 Simplify PreOrderChecksImpl 2016-02-16 13:26:08 -05:00
Michael Handschuh a6a6699b3a Removes Cfd.QuoteCurrencySymbol/Forex.QuoteCurrencySymbol 2016-02-16 13:26:03 -05:00
Michael Handschuh b4ab2bba80 Fixes bug in CalculateOrderQuantity
This method wasn't taking into account contract multipler or conversion rates, now uses a 'unitPrice' instead of the price of the security for the iteration
2016-02-04 20:45:55 -05:00
Michael Handschuh 7a7b77cae1 Update Order.GetValue to take a Security
Previously the get value functions were not respecting various conversion rates and contract multipliers
2016-02-04 19:56:26 -05:00
Michael Handschuh 983e5fd20b Remove redundant SecurityType Order.ctor argument 2016-02-04 17:59:35 -05:00
Stefano Raggi 49a8dd73ed Resolved merge conflicts 2016-01-30 00:26:54 +01:00
Michael Handschuh 5e97017fe3 Remove usages of SecurityExchange.MarketOpen/MarketClose properties 2016-01-29 12:29:03 -05:00
Stefano Raggi 932b757a1b Remove Cfd.GetQuoteCurrency(Symbol) 2016-01-24 16:29:52 +01:00
Stefano Raggi 1374a7985f Adds CFD support to QCAlgorithm.PreOrderChecksImpl 2016-01-20 22:12:42 +01:00
Michael Handschuh 5200791de0 Remove some usages of Security.TransactionModel
We should prefer the FillModel/FeeModel/SlippageModel properties instead
2016-01-18 19:22:07 -05:00
Stefano Raggi 56e6bdee04 Reverted market order fill behavior 2016-01-07 22:03:23 +01:00
Stefano Raggi fb45abd718 Delayed order fills one time step 2016-01-07 21:24:55 +01:00
snugs 5e691bb907 Use Transactions.GetOpenOrders(Symbol) in Liquidate 2015-12-30 12:44:09 -05:00
Stefano Raggi e21e6f55f0 Added Status.IsOpen check 2015-12-30 12:43:11 -05:00
Stefano Raggi f4c4c2f9ce Algorithm.Liquidate method now also cancels open orders 2015-12-30 12:43:10 -05:00
snugs 6383cc8bcf Properly pass tag through in SetHoldings overloads 2015-11-23 13:40:02 -05:00