買い(売りも同様)注文画面(正確には買い注文画面→注文確認画面→注文受付完了画面に遷移する)のHTMLソース(一部を抜粋)は以下のようになっています。
<html>
<head></head>
<body>
<form name="OrdJpStkNewForm" method="post" action="xxx" id="form">
数量
<input type="text" name="orderValue" maxlength="8" size="12" value="">株
<input type="radio" name="marketOrderKbn" value="0" checked="checked" id="priceLimit">
<label for="priceLimit">指値</label>
<input type="text" name="marketOrderPrice">円
<input type="radio" name="marketOrderKbn" value="1" id="priceMarket">
<label for="priceMarket">成行</label>
<select name="execCondCd" id="execCondCd">
<option value="1">本日中</option>
<option value="2">今週中</option>
<option value="3">寄付</option>
<option value="4">引け</option>
<option value="7">不成</option>
</select>
<input type="submit" value=" 確 認 ">
</form>
</body>
</html>
<html>
<head>
</head>
<body>
<form name="OrdJpStkConfirmForm" method="post" action="xxx">
取引暗証番号
<input type="password" name="password">
<input type="submit" value=" 注 文 " id="sbm">
</form>
</body>
</html>
<html>
<head></head>
<body>
<table>
<table><tr><td>
買い注文 / 受付完了
</td>
<td></td>
</tr>
</table>
買い注文を受け付けました。
<table>
</table>
</table>
<table></table>
<table></table>
<table></table>
</body>
</html>
Public MustInherit Class AbstructOrderFrame
Inherits AbstructRakutenWebLoginSession
Private Shared ReadOnly PASS_ID As String = "xxxxxxxx"
Protected Sub New(ByVal screen As AbstructWebScreen)
MyBase.new(screen)
End Sub
Protected Sub ExecuteCommon(ByVal price As Long, ByVal unit As Long, ByVal processName As AbstructWebOrder.OrderType, ByVal orderActionName As AbstructWebOrder.OrderActionType, ByVal execConditionName As AbstructWebOrder.ExecuteConditionType)
Try
FocusMainFrame()
_ie.RootDocument()
_ie.TypeValue("orderValue", CStr(unit))
If price = 0 Then
_ie.SetRadioButton("marketOrderKbn", "1")
_ie.TypeValue("marketOrderPrice", "")
Else
_ie.SetRadioButton("marketOrderKbn", "0")
_ie.TypeValue("marketOrderPrice", CStr(price))
End If
_ie.SetSelectBox("execCondCd", execConditionName.ToString())
_ie.ClickSubmit(0)
Return
Catch e As Exception
DispatchException(e, String.Format("{0}{1}", processName.ToString(), orderActionName.ToString()))
End Try
Throw New WebScreenException(String.Format("{0}{1}", processName.ToString(), orderActionName.ToString()))
End Sub
Protected Sub ConfirmPassId()
_ie.RootDocument()
_ie.TypeValue("password", PASS_ID)
_ie.ClickSubmit(0)
_ie.RootDocument()
Dim str As String = _ie.Element("table", 0).InnerText
If str.IndexOf("受付完了") >= 0 AndAlso str.IndexOf("注文を受け付けました。") >= 0 Then
Return
Else
Throw New WebScreenException(String.Format("注文受付に失敗しました。msg={0}", str))
End If
End Sub
End Class
Public MustInherit Class AbstructWebOrder
Public Enum OrderType
買付
売付
End Enum
Public Enum ConfirmType
約定
取消済
End Enum
Public Enum ConfirmActionType
取消
訂正
注文詳細
End Enum
Public Enum OrderActionType
新規注文
訂正注文
End Enum
Public Enum ExecuteConditionType
本日中
今週中
寄付
引け
不成
End Enum
End Class
ExecuteCommonメソッドの処理は、orderValueテキストボックスに注文枚数、marketOrderKbnラジオボタンで指値/成行、marketOrderPriceテキストボックスに注文価格、execCondCdセレクトボックスで注文条件を指定し、確認(Submit)ボタンをクリックします。
ConfirmPassIdメソッドでは、passwordテキストボックスに注文確認用のパスワードを入力し、次の画面でtable要素の中の「受付完了」「注文を受け付けました。」という文字を見つけることで、注文完了を確認しています。
スポンサーリンク