Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
O-h-y-o committed Jun 26, 2023
1 parent a766e3f commit 1bda593
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 26 deletions.
Empty file.
30 changes: 19 additions & 11 deletions src/ko/posts/upbit/upbit-chart.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ order: 2
export const useUpbitSocketStore = defineStore("upbitSocket", {
state: (): ISocketState => ({
chartTime: "1", // 차트 분봉
coinCode: "KRW-BTC", // 업비트 API에서 가져올 코인 이름
coinName: { ko: "비트코인", en: "Bitcoin" },
selectCoin: "KRW-BTC", // 업비트 API에서 가져올 코인 이름
coinFullName: { ko: "비트코인", en: "Bitcoin" },
}),
});
```
Expand All @@ -27,8 +27,8 @@ export {};
declare global {
interface ISocketState {
chartTime: string;
coinFullName: { ko: string; en: string };
selectCoin: string;
coinFullName: { ko: string; en: string };
}
}
```
Expand Down Expand Up @@ -172,13 +172,16 @@ import axios from "axios";
import dayjs from "dayjs";
import EchartsDefault from "src/components/EchartsDefault.vue";
import { colors } from "src/utils/rule";
import { useUpbitSocketStore } from 'src/stores/socket-upbit';
const upbit = useUpbitSocketStore();
const bindingOptions = ref({
animationDuration: 100,
animationDurationUpdate: 100,
title: {
text: "비트코인",
subtext: "KRW-BTC",
text: ${upbit.coinFullName.ko},
subtext: ${upbit.selectCoin},
left: "center",
top: 40,
textStyle: {
Expand Down Expand Up @@ -342,7 +345,7 @@ const updateMarkLine = <T>(
const getCandleAPI = async (count = 50) => {
const response = await axios.get<ICandleStickResponse[]>(
`https://api.upbit.com/v1/candles/minutes/1?market=KRW-BTC&count=${count}`
`https://api.upbit.com/v1/candles/minutes/${upbit.chartTime}?market=${upbit.selectCoin}&count=${count}`
);
for (const i in response.data.reverse()) {
Expand Down Expand Up @@ -396,6 +399,7 @@ declare global {
interface ISocketState {
tradeData: ISocketTradeResponse;
reloadCandle: Function;
}

interface ISocketTradeResponse {
Expand Down Expand Up @@ -429,6 +433,7 @@ export const useUpbitSocketStore = defineStore("upbitSocket", {
coinFullName: { ko: "비트코인", en: "Bitcoin" },
selectCoin: "KRW-BTC",
tradeData: {} as ISocketTradeResponse,
reloadCandle: async () => {},
}),
actions: {
connectTradeSocket() {
Expand Down Expand Up @@ -477,12 +482,14 @@ import EchartsDefault from "src/components/EchartsDefault.vue";
import { colors } from "src/utils/rule";
import { useUpbitSocketStore } from "src/stores/socket-upbit";
const upbit = useUpbitSocketStore();
const bindingOptions = ref({
animationDuration: 100,
animationDurationUpdate: 100,
title: {
text: "비트코인",
subtext: "KRW-BTC",
text: ${upbit.coinFullName.ko},
subtext: ${upbit.selectCoin},
left: "center",
top: 40,
textStyle: {
Expand Down Expand Up @@ -633,7 +640,7 @@ const bindingOptions = ref({
const candleData = ref<{ [key: string]: number[] }>({});
const candleVolume = ref<{ [key: string]: number[] }>({});
const tradeData = computed(() => useUpbitSocketStore().tradeData);
const tradeData = computed(() => upbit.tradeData);
const stop = ref(false);
const updateMarkLine = <T>(
Expand All @@ -648,7 +655,7 @@ const updateMarkLine = <T>(
const getCandleAPI = async (count = 50) => {
const response = await axios.get<ICandleStickResponse[]>(
`https://api.upbit.com/v1/candles/minutes/1?market=KRW-BTC&count=${count}`
`https://api.upbit.com/v1/candles/minutes/${upbit.chartTime}?market=${upbit.selectCoin}&count=${count}`
);
for (const i in response.data.reverse()) {
Expand Down Expand Up @@ -720,7 +727,8 @@ watch(
onBeforeMount(() => {
getCandleAPI();
useUpbitSocketStore().connectTradeSocket();
upbit.connectTradeSocket();
upbit.reloadCandle = getCandleAPI;
});
</script>
```
Expand Down
5 changes: 3 additions & 2 deletions src/ko/posts/upbit/upbit-market-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,8 @@ interface IMarkets {
<script setup lang="ts">
import axios from "axios";
import { ref, onMounted } from "vue";
import { useUpbitSocketStore } from "../stores/socket-upbit";
import { objSort } from "../utils/rule";
import { useUpbitSocketStore } from "src/stores/socket-upbit";
import { objSort } from "src/utils/rule";
const upbit = useUpbitSocketStore();
Expand Down Expand Up @@ -730,6 +730,7 @@ const changeMarket = (market: string) => {
const changeCoin = (market: string, name: string) => {
upbit.selectCoin = market;
upbit.coinFullName.ko = name;
upbit.reloadCandle();
};
let tickerSocket: WebSocket;
Expand Down
30 changes: 19 additions & 11 deletions src/posts/upbit/upbit-chart.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ I'll only bring 50 at first.
export const useUpbitSocketStore = defineStore("upbitSocket", {
state: (): ISocketState => ({
chartTime: "1", // chart segmentation
coinCode: "KRW-BTC", // Coin name to get from Upbit API
coinName: { ko: "비트코인", en: "Bitcoin" },
selectCoin: "KRW-BTC", // Coin name to get from Upbit API
coinFullName: { ko: "비트코인", en: "Bitcoin" },
}),
});
```
Expand All @@ -27,8 +27,8 @@ export {};
declare global {
interface ISocketState {
chartTime: string;
coinFullName: { ko: string; en: string };
selectCoin: string;
coinFullName: { ko: string; en: string };
}
}
```
Expand Down Expand Up @@ -171,13 +171,16 @@ import axios from "axios";
import dayjs from "dayjs";
import EchartsDefault from "src/components/EchartsDefault.vue";
import { colors } from "src/utils/rule";
import { useUpbitSocketStore } from "src/stores/socket-upbit";
const upbit = useUpbitSocketStore();
const bindingOptions = ref({
animationDuration: 100,
animationDurationUpdate: 100,
title: {
text: "Bitcoin",
subtext: "KRW-BTC",
text: ${ upbit.coinFullName.en },
subtext: ${ upbit.selectCoin },
left: "center",
top: 40,
textStyle: {
Expand Down Expand Up @@ -341,7 +344,7 @@ const updateMarkLine = <T>(
const getCandleAPI = async (count = 50) => {
const response = await axios.get<ICandleStickResponse[]>(
`https://api.upbit.com/v1/candles/minutes/1?market=KRW-BTC&count=${count}`
`https://api.upbit.com/v1/candles/minutes/${upbit.chartTime}?market=${upbit.selectCoin}&count=${count}`
);
for (const i in response.data.reverse()) {
Expand Down Expand Up @@ -395,6 +398,7 @@ declare global {
interface ISocketState {
tradeData: ISocketTradeResponse;
reloadCandle: Function;
}

interface ISocketTradeResponse {
Expand Down Expand Up @@ -430,6 +434,7 @@ export const useUpbitSocketStore = defineStore("upbitSocket", {
coinFullName: { ko: "비트코인", en: "Bitcoin" },
selectCoin: "KRW-BTC",
tradeData: {} as ISocketTradeResponse,
reloadCandle: async () => {},
}),
actions: {
connectTradeSocket() {
Expand Down Expand Up @@ -482,12 +487,14 @@ import EchartsDefault from "src/components/EchartsDefault.vue";
import { colors } from "src/utils/rule";
import { useUpbitSocketStore } from "src/stores/socket-upbit";
const upbit = useUpbitSocketStore();
const bindingOptions = ref({
animationDuration: 100,
animationDurationUpdate: 100,
title: {
text: "비트코인",
subtext: "KRW-BTC",
text: ${upbit.coinFullName.en},
subtext: ${upbit.selectCoin},
left: "center",
top: 40,
textStyle: {
Expand Down Expand Up @@ -638,7 +645,7 @@ const bindingOptions = ref({
const candleData = ref<{ [key: string]: number[] }>({});
const candleVolume = ref<{ [key: string]: number[] }>({});
const tradeData = computed(() => useUpbitSocketStore().tradeData);
const tradeData = computed(() => upbit.tradeData);
const stop = ref(false);
const updateMarkLine = <T>(
Expand All @@ -653,7 +660,7 @@ const updateMarkLine = <T>(
const getCandleAPI = async (count = 50) => {
const response = await axios.get<ICandleStickResponse[]>(
`https://api.upbit.com/v1/candles/minutes/1?market=KRW-BTC&count=${count}`
`https://api.upbit.com/v1/candles/minutes/${upbit.chartTime}?market=${upbit.selectCoin}&count=${count}`
);
for (const i in response.data.reverse()) {
Expand Down Expand Up @@ -725,7 +732,8 @@ watch(
onBeforeMount(() => {
getCandleAPI();
useUpbitSocketStore().connectTradeSocket();
upbit.connectTradeSocket();
upbit.reloadCandle = getCandleAPI;
});
</script>
```
Expand Down
5 changes: 3 additions & 2 deletions src/posts/upbit/upbit-market-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,8 @@ interface IMarkets {
<script setup lang="ts">
import axios from "axios";
import { ref, onMounted } from "vue";
import { useUpbitSocketStore } from "../stores/socket-upbit";
import { objSort } from "../utils/rule";
import { useUpbitSocketStore } from "src/stores/socket-upbit";
import { objSort } from "src/utils/rule";
const upbit = useUpbitSocketStore();
Expand Down Expand Up @@ -730,6 +730,7 @@ const changeMarket = (market: string) => {
const changeCoin = (market: string, name: string) => {
upbit.selectCoin = market;
upbit.coinFullName.ko = name;
upbit.reloadCandle();
};
let tickerSocket: WebSocket;
Expand Down

0 comments on commit 1bda593

Please sign in to comment.