-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from aoki-h-jp/feature/1.0.0/get-funding-rate
Initial commit
- Loading branch information
Showing
4 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
""" | ||
An example of fetching funding rate | ||
""" | ||
from frarb import FundingRateArbitrage | ||
from frarb.utils import Exchange | ||
|
||
|
||
if __name__ == '__main__': | ||
# fetch from binance | ||
fr = FundingRateArbitrage() | ||
fr.fetch_all_funding_rate(Exchange.BINANCE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,23 @@ | ||
import utils | ||
import ccxt | ||
import pandas as pd | ||
|
||
|
||
class FundingRateArbitrage: | ||
def __init__(self): | ||
pass | ||
|
||
def fetch_all_funding_rate(self, exchange: utils.Exchange) -> dict: | ||
""" | ||
Fetch funding rates on all perpetual contracts listed on the exchange. | ||
Args: | ||
exchange (utils.Exchange): Exchange (binance, bybit, ...) | ||
Returns (dict): Dict of perpetual contract pair and funding rate | ||
""" | ||
ex = getattr(ccxt, exchange)() | ||
info = ex.load_markets() | ||
perp = [p for p in info if info[p]['linear']] | ||
return {p: ex.fetch_funding_rate(p)['fundingRate'] for p in perp} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from enum import Enum | ||
|
||
|
||
class Exchange(Enum): | ||
BINANCE = 'binance' | ||
BYBIT = 'bybit' | ||
OKX = 'okx' | ||
BITGET = 'bitget' | ||
GATEIO = 'gate' | ||
COINEX = 'coinex' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ccxt | ||
pandas |