ArsenAbazian / CryptoTradingFramework

A self hosted, cryptocurrency trading bot and framework supporting multiple exchanges with GUI
Other
176 stars 80 forks source link

About add Futures module #23

Open xyong6024 opened 2 years ago

xyong6024 commented 2 years ago

Hello, I'm a little tangled after studying the code. I want to add the Futures module of Binance, so I should add a new Exchange "Binance Futures" or add a Futures market in "Binance Exchange".

From the perspective of program logic, adding "Binance Futures" Exchange has minimal changes. I just need to copy a copy of Binance's Exchange module code, register it as a new Exchange, and then replace all the API addresses in the function with Futures API,However, this does not conform to the business logic. image

which will lead to one more exchange for every Futures added to a Exchange platform. However, if I add a future market in "Binance" exchange, because I refer to the same exchange class module, I will copy all the original functions, resulting in two sets of functions with the same function in the same Class, This is not in line with the development idea and is not conducive to expansion, so I want to ask you what is the most appropriate, thanks image

ArsenAbazian commented 2 years ago

Hi!

From the perspective of program logic, adding "Binance Futures" Exchange has minimal changes. I just need to copy a copy of Binance's Exchange module code, register it as a new Exchange, and then replace all the API addresses in the function with Futures API. However, this does not conform to the business logic.

I like this approach more. I started already to add a new Binance Future Exchange which is a descendant of BinanceExchange. While I did not implement all functionality (missed while Buy, Sell e.t.c), it already lists all tickers from the exchange, shows order book, and trade history. It is not difficult to add missed functionality, but it takes time.

However, I found a bug (showstopper) in CryptoMarketClient while tested BinanceFutures. When you open the ticker's screen (chart and order book) after several seconds exception is raised.

image

I need time to fix it. BTW I updated the project so you can start to use BinanceFutures Exchange.

Thanks, Arsen.

xyong6024 commented 2 years ago

It should be that your account information is not updated correctly. "Binance future" uses an independent account, so the API is also different, but you still inherit the updatebalance method of the binance parent class Including “My Trades” and “Open order”, which have not been updated

xyong6024 commented 2 years ago

image image

ArsenAbazian commented 2 years ago

Hi xyong

It should be that your account information is not updated correctly.

Yes... to be more correct - you should check the futures check-box in your API key settings (at binance site). And there was a bug in BinanceFuturesModel. There are two methods GetBalances and UpdateBalances (should do something with it), and I did not use BalancesApiKey in UpdateBalancesMethod. There are also other bugs, which I fixed. I tested it with my new API key, supporting futures. Everything worked. I had to fix InvalidOperationException first because I can't work with OpenedOrders and MyTrades. I'll get back to you when I have the results.

For now, you can update your project and check Binance Futures Balances on your side.

I thought more... I did not check the scenario when you check both "fiat and spot" & futures check-box... Do it later

Thanks, Arsen.

xyong6024 commented 2 years ago

Hi xyong

It should be that your account information is not updated correctly.

Yes... to be more correct - you should check the futures check-box in your API key settings (at binance site). And there was a bug in BinanceFuturesModel. There are two methods GetBalances and UpdateBalances (should do something with it), and I did not use BalancesApiKey in UpdateBalancesMethod. There are also other bugs, which I fixed. I tested it with my new API key, supporting futures. Everything worked. I had to fix InvalidOperationException first because I can't work with OpenedOrders and MyTrades. I'll get back to you when I have the results.

For now, you can update your project and check Binance Futures Balances on your side.

I thought more... I did not check the scenario when you check both "fiat and spot" & futures check-box... Do it later

Thanks, Arsen.

I'm looking forward to your good news,thanks

xiuxiang commented 2 years ago

I'm also looking forward to binance Futures, if the api is complete