Skip to content

Instantly share code, notes, and snippets.

@shaunsales
Last active January 15, 2023 14:26
Show Gist options
  • Save shaunsales/061bc1dd766cc0c0b7abac096eea35e3 to your computer and use it in GitHub Desktop.
Save shaunsales/061bc1dd766cc0c0b7abac096eea35e3 to your computer and use it in GitHub Desktop.
public sealed class Position
{
public string PositionId { get; init; } = string.Empty;
public string StrategyJobId { get; init; } = string.Empty;
public DateTime EntryTimestamp { get; init; }
public DateTime ExitTimestamp { get; init; }
public ExchangeMarket Market { get; init; } // BinanceSpot, BinanceUsdFutures, BinanceCoinFutures
public string Symbol { get; init; } = string.Empty; // BTCUSDT
public string BaseAsset { get; init; } = string.Empty; // BTC
public string QuoteAsset { get; init; } = string.Empty; // USDT
public decimal TargetEntryQuantity { get; init; } // The quantity set when Enter Position was called
public decimal TargetEntryPrice { get; init; } // The price set when Enter Position was called (0 for market orders)
public decimal TargetExitPrice { get; init; } // The price set when Exit Position was called (0 for market orders)
public decimal AverageEntryPrice { get; init; } // Average Entry Price based on filled orders
public decimal AverageExitPrice { get; init; } // Average Exit Price based on filled orders
public decimal FilledEntryQuantity { get; init; } // How much of the position entry has been filled
public decimal FilledExitQuantity { get; init; } // How much of the position exit has been filled
public OrderExecutionDirection ExecutionDirection { get; init; } // The current execution direction: Entering, Exiting, NotTrading
public ExecutionStrategy ExecutionStrategy { get; init; } // DMA, Peg, Sniper, TWAP (can change if different strat used on Exit)
public string ExecutionStrategyParameters { get; init; } = string.Empty; // Parameters used for the execution strategy i.e. Time/Slices for TWAP
public PositionStatus PositionStatus { get; init; } // Open or Closed
public TradeMode TradeMode { get; init; } // Live or Sim
public PositionSide PositionSide { get; init; } // Long or Short
}
@achenquant
Copy link

As we discussed last week, a parameter of position process status is required, eg. 1. whether the entry/exit is finished(filled all) or 2. terminated(twap execution time expired but partial filled).

Let's suppose it is an entry: now I know OriginalQuantity and FilledEntryQuantity, but I still don't know the two cases above.

@shaunsales
Copy link
Author

@achenquant have updated the fields. The above has been implemented in the code.

@achenquant
Copy link

Thanks @shaunsales , looks good now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment