-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FTX REST bootstrapping, websocket is missing orderbook channel and ex…
…ample ftx.ws client is working.
- Loading branch information
1 parent
58e19fb
commit 4e1cf67
Showing
58 changed files
with
1,308 additions
and
427 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
.github/ISSUE_TEMPLATES/ccip---ccex-improvement-proposal.md
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,19 @@ | ||
--- | ||
name: CCIP - CCEX Improvement Proposal | ||
about: Suggest an idea for this project | ||
title: "[CCIP]" | ||
labels: '' | ||
assignees: murlokito | ||
--- | ||
|
||
**Is your feature request related to a problem? Please describe.** | ||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||
|
||
**Describe the solution you'd like** | ||
A clear and concise description of what you want to happen. | ||
|
||
**Describe alternatives you've considered** | ||
A clear and concise description of any alternative solutions or features you've considered. | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the feature request here. |
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,31 @@ | ||
--- | ||
name: Issues / Bug Reports | ||
about: Create a report to help us improve | ||
title: "[Issue]" | ||
labels: '' | ||
assignees: murlokito | ||
--- | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
|
||
**To Reproduce** | ||
Steps to reproduce the behavior: | ||
1. Go to '...' | ||
2. Click on '....' | ||
3. Scroll down to '....' | ||
4. See error | ||
|
||
**Expected behavior** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**Screenshots** | ||
If applicable, add screenshots to help explain your problem. | ||
|
||
**Desktop (please complete the following information):** | ||
- OS: [e.g. iOS] | ||
- Browser [e.g. chrome, safari] | ||
- Version [e.g. 22] | ||
|
||
**Additional context** | ||
Add any other context about the problem here. |
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
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,4 +1,4 @@ | ||
package ccex | ||
package builder | ||
|
||
const ( | ||
Binance = iota | ||
|
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
|
@@ -7,4 +7,4 @@ const ( | |
Spot = iota | ||
Futures | ||
Options | ||
) | ||
) |
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 |
---|---|---|
|
@@ -7,6 +7,4 @@ const ( | |
LimitOrder = iota | ||
MarketOrder | ||
TriggerOrder | ||
) | ||
|
||
|
||
) |
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
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
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
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,41 +1,78 @@ | ||
package ftx | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/murlokito/ccex/auth" | ||
"github.com/murlokito/ccex/builder" | ||
"github.com/murlokito/ccex/config" | ||
"github.com/murlokito/ccex/ftx" | ||
"github.com/murlokito/ccex/ftx/websocket" | ||
"github.com/murlokito/ccex/ftx/websocket/models" | ||
"time" | ||
) | ||
|
||
type Data struct { | ||
Trades map[string][]models.TradeData | ||
Ticker map[string]models.TickerData | ||
} | ||
|
||
func main() { | ||
|
||
cfg := &config.Configuration{ | ||
Auth: &auth.Authentication{ | ||
Key: "some-key", | ||
Secret: "some-secret", | ||
}, | ||
SubAccount: "some-sub-account", | ||
markets := []string{ | ||
"BTC-PERP", "ETH-PERP", | ||
} | ||
|
||
ftxClient, err := builder.NewFTXClient(cfg) | ||
if err != nil { | ||
fmt.Printf("err: %v", err) | ||
data := Data{ | ||
Trades: map[string][]models.TradeData{}, | ||
Ticker: map[string]models.TickerData{}, | ||
} | ||
|
||
handler := func(message models.TickerMessage) { | ||
fmt.Printf("bid: %v ask: %v last: %v", message.Data.Bid, message.Data.Ask, message.Data.Last) | ||
tickerHandler := func(message models.TickerMessage) { | ||
//fmt.Printf("bid: %v ask: %v last: %v\n", message.Data.Bid, message.Data.Ask, message.Data.Last) | ||
data.Ticker[message.Market] = message.Data | ||
} | ||
|
||
err = ftxClient.Websocket.TickerHandler(handler) | ||
if err != nil { | ||
fmt.Printf("err: %v", err) | ||
tradeHandler := func(message models.TradeMessage) { | ||
//complete := fmt.Sprintf("num trades: %v", len(message.Data)) | ||
for _, trade := range message.Data { | ||
data.Trades[message.Market] = append(data.Trades[message.Market], trade) | ||
//str := fmt.Sprintf("price: %v size: %v side: %v liq: %v\n", trade.Price, trade.Price, trade.Side, trade.Liquidation) | ||
//complete += str | ||
tradeVol := trade.Size * trade.Price | ||
if tradeVol > 100000 { | ||
fmt.Printf("{%v} {%v} Volume: $%.2f Price: $%v Liquidation: %v\n", message.Market, trade.Side, tradeVol, trade.Price, trade.Liquidation) | ||
} | ||
} | ||
//fmt.Println(complete) | ||
} | ||
|
||
err = ftxClient.Websocket.Subscribe(websocket.Ticker, "BTC-PERP") | ||
ftxClient, err := ftx.NewFTXClient(nil, nil, tickerHandler, tradeHandler, nil) | ||
if err != nil { | ||
fmt.Printf("err: %v", err) | ||
} | ||
|
||
ftxClient.Websocket.Connect() | ||
|
||
for _, market := range markets { | ||
err = ftxClient.Websocket.Subscribe(websocket.Ticker, market) | ||
if err != nil { | ||
fmt.Printf("err: %v", err) | ||
} | ||
|
||
err = ftxClient.Websocket.Subscribe(websocket.Trades, market) | ||
if err != nil { | ||
fmt.Printf("err: %v", err) | ||
} | ||
} | ||
|
||
for { | ||
if ftxClient.Websocket.Connected() { | ||
fmt.Println(fmt.Sprintf("client is connected - active subs %v", ftxClient.Websocket.Subscriptions())) | ||
} | ||
for k, v := range data.Trades { | ||
fmt.Println(fmt.Sprintf("number of trades for %v - %v", k, len(v))) | ||
} | ||
for k, v := range data.Ticker { | ||
fmt.Println(fmt.Sprintf("latest ticker for %v - %v", k, v.Last)) | ||
} | ||
time.Sleep(15 * time.Second) | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
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,3 @@ | ||
# exchange | ||
|
||
This package specifies library-wide interfaces and constants. |
Oops, something went wrong.