Files
Work/ClassGen/HistoricDA.cs
2024-08-07 09:12:07 -04:00

154 lines
8.6 KiB
C#

using System;
using System.Collections;
using System.Data.SqlClient;
namespace ZBI.Risk.Server.Mapped
{
public class HistoricDA
{
public ArrayList readAll()
{
SqlConnection sqlConnection=null;
SqlDataReader sqlDataReader=null;
SqlCommand sqlCommand=null;
try
{
ArrayList arrayList=new ArrayList();
string strQuery="select trade_date, trade_date_txt, portfolio, sub_portfolio, ticker, ticker_desc, uticker, instrument, contract_size, hedge_index, hedge_sector, area, area_sector, y_close, uticker_close, y_uticker_close, delta, y_delta, hedge_beta, area_beta, sector_beta, group_beta, qty, y_qty, qty_change, hedge_close, hedge_perc, area_close, area_perc, sector_close, sector_perc, mkt_value, y_mkt_value, exposure, y_exposure, hb_exposure, y_hb_exposure, ab_exposure, y_ab_exposure, sb_exposure, y_sb_exposure, pnl, pnl_perc, price_change, price_change_perc, price_change_amt, sector_alpha_perc, group_alpha_perc, area_alpha_perc, hedge_alpha_perc, area_pnl_amt, sector_pnl_amt, sector_alpha_amt, group_alpha_amt, area_alpha_amt, hedge_alpha_amt, ab_return_amt, ab_return_perc, alt_index_return_perc, alt_index_return_amt, index_beta_adj_perc, index_beta_adj_amt, intraday_perc, intraday_amt, optionality_perc, optionality_amt, currency, base_close, y_base_close, fx_perc, fx_amt, fx_rate, y_fx_rate, exposure_view, market_view, call_put, days_expire, strike_price, associate, ipo, ratio, exported, source, vwap, vwap_pnl, adh, aac, azap, go_around, alpha_go_around, alpha_real, alpha_unreal, pnl_real, pnl_unreal, cash_flow, beta_cash_flow, last_trade_date, last_trade_qty, enterprise_value, mkt_cap, wgt_ave, volume, RowID from dt_main_positions";
sqlConnection=createSqlConnection(DRMS,dt_main_positions,"sa","");
sqlCommand=new SqlCommand(strQuery,sqlConnection);
sqlDataReader=sqlCommand.ExecuteReader();
while(sqlDataReader.Read())
{
Historic historic=new Historic();
historic.TradeDate=sqlDataReader.getDateTime(0);
historic.TradeDateTxt=sqlDataReader.getString(1);
historic.Portfolio=sqlDataReader.getString(2);
historic.SubPortfolio=sqlDataReader.getString(3);
historic.Ticker=sqlDataReader.getString(4);
historic.TickerDesc=sqlDataReader.getString(5);
historic.Uticker=sqlDataReader.getString(6);
historic.Instrument=sqlDataReader.getString(7);
historic.ContractSize=sqlDataReader.getDecimal(8);
historic.HedgeIndex=sqlDataReader.getString(9);
historic.HedgeSector=sqlDataReader.getString(10);
historic.Area=sqlDataReader.getString(11);
historic.AreaSector=sqlDataReader.getString(12);
historic.YClose=sqlDataReader.getDecimal(13);
historic.UtickerClose=sqlDataReader.getDecimal(14);
historic.YUtickerClose=sqlDataReader.getDecimal(15);
historic.Delta=sqlDataReader.getDecimal(16);
historic.YDelta=sqlDataReader.getDecimal(17);
historic.HedgeBeta=sqlDataReader.getDecimal(18);
historic.AreaBeta=sqlDataReader.getDecimal(19);
historic.SectorBeta=sqlDataReader.getDecimal(20);
historic.GroupBeta=sqlDataReader.getDecimal(21);
historic.Qty=sqlDataReader.getDecimal(22);
historic.YQty=sqlDataReader.getDecimal(23);
historic.QtyChange=sqlDataReader.getDecimal(24);
historic.HedgeClose=sqlDataReader.getDecimal(25);
historic.HedgePerc=sqlDataReader.getDecimal(26);
historic.AreaClose=sqlDataReader.getDecimal(27);
historic.AreaPerc=sqlDataReader.getDecimal(28);
historic.SectorClose=sqlDataReader.getDecimal(29);
historic.SectorPerc=sqlDataReader.getDecimal(30);
historic.MktValue=sqlDataReader.getDecimal(31);
historic.YMktValue=sqlDataReader.getDecimal(32);
historic.Exposure=sqlDataReader.getDecimal(33);
historic.YExposure=sqlDataReader.getDecimal(34);
historic.HbExposure=sqlDataReader.getDecimal(35);
historic.YHbExposure=sqlDataReader.getDecimal(36);
historic.AbExposure=sqlDataReader.getDecimal(37);
historic.YAbExposure=sqlDataReader.getDecimal(38);
historic.SbExposure=sqlDataReader.getDecimal(39);
historic.YSbExposure=sqlDataReader.getDecimal(40);
historic.Pnl=sqlDataReader.getDecimal(41);
historic.PnlPerc=sqlDataReader.getDecimal(42);
historic.PriceChange=sqlDataReader.getDecimal(43);
historic.PriceChangePerc=sqlDataReader.getDecimal(44);
historic.PriceChangeAmt=sqlDataReader.getDecimal(45);
historic.SectorAlphaPerc=sqlDataReader.getDecimal(46);
historic.GroupAlphaPerc=sqlDataReader.getDecimal(47);
historic.AreaAlphaPerc=sqlDataReader.getDecimal(48);
historic.HedgeAlphaPerc=sqlDataReader.getDecimal(49);
historic.AreaPnlAmt=sqlDataReader.getDecimal(50);
historic.SectorPnlAmt=sqlDataReader.getDecimal(51);
historic.SectorAlphaAmt=sqlDataReader.getDecimal(52);
historic.GroupAlphaAmt=sqlDataReader.getDecimal(53);
historic.AreaAlphaAmt=sqlDataReader.getDecimal(54);
historic.HedgeAlphaAmt=sqlDataReader.getDecimal(55);
historic.AbReturnAmt=sqlDataReader.getDecimal(56);
historic.AbReturnPerc=sqlDataReader.getDecimal(57);
historic.AltIndexReturnPerc=sqlDataReader.getDecimal(58);
historic.AltIndexReturnAmt=sqlDataReader.getDecimal(59);
historic.IndexBetaAdjPerc=sqlDataReader.getDecimal(60);
historic.IndexBetaAdjAmt=sqlDataReader.getDecimal(61);
historic.IntradayPerc=sqlDataReader.getDecimal(62);
historic.IntradayAmt=sqlDataReader.getDecimal(63);
historic.OptionalityPerc=sqlDataReader.getDecimal(64);
historic.OptionalityAmt=sqlDataReader.getDecimal(65);
historic.Currency=sqlDataReader.getString(66);
historic.BaseClose=sqlDataReader.getDecimal(67);
historic.YBaseClose=sqlDataReader.getDecimal(68);
historic.FxPerc=sqlDataReader.getDecimal(69);
historic.FxAmt=sqlDataReader.getDecimal(70);
historic.FxRate=sqlDataReader.getDecimal(71);
historic.YFxRate=sqlDataReader.getDecimal(72);
historic.ExposureView=sqlDataReader.getString(73);
historic.MarketView=sqlDataReader.getString(74);
historic.CallPut=sqlDataReader.getString(75);
historic.DaysExpire=sqlDataReader.getInt(76);
historic.StrikePrice=sqlDataReader.getDecimal(77);
historic.Associate=sqlDataReader.getString(78);
historic.Ipo=sqlDataReader.getBool(79);
historic.Ratio=sqlDataReader.getDecimal(80);
historic.Exported=sqlDataReader.getBool(81);
historic.Source=sqlDataReader.getString(82);
historic.Vwap=sqlDataReader.getDecimal(83);
historic.VwapPnl=sqlDataReader.getDecimal(84);
historic.Adh=sqlDataReader.getDecimal(85);
historic.Aac=sqlDataReader.getDecimal(86);
historic.Azap=sqlDataReader.getDecimal(87);
historic.GoAround=sqlDataReader.getDateTime(88);
historic.AlphaGoAround=sqlDataReader.getDecimal(89);
historic.AlphaReal=sqlDataReader.getDecimal(90);
historic.AlphaUnreal=sqlDataReader.getDecimal(91);
historic.PnlReal=sqlDataReader.getDecimal(92);
historic.PnlUnreal=sqlDataReader.getDecimal(93);
historic.CashFlow=sqlDataReader.getDecimal(94);
historic.BetaCashFlow=sqlDataReader.getDecimal(95);
historic.LastTradeDate=sqlDataReader.getDateTime(96);
historic.LastTradeQty=sqlDataReader.getDecimal(97);
historic.EnterpriseValue=sqlDataReader.getDecimal(98);
historic.MktCap=sqlDataReader.getDecimal(99);
historic.WgtAve=sqlDataReader.getDecimal(100);
historic.Volume=sqlDataReader.getDecimal(101);
historic.RowID=sqlDataReader.getLong(102);
arrayList.add(historic);
}
return arrayList;
}
finally
{
if(null!=sqlDataReader)sqlDataReader.Close();
if(null!=sqlConnection)sqlConnection.Close();
}
}
private static SqlConnection createSqlConnection(string datssource,string database,string username,string password)
{
try
{
string connectionString="Data Source=DRMS;User ID=sa;password=";
SqlConnection connection=new SqlConnection(connectionString);
connection.Open();
return connection;
}
catch(SqlException exception)
{
Console.WriteLine(exception.ToString());
return null;
}
}
}
}