Wind API learning note 5 (TDays date function)

5.1 return the date series w.tdays in the interval

definition

Command is used to obtain the date series under a certain rule in a time interval.

Function input

Function name: TDays(startDate,endDate,[Optional argument])

||Element | Type| Description ||

| :------------- :|:-------------:| :-----:|

|Start date (required) | StartDate| String | start date of time series | example 1: "2015-01-01". Date macros are supported|

|End date (required) | EndDate | String | the end date of the time series. If it is left blank, the current latest date will be taken. Example 1: "2015-06-30". Date macros are supported|

|Date type (optional) | Days| String | all working days: Weekdays, all calendar days: Alldays, excluding all non trading days: Trading | example: 'Days=Trading', default Days=Trading|

|Frequency conversion parameter (optional) | Period| String | daily value: D, weekly value: W, monthly value: M:, quarterly value: Q, semi annual value: S, annual value: Y | example: 'Period=D'|
|Transaction calendar (optional)| TradingCalendar| String|| TradingCalendar defaults to Shanghai Stock Exchange. When DAYS is calendar day, this parameter does not work. Only when DAYS is trading day, this parameter works. The default is "TradingCalendar=SSE" (Shanghai Stock Exchange)|

Example

Example 11 take the trading date series of Shanghai Stock Exchange since 2018. If the exchange is empty, it is Shanghai Stock Exchange by default

date_list=w.tdays("2018-05-13", "2018-06-13"," ")
date_list

return:

.ErrorCode=0
.RequestID=2071
.Codes=[]
.Fields=[]
.Times=[20180514,20180515,20180516,20180517,20180518,20180521,20180522,20180523,20180524,20180525,...]
.Data=[[2018-05-14 00:00:00.005000,2018-05-15 00:00:00.005000,2018-05-16 00:00:00.005000,2018-05-17 00:00:00.005000,2018-05-18 00:00:00.005000,2018-05-21 00:00:00.005000,2018-05-22 00:00:00.005000,2018-05-23 00:00:00.005000,2018-05-24 00:00:00.005000,2018-05-25 00:00:00.005000,...]]

5.2 return the date w.tdaysofset corresponding to an offset value

definition

The command is used to obtain the date of a specified number of days pushed forward (< 0) or pushed back (> 0) based on a base time.
The prototype of the command is: data = w.tdaysofset (offset value, base time, optional parameters)

Function input

** Function name:TDaysOffset(offset, refDate, [Optional argument])**

Example

Example 12 take the calendar day pushed forward 10 months from today
import datetime
today = datetime.date.today() 
w.tdaysoffset(-10, today.isoformat(), "Period=M;Days=Alldays")

return:

.ErrorCode=0
.RequestID=56
.Codes=[]
.Fields=[]
.Times=[20170820]
.Data=[[2017-08-20 00:00:00.005000]]

5.3 return the date quantity w.tdayscount in a certain interval

definition

Command is used to obtain the number of date series under a certain rule in two time intervals
The prototype of the command is: data = w.tdayscout (start time, end time, optional parameters)

Function input

Function name: TDaysCount(startDate,endDate, [Optional argument])

 

 ||Element|Type| Description ||

| :------------- :|:-------------:| :-----:|

|Start date (required) | StartDate| String | start date of time series | example 1: "2017-01-01". Date macros are supported|

|End date | EndDate| String | end date of time series. If it is left blank, the current latest date will be taken | example 1: "June 30, 2017". Date macros are supported|

|Date type (optional) | Days| String | all working days: Weekdays, all calendar days: Alldays, excluding all non trading days: Trading | example: 'Days=Trading', default Days=Trading|

|Trading calendar (optional) | tradingcalendar | string | tradingcalendar is Shanghai Stock Exchange by default. When DAYS is calendar day, this parameter does not work. This parameter only works when DAYS is trading day. The default is "TradingCalendar=SSE" (Shanghai Stock Exchange)|

Example 13 statistics of trading days in 2017

days=w.tdayscount("2017-01-01", "2017-12-31", "").Data[0]
days

result:
[244]

 

 

 

Posted by WeAnswer.IT on Fri, 03 Dec 2021 03:49:10 -0800