using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TradeIdeas.Extensions;
using TradeIdeas.TIProGUI;
using TradeIdeas.TIProData.Configuration;
namespace TIProSkunkWorksExtension
{
public static class SkunkWorks
{
private static IMainProgram _mainProgram;
//private static RealTimeStockRaceForm _realTimeStockRaceForm;
// Hard-coded for now - RVHTODO
private static string _config = "form=1&sort=MaxFCP&count=100&MinPrice=2&MinRV=0.5&MinTV=20000&MinVol5D=100000&X_NYSE=on&X_ARCA=on&X_AMEX=on&XN=on&EntireUniverse=2&SL_1_5=on&WN=Biggest+Gainers+(%25)&show0=D_Symbol&show1=Price&show2=FCD&show3=FCP&show4=TV&show5=RD&show6=&col_ver=1";
///
/// The interface to the Main Program.
///
public static IMainProgram MainProgram
{
get { return _mainProgram; }
set { _mainProgram = value; }
}
///
/// Shows the Real-Time Stock Race Form.
///
public static void ShowRealTimeStockRaceForm(bool showConfigWindow, string config)
{
// Set config to passed value if not null.
if (config != null)
_config = config;
if (showConfigWindow)
{
ConfigWindowWrapper configWindowWrapper = ConfigWindowWrapper.DefaultFactory(ConfigurationType.TopList, _mainProgram.ConnectionMaster);
configWindowWrapper.InitialConfig = _config;
configWindowWrapper.AllowOkayImmediately = true;
configWindowWrapper.IsDefaultStrategy = true;
configWindowWrapper.ShowIt();
if (!configWindowWrapper.Canceled)
{
_config = configWindowWrapper.Strategy.MakeConfigString();
RealTimeStockRaceForm realTimeStockRaceForm = new RealTimeStockRaceForm(_mainProgram.ConnectionMaster, _config);
realTimeStockRaceForm.Show();
}
}
else
{
RealTimeStockRaceForm realTimeStockRaceForm = new RealTimeStockRaceForm(_mainProgram.ConnectionMaster, _config);
realTimeStockRaceForm.Show();
}
}
public static string CheckMBT(double value) //check if number is billion,trillions-abbreviate if conditions met
{
string retVal = "";
double result;
double test = Math.Abs(value);
if (test >= 1000 && test < 1000000)
{
result = value / 1.0e+3;
retVal = result.ToString("N02") + "K";
}
if (test >= 1000000 && test < 1000000000)
{
result = value / 1.0e+6;
retVal = result.ToString("N02") + "M";
}
if (test >= 1000000000 && test < 1000000000000)
{
result = value / 1.0e+9;
retVal = result.ToString("N02") + "B";
}
else if (test >= 1000000000000)
{
result = value / 1.0e+12;
retVal = result.ToString("N02") + "T";
}
return retVal;
}
}
}