TraderShop.Financials.TdAmeritrade.Orders 2.0.0

.NET 7.0
dotnet add package TraderShop.Financials.TdAmeritrade.Orders --version 2.0.0
NuGet\Install-Package TraderShop.Financials.TdAmeritrade.Orders -Version 2.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TraderShop.Financials.TdAmeritrade.Orders" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TraderShop.Financials.TdAmeritrade.Orders --version 2.0.0
#r "nuget: TraderShop.Financials.TdAmeritrade.Orders, 2.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install TraderShop.Financials.TdAmeritrade.Orders as a Cake Addin
#addin nuget:?package=TraderShop.Financials.TdAmeritrade.Orders&version=2.0.0

// Install TraderShop.Financials.TdAmeritrade.Orders as a Cake Tool
#tool nuget:?package=TraderShop.Financials.TdAmeritrade.Orders&version=2.0.0

Orders Library

<img src="https://img.shields.io/github/issues/ucrengineer/TraderShop.Financials" alt = "home screen" style = "float: left"/> <img src="https://img.shields.io/github/forks/ucrengineer/TraderShop.Financials" alt = "home screen" style = "float: left"/> <img src="https://img.shields.io/github/stars/ucrengineer/TraderShop.Financials" alt = "home screen" style = "float: left"/> <img src="https://img.shields.io/github/license/ucrengineer/TraderShop.Financials.TdAmeritrade" alt = "home screen" style = "float: left"/>

<br></br> <a href="https://www.buymeacoffee.com/ucrengineer" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a>

<br></br> TdAmeritrade API Documentation

Usage

  public class OrdersProvider
    {
        private readonly ITdAmeritradeOrdersProvider _ordersProvider;
        private readonly TdAmeritradeOptions _options;

        public OrdersProvider(ITdAmeritradeOrdersProvider ordersProvider, TdAmeritradeOptions options)
        {
            _ordersProvider = ordersProvider;
            _options = options;
        }

        public async Task Return_Order_Successfully()
        {
            var result = await _ordersProvider.GetOrder(_options.account_number, "5408819438");
        }

        public async Task Return_Orders_By_Path_Successfully()
        {
            var result = await _ordersProvider.GetOrdersByPath(_options.account_number, orderQuery: new OrderQuery { FromEnteredTime = DateTime.Now.AddYears(-10) });
        }

        public async Task Return_Orders_By_Query_Successfully()
        {
            var result = await _ordersProvider.GetOrdersByQuery(orderQuery: new OrderQuery() { FromEnteredTime = DateTime.Now.AddYears(-1) });
        }

        public async Task Place_Order_Successfully()
        {
            var order = new PlaceOrder("LIMIT", 100,
                "NORMAL",
                "DAY",
                "SINGLE",
                new OrderLegCollection[]
                {
                    new OrderLegCollection("BUY",1,"MSFT","EQUITY")
                });

            var result = await _ordersProvider.PlaceOrder(_options.account_number, order);
        }

        public async Task Replace_Order_Successfully()
        {
            var order = new PlaceOrder("LIMIT", 100,
                           "NORMAL",
                           "DAY",
                           "SINGLE",
                           new OrderLegCollection[]
                           {
                                        new OrderLegCollection("BUY",2,"MSFT","EQUITY")
                           });
            var result = await _ordersProvider.ReplaceOrder(_options.account_number, "5586319823", order);

        }

        public async Task Cancel_Order_Successfully()
        {
            var orders = await _ordersProvider.GetOrdersByQuery();

            var order = orders.FirstOrDefault(x => x.Status != "CANCELED");

            var result = await _ordersProvider.CancelOrder(_options.account_number, order.OrderId.ToString());

        }

        public async Task Place_Conditional_Order_Successfully()
        {
            var order = new ConditionalTriggerOrder("LIMIT", 100,
                        "NORMAL",
                        "DAY",
                        "SINGLE",
                        new OrderLegCollection[]
                        {
                            new OrderLegCollection("BUY",1,"MSFT","EQUITY")
                        },
                        new PlaceOrder[]
                        {
                            new PlaceOrder("LIMIT", 1,
                               "NORMAL",
                               "DAY",
                               "SINGLE",
                               new OrderLegCollection[]
                               {
                                            new OrderLegCollection("SELL",1,"MSFT","EQUITY")
                               })
                        });

            var result = await _ordersProvider.PlaceOrder<ConditionalTriggerOrder>(_options.account_number, order);


            var optionOrder = new OptionOrder(
                "NONE",
                "LIMIT",
                2.0,
                "NORMAL",
                "DAY",
                "SINGLE",
                new OrderLegCollection[]
                {
                    new OrderLegCollection(
                        "BUY_TO_OPEN",
                        1,
                        ".MSFT220715C245",
                        "OPTION")
                });

            var optionsResult = await _ordersProvider.PlaceOrder<OptionOrder>(_options.account_number, optionOrder);

            var verticalCallSpread = new OptionOrder(
                "VERTICAL",
                "NET_DEBIT",
                2.0,
                "NORMAL",
                "DAY",
                "SINGLE",
                new OrderLegCollection[]
                {
                    new OrderLegCollection(
                        "BUY_TO_OPEN",
                        1,
                        ".MSFT220715C245",
                        "OPTION"),
                    new OrderLegCollection(
                        "SELL_TO_OPEN",
                        1,
                        ".MSFT220617C250",
                        "OPTION"),
                });

            var optionsVerticalSpreadResult = await _ordersProvider.PlaceOrder<OptionOrder>(_options.account_number, verticalCallSpread);

            var conditionalOrder = new ConditionalTriggerOrder(
            "LIMIT",
            100,
            "NORMAL",
            "DAY",
            "TRIGGER",
            new OrderLegCollection[]
            {
                            new OrderLegCollection("BUY",1,"MSFT","EQUITY")
            },
            new PlaceOrder[]
            {
                            new PlaceOrder("LIMIT", 1,
                               "NORMAL",
                               "DAY",
                               "SINGLE",
                               new OrderLegCollection[]
                               {
                                            new OrderLegCollection("SELL",1,"MSFT","EQUITY")
                               })
            });

            var conditionalOrderResult = await _ordersProvider.PlaceOrder<ConditionalTriggerOrder>(_options.account_number, conditionalOrder);


        }
    }

Desciption

This library is in charge of interacting with the TdAmeritrade API to retrieve & place orders.

Product Versions
.NET net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0 52 11/21/2022
1.1.4 172 7/4/2022
1.1.3 169 6/20/2022
1.1.2 157 6/19/2022
1.0.2 169 6/10/2022
1.0.1 163 5/24/2022
1.0.0 158 5/24/2022
1.0.0-preview1 71 5/24/2022

updated contracts