-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatus.rb
74 lines (67 loc) · 2.63 KB
/
status.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
module StatusValues
INITSTATUS = 0
GET_MYAMOUNT = 1
GET_PRICE = 2
CALC_BUYPRICE = 3
CALC_BUYAMOUNT = 4
ORDER_BUY = 5
WAIT_BUY = 6
CALC_SELLPRICE = 7
CALC_SELLAMOUNT = 8
ORDER_SELL = 9
WAIT_SELL = 10
CANCEL_BUYORDER = 11
CANCEL_SELLORDER = 12
DISP_PROFITS = 13
end
# status class
class Status
STATUS_NAMES = {
StatusValues::INITSTATUS => '初期状態',
# StatusValues::GET_MYAMOUNT => '残高取得中',
StatusValues::GET_PRICE => '現在価格取得',
StatusValues::CALC_BUYPRICE => '購入価格計算',
StatusValues::CALC_BUYAMOUNT => '購入数量計算',
StatusValues::ORDER_BUY => '発注(購入)',
StatusValues::WAIT_BUY => '購入約定待ち',
StatusValues::CALC_SELLPRICE => '販売価格計算',
StatusValues::CALC_SELLAMOUNT => '販売数量計算',
StatusValues::ORDER_SELL => '発注(販売)',
StatusValues::WAIT_SELL => '販売約定待ち',
StatusValues::CANCEL_BUYORDER => '購入注文中断',
StatusValues::CANCEL_SELLORDER => '販売注文中断',
StatusValues::DISP_PROFITS => '利益表示'
}.freeze
attr_accessor :current_status
public def initialize
@current_status = StatusValues::INITSTATUS
end
NEXT = {
# StatusValues::INITSTATUS => StatusValues::GET_MYAMOUNT,
# StatusValues::GET_MYAMOUNT => StatusValues::GET_PRICE,
StatusValues::INITSTATUS => StatusValues::GET_PRICE,
StatusValues::GET_PRICE => StatusValues::CALC_BUYPRICE,
StatusValues::CALC_BUYPRICE => StatusValues::CALC_BUYAMOUNT,
StatusValues::CALC_BUYAMOUNT => StatusValues::ORDER_BUY,
StatusValues::ORDER_BUY => StatusValues::WAIT_BUY,
StatusValues::WAIT_BUY => StatusValues::CALC_SELLPRICE,
StatusValues::CALC_SELLPRICE => StatusValues::CALC_SELLAMOUNT,
StatusValues::CALC_SELLAMOUNT => StatusValues::ORDER_SELL,
StatusValues::ORDER_SELL => StatusValues::WAIT_SELL,
StatusValues::WAIT_SELL => StatusValues::DISP_PROFITS,
# StatusValues::DISP_PROFITS => StatusValues::GET_MYAMOUNT,
StatusValues::DISP_PROFITS => StatusValues::GET_PRICE,
# StatusValues::CANCEL_BUYORDER => StatusValues::GET_MYAMOUNT,
StatusValues::CANCEL_BUYORDER => StatusValues::GET_PRICE,
StatusValues::CANCEL_SELLORDER => StatusValues::CALC_SELLPRICE
}.freeze
public def next
@current_status = NEXT[@current_status]
end
public def set(newstatus)
@current_status = newstatus
end
public def to_s
STATUS_NAMES[@current_status]
end
end