| 91 | |
| 92 | # Generate a printable table of all available pairs with a header |
| 93 | def generate_table(amnt, lvrg, period): |
| 94 | available_FTX = FTX_sourcer.available_FTX |
| 95 | |
| 96 | data = [] |
| 97 | |
| 98 | # Make a data header |
| 99 | data.append({ |
| 100 | 'pair': 'Name', |
| 101 | 'funding_rate': 'Funding %/' + period, |
| 102 | 'spread': 'Spread %', |
| 103 | 'profit': 'Profits $', |
| 104 | 'effective_rate': 'Effective Rate %/' + period |
| 105 | }) |
| 106 | |
| 107 | # Loop through available coins and append to the list |
| 108 | for i in available_FTX: |
| 109 | pair_funding_rate = float(FTX_sourcer.funding_rates(i + '-PERP')['funding ' + period]) |
| 110 | calculated_spread = float(calculator.difference(FTX_sourcer.PERP(i + '-PERP')['PERP_price'], FTX_sourcer.USD(i + '/USD')['USD_price'])) |
| 111 | calculated_profit = calculator.profit(amnt, pair_funding_rate, taker_fee, calculated_spread, lvrg) |
| 112 | data.append({ |
| 113 | 'pair': i, |
| 114 | 'funding_rate': "{:.4f}".format(pair_funding_rate * 100), |
| 115 | 'spread': "{:.4f}".format(calculated_spread * 100), |
| 116 | 'profit': "{:.2f}".format(calculated_profit), |
| 117 | 'effective_rate': "{:.2f}".format(calculator.effective_rate_calculator(calculated_profit, amnt)) |
| 118 | }) |
| 119 | return table(data) |
| 120 | # print(generate_table()) |