using System;
using System.Collections.Generic;
namespace NT8.Core.Common.Models
{
///
/// Strategy context - provides market and account information to strategies
///
public class StrategyContext
{
///
/// Trading symbol
///
public string Symbol { get; set; }
///
/// Current timestamp
///
public DateTime CurrentTime { get; set; }
///
/// Current position information
///
public Position CurrentPosition { get; set; }
///
/// Account information
///
public AccountInfo Account { get; set; }
///
/// Market session information
///
public MarketSession Session { get; set; }
///
/// Additional custom data
///
public Dictionary CustomData { get; set; }
///
/// Constructor for StrategyContext
///
public StrategyContext(
string symbol,
DateTime currentTime,
Position currentPosition,
AccountInfo account,
MarketSession session,
Dictionary customData)
{
Symbol = symbol;
CurrentTime = currentTime;
CurrentPosition = currentPosition;
Account = account;
Session = session;
CustomData = customData ?? new Dictionary();
}
}
///
/// Position information
///
public class Position
{
///
/// Position symbol
///
public string Symbol { get; set; }
///
/// Position quantity
///
public int Quantity { get; set; }
///
/// Average entry price
///
public double AveragePrice { get; set; }
///
/// Unrealized profit/loss
///
public double UnrealizedPnL { get; set; }
///
/// Realized profit/loss
///
public double RealizedPnL { get; set; }
///
/// Last update timestamp
///
public DateTime LastUpdate { get; set; }
///
/// Constructor for Position
///
public Position(
string symbol,
int quantity,
double averagePrice,
double unrealizedPnL,
double realizedPnL,
DateTime lastUpdate)
{
Symbol = symbol;
Quantity = quantity;
AveragePrice = averagePrice;
UnrealizedPnL = unrealizedPnL;
RealizedPnL = realizedPnL;
LastUpdate = lastUpdate;
}
}
///
/// Account information
///
public class AccountInfo
{
///
/// Current account equity
///
public double Equity { get; set; }
///
/// Available buying power
///
public double BuyingPower { get; set; }
///
/// Today's profit/loss
///
public double DailyPnL { get; set; }
///
/// Maximum drawdown
///
public double MaxDrawdown { get; set; }
///
/// Last update timestamp
///
public DateTime LastUpdate { get; set; }
///
/// Constructor for AccountInfo
///
public AccountInfo(
double equity,
double buyingPower,
double dailyPnL,
double maxDrawdown,
DateTime lastUpdate)
{
Equity = equity;
BuyingPower = buyingPower;
DailyPnL = dailyPnL;
MaxDrawdown = maxDrawdown;
LastUpdate = lastUpdate;
}
}
///
/// Market session information
///
public class MarketSession
{
///
/// Session start time
///
public DateTime SessionStart { get; set; }
///
/// Session end time
///
public DateTime SessionEnd { get; set; }
///
/// Regular Trading Hours
///
public bool IsRth { get; set; }
///
/// Session name
///
public string SessionName { get; set; }
///
/// Constructor for MarketSession
///
public MarketSession(
DateTime sessionStart,
DateTime sessionEnd,
bool isRth,
string sessionName)
{
SessionStart = sessionStart;
SessionEnd = sessionEnd;
IsRth = isRth;
SessionName = sessionName;
}
}
}