Skip to content

Commit

Permalink
ff
Browse files Browse the repository at this point in the history
  • Loading branch information
t0mk committed Feb 2, 2024
1 parent 039e1f6 commit 02f22cc
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,21 +342,31 @@ func main() {
fmt.Printf("Symbol \"%s\" not found\n", symbol)
return
}

fmt.Println("Found symbols:")
for _, v := range found {
fmt.Println(v)
}
if strings.Contains(cmd, "!") {
fmt.Println("Getting prices...")
tickerChannel := getExTickPriAsync(found)

for _, v := range found {
go getExchangeTickerPriceAsync(v, tickerChannel)
}
for i := 0; i < len(found); i++ {
etp := <-tickerChannel
fmt.Println(etp)
}
if strings.Contains(cmd, "!") {
tickerChannel := getExTickPriChan(found)
CollectExTickPrisFromChannel(tickerChannel, len(found))
/*
fmt.Println("Getting prices...")
tickerChannel := getExTickPriChan(found)
for _, v := range found {
fmt.Println("getting price for", v)
go getExchangeTickerPriceAsync(v, tickerChannel)
}
for i := 0; i < len(found); i++ {
etp := <-tickerChannel
fmt.Println(etp)
}
for _, v := range result {
fmt.Println(v)
}
*/
}
} else if stringIsInSlice(cmd, arbitrageCommands) {
arbName := os.Args[2]
Expand Down Expand Up @@ -402,13 +412,13 @@ func CollectArbResultsFromChannel(channel chan ArbResult, n int) ArbResults {
}

func ExTicksToArbResult(ets ExTickSet) ArbResult {
tickerChannel := getExTickPriAsync(ets.ExTicks)
tickerChannel := getExTickPriChan(ets.ExTicks)
result := CollectExTickPrisFromChannel(tickerChannel, len(ets.ExTicks))
arbResult := ExTickPrisToArbResult(ets.Name, result)
return arbResult
}

func getExTickPriAsync(tickers []ExTick) chan *ExTickPri {
func getExTickPriChan(tickers []ExTick) chan *ExTickPri {
tickerChannel := make(chan *ExTickPri)
for _, v := range tickers {
go getExchangeTickerPriceAsync(v, tickerChannel)
Expand Down

0 comments on commit 02f22cc

Please sign in to comment.