/
testStockMst.py
111 lines (84 loc) · 2.71 KB
/
testStockMst.py
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
################################################################################
# -*- coding: utf-8 -*-
# author : Jinwon Oh
# file name : testStockMst.py
# date : 2013-03-24 19:16:47
# ver :
# desc. :
# tab size : set sw=4, ts=4
# python ver. : 2.7.2 Stackless 3.1b3 060516 (default, Dec 21 2011, 17:08:51) [MSC v.1500 32 bit (Intel)]
# ADD CODES FROM HERE
import common
import os
from cxFile import cxFile
def getAllStockMst() :
import time
from cxCybosPlus import constants
from cxCybosPlus import gCybosPlusClassDic
from cxStockMgr import stockMgr
cpCybos = gCybosPlusClassDic['cxCpCybos']
stockMst = gCybosPlusClassDic['cxCpStockMst']
stockList = stockMgr.getStockList()
sep = u'\t'
newLine = u'\n'
fileName = u'StockMst.des'
if common.checkFileExist(fileName) == True :
os.remove(fileName)
stockMstFile = cxFile(fileName)
strLine = u''
for key in stockMst.headerIndexDic.keys() :
strLine += stockMst.headerIndexDic[key][1] + sep
strLine += newLine
print strLine
stockMstFile.write(strLine)
#stockList = [[u'A000660',u'SK하이닉스']]
for stockItem in stockList :
print stockItem[0]
stockMst.SetInputValue(u'0',stockItem[0])
stockMst.BlockRequest()
result = stockMst.getResult()
print 'getResult (',result[0],')'
if result[0] != 0 :
print stockItem[0], ': BlockRequest is failed (%d).'%(result[0])
continue
strLine = u''
for key in stockMst.headerIndexDic.keys() :
strLine += unicode(result[5][0][key][2]) + sep
strLine += newLine
print strLine
stockMstFile.write(strLine)
remainCount = cpCybos.GetLimitRemainCount(constants.LT_NONTRADE_REQUEST)
remainTime = cpCybos.LimitRequestRemainTime()
print remainCount, remainTime
if remainCount <= 0 :
time.sleep((remainTime/1000)+1)
stockMstFile.close()
def loadAllStockMst() :
fileName = u'StockMst.des'
stockFile = cxFile(fileName)
sep = u'\t'
lines = stockFile.readlines()
print lines[0]
def test() :
#getAllStockMst()
loadAllStockMst()
def collect_and_show_garbage() :
"Show what garbage is present."
print "Collecting..."
n = gc.collect()
print "Unreachable objects:", n
if n > 0 : print "Garbage:"
for i in range(n):
print "[%d] %s" % (i, gc.garbage[i])
if __name__ == "__main__" :
import gc
gc.set_debug(gc.DEBUG_LEAK)
print "before"
collect_and_show_garbage()
print "testing..."
print "-"*79
test()
print "-"*79
print "after"
collect_and_show_garbage()
raw_input("Hit any key to close this window...")