Skip to content

Commit 742ad7a

Browse files
committed
Comply change of API /adjustments
1 parent 9994abd commit 742ad7a

File tree

3 files changed

+43
-40
lines changed

3 files changed

+43
-40
lines changed

shipane_sdk/base_manager.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,11 @@ def _create_adjustment(self, target_portfolio):
395395
return adjustment
396396

397397
def _create_adjustment_request(self, target_portfolio):
398-
context = AdjustmentContext(self._sync_config['other-value'],
399-
self._sync_config['total-value-deviation-rate'],
400-
self._sync_config['reserved-securities'],
401-
self._sync_config['min-order-value'],
402-
self._sync_config['max-order-value'])
398+
context = AdjustmentSchema(self._sync_config['other-value'],
399+
self._sync_config['total-value-deviation-rate'],
400+
self._sync_config['reserved-securities'],
401+
self._sync_config['min-order-value'],
402+
self._sync_config['max-order-value'])
403403
request = Adjustment()
404404
request.target_portfolio = target_portfolio
405405
request.context = context

shipane_sdk/jobs/online_quant_sync.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,16 @@ def _create_adjustment(self, target_portfolio, client):
9393
return adjustment
9494

9595
def _create_adjustment_request(self, target_portfolio):
96-
context = AdjustmentContext(self._config.other_value,
97-
self._config.total_value_deviation_rate,
98-
self._config.reserved_securities,
99-
self._config.min_order_value,
100-
self._config.max_order_value)
96+
schema = AdjustmentSchema(self._config.reserved_securities,
97+
self._config.min_order_value,
98+
self._config.max_order_value)
10199
request = Adjustment()
100+
request.source_portfolio = Portfolio(
101+
other_value=self._config.other_value,
102+
total_value_deviation_rate=self._config.total_value_deviation_rate
103+
)
102104
request.target_portfolio = target_portfolio
103-
request.context = context
105+
request.schema = schema
104106
return request
105107

106108
def _log_progress(self, adjustment):

shipane_sdk/models.py

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ class Adjustment(object):
99
@staticmethod
1010
def to_json(instance):
1111
json = {
12+
'sourcePortfolio': Portfolio.to_json(instance.source_portfolio),
1213
'targetPortfolio': Portfolio.to_json(instance.target_portfolio),
13-
'context': AdjustmentContext.to_json(instance.context)
14+
'schema': AdjustmentSchema.to_json(instance.schema)
1415
}
1516
return json
1617

@@ -57,12 +58,12 @@ def target_portfolio(self, value):
5758
self._target_portfolio = value
5859

5960
@property
60-
def context(self):
61-
return self._context
61+
def schema(self):
62+
return self._schema
6263

63-
@context.setter
64-
def context(self, value):
65-
self._context = value
64+
@schema.setter
65+
def schema(self, value):
66+
self._schema = value
6667

6768
@property
6869
def batches(self):
@@ -81,41 +82,21 @@ def progress(self, value):
8182
self._progress = value
8283

8384

84-
class AdjustmentContext(object):
85+
class AdjustmentSchema(object):
8586
@staticmethod
8687
def to_json(instance):
8788
json = {
8889
'minOrderValue': instance.min_order_value,
8990
'maxOrderValue': instance.max_order_value,
9091
'reservedSecurities': instance.reserved_securities,
91-
'otherValue': instance.other_value,
92-
'totalValueDeviationRate': instance.total_value_deviation_rate,
9392
}
9493
return json
9594

96-
def __init__(self, other_value, total_value_deviation_rate, reserved_securities, min_order_value, max_order_value):
97-
self._other_value = other_value
98-
self._total_value_deviation_rate = total_value_deviation_rate
95+
def __init__(self, reserved_securities, min_order_value, max_order_value):
9996
self._reserved_securities = reserved_securities
10097
self._min_order_value = min_order_value
10198
self._max_order_value = max_order_value
10299

103-
@property
104-
def other_value(self):
105-
return self._other_value
106-
107-
@other_value.setter
108-
def other_value(self, value):
109-
self._other_value = value
110-
111-
@property
112-
def total_value_deviation_rate(self):
113-
return self._total_value_deviation_rate
114-
115-
@total_value_deviation_rate.setter
116-
def total_value_deviation_rate(self, value):
117-
self._total_value_deviation_rate = value
118-
119100
@property
120101
def reserved_securities(self):
121102
return self._reserved_securities
@@ -207,14 +188,18 @@ def to_json(instance):
207188
json = {
208189
'availableCash': instance.available_cash,
209190
'totalValue': instance.total_value,
191+
'otherValue': instance.other_value,
192+
'totalValueDeviationRate': instance.total_value_deviation_rate,
210193
'positionsValue': instance.positions_value,
211194
'positions': positions_json
212195
}
213196
return json
214197

215-
def __init__(self, available_cash=None, total_value=None):
198+
def __init__(self, available_cash=None, total_value=None, other_value=None, total_value_deviation_rate=None):
216199
self._available_cash = available_cash
217200
self._total_value = total_value
201+
self._other_value = other_value
202+
self._total_value_deviation_rate = total_value_deviation_rate
218203
self._positions_value = 0
219204
self._positions = dict()
220205

@@ -245,6 +230,22 @@ def total_value(self):
245230
def total_value(self, value):
246231
self._total_value = value
247232

233+
@property
234+
def other_value(self):
235+
return self._other_value
236+
237+
@other_value.setter
238+
def other_value(self, value):
239+
self._other_value = value
240+
241+
@property
242+
def total_value_deviation_rate(self):
243+
return self._total_value_deviation_rate
244+
245+
@total_value_deviation_rate.setter
246+
def total_value_deviation_rate(self, value):
247+
self._total_value_deviation_rate = value
248+
248249
@property
249250
def positions_value(self):
250251
return self._positions_value

0 commit comments

Comments
 (0)