|
@@ -8,6 +8,7 @@ import (
|
|
"flag"
|
|
"flag"
|
|
"fmt"
|
|
"fmt"
|
|
"io"
|
|
"io"
|
|
|
|
+ "io/ioutil"
|
|
"log"
|
|
"log"
|
|
"net/http"
|
|
"net/http"
|
|
"os"
|
|
"os"
|
|
@@ -23,6 +24,24 @@ import (
|
|
"tickserver/server/market"
|
|
"tickserver/server/market"
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+type Hadax struct {
|
|
|
|
+ Status string `json:"status"`
|
|
|
|
+ Ch string `json:"ch"`
|
|
|
|
+ Ts int64 `json:"ts"`
|
|
|
|
+ Data []Kdata `json:"data"`
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+type Kdata struct {
|
|
|
|
+ Id int64 `json:"id"`
|
|
|
|
+ Open float64 `json:"open"`
|
|
|
|
+ Close float64 `json:"close"`
|
|
|
|
+ Low float64 `json:"low"`
|
|
|
|
+ High float64 `json:"high"`
|
|
|
|
+ Amount float64 `json:"amount"`
|
|
|
|
+ Vol float64 `json:"vol"`
|
|
|
|
+ Count int64 `json:"count"`
|
|
|
|
+}
|
|
|
|
+
|
|
type RealTick struct {
|
|
type RealTick struct {
|
|
tg base.TickGo
|
|
tg base.TickGo
|
|
//tgCh <-chan base.TickGo
|
|
//tgCh <-chan base.TickGo
|
|
@@ -129,91 +148,296 @@ func readConf() (*Conf, error) {
|
|
func getStringSTK(stk SpecialTick, insId string) StringSpecialTick {
|
|
func getStringSTK(stk SpecialTick, insId string) StringSpecialTick {
|
|
sstk := StringSpecialTick{
|
|
sstk := StringSpecialTick{
|
|
Timestamp: fmt.Sprintf("%d", stk.Timestamp),
|
|
Timestamp: fmt.Sprintf("%d", stk.Timestamp),
|
|
- Open: fmt.Sprintf("%.4f", stk.Open),
|
|
|
|
}
|
|
}
|
|
switch insId {
|
|
switch insId {
|
|
case "bty_BCCBTC":
|
|
case "bty_BCCBTC":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.4f", stk.Open)
|
|
sstk.Last = fmt.Sprintf("%.4f", stk.Last)
|
|
sstk.Last = fmt.Sprintf("%.4f", stk.Last)
|
|
sstk.High = fmt.Sprintf("%.4f", stk.High)
|
|
sstk.High = fmt.Sprintf("%.4f", stk.High)
|
|
sstk.Low = fmt.Sprintf("%.4f", stk.Low)
|
|
sstk.Low = fmt.Sprintf("%.4f", stk.Low)
|
|
sstk.Volume = fmt.Sprintf("%.4f", stk.Volume)
|
|
sstk.Volume = fmt.Sprintf("%.4f", stk.Volume)
|
|
case "bty_ETHBTC":
|
|
case "bty_ETHBTC":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.5f", stk.Open)
|
|
sstk.Last = fmt.Sprintf("%.5f", stk.Last)
|
|
sstk.Last = fmt.Sprintf("%.5f", stk.Last)
|
|
sstk.High = fmt.Sprintf("%.5f", stk.High)
|
|
sstk.High = fmt.Sprintf("%.5f", stk.High)
|
|
sstk.Low = fmt.Sprintf("%.5f", stk.Low)
|
|
sstk.Low = fmt.Sprintf("%.5f", stk.Low)
|
|
sstk.Volume = fmt.Sprintf("%.3f", stk.Volume)
|
|
sstk.Volume = fmt.Sprintf("%.3f", stk.Volume)
|
|
case "bty_ETCBTC":
|
|
case "bty_ETCBTC":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.6f", stk.Open)
|
|
sstk.Last = fmt.Sprintf("%.6f", stk.Last)
|
|
sstk.Last = fmt.Sprintf("%.6f", stk.Last)
|
|
sstk.High = fmt.Sprintf("%.6f", stk.High)
|
|
sstk.High = fmt.Sprintf("%.6f", stk.High)
|
|
sstk.Low = fmt.Sprintf("%.6f", stk.Low)
|
|
sstk.Low = fmt.Sprintf("%.6f", stk.Low)
|
|
sstk.Volume = fmt.Sprintf("%.2f", stk.Volume)
|
|
sstk.Volume = fmt.Sprintf("%.2f", stk.Volume)
|
|
case "bty_ZECBTC":
|
|
case "bty_ZECBTC":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.5f", stk.Open)
|
|
sstk.Last = fmt.Sprintf("%.5f", stk.Last)
|
|
sstk.Last = fmt.Sprintf("%.5f", stk.Last)
|
|
sstk.High = fmt.Sprintf("%.5f", stk.High)
|
|
sstk.High = fmt.Sprintf("%.5f", stk.High)
|
|
sstk.Low = fmt.Sprintf("%.5f", stk.Low)
|
|
sstk.Low = fmt.Sprintf("%.5f", stk.Low)
|
|
sstk.Volume = fmt.Sprintf("%.3f", stk.Volume)
|
|
sstk.Volume = fmt.Sprintf("%.3f", stk.Volume)
|
|
case "bty_LTCBTC":
|
|
case "bty_LTCBTC":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.6f", stk.Open)
|
|
sstk.Last = fmt.Sprintf("%.6f", stk.Last)
|
|
sstk.Last = fmt.Sprintf("%.6f", stk.Last)
|
|
sstk.High = fmt.Sprintf("%.6f", stk.High)
|
|
sstk.High = fmt.Sprintf("%.6f", stk.High)
|
|
sstk.Low = fmt.Sprintf("%.6f", stk.Low)
|
|
sstk.Low = fmt.Sprintf("%.6f", stk.Low)
|
|
sstk.Volume = fmt.Sprintf("%.2f", stk.Volume)
|
|
sstk.Volume = fmt.Sprintf("%.2f", stk.Volume)
|
|
case "bty_BTCUSDT":
|
|
case "bty_BTCUSDT":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.2f", stk.Open)
|
|
sstk.Last = fmt.Sprintf("%.2f", stk.Last)
|
|
sstk.Last = fmt.Sprintf("%.2f", stk.Last)
|
|
sstk.High = fmt.Sprintf("%.2f", stk.High)
|
|
sstk.High = fmt.Sprintf("%.2f", stk.High)
|
|
sstk.Low = fmt.Sprintf("%.2f", stk.Low)
|
|
sstk.Low = fmt.Sprintf("%.2f", stk.Low)
|
|
sstk.Volume = fmt.Sprintf("%.4f", stk.Volume)
|
|
sstk.Volume = fmt.Sprintf("%.4f", stk.Volume)
|
|
case "bty_BCCUSDT":
|
|
case "bty_BCCUSDT":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.2f", stk.Open)
|
|
sstk.Last = fmt.Sprintf("%.2f", stk.Last)
|
|
sstk.Last = fmt.Sprintf("%.2f", stk.Last)
|
|
sstk.High = fmt.Sprintf("%.2f", stk.High)
|
|
sstk.High = fmt.Sprintf("%.2f", stk.High)
|
|
sstk.Low = fmt.Sprintf("%.2f", stk.Low)
|
|
sstk.Low = fmt.Sprintf("%.2f", stk.Low)
|
|
sstk.Volume = fmt.Sprintf("%.4f", stk.Volume)
|
|
sstk.Volume = fmt.Sprintf("%.4f", stk.Volume)
|
|
case "bty_ETHUSDT":
|
|
case "bty_ETHUSDT":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.2f", stk.Open)
|
|
sstk.Last = fmt.Sprintf("%.2f", stk.Last)
|
|
sstk.Last = fmt.Sprintf("%.2f", stk.Last)
|
|
sstk.High = fmt.Sprintf("%.2f", stk.High)
|
|
sstk.High = fmt.Sprintf("%.2f", stk.High)
|
|
sstk.Low = fmt.Sprintf("%.2f", stk.Low)
|
|
sstk.Low = fmt.Sprintf("%.2f", stk.Low)
|
|
sstk.Volume = fmt.Sprintf("%.3f", stk.Volume)
|
|
sstk.Volume = fmt.Sprintf("%.3f", stk.Volume)
|
|
case "bty_ETCUSDT":
|
|
case "bty_ETCUSDT":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.2f", stk.Open)
|
|
sstk.Last = fmt.Sprintf("%.2f", stk.Last)
|
|
sstk.Last = fmt.Sprintf("%.2f", stk.Last)
|
|
sstk.High = fmt.Sprintf("%.2f", stk.High)
|
|
sstk.High = fmt.Sprintf("%.2f", stk.High)
|
|
sstk.Low = fmt.Sprintf("%.2f", stk.Low)
|
|
sstk.Low = fmt.Sprintf("%.2f", stk.Low)
|
|
sstk.Volume = fmt.Sprintf("%.2f", stk.Volume)
|
|
sstk.Volume = fmt.Sprintf("%.2f", stk.Volume)
|
|
case "bty_ZECUSDT":
|
|
case "bty_ZECUSDT":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.2f", stk.Open)
|
|
sstk.Last = fmt.Sprintf("%.2f", stk.Last)
|
|
sstk.Last = fmt.Sprintf("%.2f", stk.Last)
|
|
sstk.High = fmt.Sprintf("%.2f", stk.High)
|
|
sstk.High = fmt.Sprintf("%.2f", stk.High)
|
|
sstk.Low = fmt.Sprintf("%.2f", stk.Low)
|
|
sstk.Low = fmt.Sprintf("%.2f", stk.Low)
|
|
sstk.Volume = fmt.Sprintf("%.3f", stk.Volume)
|
|
sstk.Volume = fmt.Sprintf("%.3f", stk.Volume)
|
|
case "bty_LTCUSDT":
|
|
case "bty_LTCUSDT":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.2f", stk.Open)
|
|
sstk.Last = fmt.Sprintf("%.2f", stk.Last)
|
|
sstk.Last = fmt.Sprintf("%.2f", stk.Last)
|
|
sstk.High = fmt.Sprintf("%.2f", stk.High)
|
|
sstk.High = fmt.Sprintf("%.2f", stk.High)
|
|
sstk.Low = fmt.Sprintf("%.2f", stk.Low)
|
|
sstk.Low = fmt.Sprintf("%.2f", stk.Low)
|
|
sstk.Volume = fmt.Sprintf("%.2f", stk.Volume)
|
|
sstk.Volume = fmt.Sprintf("%.2f", stk.Volume)
|
|
case "bty_YCCUSDT":
|
|
case "bty_YCCUSDT":
|
|
- fallthrough
|
|
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.6f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.6f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.6f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.6f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.0f", stk.Volume)
|
|
case "bty_BTYUSDT":
|
|
case "bty_BTYUSDT":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.4f", stk.Open)
|
|
sstk.Last = fmt.Sprintf("%.4f", stk.Last)
|
|
sstk.Last = fmt.Sprintf("%.4f", stk.Last)
|
|
sstk.High = fmt.Sprintf("%.4f", stk.High)
|
|
sstk.High = fmt.Sprintf("%.4f", stk.High)
|
|
sstk.Low = fmt.Sprintf("%.4f", stk.Low)
|
|
sstk.Low = fmt.Sprintf("%.4f", stk.Low)
|
|
sstk.Volume = fmt.Sprintf("%.1f", stk.Volume)
|
|
sstk.Volume = fmt.Sprintf("%.1f", stk.Volume)
|
|
case "bty_BTCSUSDT":
|
|
case "bty_BTCSUSDT":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.2f", stk.Open)
|
|
sstk.Last = fmt.Sprintf("%.2f", stk.Last)
|
|
sstk.Last = fmt.Sprintf("%.2f", stk.Last)
|
|
sstk.High = fmt.Sprintf("%.2f", stk.High)
|
|
sstk.High = fmt.Sprintf("%.2f", stk.High)
|
|
sstk.Low = fmt.Sprintf("%.2f", stk.Low)
|
|
sstk.Low = fmt.Sprintf("%.2f", stk.Low)
|
|
sstk.Volume = fmt.Sprintf("%.2f", stk.Volume)
|
|
sstk.Volume = fmt.Sprintf("%.2f", stk.Volume)
|
|
case "bty_SCUSDT":
|
|
case "bty_SCUSDT":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.6f", stk.Open)
|
|
sstk.Last = fmt.Sprintf("%.6f", stk.Last)
|
|
sstk.Last = fmt.Sprintf("%.6f", stk.Last)
|
|
sstk.High = fmt.Sprintf("%.6f", stk.High)
|
|
sstk.High = fmt.Sprintf("%.6f", stk.High)
|
|
sstk.Low = fmt.Sprintf("%.6f", stk.Low)
|
|
sstk.Low = fmt.Sprintf("%.6f", stk.Low)
|
|
sstk.Volume = fmt.Sprintf("%.0f", stk.Volume)
|
|
sstk.Volume = fmt.Sprintf("%.0f", stk.Volume)
|
|
case "bty_BTSUSDT":
|
|
case "bty_BTSUSDT":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.4f", stk.Open)
|
|
sstk.Last = fmt.Sprintf("%.4f", stk.Last)
|
|
sstk.Last = fmt.Sprintf("%.4f", stk.Last)
|
|
sstk.High = fmt.Sprintf("%.4f", stk.High)
|
|
sstk.High = fmt.Sprintf("%.4f", stk.High)
|
|
sstk.Low = fmt.Sprintf("%.4f", stk.Low)
|
|
sstk.Low = fmt.Sprintf("%.4f", stk.Low)
|
|
sstk.Volume = fmt.Sprintf("%.2f", stk.Volume)
|
|
sstk.Volume = fmt.Sprintf("%.2f", stk.Volume)
|
|
case "bty_DCRUSDT":
|
|
case "bty_DCRUSDT":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.2f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.2f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.2f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.2f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.2f", stk.Volume)
|
|
|
|
+ case "bty_BNTUSDT":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.4f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.4f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.4f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.4f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.0f", stk.Volume)
|
|
|
|
+ case "bty_BNTBTC":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.8f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.8f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.8f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.8f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.0f", stk.Volume)
|
|
|
|
+ case "bty_SCTCUSDT":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.6f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.6f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.6f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.6f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.0f", stk.Volume)
|
|
|
|
+ case "bty_SCTCBTC":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.8f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.8f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.8f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.8f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.0f", stk.Volume)
|
|
|
|
+ case "bty_YCCBTC":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.8f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.8f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.8f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.8f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.0f", stk.Volume)
|
|
|
|
+ case "bty_YCCETH":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.8f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.8f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.8f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.8f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.0f", stk.Volume)
|
|
|
|
+ case "bty_JBUSDT":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.4f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.4f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.4f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.4f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.0f", stk.Volume)
|
|
|
|
+ case "bty_JBBTC":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.8f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.8f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.8f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.8f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.0f", stk.Volume)
|
|
|
|
+ case "bty_JBETH":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.6f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.6f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.6f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.6f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.0f", stk.Volume)
|
|
|
|
+ case "bty_OPTCUSDT":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.4f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.4f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.4f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.4f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.0f", stk.Volume)
|
|
|
|
+ case "bty_OPTCBTC":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.8f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.8f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.8f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.8f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.0f", stk.Volume)
|
|
|
|
+ case "bty_OPTCETH":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.8f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.8f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.8f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.8f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.0f", stk.Volume)
|
|
|
|
+ case "bty_BTCETH":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.4f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.4f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.4f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.4f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.4f", stk.Volume)
|
|
|
|
+ case "bty_BCCETH":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.4f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.4f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.4f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.4f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.4f", stk.Volume)
|
|
|
|
+ case "bty_ZECETH":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.3f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.3f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.3f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.3f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.5f", stk.Volume)
|
|
|
|
+ case "bty_ETCETH":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.2f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.2f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.2f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.2f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.6f", stk.Volume)
|
|
|
|
+ case "bty_LTCETH":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.3f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.3f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.3f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.3f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.5f", stk.Volume)
|
|
|
|
+ case "bty_STILT":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.2f", stk.Open)
|
|
sstk.Last = fmt.Sprintf("%.2f", stk.Last)
|
|
sstk.Last = fmt.Sprintf("%.2f", stk.Last)
|
|
sstk.High = fmt.Sprintf("%.2f", stk.High)
|
|
sstk.High = fmt.Sprintf("%.2f", stk.High)
|
|
sstk.Low = fmt.Sprintf("%.2f", stk.Low)
|
|
sstk.Low = fmt.Sprintf("%.2f", stk.Low)
|
|
sstk.Volume = fmt.Sprintf("%.2f", stk.Volume)
|
|
sstk.Volume = fmt.Sprintf("%.2f", stk.Volume)
|
|
|
|
+ case "bty_ITVBUSDT":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.4f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.4f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.4f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.4f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.0f", stk.Volume)
|
|
|
|
+ case "bty_ITVBBTC":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.8f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.8f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.8f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.8f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.0f", stk.Volume)
|
|
|
|
+ case "bty_ITVBETH":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.8f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.8f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.8f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.8f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.0f", stk.Volume)
|
|
|
|
+ case "bty_BTYETH":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.8f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.8f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.8f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.8f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.0f", stk.Volume)
|
|
|
|
+ case "bty_FHUSDT":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.5f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.5f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.5f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.5f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.1f", stk.Volume)
|
|
|
|
+ case "bty_CWVUSDT":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.6f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.6f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.6f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.6f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.0f", stk.Volume)
|
|
|
|
+ case "bty_FHETH":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.7f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.7f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.7f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.7f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.1f", stk.Volume)
|
|
|
|
+ case "bty_TMCETH":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.7f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.7f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.7f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.7f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.1f", stk.Volume)
|
|
|
|
+ case "bty_FANSUSDT":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.5f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.5f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.5f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.5f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.1f", stk.Volume)
|
|
|
|
+ case "bty_FANSBTC":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.7f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.7f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.7f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.7f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.1f", stk.Volume)
|
|
|
|
+ case "bty_FANSETH":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.7f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.7f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.7f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.7f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.1f", stk.Volume)
|
|
|
|
+ case "bty_WTBWTC":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.7f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.7f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.7f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.7f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.1f", stk.Volume)
|
|
|
|
+ case "bty_CNSUSDT":
|
|
|
|
+ sstk.Open = fmt.Sprintf("%.5f", stk.Open)
|
|
|
|
+ sstk.Last = fmt.Sprintf("%.5f", stk.Last)
|
|
|
|
+ sstk.High = fmt.Sprintf("%.5f", stk.High)
|
|
|
|
+ sstk.Low = fmt.Sprintf("%.5f", stk.Low)
|
|
|
|
+ sstk.Volume = fmt.Sprintf("%.1f", stk.Volume)
|
|
default:
|
|
default:
|
|
}
|
|
}
|
|
|
|
|
|
@@ -262,6 +486,14 @@ func h24Handler(w http.ResponseWriter, r *http.Request) {
|
|
var candles []client.Candle
|
|
var candles []client.Candle
|
|
insId := typ + "_" + symbol
|
|
insId := typ + "_" + symbol
|
|
bufcandles, err := clientDown.GetLastCandles(insId, market.H1, 24)
|
|
bufcandles, err := clientDown.GetLastCandles(insId, market.H1, 24)
|
|
|
|
+ /*if insId == "bty_BTCUSDT" {
|
|
|
|
+ for i, _ := range bufcandles {
|
|
|
|
+ if bufcandles[i].Open == 7000 && (bufcandles[i].Timestamp >= 1528941600000 && bufcandles[i].Timestamp <= 1528945200000) {
|
|
|
|
+ bufcandles[i].High = 6468.7001953125
|
|
|
|
+ bufcandles[i].Open = 6269.2998046875
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }*/
|
|
/*for i, _ := range bufcandles {
|
|
/*for i, _ := range bufcandles {
|
|
if insId == "bty_ETHUSDT" {
|
|
if insId == "bty_ETHUSDT" {
|
|
if bufcandles[i].Timestamp >= 1524031200000 && bufcandles[i].Timestamp <= 1524031200000 {
|
|
if bufcandles[i].Timestamp >= 1524031200000 && bufcandles[i].Timestamp <= 1524031200000 {
|
|
@@ -353,6 +585,31 @@ func h24Handler(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
|
var stk SpecialTick
|
|
var stk SpecialTick
|
|
if len(candles) > 0 {
|
|
if len(candles) > 0 {
|
|
|
|
+ candlesOk := make([]client.Candle, len(candles))
|
|
|
|
+ begin, end := getTimeRange()
|
|
|
|
+ begin *= 1000
|
|
|
|
+ end *= 1000
|
|
|
|
+ pos := 0
|
|
|
|
+ for i := 0; i < len(candles); i++ {
|
|
|
|
+ if candles[i].Timestamp >= begin && candles[i].Timestamp <= end {
|
|
|
|
+ candlesOk[pos] = candles[i]
|
|
|
|
+ pos++
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if pos == 0 {
|
|
|
|
+ candlesHadax := getHadax(strings.ToLower(symbol), "60min", 24)
|
|
|
|
+ if len(candlesHadax) > 0 {
|
|
|
|
+ candles = candlesHadax[:]
|
|
|
|
+ } else {
|
|
|
|
+ leng := len(candles)
|
|
|
|
+ candles = candles[leng-1 : leng]
|
|
|
|
+ candles[0].Open = candles[0].Close
|
|
|
|
+ candles[0].High = candles[0].Close
|
|
|
|
+ candles[0].Low = candles[0].Close
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ candles = candlesOk[:pos]
|
|
|
|
+ }
|
|
stk.Low = candles[0].Low
|
|
stk.Low = candles[0].Low
|
|
stk.Open = candles[0].Open
|
|
stk.Open = candles[0].Open
|
|
stk.Timestamp = candles[0].Timestamp / 1000
|
|
stk.Timestamp = candles[0].Timestamp / 1000
|
|
@@ -1207,6 +1464,53 @@ func makeGzipHandler(fn http.HandlerFunc) http.HandlerFunc {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func getHadax(sym, per string, size int) []client.Candle {
|
|
|
|
+ url := fmt.Sprintf("https://api.hadax.com/market/history/kline?period=%s&size=%d&symbol=%s", per, size, sym)
|
|
|
|
+ response, err := http.Get(url)
|
|
|
|
+ if err != nil {
|
|
|
|
+ log.Println(err)
|
|
|
|
+ return nil
|
|
|
|
+ }
|
|
|
|
+ body, err := ioutil.ReadAll(response.Body)
|
|
|
|
+ if err != nil {
|
|
|
|
+ log.Println(err)
|
|
|
|
+ return nil
|
|
|
|
+ }
|
|
|
|
+ var data Hadax
|
|
|
|
+ err = json.Unmarshal(body, &data)
|
|
|
|
+ if err != nil {
|
|
|
|
+ log.Println(err)
|
|
|
|
+ return nil
|
|
|
|
+ }
|
|
|
|
+ response.Body.Close()
|
|
|
|
+ //log.Println(data)
|
|
|
|
+ datalen := len(data.Data)
|
|
|
|
+ if datalen > 0 {
|
|
|
|
+ candles := make([]client.Candle, datalen)
|
|
|
|
+ for i := datalen - 1; i >= 0; i-- {
|
|
|
|
+ candles[(datalen-1)-i].Timestamp = data.Data[i].Id * 1000
|
|
|
|
+ if per == "1day" {
|
|
|
|
+ candles[(datalen-1)-i].Timestamp += 8 * 60 * 60 * 1000
|
|
|
|
+ }
|
|
|
|
+ candles[(datalen-1)-i].Open = data.Data[i].Open
|
|
|
|
+ candles[(datalen-1)-i].High = data.Data[i].High
|
|
|
|
+ candles[(datalen-1)-i].Low = data.Data[i].Low
|
|
|
|
+ candles[(datalen-1)-i].Close = data.Data[i].Close
|
|
|
|
+ candles[(datalen-1)-i].RealVolums = data.Data[i].Amount
|
|
|
|
+ candles[(datalen-1)-i].TickVolums = float64(data.Data[i].Count)
|
|
|
|
+ }
|
|
|
|
+ return candles
|
|
|
|
+ }
|
|
|
|
+ return nil
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func getTimeRange() (begin int64, end int64) {
|
|
|
|
+ now := time.Now().Unix()
|
|
|
|
+ end = now - now%3600
|
|
|
|
+ begin = end - 24*3600
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
func main() {
|
|
func main() {
|
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
|
conf, err := readConf()
|
|
conf, err := readConf()
|