PORTFOLIO_EX SaveTrades;
DESCRIPTION SaveTrades;
CLIENTS_LIST ALL_CLIENTS;
FIRMS_LIST ALL_FIRMS;
USE_CASE_SENSITIVE_CONSTANTS;
PROGRAM
NEW_GLOBAL("NUM_OF_TRADES",0)
OUT_PATH=".\trades\"
SERVERTIME=GET_INFO_PARAM("SERVERTIME")
SERVERTIME=SUBSTR(SERVERTIME,0,2)&SUBSTR(SERVERTIME,3,2)&SUBSTR(SERVERTIME,6,2)
SERVERTIME=SERVERTIME+0
if (SERVERTIME<100000)OR(SERVERTIME>235500)
return()
end if
NEW_NUM_OF_TRADES=GET_NUMBER_OF("TRADES")+0
if NEW_NUM_OF_TRADES+0>NUM_OF_TRADES+0
CTIME = GET_DATETIME()
CYEAR = GET_VALUE(CTIME, "YEAR")
CMONTH = GET_VALUE(CTIME, "MONTH")
CDAY = GET_VALUE(CTIME, "DAY")
OUT_FILE= OUT_PATH & CYEAR & "." & PAD(CMONTH,2) & "." & PAD(CDAY,2) & ".txt"
if NUM_OF_TRADES=0
CLEAR_FILE(OUT_FILE)
end if
FOR i FROM NUM_OF_TRADES+1 to NEW_NUM_OF_TRADES
TRADE = GET_ITEM ("TRADES", i)
if GET_VALUE(TRADE,"OPERATION")&""="SELL"
OPERATION="Продажа"
else
OPERATION="Купля"
end if
S=i & ";" & GET_VALUE(TRADE,"SECCODE") & ";" & OPERATION & ";" & GET_VALUE(TRADE,"PRICE") & ";" & GET_VALUE(TRADE,"QUANTITY") & ";" & GET_VALUE(TRADE,"TIME") & ";" & GET_VALUE(TRADE,"NUMBER") & ";" & GET_VALUE(TRADE,"EXCHANGE_COMISSION") & ";" & GET_VALUE(TRADE,"COMMENT")
WRITELN(OUT_FILE, S)
delete_all_items()
ADD_ROW("Сохранена сделка",i)
end for
end if
FUNC PAD(number, length)
RESULT = number
IF LEN(number) < length
c123 = 1
FOR c123 FROM 1 TO (length - LEN(number))
RESULT = "0" & RESULT
END FOR
END IF
END FUNC
FUNC ADD_ROW(PRM, VAL)
M = CREATE_MAP()
M = SET_VALUE(M, "Param", PRM)
M = SET_VALUE(M, "Value", VAL)
ADD_ITEM(GET_NUMBER_OF("OWN") + 1, M)
END FUNC
END_PROGRAM
PARAMETER Param;
PARAMETER_TITLE Параметр;
PARAMETER_DESCRIPTION Название параметра;
PARAMETER_TYPE STRING(64);
END
PARAMETER Value;
PARAMETER_TITLE Значение;
PARAMETER_DESCRIPTION Значение параметра;
PARAMETER_TYPE STRING(20);
END
END_PORTFOLIO_EX