@@ -89,11 +89,16 @@ def _validate_name(self, name):
8989 None
9090 """
9191 if not isinstance (name , str ):
92- raise OperationalException ("The name of the algorithm must be a string" )
93-
92+ raise OperationalException (
93+ "The name of the algorithm must be a string"
94+ )
95+
9496 pattern = re .compile (r"^[a-zA-Z0-9]*$" )
9597 if not pattern .match (name ):
96- raise OperationalException ("The name of the algorithm can only contain letters and numbers" )
98+ raise OperationalException (
99+ "The name of the algorithm can only contain" +
100+ " letters and numbers"
101+ )
97102
98103 def initialize_services (
99104 self ,
@@ -256,19 +261,19 @@ def create_order(
256261 return self .order_service .create (
257262 order_data , execute = execute , validate = validate , sync = sync
258263 )
259-
264+
260265 def has_balance (self , symbol , amount , market = None ):
261266 """
262267 Function to check if the portfolio has enough balance to
263268 create an order. This function will return True if the
264- portfolio has enough balance to create an order, False
269+ portfolio has enough balance to create an order, False
265270 otherwise.
266271
267272 Parameters:
268273 symbol: The symbol of the asset
269274 amount: The amount of the asset
270275 market: The market of the asset
271-
276+
272277 Returns:
273278 Boolean: True if the portfolio has enough balance
274279 """
@@ -309,20 +314,26 @@ def create_limit_order(
309314 price: The price of the asset
310315 order_side: The side of the order
311316 amount (optional): The amount of the asset to trade
312- amount_trading_symbol (optional): The amount of the trading symbol to trade
313- percentage (optional): The percentage of the portfolio to allocate to the
317+ amount_trading_symbol (optional): The amount of the
318+ trading symbol to trade
319+ percentage (optional): The percentage of the portfolio
320+ to allocate to the
314321 order
315- percentage_of_portfolio (optional): The percentage of the portfolio to
316- allocate to the order
317- percentage_of_position (optional): The percentage of the position to
318- allocate to the order. (Only supported for SELL orders)
322+ percentage_of_portfolio (optional): The percentage
323+ of the portfolio to allocate to the order
324+ percentage_of_position (optional): The percentage
325+ of the position to allocate to
326+ the order. (Only supported for SELL orders)
319327 precision (optional): The precision of the amount
320328 market (optional): The market to trade the asset
321- execute (optional): Default True. If set to True, the order will be executed
322- validate (optional): Default True. If set to True, the order will be validated
323- sync (optional): Default True. If set to True, the created order will be synced with the
329+ execute (optional): Default True. If set to True,
330+ the order will be executed
331+ validate (optional): Default True. If set to
332+ True, the order will be validated
333+ sync (optional): Default True. If set to True,
334+ the created order will be synced with the
324335 portfolio of the algorithm
325-
336+
326337 Returns:
327338 Order: Instance of the order created
328339 """
@@ -369,10 +380,10 @@ def create_limit_order(
369380 raise OperationalException (
370381 "The amount parameter is required to create a limit order." +
371382 "Either the amount, amount_trading_symbol, percentage, " +
372- "percentage_of_portfolio or percentage_of_position parameter " +
373- "must be specified."
383+ "percentage_of_portfolio or percentage_of_position "
384+ "parameter must be specified."
374385 )
375-
386+
376387 order_data = {
377388 "target_symbol" : target_symbol ,
378389 "price" : price ,
@@ -417,7 +428,7 @@ def create_market_order(
417428 validate: If set to True, the order will be validated
418429 sync: If set to True, the created order will be synced with the
419430 portfolio of the algorithm
420-
431+
421432 Returns:
422433 Order: Instance of the order created
423434 """
@@ -454,7 +465,7 @@ def get_portfolio(self, market=None) -> Portfolio:
454465
455466 Parameters:
456467 market: The market of the portfolio
457-
468+
458469 Returns:
459470 Portfolio: The portfolio of the algorithm
460471 """
@@ -492,7 +503,7 @@ def get_total_size(self):
492503 """
493504 Returns the total size of the portfolio.
494505
495- The total size of the portfolio is the unallocated balance and the
506+ The total size of the portfolio is the unallocated balance and the
496507 allocated balance of the portfolio.
497508
498509 Returns:
@@ -597,7 +608,7 @@ def get_positions(
597608 amount_lt: The amount of the asset must be less than this
598609 amount_lte: The amount of the asset must be less than or equal
599610 to this
600-
611+
601612 Returns:
602613 List[Position]: A list of positions that match the query parameters
603614 """
@@ -1167,7 +1178,7 @@ def get_closed_trades(self) -> List[Trade]:
11671178 """
11681179 Function to get all closed trades. This function will return all
11691180 closed trades of the algorithm.
1170-
1181+
11711182 Returns:
11721183 List[Trade]: A list of closed trades
11731184 """
@@ -1234,8 +1245,9 @@ def has_trading_symbol_position_available(
12341245 the position must be greater than the net_size of the
12351246 portfolio.
12361247
1237- :param amount_gt: The amount of the position must be greater than
1238- this amount.
1248+ Parameters:
1249+ amount_gt: The amount of the position must be greater than this
1250+ amount.
12391251 :param amount_gte: The amount of the position must be greater than
12401252 or equal to this amount.
12411253 :param percentage_of_portfolio: The amount of the position must be
0 commit comments