generated from QuantConnect/Lean.Brokerages.Template
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use order instance converted from json to access order properties (#15)
This helps avoiding manually getting and using properties that might not be defined for some order types.
- Loading branch information
1 parent
14ea8aa
commit 15ba338
Showing
2 changed files
with
80 additions
and
16 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
QuantConnect.OandaBrokerage.Tests/OandaBrokerageAdditionalTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals. | ||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
using System; | ||
using NUnit.Framework; | ||
using QuantConnect.Brokerages.Oanda; | ||
using QuantConnect.Configuration; | ||
using QuantConnect.Lean.Engine.DataFeeds; | ||
using Environment = QuantConnect.Brokerages.Oanda.Environment; | ||
|
||
namespace QuantConnect.Tests.Brokerages.Oanda | ||
{ | ||
[TestFixture] | ||
public class OandaBrokerageAdditionalTests | ||
{ | ||
[Test] | ||
[Explicit("This test will only pass if the Practice account at least one open order all of them are of a supported type")] | ||
public void GetsOpenOrders() | ||
{ | ||
var brokerage = CreateBrokerage(); | ||
var openOrders = brokerage.GetOpenOrders(); | ||
Assert.That(openOrders, Is.Not.Null.And.Not.Empty); | ||
} | ||
|
||
[Test] | ||
[Explicit("This test will only pass if the Practice account has an open order of an unsupported type, like STOP_LOSS")] | ||
public void ThrowsOnUnsupportedOpenOrders() | ||
{ | ||
var brokerage = CreateBrokerage(); | ||
Assert.Throws<NotSupportedException>(() => brokerage.GetOpenOrders()); | ||
} | ||
|
||
private OandaBrokerage CreateBrokerage() | ||
{ | ||
var environment = Config.Get("oanda-environment").ConvertTo<Environment>(); | ||
var accessToken = Config.Get("oanda-access-token"); | ||
var accountId = Config.Get("oanda-account-id"); | ||
var aggregator = new AggregationManager(); | ||
|
||
var brokerage =new OandaBrokerage(new OrderProvider(), new SecurityProvider(), aggregator, environment, accessToken, accountId); | ||
|
||
brokerage.Connect(); | ||
Assert.IsTrue(brokerage.IsConnected); | ||
|
||
return brokerage; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters