moexapi 1.7.7__tar.gz → 1.7.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: moexapi
3
- Version: 1.7.7
3
+ Version: 1.7.9
4
4
  Summary: Python API for MOEX ISS
5
5
  Author-email: Aliaksei Rak <kventinel@gmail.com>
6
6
  License: MIT License
@@ -99,31 +99,34 @@ class Bond:
99
99
  for line in amortization:
100
100
  date = datetime.date.fromisoformat(line["amortdate"])
101
101
  end_date = _max(end_date, date)
102
- self.amortization.append(
103
- Amortization(date=date, value=line["value"], initialfacevalue=line["initialfacevalue"])
102
+ item = Amortization(
103
+ date=date,
104
+ value=line["value"],
105
+ initialfacevalue=line["initialfacevalue"],
104
106
  )
107
+ if item not in self.amortization:
108
+ self.amortization.append(item)
105
109
  for line in coupons:
106
110
  date = datetime.date.fromisoformat(line["recorddate"] if line["recorddate"] else line["coupondate"])
107
111
  end_date = _max(end_date, date)
108
- self.coupons.append(
109
- Coupon(
110
- date=date,
111
- start_date=datetime.date.fromisoformat(line["startdate"])
112
- if line.get("startdate") else None,
113
- value=line["value"],
114
- initialfacevalue=line["initialfacevalue"],
115
- )
112
+ item = Coupon(
113
+ date=date,
114
+ start_date=datetime.date.fromisoformat(line["startdate"])
115
+ if line.get("startdate") else None,
116
+ value=line["value"],
117
+ initialfacevalue=line["initialfacevalue"],
116
118
  )
119
+ if item not in self.coupons:
120
+ self.coupons.append(item)
117
121
  for line in offers:
118
122
  date = datetime.date.fromisoformat(line["offerdate"])
119
123
  end_date = _max(end_date, date)
120
- self.offers.append(Offer(date=date, value=line["value"]))
124
+ item = Offer(date=date, value=line["value"])
125
+ if item not in self.offers:
126
+ self.offers.append(item)
121
127
  if end_date == start_date:
122
128
  break
123
129
  start_date = end_date
124
- self.amortization = [item for item in self.amortization if item.date != start_date]
125
- self.coupons = [item for item in self.coupons if item.date != start_date]
126
- self.offers = [item for item in self.offers if item.date != start_date]
127
130
  original_values = [item.value for item in self.amortization]
128
131
  amortization_sum = sum(original_values)
129
132
  if abs(amortization_sum - self.initial_face_value) > 1e-9 and len(original_values) > 1:
@@ -131,16 +131,35 @@ class TickerBoardInfo:
131
131
  )
132
132
  if result:
133
133
  result.boards.extend(board for board, currency in boards if currency == result.currency)
134
- response = utils.json_api_call(f"https://iss.moex.com/iss/securities/{secid}.json")
135
- for line in utils.prepare_dict(response, "boards"):
136
- board = line[BOARDID.lower()]
137
- if (
138
- board not in result.boards
139
- and line["engine"] in market.engines
140
- and line["market"] in market.markets
141
- and _sur_to_rub(line.get(CURRENCY.lower())) == result.currency
142
- ):
143
- result.boards.append(board)
134
+ response = utils.json_api_call(f"https://iss.moex.com/iss/securities/{secid}.json")
135
+ board_lines = utils.prepare_dict(response, "boards")
136
+ if result is None:
137
+ primary_lines = [
138
+ line for line in board_lines
139
+ if line[BOARDID.lower()] == primary_board
140
+ ]
141
+ if not primary_lines:
142
+ return None
143
+ currency = _sur_to_rub(primary_lines[0].get(CURRENCY.lower()))
144
+ result = cls(
145
+ boards=[primary_board],
146
+ currency=currency,
147
+ raw_price=None,
148
+ price=None,
149
+ price_in_rub=None,
150
+ accumulated_coupon=0,
151
+ listlevel=None,
152
+ value=None,
153
+ )
154
+ for line in board_lines:
155
+ board = line[BOARDID.lower()]
156
+ if (
157
+ board not in result.boards
158
+ and line["engine"] in market.engines
159
+ and line["market"] in market.markets
160
+ and _sur_to_rub(line.get(CURRENCY.lower())) == result.currency
161
+ ):
162
+ result.boards.append(board)
144
163
  return result
145
164
 
146
165
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: moexapi
3
- Version: 1.7.7
3
+ Version: 1.7.9
4
4
  Summary: Python API for MOEX ISS
5
5
  Author-email: Aliaksei Rak <kventinel@gmail.com>
6
6
  License: MIT License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "moexapi"
7
- version = "1.7.7"
7
+ version = "1.7.9"
8
8
  description = "Python API for MOEX ISS"
9
9
  readme = "README.md"
10
10
  authors = [{ name = "Aliaksei Rak", email = "kventinel@gmail.com" }]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes