boyan-soubachov / tastyworks_api

An unofficial, reverse-engineered Python API for tastyworks.
Apache License 2.0
209 stars 79 forks source link

How can I tell if the option position is my long or short leg? #51

Closed lfender6445 closed 3 years ago

lfender6445 commented 3 years ago

given the following response from get_positions, how can i tell if the leg is bought or sold?

{
  "AAPL_110620P105": {
    "assetType": "OPTION",
    "assetMainType": "OPTION",
    "cusip": "0AAPL.W600105000",
    "symbol": "AAPL_110620P105",
    "description": "AAPL Nov 6 2020 105 Put (Weekly)",
    "bidPrice": 2.73,
    "bidSize": 11,
    "askPrice": 3.05,
    "askSize": 47,
    "lastPrice": 2.72,
    "lastSize": 10,
    "openPrice": 3.4,
    "highPrice": 3.43,
    "lowPrice": 2.56,
    "closePrice": 3.6176,
    "netChange": -0.8976,
    "totalVolume": 197,
    "quoteTimeInLong": 1601495999860,
    "tradeTimeInLong": 1601495870326,
    "mark": 2.89,
    "openInterest": 174,
    "volatility": 50.1236,
    "moneyIntrinsicValue": -10.81,
    "multiplier": 100.0,
    "digits": 2,
    "strikePrice": 105.0,
    "contractType": "P",
    "underlying": "AAPL",
    "expirationDay": 6,
    "expirationMonth": 11,
    "expirationYear": 2020,
    "daysToExpiration": 37,
    "timeValue": 2.72,
    "deliverables": "",
    "delta": -0.2403,
    "gamma": 0.0165,
    "theta": -0.0773,
    "vega": 0.1166,
    "rho": -0.0321,
    "securityStatus": "Normal",
    "theoreticalOptionValue": 2.89,
    "underlyingPrice": 115.81,
    "uvExpirationType": "S",
    "exchange": "o",
    "exchangeName": "OPR",
    "lastTradingDay": 1604710800000,
    "settlementType": " ",
    "netPercentChangeInDouble": -24.812,
    "markChangeInDouble": -0.7276,
    "markPercentChangeInDouble": -20.1128,
    "delayed": false
  },
  "AAPL_110620P104": {
    "assetType": "OPTION",
    "assetMainType": "OPTION",
    "cusip": "0AAPL.W600104000",
    "symbol": "AAPL_110620P104",
    "description": "AAPL Nov 6 2020 104 Put (Weekly)",
    "bidPrice": 2.46,
    "bidSize": 17,
    "askPrice": 2.74,
    "askSize": 36,
    "lastPrice": 2.76,
    "lastSize": 1,
    "openPrice": 3.12,
    "highPrice": 3.12,
    "lowPrice": 2.48,
    "closePrice": 3.2978,
    "netChange": -0.5378,
    "totalVolume": 9,
    "quoteTimeInLong": 1601495999399,
    "tradeTimeInLong": 1601494410055,
    "mark": 2.6,
    "openInterest": 45,
    "volatility": 50.0645,
    "moneyIntrinsicValue": -11.81,
    "multiplier": 100.0,
    "digits": 2,
    "strikePrice": 104.0,
    "contractType": "P",
    "underlying": "AAPL",
    "expirationDay": 6,
    "expirationMonth": 11,
    "expirationYear": 2020,
    "daysToExpiration": 37,
    "timeValue": 2.76,
    "deliverables": "",
    "delta": -0.222,
    "gamma": 0.0159,
    "theta": -0.0739,
    "vega": 0.1115,
    "rho": -0.0296,
    "securityStatus": "Normal",
    "theoreticalOptionValue": 2.6,
    "underlyingPrice": 115.81,
    "uvExpirationType": "S",
    "exchange": "o",
    "exchangeName": "OPR",
    "lastTradingDay": 1604710800000,
    "settlementType": " ",
    "netPercentChangeInDouble": -16.3078,
    "markChangeInDouble": -0.6978,
    "markPercentChangeInDouble": -21.1596,
    "delayed": false
  }
lfender6445 commented 3 years ago

nevermind me i was looking at the wrong data