Skip to content

Commit

Permalink
refactor: repo name change
Browse files Browse the repository at this point in the history
  • Loading branch information
richklee committed May 20, 2022
1 parent 488c404 commit 0776baa
Show file tree
Hide file tree
Showing 70 changed files with 235 additions and 230 deletions.
6 changes: 3 additions & 3 deletions broker/backtest/backtest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"time"

"github.com/stretchr/testify/assert"
"github.com/thecolngroup/zerotoalgo/broker"
"github.com/thecolngroup/zerotoalgo/internal/dec"
"github.com/thecolngroup/zerotoalgo/market"
"github.com/thecolngroup/alphakit/broker"
"github.com/thecolngroup/alphakit/internal/dec"
"github.com/thecolngroup/alphakit/market"
)

func TestLongTradeWithCosts(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion broker/backtest/coster.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"time"

"github.com/shopspring/decimal"
"github.com/thecolngroup/zerotoalgo/broker"
"github.com/thecolngroup/alphakit/broker"
)

type Coster interface {
Expand Down
16 changes: 8 additions & 8 deletions broker/backtest/dealer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"context"

"github.com/shopspring/decimal"
"github.com/thecolngroup/zerotoalgo/broker"
"github.com/thecolngroup/zerotoalgo/market"
"github.com/thecolngroup/zerotoalgo/netapi"
"github.com/thecolngroup/alphakit/broker"
"github.com/thecolngroup/alphakit/market"
"github.com/thecolngroup/alphakit/web"
)

// Enforce at compile time that the type implements the interface
Expand All @@ -32,26 +32,26 @@ func (d *Dealer) SetInitialCapital(amount decimal.Decimal) {
d.simulator.SetInitialCapital(amount)
}

func (d *Dealer) GetBalance(ctx context.Context) (*broker.AccountBalance, *netapi.Response, error) {
func (d *Dealer) GetBalance(ctx context.Context) (*broker.AccountBalance, *web.Response, error) {
acc := d.simulator.Balance()
return &acc, nil, nil
}

func (d *Dealer) PlaceOrder(ctx context.Context, order broker.Order) (*broker.Order, *netapi.Response, error) {
func (d *Dealer) PlaceOrder(ctx context.Context, order broker.Order) (*broker.Order, *web.Response, error) {
order, err := d.simulator.AddOrder(order)
return &order, nil, err
}

func (d *Dealer) CancelOrders(ctx context.Context) (*netapi.Response, error) {
func (d *Dealer) CancelOrders(ctx context.Context) (*web.Response, error) {
d.simulator.CancelOrders()
return nil, nil
}

func (d *Dealer) ListPositions(ctx context.Context, opts *netapi.ListOpts) ([]broker.Position, *netapi.Response, error) {
func (d *Dealer) ListPositions(ctx context.Context, opts *web.ListOpts) ([]broker.Position, *web.Response, error) {
return d.simulator.Positions(), nil, nil
}

func (d *Dealer) ListTrades(ctx context.Context, opts *netapi.ListOpts) ([]broker.Trade, *netapi.Response, error) {
func (d *Dealer) ListTrades(ctx context.Context, opts *web.ListOpts) ([]broker.Trade, *web.Response, error) {
return d.simulator.Trades(), nil, nil
}

Expand Down
8 changes: 4 additions & 4 deletions broker/backtest/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"io"
"os"

"github.com/thecolngroup/zerotoalgo/broker"
"github.com/thecolngroup/zerotoalgo/internal/dec"
"github.com/thecolngroup/zerotoalgo/market"
"github.com/thecolngroup/zerotoalgo/perf"
"github.com/thecolngroup/alphakit/broker"
"github.com/thecolngroup/alphakit/internal/dec"
"github.com/thecolngroup/alphakit/market"
"github.com/thecolngroup/alphakit/perf"
)

func Example() {
Expand Down
4 changes: 2 additions & 2 deletions broker/backtest/makedealer.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package backtest

import (
"github.com/thecolngroup/zerotoalgo/broker"
"github.com/thecolngroup/zerotoalgo/internal/dec"
"github.com/thecolngroup/alphakit/broker"
"github.com/thecolngroup/alphakit/internal/dec"
)

func MakeDealerFromConfig(config map[string]any) (broker.SimulatedDealer, error) {
Expand Down
4 changes: 2 additions & 2 deletions broker/backtest/perpcost.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"time"

"github.com/shopspring/decimal"
"github.com/thecolngroup/zerotoalgo/broker"
"github.com/thecolngroup/zerotoalgo/internal/dec"
"github.com/thecolngroup/alphakit/broker"
"github.com/thecolngroup/alphakit/internal/dec"
)

var _ Coster = (*PerpCost)(nil)
Expand Down
4 changes: 2 additions & 2 deletions broker/backtest/perpcost_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"github.com/shopspring/decimal"
"github.com/stretchr/testify/assert"
"github.com/thecolngroup/zerotoalgo/broker"
"github.com/thecolngroup/zerotoalgo/internal/dec"
"github.com/thecolngroup/alphakit/broker"
"github.com/thecolngroup/alphakit/internal/dec"
)

func TestPerpCostFunding(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions broker/backtest/simulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"time"

"github.com/shopspring/decimal"
"github.com/thecolngroup/zerotoalgo/broker"
"github.com/thecolngroup/zerotoalgo/internal/dec"
"github.com/thecolngroup/zerotoalgo/market"
"github.com/thecolngroup/alphakit/broker"
"github.com/thecolngroup/alphakit/internal/dec"
"github.com/thecolngroup/alphakit/market"
"golang.org/x/exp/maps"
)

Expand Down
6 changes: 3 additions & 3 deletions broker/backtest/simulator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (

"github.com/shopspring/decimal"
"github.com/stretchr/testify/assert"
"github.com/thecolngroup/zerotoalgo/broker"
"github.com/thecolngroup/zerotoalgo/internal/dec"
"github.com/thecolngroup/zerotoalgo/market"
"github.com/thecolngroup/alphakit/broker"
"github.com/thecolngroup/alphakit/internal/dec"
"github.com/thecolngroup/alphakit/market"
)

var _fixed time.Time = time.Date(2022, time.January, 1, 0, 0, 0, 0, time.Local)
Expand Down
14 changes: 7 additions & 7 deletions broker/dealer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import (
"context"

"github.com/shopspring/decimal"
"github.com/thecolngroup/zerotoalgo/market"
"github.com/thecolngroup/zerotoalgo/netapi"
"github.com/thecolngroup/alphakit/market"
"github.com/thecolngroup/alphakit/web"
)

type Dealer interface {
GetBalance(context.Context) (*AccountBalance, *netapi.Response, error)
PlaceOrder(context.Context, Order) (*Order, *netapi.Response, error)
CancelOrders(context.Context) (*netapi.Response, error)
ListPositions(context.Context, *netapi.ListOpts) ([]Position, *netapi.Response, error)
ListTrades(context.Context, *netapi.ListOpts) ([]Trade, *netapi.Response, error)
GetBalance(context.Context) (*AccountBalance, *web.Response, error)
PlaceOrder(context.Context, Order) (*Order, *web.Response, error)
CancelOrders(context.Context) (*web.Response, error)
ListPositions(context.Context, *web.ListOpts) ([]Position, *web.Response, error)
ListTrades(context.Context, *web.ListOpts) ([]Trade, *web.Response, error)
}

type SimulatedDealer interface {
Expand Down
22 changes: 11 additions & 11 deletions broker/mockdealer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"

"github.com/stretchr/testify/mock"
"github.com/thecolngroup/zerotoalgo/netapi"
"github.com/thecolngroup/alphakit/web"
)

var _ Dealer = (*MockDealer)(nil)
Expand All @@ -13,32 +13,32 @@ type MockDealer struct {
mock.Mock
}

func (d *MockDealer) GetBalance(ctx context.Context) (*AccountBalance, *netapi.Response, error) {
func (d *MockDealer) GetBalance(ctx context.Context) (*AccountBalance, *web.Response, error) {
args := d.Called(ctx)
return args.Get(0).(*AccountBalance), args.Get(1).(*netapi.Response), args.Error(2)
return args.Get(0).(*AccountBalance), args.Get(1).(*web.Response), args.Error(2)
}

func (d *MockDealer) PlaceOrder(ctx context.Context, order Order) (*Order, *netapi.Response, error) {
func (d *MockDealer) PlaceOrder(ctx context.Context, order Order) (*Order, *web.Response, error) {
args := d.Called(ctx, order)

if len(args) == 0 {
return nil, nil, nil
}

return args.Get(0).(*Order), args.Get(1).(*netapi.Response), args.Error(2)
return args.Get(0).(*Order), args.Get(1).(*web.Response), args.Error(2)
}

func (d *MockDealer) CancelOrders(ctx context.Context) (*netapi.Response, error) {
func (d *MockDealer) CancelOrders(ctx context.Context) (*web.Response, error) {
args := d.Called(ctx)
return args.Get(0).(*netapi.Response), args.Error(1)
return args.Get(0).(*web.Response), args.Error(1)
}

func (d *MockDealer) ListPositions(ctx context.Context, opts *netapi.ListOpts) ([]Position, *netapi.Response, error) {
func (d *MockDealer) ListPositions(ctx context.Context, opts *web.ListOpts) ([]Position, *web.Response, error) {
args := d.Called(ctx, opts)
return args.Get(0).([]Position), args.Get(1).(*netapi.Response), args.Error(2)
return args.Get(0).([]Position), args.Get(1).(*web.Response), args.Error(2)
}

func (d *MockDealer) ListTrades(ctx context.Context, opts *netapi.ListOpts) ([]Trade, *netapi.Response, error) {
func (d *MockDealer) ListTrades(ctx context.Context, opts *web.ListOpts) ([]Trade, *web.Response, error) {
args := d.Called(ctx, opts)
return args.Get(0).([]Trade), args.Get(1).(*netapi.Response), args.Error(2)
return args.Get(0).([]Trade), args.Get(1).(*web.Response), args.Error(2)
}
2 changes: 1 addition & 1 deletion broker/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"time"

"github.com/shopspring/decimal"
"github.com/thecolngroup/zerotoalgo/market"
"github.com/thecolngroup/alphakit/market"
)

type OrderSide int
Expand Down
2 changes: 1 addition & 1 deletion broker/position.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"time"

"github.com/shopspring/decimal"
"github.com/thecolngroup/zerotoalgo/market"
"github.com/thecolngroup/alphakit/market"
)

type PositionState int
Expand Down
14 changes: 7 additions & 7 deletions broker/stubdealer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"

"github.com/shopspring/decimal"
"github.com/thecolngroup/zerotoalgo/market"
"github.com/thecolngroup/zerotoalgo/netapi"
"github.com/thecolngroup/alphakit/market"
"github.com/thecolngroup/alphakit/web"
)

var _ SimulatedDealer = (*StubDealer)(nil)
Expand All @@ -21,23 +21,23 @@ func (d *StubDealer) Configure(map[string]any) error { return nil }

func (d *StubDealer) SetInitialCapital(amount decimal.Decimal) {}

func (d *StubDealer) GetBalance(ctx context.Context) (*AccountBalance, *netapi.Response, error) {
func (d *StubDealer) GetBalance(ctx context.Context) (*AccountBalance, *web.Response, error) {
return nil, nil, nil
}

func (d *StubDealer) PlaceOrder(ctx context.Context, order Order) (*Order, *netapi.Response, error) {
func (d *StubDealer) PlaceOrder(ctx context.Context, order Order) (*Order, *web.Response, error) {
return nil, nil, nil
}

func (d *StubDealer) CancelOrders(ctx context.Context) (*netapi.Response, error) {
func (d *StubDealer) CancelOrders(ctx context.Context) (*web.Response, error) {
return nil, nil
}

func (d *StubDealer) ListPositions(ctx context.Context, opts *netapi.ListOpts) ([]Position, *netapi.Response, error) {
func (d *StubDealer) ListPositions(ctx context.Context, opts *web.ListOpts) ([]Position, *web.Response, error) {
return nil, nil, nil
}

func (d *StubDealer) ListTrades(ctx context.Context, opts *netapi.ListOpts) ([]Trade, *netapi.Response, error) {
func (d *StubDealer) ListTrades(ctx context.Context, opts *web.ListOpts) ([]Trade, *web.Response, error) {
return nil, nil, nil
}

Expand Down
2 changes: 1 addition & 1 deletion broker/trade.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"time"

"github.com/shopspring/decimal"
"github.com/thecolngroup/zerotoalgo/market"
"github.com/thecolngroup/alphakit/market"
)

type Trade struct {
Expand Down
8 changes: 4 additions & 4 deletions cmd/npocstudy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"time"

"github.com/gonum/stat"
"github.com/thecolngroup/zerotoalgo/internal/studyrun"
"github.com/thecolngroup/zerotoalgo/market"
"github.com/thecolngroup/zerotoalgo/ta"
"github.com/thecolngroup/alphakit/internal/studyrun"
"github.com/thecolngroup/alphakit/market"
"github.com/thecolngroup/alphakit/ta"
"golang.org/x/exp/slices"
)

Expand Down Expand Up @@ -50,7 +50,7 @@ func main() {

var err error

pricePath := "/Users/richklee/Dropbox/dev-share/github.com/thecolngroup/zerotoalgo/prices/spot/btcusdt-m1/all"
pricePath := "/Users/richklee/Dropbox/dev-share/github.com/thecolngroup/alphakit/prices/spot/btcusdt-m1/all"

sample, err := studyrun.ReadPriceSeries(pricePath)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/studyrun/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"

"github.com/schollz/progressbar/v3"
"github.com/thecolngroup/zerotoalgo/internal/studyrun"
"github.com/thecolngroup/alphakit/internal/studyrun"
"golang.org/x/exp/maps"
)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/thecolngroup/zerotoalgo
module github.com/thecolngroup/alphakit

go 1.18

Expand Down
4 changes: 2 additions & 2 deletions internal/studyrun/readdealer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package studyrun
import (
"errors"

"github.com/thecolngroup/zerotoalgo/broker"
"github.com/thecolngroup/zerotoalgo/broker/backtest"
"github.com/thecolngroup/alphakit/broker"
"github.com/thecolngroup/alphakit/broker/backtest"
)

func ReadDealerFromConfig(config map[string]any) (broker.MakeSimulatedDealer, error) {
Expand Down
6 changes: 3 additions & 3 deletions internal/studyrun/readoptimizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"errors"
"fmt"

"github.com/thecolngroup/zerotoalgo/internal/util"
"github.com/thecolngroup/zerotoalgo/optimize"
"github.com/thecolngroup/zerotoalgo/trader"
"github.com/thecolngroup/alphakit/internal/util"
"github.com/thecolngroup/alphakit/optimize"
"github.com/thecolngroup/alphakit/trader"
)

func ReadBruteOptimizerFromConfig(config map[string]any) (*optimize.BruteOptimizer, error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/studyrun/readprices.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"os"
"path/filepath"

"github.com/thecolngroup/zerotoalgo/market"
"github.com/thecolngroup/alphakit/market"
)

func ReadPricesFromConfig(config map[string]any) ([][]market.Kline, error) {
Expand Down
6 changes: 3 additions & 3 deletions internal/studyrun/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"os"

"github.com/olekukonko/tablewriter"
"github.com/thecolngroup/zerotoalgo/internal/util"
"github.com/thecolngroup/zerotoalgo/optimize"
"github.com/thecolngroup/zerotoalgo/perf"
"github.com/thecolngroup/alphakit/internal/util"
"github.com/thecolngroup/alphakit/optimize"
"github.com/thecolngroup/alphakit/perf"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
)
Expand Down
6 changes: 3 additions & 3 deletions internal/studyrun/typeregistry.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package studyrun

import (
"github.com/thecolngroup/zerotoalgo/trader"
"github.com/thecolngroup/zerotoalgo/trader/hodl"
"github.com/thecolngroup/zerotoalgo/trader/trend"
"github.com/thecolngroup/alphakit/trader"
"github.com/thecolngroup/alphakit/trader/hodl"
"github.com/thecolngroup/alphakit/trader/trend"
)

var _typeRegistry = map[string]any{
Expand Down
2 changes: 1 addition & 1 deletion internal/studyrun/writereports.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"

"github.com/jszwec/csvutil"
"github.com/thecolngroup/zerotoalgo/optimize"
"github.com/thecolngroup/alphakit/optimize"
)

const _filenameFriendlyTimeFormat = "20060102T150405"
Expand Down
2 changes: 1 addition & 1 deletion market/csvklinereader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"time"

"github.com/stretchr/testify/assert"
"github.com/thecolngroup/zerotoalgo/internal/dec"
"github.com/thecolngroup/alphakit/internal/dec"
)

func TestCSVKlineReader_Read(t *testing.T) {
Expand Down
Loading

0 comments on commit 0776baa

Please sign in to comment.