Apply refactoring to root package bfxapi.

This commit is contained in:
Davide Casale
2023-02-17 18:38:07 +01:00
parent d72fcf3981
commit ab66170cf3
29 changed files with 81 additions and 78 deletions

View File

@@ -2,10 +2,10 @@
import os
from bfxapi.client import Client, Constants
from bfxapi.client import Client, REST_HOST
bfx = Client(
REST_HOST=Constants.REST_HOST,
REST_HOST=REST_HOST,
API_KEY=os.getenv("BFX_API_KEY"),
API_SECRET=os.getenv("BFX_API_SECRET")
)

View File

@@ -2,11 +2,11 @@
import os
from bfxapi.client import Client, Constants
from bfxapi.client import Client, REST_HOST
from bfxapi.enums import FundingOfferType, Flag
bfx = Client(
REST_HOST=Constants.REST_HOST,
REST_HOST=REST_HOST,
API_KEY=os.getenv("BFX_API_KEY"),
API_SECRET=os.getenv("BFX_API_SECRET")
)

View File

@@ -1,11 +1,11 @@
# python -c "import examples.rest.create_order"
import os
from bfxapi.client import Client, Constants
from bfxapi.client import Client, REST_HOST
from bfxapi.enums import OrderType, Flag
bfx = Client(
REST_HOST=Constants.REST_HOST,
REST_HOST=REST_HOST,
API_KEY=os.getenv("BFX_API_KEY"),
API_SECRET=os.getenv("BFX_API_SECRET")
)

View File

@@ -2,10 +2,10 @@
import os
from bfxapi.client import Client, Constants
from bfxapi.client import Client, REST_HOST
bfx = Client(
REST_HOST=Constants.REST_HOST,
REST_HOST=REST_HOST,
API_KEY=os.getenv("BFX_API_KEY"),
API_SECRET=os.getenv("BFX_API_SECRET")
)

View File

@@ -1,9 +1,9 @@
# python -c "import examples.rest.extra_calcs"
from bfxapi.client import Client, Constants
from bfxapi.client import Client, REST_HOST
bfx = Client(
REST_HOST=Constants.REST_HOST
REST_HOST=REST_HOST
)
t_symbol_response = bfx.rest.public.get_trading_market_average_price(

View File

@@ -2,10 +2,10 @@
import os
from bfxapi.client import Client, Constants
from bfxapi.client import Client, REST_HOST
bfx = Client(
REST_HOST=Constants.REST_HOST,
REST_HOST=REST_HOST,
API_KEY=os.getenv("BFX_API_KEY"),
API_SECRET=os.getenv("BFX_API_SECRET")
)

View File

@@ -3,10 +3,10 @@
import os
import time
from bfxapi.client import Client, Constants
from bfxapi.client import Client, REST_HOST
bfx = Client(
REST_HOST=Constants.REST_HOST,
REST_HOST=REST_HOST,
API_KEY=os.getenv("BFX_API_KEY"),
API_SECRET=os.getenv("BFX_API_SECRET")
)

View File

@@ -1,9 +1,9 @@
# python -c "import examples.rest.get_candles_hist"
from bfxapi.client import Client, Constants
from bfxapi.client import Client, REST_HOST
bfx = Client(
REST_HOST=Constants.REST_HOST
REST_HOST=REST_HOST
)
print(f"Candles: {bfx.rest.public.get_candles_hist(symbol='tBTCUSD')}")

View File

@@ -2,10 +2,10 @@
import os
from bfxapi.client import Client, Constants
from bfxapi.client import Client, REST_HOST
bfx = Client(
REST_HOST=Constants.REST_HOST,
REST_HOST=REST_HOST,
API_KEY=os.getenv("BFX_API_KEY"),
API_SECRET=os.getenv("BFX_API_SECRET")
)

View File

@@ -2,10 +2,10 @@
import os
from bfxapi.client import Client, Constants
from bfxapi.client import Client, REST_HOST
bfx = Client(
REST_HOST=Constants.REST_HOST,
REST_HOST=REST_HOST,
API_KEY=os.getenv("BFX_API_KEY"),
API_SECRET=os.getenv("BFX_API_SECRET")
)

View File

@@ -2,10 +2,10 @@
import time
from bfxapi.client import Client, Constants
from bfxapi.client import Client, REST_HOST
bfx = Client(
REST_HOST=Constants.REST_HOST
REST_HOST=REST_HOST
)
now = int(round(time.time() * 1000))

View File

@@ -3,10 +3,10 @@
import os
import time
from bfxapi.client import Client, Constants
from bfxapi.client import Client, REST_HOST
bfx = Client(
REST_HOST=Constants.REST_HOST,
REST_HOST=REST_HOST,
API_KEY=os.getenv("BFX_API_KEY"),
API_SECRET=os.getenv("BFX_API_SECRET")
)

View File

@@ -2,10 +2,10 @@
import time
from bfxapi.client import Client, Constants
from bfxapi.client import Client, REST_HOST
bfx = Client(
REST_HOST=Constants.REST_HOST
REST_HOST=REST_HOST
)
now = int(round(time.time() * 1000))

View File

@@ -2,10 +2,10 @@
import time
from bfxapi.client import Client, Constants
from bfxapi.client import Client, REST_HOST
bfx = Client(
REST_HOST=Constants.REST_HOST
REST_HOST=REST_HOST
)
now = int(round(time.time() * 1000))

View File

@@ -2,10 +2,10 @@
import os
from bfxapi.client import Client, Constants
from bfxapi.client import Client, REST_HOST
bfx = Client(
REST_HOST=Constants.REST_HOST,
REST_HOST=REST_HOST,
API_KEY=os.getenv("BFX_API_KEY"),
API_SECRET=os.getenv("BFX_API_SECRET")
)

View File

@@ -2,10 +2,10 @@
import os
from bfxapi.client import Client, Constants
from bfxapi.client import Client, REST_HOST
bfx = Client(
REST_HOST=Constants.REST_HOST,
REST_HOST=REST_HOST,
API_KEY=os.getenv("BFX_API_KEY"),
API_SECRET=os.getenv("BFX_API_SECRET")
)

View File

@@ -2,10 +2,10 @@
import os
from bfxapi.client import Client, Constants
from bfxapi.client import Client, REST_HOST
bfx = Client(
REST_HOST=Constants.REST_HOST,
REST_HOST=REST_HOST,
API_KEY=os.getenv("BFX_API_KEY"),
API_SECRET=os.getenv("BFX_API_SECRET")
)

View File

@@ -2,10 +2,10 @@
import os
from bfxapi.client import Client, Constants
from bfxapi.client import Client, REST_HOST
bfx = Client(
REST_HOST=Constants.REST_HOST,
REST_HOST=REST_HOST,
API_KEY=os.getenv("BFX_API_KEY"),
API_SECRET=os.getenv("BFX_API_SECRET")
)

View File

@@ -2,10 +2,10 @@
import os
from bfxapi.client import Client, Constants
from bfxapi.client import Client, REST_HOST
bfx = Client(
REST_HOST=Constants.REST_HOST,
REST_HOST=REST_HOST,
API_KEY=os.getenv("BFX_API_KEY"),
API_SECRET=os.getenv("BFX_API_SECRET")
)

View File

@@ -2,12 +2,12 @@
import os
from bfxapi.client import Client, Constants
from bfxapi.client import Client, WSS_HOST
from bfxapi.websocket.enums import Error, OrderType
from bfxapi.websocket.types import Notification, Order
bfx = Client(
WSS_HOST=Constants.WSS_HOST,
WSS_HOST=WSS_HOST,
API_KEY=os.getenv("BFX_API_KEY"),
API_SECRET=os.getenv("BFX_API_SECRET")
)

View File

@@ -4,7 +4,7 @@ from collections import OrderedDict
from typing import List
from bfxapi import Client, Constants
from bfxapi import Client, PUB_WSS_HOST
from bfxapi.websocket import subscriptions
from bfxapi.websocket.enums import Channel, Error
@@ -38,7 +38,7 @@ SYMBOLS = [ "tBTCUSD", "tLTCUSD", "tLTCBTC", "tETHUSD", "tETHBTC" ]
order_book = OrderBook(symbols=SYMBOLS)
bfx = Client(WSS_HOST=Constants.PUB_WSS_HOST)
bfx = Client(WSS_HOST=PUB_WSS_HOST)
@bfx.wss.on("wss-error")
def on_wss_error(code: Error, msg: str):

View File

@@ -4,7 +4,7 @@ from collections import OrderedDict
from typing import List
from bfxapi import Client, Constants
from bfxapi import Client, PUB_WSS_HOST
from bfxapi.websocket import subscriptions
from bfxapi.websocket.enums import Channel, Error
@@ -38,7 +38,7 @@ SYMBOLS = [ "tBTCUSD", "tLTCUSD", "tLTCBTC", "tETHUSD", "tETHBTC" ]
raw_order_book = RawOrderBook(symbols=SYMBOLS)
bfx = Client(WSS_HOST=Constants.PUB_WSS_HOST)
bfx = Client(WSS_HOST=PUB_WSS_HOST)
@bfx.wss.on("wss-error")
def on_wss_error(code: Error, msg: str):

View File

@@ -1,12 +1,12 @@
# python -c "import examples.websocket.ticker"
from bfxapi import Client, Constants
from bfxapi import Client, PUB_WSS_HOST
from bfxapi.websocket import subscriptions
from bfxapi.websocket.enums import Channel
from bfxapi.websocket.types import TradingPairTicker
bfx = Client(WSS_HOST=Constants.PUB_WSS_HOST)
bfx = Client(WSS_HOST=PUB_WSS_HOST)
@bfx.wss.on("t_ticker_update")
def on_t_ticker_update(subscription: subscriptions.Ticker, data: TradingPairTicker):