Skip to content

Conversation

@Romazes
Copy link
Contributor

@Romazes Romazes commented Nov 4, 2025

Description

Can we send a negative limit price for combo orders?

No, We don't. We got excecption below:


{
  "error": {
    "code": "validation_error",
    "message": "Request validation failed",
    "errors": [
      {
        "domain": "price",
        "reason": "does not have a valid value"
      }
    ]
  }
}

Comapring CharlesSchwab (above) VS Tastytrade (bellow)

image

Related Issue

closes #15

Related PR

Motivation and Context

Requires Documentation Change

How Has This Been Tested?

The Lean Algoirthm to test properlly:

private List<Leg> _verticalShortLegs = [];
private List<Leg> _verticalLongLegs = [];
private int step;

public override void Initialize()
{
    var nvda = AddEquity("NVDA");

    var contractExpiry = new DateTime(2025, 11, 21);
    var nvdaContractOne = AddOptionContract(QuantConnect.Symbol.CreateOption(nvda.Symbol, nvda.Symbol.ID.Market, SecurityType.Option.DefaultOptionStyle(), OptionRight.Call, 210m, contractExpiry));
    var nvdaContractTwo = AddOptionContract(QuantConnect.Symbol.CreateOption(nvda.Symbol, nvda.Symbol.ID.Market, SecurityType.Option.DefaultOptionStyle(), OptionRight.Call, 220m, contractExpiry));

    _verticalShortLegs = [
        new Leg() { Symbol = nvdaContractOne.Symbol, Quantity = -1 }, // strike: 210m
                new Leg() { Symbol = nvdaContractTwo.Symbol, Quantity = 1} // strike: 220m
    ];

    _verticalLongLegs = [
        new Leg() { Symbol = nvdaContractOne.Symbol, Quantity = 1 }, // strike: 210m
                new Leg() { Symbol = nvdaContractTwo.Symbol, Quantity = -1} // strike: 220m
    ];
}

private bool TryPlaceComboLimitOrder(string strategyName, List<Leg> legs, decimal limitPrice)
{
    Log("**********" + strategyName.ToUpperInvariant() + "(limitPrice:" + limitPrice + ")" + "**********");

    foreach (var leg in legs)
    {
        if (Securities.TryGetValue(leg.Symbol, out var sec) && sec.Price == 0)
        {
            Log($"[{Time}] Skipping order for {leg.Symbol}: security price is 0.");
            return false;
        }
    }

    ComboLimitOrder(legs, 1, limitPrice);
    return true;
}

public override void OnData(Slice slice)
{
    switch (step)
    {
        case 1:
            if (TryPlaceComboLimitOrder("vertical short", _verticalShortLegs, limitPrice: -1.1m))
            {
                step += 1;
                return;
            }
            break;
        case 2:
            if (TryPlaceComboLimitOrder("vertical long", _verticalLongLegs, limitPrice: 1.1m))
            {
                step += 1;
                ComboLimitOrder(_verticalLongLegs, 1, 1.1m);
                return;
            }
            break;
        default:
            step += 1;
            break;
    }
}

Result execution the algorithm from issue:

image

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Refactor (non-breaking change which improves implementation)
  • Performance (non-breaking change which improves performance. Please add associated performance test and results)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Non-functional change (xml comments/documentation/etc)

Checklist:

  • My code follows the code style of this project.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My branch follows the naming convention bug-<issue#>-<description> or feature-<issue#>-<description>

@Romazes Romazes self-assigned this Nov 4, 2025
@Romazes Romazes added bug Something isn't working OrderType: ComboLimitOrder labels Nov 4, 2025
Copy link
Member

@Martin-Molinero Martin-Molinero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@Romazes Romazes merged commit 4de9989 into master Nov 4, 2025
1 check failed
@Romazes Romazes deleted the fix-15-credit-debit-combo-limit-order branch November 4, 2025 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working OrderType: ComboLimitOrder

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Credit vs Debit Combo Limit Order

3 participants