@tradejs/connectors 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -0
- package/dist/index.d.mts +65 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.js +1324 -0
- package/dist/index.mjs +1293 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# @tradejs/connectors
|
|
2
|
+
|
|
3
|
+
Built-in TradeJS connector package.
|
|
4
|
+
|
|
5
|
+
- Homepage: https://tradejs.dev
|
|
6
|
+
- Documentation: https://docs.tradejs.dev
|
|
7
|
+
- Quickstart: https://docs.tradejs.dev/getting-started/quickstart
|
|
8
|
+
|
|
9
|
+
## What It Provides
|
|
10
|
+
|
|
11
|
+
This package contains the built-in connector plugin catalog used by TradeJS runtime:
|
|
12
|
+
|
|
13
|
+
- exchange connectors
|
|
14
|
+
- market data providers
|
|
15
|
+
- built-in test connector support used by backtests/runtime flows
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm i @tradejs/connectors @tradejs/core
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
Most projects should not add this package manually. It is already included by `@tradejs/base`.
|
|
26
|
+
|
|
27
|
+
If you want to reference it explicitly:
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { defineConfig } from '@tradejs/core/config';
|
|
31
|
+
|
|
32
|
+
export default defineConfig({
|
|
33
|
+
connectors: ['@tradejs/connectors'],
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## For Custom Connectors
|
|
38
|
+
|
|
39
|
+
Use `defineConnectorPlugin(...)` from `@tradejs/core/config` in your own package and add that package to `connectors` in `tradejs.config.ts`.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as _tradejs_types from '@tradejs/types';
|
|
2
|
+
import { KlineChartData, ConnectorRegistryEntry, ConnectorCreator } from '@tradejs/types';
|
|
3
|
+
import { DerivativesInterval, DerivativesRow, SpreadRow } from '@tradejs/infra/timescale';
|
|
4
|
+
|
|
5
|
+
type SpotKlineRequest = {
|
|
6
|
+
symbol: string;
|
|
7
|
+
interval: DerivativesInterval;
|
|
8
|
+
start: number;
|
|
9
|
+
end: number;
|
|
10
|
+
};
|
|
11
|
+
type SpotKlineProvider = {
|
|
12
|
+
kline: (request: SpotKlineRequest) => Promise<KlineChartData>;
|
|
13
|
+
};
|
|
14
|
+
declare const spotKlineProviders: {
|
|
15
|
+
binance: SpotKlineProvider;
|
|
16
|
+
coinbase: SpotKlineProvider;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type MarketDataProviderName = 'coinalyze' | 'binance_coinbase_spread';
|
|
20
|
+
type ProviderWindowParams = {
|
|
21
|
+
symbol: string;
|
|
22
|
+
marketSymbol?: string;
|
|
23
|
+
interval: DerivativesInterval;
|
|
24
|
+
fromMs: number;
|
|
25
|
+
toMs: number;
|
|
26
|
+
};
|
|
27
|
+
type ProviderWindowResult = {
|
|
28
|
+
derivativesRows?: DerivativesRow[];
|
|
29
|
+
spreadRows?: SpreadRow[];
|
|
30
|
+
};
|
|
31
|
+
interface MarketDataProvider {
|
|
32
|
+
name: MarketDataProviderName;
|
|
33
|
+
fetchWindow: (params: ProviderWindowParams) => Promise<ProviderWindowResult>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
declare const marketDataProviders: Record<MarketDataProviderName, MarketDataProvider>;
|
|
37
|
+
|
|
38
|
+
declare enum ConnectorNames {
|
|
39
|
+
ByBit = "ByBit",
|
|
40
|
+
Binance = "Binance",
|
|
41
|
+
Coinbase = "Coinbase",
|
|
42
|
+
Test = "Test"
|
|
43
|
+
}
|
|
44
|
+
declare enum ConnectorProviders {
|
|
45
|
+
bybit = "bybit",
|
|
46
|
+
binance = "binance",
|
|
47
|
+
coinbase = "coinbase"
|
|
48
|
+
}
|
|
49
|
+
declare const providerToConnectorName: Record<ConnectorProviders, ConnectorNames>;
|
|
50
|
+
declare const getConnectorProviders: () => ConnectorProviders[];
|
|
51
|
+
declare const resolveConnectorNameByProvider: (provider: unknown) => ConnectorNames | null;
|
|
52
|
+
declare const connectors: {
|
|
53
|
+
readonly ByBit: ConnectorCreator;
|
|
54
|
+
readonly Binance: ConnectorCreator;
|
|
55
|
+
readonly Coinbase: ConnectorCreator;
|
|
56
|
+
readonly Test: _tradejs_types.TestConnectorCreator;
|
|
57
|
+
};
|
|
58
|
+
declare const connectorEntries: ConnectorRegistryEntry[];
|
|
59
|
+
declare const getConnectorCreatorByProvider: (provider: unknown) => ConnectorCreator | null;
|
|
60
|
+
|
|
61
|
+
declare const _default: {
|
|
62
|
+
connectorEntries: ConnectorRegistryEntry[];
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export { ConnectorNames, ConnectorProviders, type MarketDataProvider, type MarketDataProviderName, connectorEntries, connectors, _default as default, getConnectorCreatorByProvider, getConnectorProviders, marketDataProviders, providerToConnectorName, resolveConnectorNameByProvider, spotKlineProviders };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as _tradejs_types from '@tradejs/types';
|
|
2
|
+
import { KlineChartData, ConnectorRegistryEntry, ConnectorCreator } from '@tradejs/types';
|
|
3
|
+
import { DerivativesInterval, DerivativesRow, SpreadRow } from '@tradejs/infra/timescale';
|
|
4
|
+
|
|
5
|
+
type SpotKlineRequest = {
|
|
6
|
+
symbol: string;
|
|
7
|
+
interval: DerivativesInterval;
|
|
8
|
+
start: number;
|
|
9
|
+
end: number;
|
|
10
|
+
};
|
|
11
|
+
type SpotKlineProvider = {
|
|
12
|
+
kline: (request: SpotKlineRequest) => Promise<KlineChartData>;
|
|
13
|
+
};
|
|
14
|
+
declare const spotKlineProviders: {
|
|
15
|
+
binance: SpotKlineProvider;
|
|
16
|
+
coinbase: SpotKlineProvider;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type MarketDataProviderName = 'coinalyze' | 'binance_coinbase_spread';
|
|
20
|
+
type ProviderWindowParams = {
|
|
21
|
+
symbol: string;
|
|
22
|
+
marketSymbol?: string;
|
|
23
|
+
interval: DerivativesInterval;
|
|
24
|
+
fromMs: number;
|
|
25
|
+
toMs: number;
|
|
26
|
+
};
|
|
27
|
+
type ProviderWindowResult = {
|
|
28
|
+
derivativesRows?: DerivativesRow[];
|
|
29
|
+
spreadRows?: SpreadRow[];
|
|
30
|
+
};
|
|
31
|
+
interface MarketDataProvider {
|
|
32
|
+
name: MarketDataProviderName;
|
|
33
|
+
fetchWindow: (params: ProviderWindowParams) => Promise<ProviderWindowResult>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
declare const marketDataProviders: Record<MarketDataProviderName, MarketDataProvider>;
|
|
37
|
+
|
|
38
|
+
declare enum ConnectorNames {
|
|
39
|
+
ByBit = "ByBit",
|
|
40
|
+
Binance = "Binance",
|
|
41
|
+
Coinbase = "Coinbase",
|
|
42
|
+
Test = "Test"
|
|
43
|
+
}
|
|
44
|
+
declare enum ConnectorProviders {
|
|
45
|
+
bybit = "bybit",
|
|
46
|
+
binance = "binance",
|
|
47
|
+
coinbase = "coinbase"
|
|
48
|
+
}
|
|
49
|
+
declare const providerToConnectorName: Record<ConnectorProviders, ConnectorNames>;
|
|
50
|
+
declare const getConnectorProviders: () => ConnectorProviders[];
|
|
51
|
+
declare const resolveConnectorNameByProvider: (provider: unknown) => ConnectorNames | null;
|
|
52
|
+
declare const connectors: {
|
|
53
|
+
readonly ByBit: ConnectorCreator;
|
|
54
|
+
readonly Binance: ConnectorCreator;
|
|
55
|
+
readonly Coinbase: ConnectorCreator;
|
|
56
|
+
readonly Test: _tradejs_types.TestConnectorCreator;
|
|
57
|
+
};
|
|
58
|
+
declare const connectorEntries: ConnectorRegistryEntry[];
|
|
59
|
+
declare const getConnectorCreatorByProvider: (provider: unknown) => ConnectorCreator | null;
|
|
60
|
+
|
|
61
|
+
declare const _default: {
|
|
62
|
+
connectorEntries: ConnectorRegistryEntry[];
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export { ConnectorNames, ConnectorProviders, type MarketDataProvider, type MarketDataProviderName, connectorEntries, connectors, _default as default, getConnectorCreatorByProvider, getConnectorProviders, marketDataProviders, providerToConnectorName, resolveConnectorNameByProvider, spotKlineProviders };
|