INNER CODE UNIT · Python

distributionSum

hadialaddin/crypto-genie · crypto-genie.py:325

                    distributionSum = _.sum(weightsList)
                    for weight in weightsList:
                        if _.sum(distributedTotal) <  float(scaled_order['amount']):
                            val = round_step_size((weight * float(scaled_order['amount'])) / distributionSum,qty_step[scaled_order['symbol']],min_trading_qty[scaled_order['symbol']])
                            if _.sum(distributedTotal) + val <= float(scaled_order['amount']):
                                distributedTotal.append(val)
                            else:
                                val = round_step_size((float(scaled_order['amount']) - _.sum(distributedTotal)),qty_step[scaled_order['symbol']],min_trading_qty[scaled_order['symbol']])
                                distributedTotal.append(val)

                    priceDiff = float(scaled_order['priceUpper']) - float(scaled_order['priceLower'])
                    stepsPerPricePoint = priceDiff / (int(scaled_order['orderCount']) - 1)

                    # Generate the prices we're placing orders at
                    
                    final_decimals_count = str(tick_size[scaled_order['symbol']])[::-1].find('.') # Tick Size number of decimals - 1
                    
                    orderPrices = map(lambda i: float(scaled_order['priceLower']) if i is 0 else (float(scaled_order['priceUpper']) if i is int(scaled_order['orderCount']) - 1 else float(scaled_order['priceLower']) + stepsPerPricePoint * i), _.range(int(scaled_order['orderCount']))) # Get distribution weights

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…