25 Commits

Author SHA1 Message Date
Jhonathan Abreu d82d70dacf Support asynchronous non-market orders (#8946)
API Tests / build (push) Has been cancelled
Benchmarks / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
Regression Tests / build (push) Has been cancelled
Report Generator Tests / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Syntax Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled
* Add 'asynchronous' parameter to trading api

* Add regression algorithms

* More fixes for asynchronous orders

* Fix failing unit tests

* Fix failing unit tests

* Add multiple orders requests in transaction handler

Make each transaction thread handle requests corresponding to the same order

* Refactor order state machine in BrokerageTransactionHandler

Now using a single dictionary to hold orders and their state, either pending for submission, open or closed.

* Revert: remove complete orders from new state machine in BTH

* Add order ticket to new BTH open orders state machine

* Run syn in Backtesting transaction handler for new orders submission

* Remove OpenOrderState.SubmissionPending property

* Add Security to OpenOrderState

* Minor fix

* Cleanup

* Some cleanup in BTH

* Cleanup

* Minor fix

* Minor unit test fix

* Minor fix

* Make Brokerage.ConcurrencyEnable property virtual

* Minor change

* Cleanup

* Add 'asynchronous' parameter to SetHoldings api

* Improve regression algorithms
2025-09-10 08:29:50 -04:00
Roman Yavnikov 4e13189787 Feature: support MOO in CharlesSchwabBrokerageModel (#8737)
* feat: support MOO in CharlesSchwabBrokerageModel

* feat: validate IsMarketOpen with MOO order type in PreOrderChecks

* test:feat: Validate MOO in various Market hours time

* fix: Algo with new MOO time validation

* test:fix: set DateTime of Algo explicitly in OrderQuantityConversionTest
2025-05-02 16:15:17 +03:00
Martin-Molinero 513ced31d7 Add python syntax check (#8651)
API Tests / build (push) Has been cancelled
Benchmarks / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
Regression Tests / build (push) Has been cancelled
Report Generator Tests / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Syntax Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled
* Add python syntax check

* Fix some python regression algorithms

* Fixing more bugs
2025-03-28 10:36:26 -03:00
Jhonathan Abreu 77591f90c7 PEP8 python algorithms conversion (#7950)
Benchmarks / build (push) Has been cancelled
API Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
Regression Tests / build (push) Has been cancelled
Report Generator Tests / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
* PEP8 python algorithms conversion

* Fix: Get python or c# methods in PythonData as python wrapper

* Convert portfolio models to PEP8
2024-04-18 19:43:48 -03:00
Jhonathan Abreu 906ab20bee Trailing stop orders (#7402)
* Add trailing stop orders base implementation

* Handle trailing stop order prices rounding

* Implement trailing stop orders fill logic

* Minor fill model changes

* Add ApplySplit to fill model interface for models that might need to be aware of splits.

Filling trailing stop orders require keeping track of min/max prices, which need to be split adjusted.

* Add brokerage order updated event for communicating certain order types prices changes

* Add order update event args class for brokerage side order updates

* Revert IFillModel.ApplySplit

* Add trailing stop orders regression algorithm

* Updated order ticket demo algorithm to include trailing stop orders

* Some cleanup

* Support trailing stop orders in IB brokerage model

* Some cleanup

* Fix failing tests

* Fix failing regression algorithm

* Address peer review

* Add trailing stop price calculation unit tests

* Minor changes

* Minor change
2023-07-28 17:49:58 -04:00
Jhonathan Abreu 60aba9efa4 Make order ticket available from order event (#7316)
* Make order ticket available from order event

* Add regression algorithms

* Address peer review

* Address peer review
2023-06-15 11:11:06 -04:00
Ryan Russell 052e20cbf4 refactor(Algorithm): readability improvements (#6547)
Regression Tests / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
Benchmarks / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
* refactor(Algorithm): Correct `Intrinino` -> `Intrinio` references

Signed-off-by: Ryan Russell <git@ryanrussell.org>

* refactor(Algorithm): Update `evemts` -> `events`

Signed-off-by: Ryan Russell <git@ryanrussell.org>

* refactor(BubbleAlgorithm): readability improvements

Signed-off-by: Ryan Russell <git@ryanrussell.org>

* refactor(OrderTicketDemoAlgorithm): readability improvements

Signed-off-by: Ryan Russell <git@ryanrussell.org>

Signed-off-by: Ryan Russell <git@ryanrussell.org>
2022-08-15 10:52:07 -03:00
Louis Szeto cece811cce Remove extra ; at Python files (#6248)
Regression Tests / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Co-authored-by: LouisSzeto <hke0073@hotmail.com>
2022-03-10 11:09:33 -03:00
Ricardo Andrés Marino Rojas 9e7962f5a2 Add Overload in SecurityTransactionManager Methods to Support Python Functions (#6068)
Build & Test Lean / build (push) Has been cancelled
Regression Tests / build (push) Has been cancelled
* Add PyObject overload

* Nit changes and unit tests

* Regression tests

* Nit changes

* Requested changes

* Requested changes

* Handle null parameter cases
2021-11-26 16:15:54 -03:00
Martin-Molinero 03f56481d4 Refactor python algorithm import (#5657)
Regression Tests / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
* Python research import improvements

- Improve start.py for research env
- Remove unrequired imports

* Centralize algorithm imports

* Add regression test GH action

* Unit test python import clean up

* Join research and main imports

* More python import clean up

* Fix failing skipped regression algorithm
2021-06-15 19:06:06 -03:00
Martin Molinero 78ae2d7e1b Add Price and Quantity to OrderEvent
- Adding order current Quantity, StopPrice and LimitPrice to the
OrderEvent instance
- Adding OrderTicketDemoAlgorithm as a regression test
2020-03-30 11:07:18 -03:00
Jack Simonson 0d963ccdd5 Changed Quanld source to correctly retrieve csv data, along with simple cleanup of import statements and use of Decimal 2019-03-04 09:47:33 -08:00
Jack Simonson 3bb5b647a2 Update OrderTicketDemoAlgorithm.py
StopLimitOrders seems to be coded improperly. The buy order had the limit price below the stop price, and the sell order had the limit prive above the stop price. By reversing the two, we can guarantee a sell limit at 0.25% below the close price and a buy limit at 0.25% above the close price, with a stop price at -0.1% and 0.1% respectively.
2019-01-31 12:13:54 -08:00
Michael Handschuh fdc866fda0 Reverting 'Merge pull request #2483 python-history-provider'
We didn't experience the expected performance improvements. Locally under
unit test there was aboout an order of magnitude throughput increase, but
when run against the history benchmark, this new approach was 60% slower.
We're reverting this for now to perform further analysis and better
understand the performance profiling of the python history stack.
2018-09-18 18:37:23 -04:00
AlexCatarino 3e4a71cd50 Creates QCAlgorithm.py: a bridge between C# QCAlgorithm and python algorithms 2018-09-17 19:05:48 +01:00
Jing Wu 084cd294b0 Remove semicolon in python algrotihms 2018-07-06 11:05:16 -04:00
Michael Handschuh 18a559943e Upgrade LEAN Python to 3.6 from 2.7
- Adds log to display the python version the algorithm is using.
- Fixes python algorithms that were failing because of small subtleties
like leading zeroes.
- Updates pythonnet with a version compiled with python 3.6 flags

- Changes in DockerfileFoundation: we now use miniconda to manage the python
environment.
- Took the opportunity to add NTLK (#1349), Tensorforce (#1369) and
PyTorch/Pyro (#1385).
- Changes readme in Algorithm.Python to show steps to install miniconda
2018-02-23 15:09:06 -05:00
Stefano Raggi a39e6a8e28 Revert "Merge pull request #1526 from AlexCatarino/python3"
This reverts commit 2e523992d0, reversing
changes made to fa48fc23ea.
2018-02-14 16:03:12 +01:00
AlexCatarino 84282503d0 Fixes python algorithm to be python 3 compliant 2018-02-13 13:00:50 +00:00
Jing Wu b94e62f796 fix sign typo 2018-01-25 15:03:58 -05:00
Jared Broad dc27c4e3d6 Added tags to python algorithms 2017-09-21 08:27:41 -04:00
AlexCatarino 799fbde198 Adds tests for keras and tensorflow
Updates PythonPackageTestAlgorithm to include tests for keras an tensorflow packages
Fix bugs in two algorithms due to pythonnet update.
2017-06-02 10:45:45 +01:00
AlexCatarino 18d83fb8ec Updates python framework to support python datetime
Updates nuget package to support conversion from C# DateTime to python datetime.
Updates algorithms to reflect this change.
2017-05-23 13:40:26 +01:00
Alexandre Catarino 58f0caf647 Updates example algorithms written in Python (#889)
Some python algorithms suffered corrections to run under the new python framework (pythonnet).
Others were deleted because some features will be supported in futures implementations.

Adds a method in AlgorithmPythonUtil to transform C# DateTime into Python datetime
2017-05-04 13:02:25 -04:00
AlexCatarino 3426bd9ffd Adds OrderTicketDemoAlgorithm.py
Adds Python version of OrderTicketDemoAlgorithm
2016-03-22 11:38:41 -03:00