quantconnect / lean.brokerages.bybit Goto Github PK
View Code? Open in Web Editor NEWByBit Brokerage Integration to LEAN
ByBit Brokerage Integration to LEAN
When running live and there is an open position when funding happens an exception is thrown and the algo stops. Apparently, I never had a trade open during funding when I was initially testing this brokerage ๐
The brokerage handles the funding ws message properly.
A serialization exception is thrown cause there is no OrderType
which equals UNKNOWN
Add UNKNOWN
to the OrderType
enum and handle the funding message properly. @Martin-Molinero do we need to submit an order update when funding occurs?
Having an open order when funding occurs. I unfortunately don't have the exact log anymore.
master
branchOrders are being canceled at all times without issues.
Some orders can not always be canceled, it happens in multiple occasions but It seems I found one way to reliably reproduce it. (See reproducing the problem)
Don't raise an error when the status is CancelPending
here:
Lean.Brokerages.ByBit/QuantConnect.BybitBrokerage/BybitBrokerage.Brokerage.cs
Lines 201 to 206 in a5b3f02
It seems that sometimes the order status is already CancelPending
even though the cancel request was never sent to the brokerage.
20231129 06:56:56.592 ERROR:: Brokerage Warning: Order already canceled or cancellation submitted
20231129 06:56:56.593 ERROR:: Brokerage failed to cancel order with id 1
master
branchUsers are informed of the cause of invalid orders.
The algorithm received the following information
2024-03-05T15:05:00.7148461Z TRACE:: LiveTradingResultHandler.OrderEvent(): Time: 03/05/2024 15:05:00 OrderID: 2 EventID: 1 Symbol: BTCUSDT Status: Invalid Quantity: -0.047175 Message: Brokerage failed to place orders: [2] BrokerId:
and we don't know why.
When we inpect the syslog, we can read:
ErrorMessage: Cross Margin Trading not yet supported by the selected coin
2024-03-05T15:05:00.7146835Z ERROR:: BrokerageTransactionHandler.HandleSubmitOrderRequest(): System.Exception: ByBitApiClient request failed: [200] OK, Content: {"retCode":170037,"retMsg":"Cross Margin Trading not yet supported by the selected coin","result":{},"retExtInfo":{},"time":1709651100616}, ErrorCode: 170037 ErrorMessage: Cross Margin Trading not yet supported by the selected coin
at QuantConnect.Brokerages.Bybit.Api.BybitTradeApiEndpoint.PlaceOrder(BybitProductCategory category, Order order, Boolean useMargin)
at QuantConnect.Brokerages.Bybit.BybitBrokerage.g.d()
at QuantConnect.Brokerages.BrokerageConcurrentMessageHandler`1.WithLockedStream(Action code) in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/LeanEnterprise/Brokerages/BrokerageConcurrentMessageHandler.cs:line 82
at QuantConnect.Brokerages.Bybit.BybitBrokerage.PlaceOrder(Order order)
The user should receive that error message instead of "Brokerage failed to place orders" or as a Brokerage Message.
N/A
SetHolding("BTCUSDT", 1);
then
SetHolding("BTCUSDT", 0);
master
branchLEAN fetches open orders from Bybit and creates the LEAN orders accordingly.
StopMarketOrder
s have zero stop prices. LimitOrder
s have non-zero limit prices as expected.
Place StopMarketOrder
orders with Binance Futures, and stop the algorithm. Redeploy and verify the new stop price is zero.
Observed with LEAN CLI.
master
branchError Message:
---> System.MissingMethodException: Cannot dynamically create an instance of type 'QuantConnect.Brokerages.Bybit.ToolBox.BybitBrokerageDownloader'. Reason: No parameterless constructor
defined.
at System.RuntimeType.ActivatorCache..ctor(RuntimeType rt)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
at QuantConnect.Util.Composer.GetExportedValueByTypeName[T](String typeName, Boolean forceTypeNameOnExisting) in
/LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Common/Util/Composer.cs:line 290
at QuantConnect.Lean.Engine.DataFeeds.DownloaderDataProvider..ctor() in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Engine/DataFeeds/DownloaderDataProvider.cs:line 57
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
--- End of inner exception stack trace ---
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
at QuantConnect.Util.Composer.GetExportedValueByTypeName[T](String typeName, Boolean forceTypeNameOnExisting) in
/LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Common/Util/Composer.cs:line 290
at QuantConnect.Lean.Engine.LeanEngineAlgorithmHandlers.FromConfiguration(Composer composer, Boolean researchMode) in
/LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Engine/LeanEngineAlgorithmHandlers.cs:line 208
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.