async하게 수정
This commit is contained in:
476
AutoSeller.cs
476
AutoSeller.cs
@@ -1,13 +1,18 @@
|
||||
using MaterialSkin;
|
||||
using MaterialSkin.Controls;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
@@ -51,6 +56,8 @@ namespace AutoSellerNS
|
||||
string m_strSelectedCode = "";
|
||||
bool m_bSell = false;
|
||||
|
||||
SemaphoreSlim m_UpdateSemaphore = new SemaphoreSlim(1, 1);
|
||||
SemaphoreSlim m_NCUpdateSemaphore = new SemaphoreSlim(1, 1);
|
||||
System.Timers.Timer m_Timer = new System.Timers.Timer();
|
||||
|
||||
public AutoSeller()
|
||||
@@ -100,6 +107,8 @@ namespace AutoSellerNS
|
||||
tbCFTimeDown.Text = Config.GetTimeDown().ToString();
|
||||
tbCFIgnorePrice.Text = Config.GetIgnorePrice().ToString();
|
||||
|
||||
cbMockTrading.Checked = Config.GetMockTrading();
|
||||
|
||||
m_CybosHelper = new CybosHelper(this);
|
||||
|
||||
m_iCurPricePanelWith = 240;
|
||||
@@ -114,28 +123,6 @@ namespace AutoSellerNS
|
||||
m_Timer.Start();
|
||||
}
|
||||
|
||||
private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
if(m_bSell == false)
|
||||
return;
|
||||
|
||||
var ClonedList = m_NCItems.ConvertAll(s => s);
|
||||
foreach(var NCItem in ClonedList)
|
||||
{
|
||||
if(NCItem.m_bAsk == true && DateTime.Now-NCItem.m_Time >= TimeSpan.FromSeconds(5))
|
||||
{
|
||||
var CurItem = m_CybosHelper.GetItem(NCItem.m_strCode);
|
||||
if(CurItem == null)
|
||||
continue;
|
||||
|
||||
int iAskPrice = CurItem.m_aiAskPrice[0];
|
||||
m_CybosHelper.CorrectionItem(NCItem.m_strCode, NCItem.m_iOrderNo, NCItem.m_iRemainCnt, iAskPrice);
|
||||
NCItem.m_Time = DateTime.Now;
|
||||
Util.Log(Util.LOG_TYPE.SELL, string.Format("[{0}] 정정 주문 (주문번호: {1})", NCItem.m_strCodeName, NCItem.m_iOrgOrderNo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetAccountList(string[] aAccountList)
|
||||
{
|
||||
cbAccount.Items.Clear();
|
||||
@@ -157,9 +144,9 @@ namespace AutoSellerNS
|
||||
splitContainer2.SplitterDistance = iDist;
|
||||
}
|
||||
|
||||
private void btCybos_Click(object sender, EventArgs e)
|
||||
private async void btCybos_Click(object sender, EventArgs e)
|
||||
{
|
||||
m_CybosHelper.InitCybos();
|
||||
await m_CybosHelper.InitCybosAsync();
|
||||
|
||||
btCybos.Primary = false;
|
||||
btCybos.Enabled = false;
|
||||
@@ -167,147 +154,237 @@ namespace AutoSellerNS
|
||||
btUpdate.Enabled = true;
|
||||
btSell.Enabled = true;
|
||||
|
||||
//btUpdate_Click(null, null);
|
||||
UpdateItem();
|
||||
}
|
||||
|
||||
private void AddItem(ITEM Item)
|
||||
void SyncItems(List<ITEM> OldItems, List<ITEM> NewItems)
|
||||
{
|
||||
m_Items.Add(Item);
|
||||
|
||||
if(lvItems.InvokeRequired)
|
||||
foreach(ITEM newItem in NewItems)
|
||||
{
|
||||
CybosHelper.STOCK_CUR_ITEM ItemCur = m_CybosHelper.GetItem(Item.m_strCode);
|
||||
|
||||
lvItems.Invoke(new Action(() => {
|
||||
lvItems.Items.Add(new ListViewItem(new string[] {
|
||||
Item.m_strCode,
|
||||
Item.m_strCodeName,
|
||||
string.Format("{0:n0}", Item.m_iCurPrice),
|
||||
string.Format("{0:n0}", Item.m_iAvailableQuantity),
|
||||
string.Format("{0:n2}", Item.m_dBookUnitPrice),
|
||||
string.Format("{0:n0}", Item.m_iProfitUnitPrice),
|
||||
string.Format("{0:n0}", Item.m_iAssessedValue),
|
||||
string.Format("{0:n0}", Item.m_iValuationGains),
|
||||
string.Format("{0:n2}", Item.m_dYield),
|
||||
ItemCur != null ? string.Format("{0:n0}", ItemCur.m_iMaxPrice) : "",
|
||||
ItemCur != null ? string.Format("{0:n2}", ItemCur.m_dCheckCountLimit) : "",
|
||||
ItemCur != null ? string.Format("{0:n0}", ItemCur.m_iCheckCount) : "",
|
||||
}));
|
||||
|
||||
var listviewItem = lvItems.Items[lvItems.Items.Count - 1];
|
||||
|
||||
lvItems.Items[lvItems.Items.Count - 1].UseItemStyleForSubItems = false;
|
||||
lvItems.Items[lvItems.Items.Count - 1].SubItems[chValuation.Index].ForeColor = (Item.m_iValuationGains > 0) ? Color.Red : (Item.m_iValuationGains < 0) ? Color.Blue : Color.Black;
|
||||
lvItems.Items[lvItems.Items.Count - 1].SubItems[chYield.Index].ForeColor = (Item.m_dYield > 0) ? Color.Red : (Item.m_dYield < 0) ? Color.Blue : Color.Black;
|
||||
|
||||
m_CybosHelper.Subscribe(Item);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
CybosHelper.STOCK_CUR_ITEM ItemCur = m_CybosHelper.GetItem(Item.m_strCode);
|
||||
|
||||
lvItems.Items.Add(new ListViewItem(new string[] {
|
||||
Item.m_strCode,
|
||||
Item.m_strCodeName,
|
||||
string.Format("{0:n0}", Item.m_iCurPrice),
|
||||
string.Format("{0:n0}", Item.m_iAvailableQuantity),
|
||||
string.Format("{0:n2}", Item.m_dBookUnitPrice),
|
||||
string.Format("{0:n0}", Item.m_iProfitUnitPrice),
|
||||
string.Format("{0:n0}", Item.m_iAssessedValue),
|
||||
string.Format("{0:n0}", Item.m_iValuationGains),
|
||||
string.Format("{0:n2}", Item.m_dYield),
|
||||
ItemCur != null ? string.Format("{0:n0}", ItemCur.m_iMaxPrice) : "",
|
||||
ItemCur != null ? string.Format("{0:n2}", ItemCur.m_dCheckCountLimit) : "",
|
||||
ItemCur != null ? string.Format("{0:n0}", ItemCur.m_iCheckCount) : "",
|
||||
}));
|
||||
|
||||
|
||||
|
||||
var listviewItem = lvItems.Items[lvItems.Items.Count - 1];
|
||||
|
||||
lvItems.Items[lvItems.Items.Count - 1].UseItemStyleForSubItems = false;
|
||||
lvItems.Items[lvItems.Items.Count - 1].SubItems[chValuation.Index].ForeColor = (Item.m_iValuationGains > 0) ? Color.Red : (Item.m_iValuationGains < 0) ? Color.Blue : Color.Black;
|
||||
lvItems.Items[lvItems.Items.Count - 1].SubItems[chYield.Index].ForeColor = (Item.m_dYield > 0) ? Color.Red : (Item.m_dYield < 0) ? Color.Blue : Color.Black;
|
||||
|
||||
m_CybosHelper.Subscribe(Item);
|
||||
}
|
||||
}
|
||||
|
||||
private void btUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
// 잔고
|
||||
var Items = m_CybosHelper.UpdateItems();
|
||||
|
||||
m_Items.Clear();
|
||||
lvItems.Items.Clear();
|
||||
foreach(var Item in Items)
|
||||
AddItem(Item);
|
||||
|
||||
// 미체결
|
||||
UpdateNC();
|
||||
}
|
||||
|
||||
void UpdateNC()
|
||||
{
|
||||
var NCItems = m_CybosHelper.UpdateNC();
|
||||
m_NCItems = NCItems;
|
||||
|
||||
lvNCItem.Items.Clear();
|
||||
if(lvNCItem.InvokeRequired)
|
||||
{
|
||||
lvNCItem.Invoke(new Action(() => {
|
||||
foreach(var NCItem in NCItems)
|
||||
{
|
||||
ListViewItem viewItem = new ListViewItem(new string[] {
|
||||
NCItem.m_iOrderNo.ToString(),
|
||||
NCItem.m_iOrgOrderNo.ToString(),
|
||||
NCItem.m_strCode,
|
||||
NCItem.m_strCodeName,
|
||||
NCItem.m_strDesc,
|
||||
string.Format("{0:n0}", NCItem.m_iOrderPrice),
|
||||
string.Format("{0:n0}", NCItem.m_iRemainCnt),
|
||||
});
|
||||
lvNCItem.Items.Add(viewItem);
|
||||
viewItem.UseItemStyleForSubItems = false;
|
||||
viewItem.SubItems[chNCType.Index].ForeColor = NCItem.m_bAsk ? Color.Blue : Color.Red;
|
||||
}
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach(var NCItem in NCItems)
|
||||
ITEM oldItem = OldItems.FirstOrDefault(s => s.m_strCode == newItem.m_strCode);
|
||||
if (oldItem != null)
|
||||
{
|
||||
ListViewItem viewItem = new ListViewItem(new string[] {
|
||||
NCItem.m_iOrderNo.ToString(),
|
||||
NCItem.m_iOrgOrderNo.ToString(),
|
||||
NCItem.m_strCode,
|
||||
NCItem.m_strCodeName,
|
||||
NCItem.m_strDesc,
|
||||
string.Format("{0:n0}", NCItem.m_iOrderPrice),
|
||||
string.Format("{0:n0}", NCItem.m_iRemainCnt),
|
||||
});
|
||||
lvNCItem.Items.Add(viewItem);
|
||||
viewItem.UseItemStyleForSubItems = false;
|
||||
viewItem.SubItems[chNCType.Index].ForeColor = NCItem.m_bAsk ? Color.Blue : Color.Red;
|
||||
// update
|
||||
oldItem.m_iItemCnt = newItem.m_iItemCnt;
|
||||
oldItem.m_iAssessedValue = newItem.m_iAssessedValue;
|
||||
oldItem.m_iValuationGains = newItem.m_iValuationGains;
|
||||
oldItem.m_dYield = newItem.m_dYield;
|
||||
oldItem.m_iAvailableQuantity = newItem.m_iAvailableQuantity;
|
||||
oldItem.m_dBookUnitPrice = newItem.m_dBookUnitPrice;
|
||||
oldItem.m_iProfitUnitPrice = newItem.m_iProfitUnitPrice;
|
||||
oldItem.m_iCurPrice = newItem.m_iCurPrice;
|
||||
}
|
||||
else
|
||||
{
|
||||
// add
|
||||
m_Items.Add(newItem);
|
||||
m_CybosHelper.Subscribe(newItem);
|
||||
}
|
||||
}
|
||||
|
||||
// remove
|
||||
OldItems.RemoveAll(s => (NewItems.Any(k => k.m_strCode == s.m_strCode) == false));
|
||||
}
|
||||
|
||||
void SyncListViewItems(List<ITEM> Items)
|
||||
{
|
||||
lvItems.Items.Cast<ListViewItem>().ToList().RemoveAll(s => (Items.Any(t => t.m_strCode == s.SubItems[chCode.Index].Text) == false));
|
||||
|
||||
foreach(ITEM item in Items)
|
||||
{
|
||||
ListViewItem row = lvItems.Items.Cast<ListViewItem>().FirstOrDefault(s => s.SubItems[chCode.Index].Text == item.m_strCode);
|
||||
if(row == null)
|
||||
{
|
||||
// insert
|
||||
row = lvItems.Items.Add(new ListViewItem(new string[12]));
|
||||
row.SubItems[chCode.Index].Text = item.m_strCode;
|
||||
row.SubItems[chCodeName.Index].Text = item.m_strCodeName;
|
||||
|
||||
row.UseItemStyleForSubItems = false;
|
||||
}
|
||||
|
||||
// update
|
||||
CybosHelper.STOCK_CUR_ITEM ItemCur = m_CybosHelper.GetItem(item.m_strCode);
|
||||
|
||||
row.SubItems[chCurPrice.Index].Text = string.Format("{0:n0}", item.m_iCurPrice);
|
||||
row.SubItems[chCount.Index].Text = string.Format("{0:n0}", item.m_iAvailableQuantity);
|
||||
row.SubItems[chBookValue.Index].Text = string.Format("{0:n2}", item.m_dBookUnitPrice);
|
||||
row.SubItems[chCapitalGains.Index].Text = string.Format("{0:n0}", item.m_iProfitUnitPrice);
|
||||
row.SubItems[chAssessedValue.Index].Text = string.Format("{0:n0}", item.m_iAssessedValue / 1000);
|
||||
row.SubItems[chValuation.Index].Text = string.Format("{0:n0}", item.m_iValuationGains / 1000);
|
||||
row.SubItems[chYield.Index].Text = string.Format("{0:n2}", item.m_dYield);
|
||||
row.SubItems[chMaxPrice.Index].Text = ItemCur != null ? string.Format("{0:n0}", ItemCur.m_iMaxPrice) : "";
|
||||
row.SubItems[chCheckCountLimit.Index].Text = ItemCur != null ? string.Format("{0:n2}", ItemCur.m_dCheckCountLimit) : "";
|
||||
row.SubItems[chCheckCount.Index].Text = ItemCur != null ? string.Format("{0:n0}", ItemCur.m_iCheckCount) : "";
|
||||
|
||||
row.SubItems[chValuation.Index].ForeColor = (item.m_iValuationGains > 0) ? Color.Red : (item.m_iValuationGains < 0) ? Color.Blue : Color.Black;
|
||||
row.SubItems[chYield.Index].ForeColor = (item.m_dYield > 0) ? Color.Red : (item.m_dYield < 0) ? Color.Blue : Color.Black;
|
||||
}
|
||||
}
|
||||
|
||||
public async void UpdateItem()
|
||||
{
|
||||
await m_UpdateSemaphore.WaitAsync();
|
||||
List<ITEM> Items = await m_CybosHelper.UpdateItemsAsync();
|
||||
SyncItems(m_Items, Items);
|
||||
SyncListViewItems(m_Items);
|
||||
m_UpdateSemaphore.Release();
|
||||
}
|
||||
|
||||
void SyncNCItems(List<NCITEM> oldList, List<NCITEM> newList)
|
||||
{
|
||||
oldList.RemoveAll(s => newList.Any(t => t.m_iOrgOrderNo == s.m_iOrgOrderNo) == false);
|
||||
foreach (var NCItem in newList)
|
||||
{
|
||||
if (oldList.Any(s => s.m_iOrgOrderNo == NCItem.m_iOrgOrderNo) == false)
|
||||
{
|
||||
NCItem.m_Time = DateTime.Now;
|
||||
oldList.Add(NCItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateItem(string strCode, string strCodeName, bool bBid, int iConclusionCnt, int iRemainCnt, int iBookValue)
|
||||
void SyncNCListVIewItems(List<NCITEM> NCItems)
|
||||
{
|
||||
// 잔고
|
||||
var Items = m_CybosHelper.UpdateItems();
|
||||
lvNCItem.Items.Cast<ListViewItem>().ToList().RemoveAll(r =>
|
||||
NCItems.Any(t => (t.m_iOrgOrderNo.ToString() == r.SubItems[chNCOrgOrderNo.Index].Text) == false));
|
||||
|
||||
m_Items.Clear();
|
||||
lvItems.Items.Clear();
|
||||
foreach(var Item in Items)
|
||||
AddItem(Item);
|
||||
foreach (var NCItem in NCItems)
|
||||
{
|
||||
ListViewItem row = lvNCItem.Items.Cast<ListViewItem>().FirstOrDefault(r => r.SubItems[chNCOrgOrderNo.Index].Text == NCItem.m_iOrgOrderNo.ToString());
|
||||
if(row == null)
|
||||
{
|
||||
// insert
|
||||
row = new ListViewItem(new string[7]);
|
||||
row.SubItems[chNCOrderNo.Index].Text = NCItem.m_iOrderNo.ToString();
|
||||
row.SubItems[chNCOrgOrderNo.Index].Text = NCItem.m_iOrgOrderNo.ToString();
|
||||
row.SubItems[chNCCode.Index].Text = NCItem.m_strCode;
|
||||
row.SubItems[chNCCodeName.Index].Text = NCItem.m_strCodeName;
|
||||
row.SubItems[chNCType.Index].Text = NCItem.m_strDesc;
|
||||
|
||||
row.UseItemStyleForSubItems = false;
|
||||
lvNCItem.Items.Add(row);
|
||||
}
|
||||
|
||||
// update
|
||||
row.SubItems[chNCPrice.Index].Text = NCItem.m_iOrderPrice.ToString("n0");
|
||||
row.SubItems[chNCCount.Index].Text = NCItem.m_iRemainCnt.ToString("n0");
|
||||
row.SubItems[chNCType.Index].ForeColor = NCItem.m_bAsk ? Color.Blue : Color.Red;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateNCItem()
|
||||
public async void UpdateNCItem()
|
||||
{
|
||||
UpdateNC();
|
||||
await m_NCUpdateSemaphore.WaitAsync();
|
||||
List<NCITEM> NCItems = await m_CybosHelper.UpdateNCAsync();
|
||||
SyncNCItems(m_NCItems, NCItems);
|
||||
SyncNCListVIewItems(m_NCItems);
|
||||
m_NCUpdateSemaphore.Release();
|
||||
}
|
||||
|
||||
async void CorrectItems()
|
||||
{
|
||||
if (m_bSell == false)
|
||||
return;
|
||||
|
||||
var ClonedList = m_NCItems.ConvertAll(s => s);
|
||||
foreach (var NCItem in ClonedList)
|
||||
{
|
||||
if (NCItem.m_bAsk == true && DateTime.Now - NCItem.m_Time >= TimeSpan.FromSeconds(3))
|
||||
{
|
||||
var CurItem = m_CybosHelper.GetItem(NCItem.m_strCode);
|
||||
if (CurItem == null)
|
||||
continue;
|
||||
|
||||
int iPrice = CurItem.m_aiBidPrice[0];
|
||||
await m_CybosHelper.CorrectionItem(NCItem.m_strCode, NCItem.m_iOrderNo, NCItem.m_iRemainCnt, iPrice);
|
||||
NCItem.m_Time = DateTime.Now;
|
||||
Util.Log(Util.LOG_TYPE.SELL, string.Format("[{0}] 정정 주문 (주문번호: {1})", NCItem.m_strCodeName, NCItem.m_iOrgOrderNo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
CorrectItems();
|
||||
}
|
||||
|
||||
private void btUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
UpdateItem();
|
||||
}
|
||||
|
||||
public class HttpResult
|
||||
{
|
||||
public HttpStatusCode StatusCode;
|
||||
public string strData;
|
||||
};
|
||||
|
||||
async Task<HttpResult> Request(string url, HttpMethod method,
|
||||
string data = null,
|
||||
Dictionary<string, string> headers = null)
|
||||
{
|
||||
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
|
||||
req.Method = method.ToString();
|
||||
req.ContentType = "application/json";
|
||||
if (headers != null)
|
||||
{
|
||||
foreach (var kv in headers)
|
||||
req.Headers[kv.Key] = kv.Value;
|
||||
}
|
||||
|
||||
if (data != null)
|
||||
{
|
||||
Stream writeStream = req.GetRequestStream();
|
||||
byte[] buffer = Encoding.UTF8.GetBytes(data);
|
||||
await writeStream.WriteAsync(buffer, 0, buffer.Length);
|
||||
}
|
||||
|
||||
HttpWebResponse resp = null;
|
||||
HttpResult result = null;
|
||||
try
|
||||
{
|
||||
resp = await req.GetResponseAsync() as HttpWebResponse;
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
if (ex.Status == WebExceptionStatus.ProtocolError)
|
||||
resp = ex.Response as HttpWebResponse;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Stream readStream = resp.GetResponseStream();
|
||||
StreamReader sr = new StreamReader(readStream);
|
||||
result = new HttpResult()
|
||||
{
|
||||
StatusCode = resp.StatusCode,
|
||||
strData = await sr.ReadToEndAsync()
|
||||
};
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async void SendConfiguration()
|
||||
{
|
||||
var oData = new
|
||||
{
|
||||
Mac = NetworkInterface.GetAllNetworkInterfaces()[0].GetPhysicalAddress().ToString(),
|
||||
Date = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
Config = Config.GetAllConfig(),
|
||||
};
|
||||
|
||||
string serverURL = "http://mjjo53.us.to:9200";
|
||||
string index = "trading-autoseller";
|
||||
string doc = "default";
|
||||
string id = $"{oData.Mac}-{oData.Date}";
|
||||
JObject data = JObject.FromObject(oData);
|
||||
string json = data.ToString(Newtonsoft.Json.Formatting.Indented);
|
||||
|
||||
Dictionary<string, string> headers = new Dictionary<string, string>();
|
||||
headers["Authorization"] = "Basic dHJhZGVyOnNidG1hb2Fv";
|
||||
|
||||
var result = await Request($"{serverURL}/{index}/{doc}/{id}?pretty", HttpMethod.Post, json, headers);
|
||||
}
|
||||
|
||||
private void btSell_Click(object sender, EventArgs e)
|
||||
@@ -317,12 +394,14 @@ namespace AutoSellerNS
|
||||
|
||||
if(m_bSell == true)
|
||||
{
|
||||
FileTransfer ft = new FileTransfer();
|
||||
string today = DateTime.Now.ToString("yyyy-MM-dd");
|
||||
string macAddr = NetworkInterface.GetAllNetworkInterfaces()[0].GetPhysicalAddress().ToString();
|
||||
ft.SendDir("/configure", macAddr + "/AutoSeller/" + today);
|
||||
//FileTransfer ft = new FileTransfer();
|
||||
//string today = DateTime.Now.ToString("yyyy-MM-dd");
|
||||
//string macAddr = NetworkInterface.GetAllNetworkInterfaces()[0].GetPhysicalAddress().ToString();
|
||||
//ft.SendDir("/configure", macAddr + "/AutoSeller/" + today);
|
||||
//ft.SendDir("/log", macAddr + "/AutoSeller");
|
||||
//ft.SendDir("/simulation", macAddr + "/AutoSeller");
|
||||
|
||||
SendConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,50 +421,30 @@ namespace AutoSellerNS
|
||||
Item.m_iValuationGains = (iPrice-Item.m_iProfitUnitPrice)*Item.m_iItemCnt;
|
||||
Item.m_dYield = (iPrice-Item.m_iProfitUnitPrice)*100 / (double)Item.m_iProfitUnitPrice;
|
||||
|
||||
if (lvItems.InvokeRequired)
|
||||
{
|
||||
lvItems.Invoke(new Action(() =>
|
||||
{
|
||||
ListViewItem row = lvItems.Items.Cast<ListViewItem>().FirstOrDefault(s => s.SubItems[chCode.Index].Text == strCode);
|
||||
if (row == default(ListViewItem))
|
||||
return;
|
||||
|
||||
row.SubItems[chCurPrice.Index].Text = string.Format("{0}{1:n0}", bReal?"":"*", Item.m_iCurPrice);
|
||||
row.SubItems[chAssessedValue.Index].Text = string.Format("{0:n0}", Item.m_iAssessedValue);
|
||||
row.SubItems[chValuation.Index].Text = string.Format("{0:n0}", Item.m_iValuationGains);
|
||||
row.SubItems[chYield.Index].Text = string.Format("{0:n2}", Item.m_dYield);
|
||||
row.SubItems[chMaxPrice.Index].Text = string.Format("{0:n0}", iMaxPrice);
|
||||
row.SubItems[chCheckCountLimit.Index].Text = string.Format("{0:n2}", dCheckCountLimit);
|
||||
row.SubItems[chCheckCount.Index].Text = string.Format("{0:n0}", iCheckCount);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
Action update = delegate {
|
||||
ListViewItem row = lvItems.Items.Cast<ListViewItem>().FirstOrDefault(s => s.SubItems[chCode.Index].Text == strCode);
|
||||
if (row == default(ListViewItem))
|
||||
return;
|
||||
|
||||
row.SubItems[chCurPrice.Index].Text = string.Format("{0}{1:n0}", bReal?"":"*", Item.m_iCurPrice);
|
||||
row.SubItems[chAssessedValue.Index].Text = string.Format("{0:n0}", Item.m_iAssessedValue);
|
||||
row.SubItems[chValuation.Index].Text = string.Format("{0:n0}", Item.m_iValuationGains);
|
||||
row.SubItems[chCurPrice.Index].Text = string.Format("{0}{1:n0}", bReal ? "" : "*", Item.m_iCurPrice);
|
||||
row.SubItems[chAssessedValue.Index].Text = string.Format("{0:n0}", Item.m_iAssessedValue / 1000);
|
||||
row.SubItems[chValuation.Index].Text = string.Format("{0:n0}", Item.m_iValuationGains / 1000);
|
||||
row.SubItems[chYield.Index].Text = string.Format("{0:n2}", Item.m_dYield);
|
||||
row.SubItems[chMaxPrice.Index].Text = string.Format("{0:n0}", iMaxPrice);
|
||||
row.SubItems[chCheckCountLimit.Index].Text = string.Format("{0:n2}", dCheckCountLimit);
|
||||
row.SubItems[chCheckCount.Index].Text = string.Format("{0:n0}", iCheckCount);
|
||||
}
|
||||
};
|
||||
|
||||
if (lvItems.InvokeRequired)
|
||||
lvItems.BeginInvoke(update);
|
||||
else
|
||||
update();
|
||||
|
||||
if(strCode == m_strSelectedCode)
|
||||
{
|
||||
if (lvCurPrice.InvokeRequired)
|
||||
{
|
||||
lvCurPrice.Invoke(new Action(() => {
|
||||
lvCurPrice.Items[10].SubItems[chCallPrice.Index].Text = string.Format("{0:n0}", Item.m_iCurPrice);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
lvCurPrice.BeginInvoke((MethodInvoker)(() => {
|
||||
lvCurPrice.Items[10].SubItems[chCallPrice.Index].Text = string.Format("{0:n0}", Item.m_iCurPrice);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -398,43 +457,27 @@ namespace AutoSellerNS
|
||||
if (Item == default(ITEM))
|
||||
return;
|
||||
|
||||
if (lvCurPrice.InvokeRequired)
|
||||
{
|
||||
lvCurPrice.Invoke(new Action(() => {
|
||||
|
||||
if(iCurPrice > 0)
|
||||
lvCurPrice.Items[10].SubItems[chCallPrice.Index].Text = string.Format("{0:n0}", iCurPrice);
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
lvCurPrice.Items[i].SubItems[chAskCount.Index].Text = string.Format("{0:n0}", aiAskCount[9-i]);
|
||||
lvCurPrice.Items[i].SubItems[chCallPrice.Index].Text = string.Format("{0:n0}", aiAskPrice[9-i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
lvCurPrice.Items[11 + i].SubItems[chBidCount.Index].Text = string.Format("{0:n0}", aiBidCount[i]);
|
||||
lvCurPrice.Items[11 + i].SubItems[chCallPrice.Index].Text = string.Format("{0:n0}", aiBidPrice[i]);
|
||||
}
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(iCurPrice > 0)
|
||||
Action update = delegate {
|
||||
if (iCurPrice > 0)
|
||||
lvCurPrice.Items[10].SubItems[chCallPrice.Index].Text = string.Format("{0:n0}", iCurPrice);
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
lvCurPrice.Items[i].SubItems[chAskCount.Index].Text = string.Format("{0:n0}", aiAskCount[9-i]);
|
||||
lvCurPrice.Items[i].SubItems[chCallPrice.Index].Text = string.Format("{0:n0}", aiAskPrice[9-i]);
|
||||
lvCurPrice.Items[i].SubItems[chAskCount.Index].Text = string.Format("{0:n0}", aiAskCount[9 - i]);
|
||||
lvCurPrice.Items[i].SubItems[chCallPrice.Index].Text = string.Format("{0:n0}", aiAskPrice[9 - i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
lvCurPrice.Items[11+i].SubItems[chBidCount.Index].Text = string.Format("{0:n0}", aiBidCount[i]);
|
||||
lvCurPrice.Items[11+i].SubItems[chCallPrice.Index].Text = string.Format("{0:n0}", aiBidPrice[i]);
|
||||
lvCurPrice.Items[11 + i].SubItems[chBidCount.Index].Text = string.Format("{0:n0}", aiBidCount[i]);
|
||||
lvCurPrice.Items[11 + i].SubItems[chCallPrice.Index].Text = string.Format("{0:n0}", aiBidPrice[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (lvCurPrice.InvokeRequired)
|
||||
lvCurPrice.BeginInvoke(update);
|
||||
else
|
||||
update();
|
||||
}
|
||||
|
||||
public int GetSellableCount(string strCode)
|
||||
@@ -499,6 +542,8 @@ namespace AutoSellerNS
|
||||
double.TryParse(tbCFTimeDown.Text, out dTimeDown);
|
||||
int.TryParse(tbCFIgnorePrice.Text, out iIgnorePrice);
|
||||
Config.SetVolatility(iListSize, dFastSD, dFastUp, dFastDown, dSlowSD, dSlowUp, dSlowDown, iTimeLimit, dTimeDown, iIgnorePrice);
|
||||
|
||||
Config.SetMockTrading(cbMockTrading.Checked);
|
||||
}
|
||||
|
||||
#region Simulation
|
||||
@@ -514,5 +559,6 @@ namespace AutoSellerNS
|
||||
helper.StartSimuation2();
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user