Futures Data
futures(date, contract_code)
Fetches data for a specified futures contract based on type and reference date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
contract_code
|
str
|
The B3 futures contract code identifying the derivative. Supported contract codes are: - "DI1": One-day Interbank Deposit Futures (Futuro de DI) from B3. - "DDI": DI x U.S. Dollar Spread Futures (Futuro de Cupom Cambial) from B3. - "FRC": Forward Rate Agreement (FRA) from B3. - "DAP": DI x IPCA Spread Futures. - "DOL": U.S. Dollar Futures from B3. - "WDO": Mini U.S. Dollar Futures from B3. - "IND": Ibovespa Futures from B3. - "WIN": Mini Ibovespa Futures from B3. |
required |
date
|
DateLike
|
The date for which to fetch the data. If the reference date is a string, it should be in 'DD-MM-YYYY' format. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
pl.DataFrame: DataFrame containing the fetched data for the specified futures contract. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the futures contract code is not recognized or supported. |
Examples:
>>> futures("31-05-2024", "DI1")
shape: (40, 20)
┌────────────┬──────────────┬────────────────┬────────────┬───┬──────────────┬───────────┬────────────────┬─────────────┐
│ TradeDate ┆ TickerSymbol ┆ ExpirationDate ┆ BDaysToExp ┆ … ┆ CloseBidRate ┆ CloseRate ┆ SettlementRate ┆ ForwardRate │
│ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │
│ date ┆ str ┆ date ┆ i64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │
╞════════════╪══════════════╪════════════════╪════════════╪═══╪══════════════╪═══════════╪════════════════╪═════════════╡
│ 2024-05-31 ┆ DI1M24 ┆ 2024-06-03 ┆ 1 ┆ … ┆ 0.10404 ┆ 0.10404 ┆ 0.10399 ┆ 0.10399 │
│ 2024-05-31 ┆ DI1N24 ┆ 2024-07-01 ┆ 21 ┆ … ┆ 0.1039 ┆ 0.10386 ┆ 0.1039 ┆ 0.103896 │
│ 2024-05-31 ┆ DI1Q24 ┆ 2024-08-01 ┆ 44 ┆ … ┆ 0.10374 ┆ 0.10374 ┆ 0.1037 ┆ 0.103517 │
│ 2024-05-31 ┆ DI1U24 ┆ 2024-09-02 ┆ 66 ┆ … ┆ 0.10365 ┆ 0.10355 ┆ 0.1036 ┆ 0.1034 │
│ 2024-05-31 ┆ DI1V24 ┆ 2024-10-01 ┆ 87 ┆ … ┆ 0.1036 ┆ 0.10355 ┆ 0.1036 ┆ 0.1036 │
│ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │
│ 2024-05-31 ┆ DI1F35 ┆ 2035-01-02 ┆ 2654 ┆ … ┆ 0.1193 ┆ 0.1192 ┆ 0.11907 ┆ 0.12179 │
│ 2024-05-31 ┆ DI1F36 ┆ 2036-01-02 ┆ 2903 ┆ … ┆ null ┆ null ┆ 0.11887 ┆ 0.11674 │
│ 2024-05-31 ┆ DI1F37 ┆ 2037-01-02 ┆ 3156 ┆ … ┆ null ┆ null ┆ 0.11887 ┆ 0.11887 │
│ 2024-05-31 ┆ DI1F38 ┆ 2038-01-04 ┆ 3405 ┆ … ┆ null ┆ null ┆ 0.11887 ┆ 0.11887 │
│ 2024-05-31 ┆ DI1F39 ┆ 2039-01-03 ┆ 3656 ┆ … ┆ null ┆ null ┆ 0.11887 ┆ 0.11887 │
└────────────┴──────────────┴────────────────┴────────────┴───┴──────────────┴───────────┴────────────────┴─────────────┘
>>> futures("31-05-2024", "DAP")
shape: (22, 19)
┌────────────┬──────────────┬────────────────┬────────────┬───┬──────────────┬───────────┬────────────────┬─────────────┐
│ TradeDate ┆ TickerSymbol ┆ ExpirationDate ┆ BDaysToExp ┆ … ┆ CloseBidRate ┆ CloseRate ┆ SettlementRate ┆ ForwardRate │
│ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │
│ date ┆ str ┆ date ┆ i64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │
╞════════════╪══════════════╪════════════════╪════════════╪═══╪══════════════╪═══════════╪════════════════╪═════════════╡
│ 2024-05-31 ┆ DAPM24 ┆ 2024-06-17 ┆ 11 ┆ … ┆ null ┆ null ┆ 0.0555 ┆ 0.0555 │
│ 2024-05-31 ┆ DAPN24 ┆ 2024-07-15 ┆ 31 ┆ … ┆ null ┆ null ┆ 0.07524 ┆ 0.086254 │
│ 2024-05-31 ┆ DAPQ24 ┆ 2024-08-15 ┆ 54 ┆ … ┆ null ┆ 0.0885 ┆ 0.0885 ┆ 0.106631 │
│ 2024-05-31 ┆ DAPU24 ┆ 2024-09-16 ┆ 76 ┆ … ┆ null ┆ 0.0865 ┆ 0.0855 ┆ 0.078171 │
│ 2024-05-31 ┆ DAPV24 ┆ 2024-10-15 ┆ 97 ┆ … ┆ null ┆ null ┆ 0.07932 ┆ 0.057247 │
│ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │
│ 2024-05-31 ┆ DAPQ40 ┆ 2040-08-15 ┆ 4064 ┆ … ┆ null ┆ 0.0609 ┆ 0.06099 ┆ 0.060553 │
│ 2024-05-31 ┆ DAPK45 ┆ 2045-05-15 ┆ 5251 ┆ … ┆ null ┆ 0.0619 ┆ 0.0588 ┆ 0.051336 │
│ 2024-05-31 ┆ DAPQ50 ┆ 2050-08-15 ┆ 6566 ┆ … ┆ null ┆ 0.0605 ┆ 0.06086 ┆ 0.069126 │
│ 2024-05-31 ┆ DAPK55 ┆ 2055-05-17 ┆ 7755 ┆ … ┆ null ┆ 0.0646 ┆ 0.06022 ┆ 0.056693 │
│ 2024-05-31 ┆ DAPQ60 ┆ 2060-08-16 ┆ 9072 ┆ … ┆ null ┆ null ┆ 0.05821 ┆ 0.046451 │
└────────────┴──────────────┴────────────────┴────────────┴───┴──────────────┴───────────┴────────────────┴─────────────┘
Source code in pyield/b3/futures/core.py
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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |