Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
dist
node_modules
.log
30 changes: 30 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Unofficial library to interact with websockets on Tradingview.
- Fetching candlesticks for any symbol with any available timeframe

## Example

### Getting candles
here is an example when you want to get a candle with a one-time function this function returns a candle that matches the symbol you provide
```ts
import { connect, getCandles } from 'tradingview-ws'

Expand All @@ -24,6 +27,33 @@ import { connect, getCandles } from 'tradingview-ws'
}());
```

### Subscribe With Symbol
The following is an example of subscribing to some of the symbols that you follow. You have to send a callback to find out which symbols you are subscribing for

```ts
import { connect, connectAndSubscribe } from 'tradingview-ws'

(async function () {
try {
for (const iterator of ["SOLUSDT", "BTCUSDT"]) {
const connection = await connect()
connectAndSubscribe({
connection,
symbols: [iterator],
amount: 1,
timeframe: 1,
callback: (event) => {
console.log(event)
}
})
}
} catch (error) {
console.error(error)
}
}());
```


## API

### `connect(options: ConnectionOptions = {}): Promise<TradingviewConnection>`
Expand Down
4 changes: 4 additions & 0 deletions dist/TradingViewWebsocket.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare class TradingViewWebsocker {
constructor();
}
//# sourceMappingURL=TradingViewWebsocket.d.ts.map
1 change: 1 addition & 0 deletions dist/TradingViewWebsocket.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions dist/TradingViewWebsocket.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/TradingViewWebsocket.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Candle, ConnectionOptions, GetCandlesParams, TradingviewConnection } from './types';
export declare const EVENT_NAMES: {
TIMESCALE_UPDATE: string;
SERIES_COMPLETED: string;
SYMBOL_ERROR: string;
RESOLVE_SYMBOL: string;
CREATE_SERIES: string;
REQUEST_MORE_DATA: string;
};
export declare function connect(options?: ConnectionOptions): Promise<TradingviewConnection>;
export declare function getCandlesV2({ connection, symbols, amount, timeframe }: GetCandlesParams): Promise<unknown[]>;
export declare function getCandles({ connection, symbols, amount, timeframe }: GetCandlesParams): Promise<Candle[][]>;
export declare function connectAndSubscribe({ connection, symbols, timeframe }: GetCandlesParams): Promise<never[] | undefined>;
//# sourceMappingURL=index.d.ts.map
1 change: 1 addition & 0 deletions dist/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

253 changes: 253 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading