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 NUnit . Framework ;
17+ using QuantConnect . BybitBrokerage . Models . Enums ;
18+ using QuantConnect . Tests . Brokerages ;
19+
20+ namespace QuantConnect . BybitBrokerage . Tests ;
21+
22+ [ TestFixture , Explicit ( "Requires valid credentials to be setup and run outside USA" ) ]
23+ public partial class BybitInverseFuturesBrokerageTests : BybitBrokerageTests
24+ {
25+ private static Symbol BTCUSD = Symbol . Create ( "BTCUSD" , SecurityType . CryptoFuture , "bybit" ) ;
26+ protected override Symbol Symbol { get ; } = BTCUSD ;
27+
28+ protected override SecurityType SecurityType => SecurityType . Future ;
29+ protected override BybitProductCategory Category => BybitProductCategory . Inverse ;
30+ protected override decimal TakerFee => 0.00025m ;
31+
32+ protected override decimal GetDefaultQuantity ( ) => 10m ;
33+
34+
35+ /// <summary>
36+ /// Provides the data required to test each order type in various cases
37+ /// </summary>
38+ private static TestCaseData [ ] OrderParameters ( )
39+ {
40+ return new [ ]
41+ {
42+ new TestCaseData ( new MarketOrderTestParameters ( BTCUSD ) ) . SetName ( "MarketOrder" ) ,
43+ new TestCaseData ( new LimitOrderTestParameters ( BTCUSD , 50000m , 10000m ) ) . SetName ( "LimitOrder" ) ,
44+ new TestCaseData ( new StopMarketOrderTestParameters ( BTCUSD , 50000m , 10000m ) ) . SetName ( "StopMarketOrder" ) ,
45+ new TestCaseData ( new StopLimitOrderTestParameters ( BTCUSD , 50000m , 10000m ) ) . SetName ( "StopLimitOrder" ) ,
46+ new TestCaseData ( new LimitIfTouchedOrderTestParameters ( BTCUSD , 50000m , 20000 ) ) . SetName (
47+ "LimitIfTouchedOrder" )
48+ } ;
49+ }
50+
51+
52+ [ Test , TestCaseSource ( nameof ( OrderParameters ) ) ]
53+ public override void CancelOrders ( OrderTestParameters parameters )
54+ {
55+ base . CancelOrders ( parameters ) ;
56+ }
57+
58+ [ Test , TestCaseSource ( nameof ( OrderParameters ) ) ]
59+ public override void LongFromZero ( OrderTestParameters parameters )
60+ {
61+ base . LongFromZero ( parameters ) ;
62+ }
63+
64+ [ Test , TestCaseSource ( nameof ( OrderParameters ) ) ]
65+ public override void CloseFromLong ( OrderTestParameters parameters )
66+ {
67+ base . CloseFromLong ( parameters ) ;
68+ }
69+
70+ [ Test , TestCaseSource ( nameof ( OrderParameters ) ) ]
71+ public override void ShortFromZero ( OrderTestParameters parameters )
72+ {
73+ base . ShortFromZero ( parameters ) ;
74+ }
75+
76+ [ Test , TestCaseSource ( nameof ( OrderParameters ) ) ]
77+ public override void CloseFromShort ( OrderTestParameters parameters )
78+ {
79+ base . CloseFromShort ( parameters ) ;
80+ }
81+
82+ [ Test , TestCaseSource ( nameof ( OrderParameters ) ) ]
83+ public override void ShortFromLong ( OrderTestParameters parameters )
84+ {
85+ base . ShortFromLong ( parameters ) ;
86+ }
87+
88+ [ Test , TestCaseSource ( nameof ( OrderParameters ) ) ]
89+ public override void LongFromShort ( OrderTestParameters parameters )
90+ {
91+ base . LongFromShort ( parameters ) ;
92+ }
93+
94+ [ Ignore ( "The brokerage is shared between different product categories, therefore this test is only required in the base class" ) ]
95+ public override void GetAccountHoldings ( )
96+ {
97+ base . GetAccountHoldings ( ) ;
98+ }
99+ }
0 commit comments