호가 계산기능 추가

This commit is contained in:
DESKTOP-1A3P75F\lee
2022-04-17 15:48:59 +09:00
parent 4c7236062d
commit 9ea1f8393a
4 changed files with 129 additions and 2 deletions

View File

@@ -34,6 +34,9 @@
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.textBoxAskInput = new System.Windows.Forms.TextBox();
this.textBoxAskOutput = new System.Windows.Forms.TextBox();
this.button5 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
@@ -78,7 +81,7 @@
//
// button3
//
this.button3.Location = new System.Drawing.Point(47, 203);
this.button3.Location = new System.Drawing.Point(47, 128);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 23);
this.button3.TabIndex = 4;
@@ -88,7 +91,7 @@
//
// button4
//
this.button4.Location = new System.Drawing.Point(47, 299);
this.button4.Location = new System.Drawing.Point(47, 157);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(75, 23);
this.button4.TabIndex = 5;
@@ -96,11 +99,38 @@
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// textBoxAskInput
//
this.textBoxAskInput.Location = new System.Drawing.Point(608, 18);
this.textBoxAskInput.Name = "textBoxAskInput";
this.textBoxAskInput.Size = new System.Drawing.Size(100, 21);
this.textBoxAskInput.TabIndex = 6;
//
// textBoxAskOutput
//
this.textBoxAskOutput.Location = new System.Drawing.Point(714, 18);
this.textBoxAskOutput.Name = "textBoxAskOutput";
this.textBoxAskOutput.Size = new System.Drawing.Size(100, 21);
this.textBoxAskOutput.TabIndex = 7;
//
// button5
//
this.button5.Location = new System.Drawing.Point(608, 45);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(75, 23);
this.button5.TabIndex = 8;
this.button5.Text = "호가값";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1415, 703);
this.Controls.Add(this.button5);
this.Controls.Add(this.textBoxAskOutput);
this.Controls.Add(this.textBoxAskInput);
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
@@ -122,6 +152,9 @@
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.TextBox textBoxAskInput;
private System.Windows.Forms.TextBox textBoxAskOutput;
private System.Windows.Forms.Button button5;
}
}

View File

@@ -421,5 +421,20 @@ namespace Million_Prototype
}
resultList.ToString();
}
private void button5_Click(object sender, EventArgs e)
{
try
{
var ask_price = double.Parse(textBoxAskInput.Text);
textBoxAskOutput.Text = OrderbookManager.GetAskPrice(ask_price).ToString();
}
catch(Exception ex)
{
ex.ToString();
}
}
}
}

View File

@@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Million.Manager
{
public class OrderbookManager
{
/// <summary>
/// 해당 값의 호가 정보 반환
/// </summary>
/// <param name="value"></param>
/// <param name="upDown">true면 업, false면 다운</param>
/// <returns></returns>
public static double GetAskPrice(double value, bool upDown = true)
{
double priceUnit = 0;
switch(value)
{
case double n when(0<= n && n< 0.1):
priceUnit = 0.0001;
value = Math.Truncate(value * 10000) / 10000;
break;
case double n when (0.1 <= n && n < 1):
priceUnit = 0.001;
value = Math.Truncate(value * 1000) / 1000;
break;
case double n when (1 <= n && n <10):
priceUnit = 0.01;
value = Math.Truncate(value * 100) / 100;
break;
case double n when (10 <= n && n < 100):
priceUnit = 0.1;
value = Math.Truncate(value * 10) / 10;
break;
case double n when (100 <= n && n < 1000):
priceUnit = 1;
value = Math.Truncate(value);
break;
case double n when (1000 <= n && n < 10000):
priceUnit = 5;
value = ((int)value / 5) * 5;
break;
case double n when (10000 <= n && n < 100000):
priceUnit = 10;
value = ((int)value / 10) * 10;
break;
case double n when (100000 <= n && n < 500000):
priceUnit = 50;
value = ((int)value / 50) * 50;
break;
case double n when (500000 <= n && n < 1000000):
priceUnit = 100;
value = ((int)value / 100) * 100;
break;
case double n when (1000000 <= n && n < 2000000):
priceUnit = 500;
value = ((int)value / 500) * 500;
break;
case double n when (2000000 <= n ):
priceUnit = 1000;
value = ((int)value / 1000) * 1000;
break;
}
if (upDown)
{
value += priceUnit;
}
return value;
}
}
}

View File

@@ -135,6 +135,7 @@
</Compile>
<Compile Include="Manager\BuyLogicManager.cs" />
<Compile Include="Manager\DataSettingManager.cs" />
<Compile Include="Manager\OrderbookManager.cs" />
<Compile Include="Manager\ResultLogicManager.cs" />
<Compile Include="Manager\SellLogicManager.cs" />
<Compile Include="Manager\ValidationCheckManager.cs" />