?? nseutilities.cs
字號(hào):
using System;
using System.Collections.Generic;
using System.Text;
namespace NSEGrabber {
class NSEUtilities {
public static float getLastTradePrice(string str) {
float lastTradePrice = 0;
int index = str.IndexOf("Last Price");
if (index != -1) {
string tempStr = str.Substring(index);
tempStr = tempStr.Substring(tempStr.IndexOf("t1>") + 3);
int endIndex = tempStr.IndexOf("</td>");
string ltp = tempStr.Substring(0, endIndex);
lastTradePrice = float.Parse(ltp);
}
return lastTradePrice;
}
public static float getPreviousDayClose(string str) {
float previousDayClose = 0;
int index = str.IndexOf("Prev. Close");
if (index != -1) {
string tempStr = str.Substring(index);
tempStr = tempStr.Substring(tempStr.IndexOf("t1>") + 3);
int endIndex = tempStr.IndexOf("</td>");
string ltp = tempStr.Substring(0, endIndex);
previousDayClose = float.Parse(ltp);
}
return previousDayClose;
}
public static int getTradeQuantity(string str) {
int tradeQuantity = 0;
int index = str.IndexOf("Total traded quantity");
if (index != -1) {
string tempStr = str.Substring(index);
tempStr = tempStr.Substring(tempStr.IndexOf("t1>") + 3);
tempStr = tempStr.Substring(tempStr.IndexOf("t1>") + 3);
tempStr = tempStr.Substring(tempStr.IndexOf("t1>") + 3);
tempStr = tempStr.Substring(tempStr.IndexOf("t1>") + 3);
int endIndex = tempStr.IndexOf("</td>");
string ltp = tempStr.Substring(0, endIndex);
tradeQuantity = int.Parse(ltp);
}
return tradeQuantity;
}
public static float calculatePercentage(float yest, float today) {
return ((today - yest) / yest) * 100;
}
public static float getTodaysHigh(string str) {
float todayHigh = 0;
int index = str.IndexOf("High", StringComparison.Ordinal);
if (index != -1) {
string tempStr = str.Substring(index);
tempStr = tempStr.Substring(tempStr.IndexOf("t1>") + 3);
tempStr = tempStr.Substring(tempStr.IndexOf("t1>") + 3);
tempStr = tempStr.Substring(tempStr.IndexOf("t1>") + 3);
int endIndex = tempStr.IndexOf("</td>");
string th = tempStr.Substring(0, endIndex);
todayHigh = float.Parse(th);
}
return todayHigh;
}
public static float getTodaysLow(string str) {
float todayLow = 0;
//Some problem in search the "Low". So instead use Average Price
int index = str.IndexOf("Average Price", StringComparison.Ordinal);
if (index != -1) {
string tempStr = str.Substring(index);
tempStr = tempStr.Substring(tempStr.IndexOf("t1>") + 3);
tempStr = tempStr.Substring(tempStr.IndexOf("t1>") + 3);
tempStr = tempStr.Substring(tempStr.IndexOf("t1>") + 3);
tempStr = tempStr.Substring(tempStr.IndexOf("t1>") + 3);
int endIndex = tempStr.IndexOf("</td>");
string tl = tempStr.Substring(0, endIndex);
todayLow = float.Parse(tl);
}
return todayLow;
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -