home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freelog Special Freeware 31
/
FreelogHS31.iso
/
ArgentCompta
/
Bankperfect
/
bp.exe
/
Scripts
/
UpdateStock
/
update_stock.py
< prev
Wrap
Text File
|
2005-07-24
|
1KB
|
48 lines
import BP
current_account = BP.AccountCurrent()
dates = BP.OperationDate[current_account]
modes = BP.OperationMode[current_account]
infos = BP.OperationDetails[current_account]
thirds = BP.Operationthirdparty[current_account]
values = BP.OperationAmount[current_account]
symb1 = BP.AccountCurrency1[current_account]
symb2 = BP.AccountCurrency2[current_account]
symb1, rate1 = symb1.split("|")
symb2, rate2 = symb2.split("|")
rate1 = float(rate1.replace(",", "."))
rate2 = float(rate2.replace(",", "."))
nb_lines = len(dates)
def extract_value(s, start_points, right_bound):
for point in start_points:
i = s.find(point)
if i == -1: return ""
s = s[i + len(point):]
i = s.find(right_bound)
if i == -1: return ""
return s[:i]
for i in range(nb_lines):
if modes[i] == "Titre":
isin = infos[i]
if isin != "":
s = BP.GetURL("http://fr.finance.yahoo.com/q?s=%s" %isin)
s = extract_value(s, ["yfnc_tabledata1", "<b>"], "</b>")
s = s.strip().replace(",", ".")
p = s.find(" ")
if p > -1: s = s[:p]
p = s.find("&")
if p > -1: s = s[:p]
try:
val0 = float(s)
if symb2 == "Ç" and symb1 != "Ç":
val0 = val0 * rate1 / rate2
qty = float(thirds[i].split(" ")[0].replace(",", "."))
val = val0 * qty
values[i] = val
except:
pass
BP.AccountRefreshScreen()